Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
PeteCoward committed Jul 24, 2024
1 parent 4648a55 commit 842b79d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
42 changes: 24 additions & 18 deletions simple_locations/base_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,23 @@ class Meta:
def __str__(self):
return _("%(lat)s, %(lon)s") % {"lat": self.latitude, "lon": self.longitude}

Meta = type('Meta', (object,), {'abstract': True})

Meta = type("Meta", (object,), {"abstract": True})


def get_area_base(kind_model: AbstractBaseAreaType, point_model: AbstractBasePoint):
"""Return the AbstractBaseArea base class
kind_model: Concrete Model for Area Type
point_model: Concrete Model for Point
kind_model: Concrete Model for Area Type
point_model: Concrete Model for Point
"""
attrs = {
'kind': models.ForeignKey(kind_model, blank=True, null=True, on_delete=models.CASCADE),
'location': models.ForeignKey(point_model, blank=True, null=True, on_delete=models.CASCADE),
'__module__': __name__,
'Meta': Meta(),
"kind": models.ForeignKey(kind_model, blank=True, null=True, on_delete=models.CASCADE),
"location": models.ForeignKey(point_model, blank=True, null=True, on_delete=models.CASCADE),
"__module__": __name__,
"Meta": Meta(),
}
return type('AbstractBaseArea', (_AbstractBaseArea,), attrs)
return type("AbstractBaseArea", (_AbstractBaseArea,), attrs)


class _AbstractBaseArea(MPTTModel):
class Meta:
Expand Down Expand Up @@ -110,14 +113,15 @@ def __str__(self) -> str:

def get_projected_area_base(area_model: _AbstractBaseArea):
"""Return the AbstractBaseProjectedArea base class
area_model: Concrete Model for Area
area_model: Concrete Model for Area
"""
attrs = {
'area': models.OneToOneField(area_model, primary_key=True, on_delete=models.CASCADE),
'__module__': __name__,
'Meta': Meta(),
"area": models.OneToOneField(area_model, primary_key=True, on_delete=models.CASCADE),
"__module__": __name__,
"Meta": Meta(),
}
return type('AbstractBaseProjectedArea', (_AbstractBaseProjectedArea,), attrs)
return type("AbstractBaseProjectedArea", (_AbstractBaseProjectedArea,), attrs)


class _AbstractBaseProjectedArea(models.Model):
"""
Expand All @@ -132,16 +136,18 @@ class Meta:

geom = MultiPolygonField(null=True, blank=True, srid=3857)


def get_border_base(area_model: _AbstractBaseArea):
"""Return the AbstractBaseProjectedArea base class
area_model: Concrete Model for Area
area_model: Concrete Model for Area
"""
attrs = {
'area': models.ManyToManyField(area_model),
'__module__': __name__,
'Meta': Meta(),
"area": models.ManyToManyField(area_model),
"__module__": __name__,
"Meta": Meta(),
}
return type('AbstractBaseBorder', (_AbstractBaseBorder,), attrs)
return type("AbstractBaseBorder", (_AbstractBaseBorder,), attrs)


class _AbstractBaseBorder(models.Model):
"""
Expand Down
4 changes: 3 additions & 1 deletion simple_locations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,17 @@ class Point(base_models.AbstractBasePoint):
class Meta(base_models.AbstractBasePoint.Meta):
app_label = "simple_locations"


class AreaType(base_models.AbstractBaseAreaType):
class Meta(base_models.AbstractBaseAreaType.Meta):
app_label = "simple_locations"

class Area(base_models.get_area_base(AreaType, Point)):

class Area(base_models.get_area_base(AreaType, Point)):
class Meta(base_models._AbstractBaseArea.Meta):
app_label = "simple_locations"


class ProjectedArea(base_models.get_projected_area_base(Area)):
pass

Expand Down
2 changes: 1 addition & 1 deletion sl_tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class WgsPoint(models.Model):


class MercatorPoint(models.Model):
position = models.PointField(srid=3857)
position = models.PointField(srid=3857)

0 comments on commit 842b79d

Please sign in to comment.