remove new_serialize, this is now the new standard
This commit is contained in:
parent
c1eb47a0e0
commit
3ab84b6e8d
9 changed files with 1 additions and 51 deletions
|
@ -73,7 +73,7 @@ class BaseSchema(Schema):
|
|||
@classmethod
|
||||
def _run_root_validator(cls, values: Any, handler: ModelWrapValidatorHandler[Schema], info: ValidationInfo) -> Any:
|
||||
""" overwriting this, we need to call serialize to get the correct data """
|
||||
if hasattr(values, 'serialize') and callable(values.serialize) and not getattr(values, 'new_serialize', False):
|
||||
if hasattr(values, 'serialize') and callable(values.serialize):
|
||||
converted = make_serializable(values.serialize())
|
||||
elif isinstance(values, Model):
|
||||
converted = ModelDataForwarder(
|
||||
|
|
|
@ -17,8 +17,6 @@ from c3nav.mapdata.models.base import SerializableMixin, TitledMixin
|
|||
|
||||
|
||||
class AccessRestriction(TitledMixin, models.Model):
|
||||
new_serialize = True
|
||||
|
||||
"""
|
||||
An access restriction
|
||||
"""
|
||||
|
@ -59,8 +57,6 @@ class AccessRestriction(TitledMixin, models.Model):
|
|||
|
||||
|
||||
class AccessRestrictionGroup(TitledMixin, models.Model):
|
||||
new_serialize = True
|
||||
|
||||
"""
|
||||
An access restriction group
|
||||
"""
|
||||
|
|
|
@ -100,8 +100,6 @@ class Building(LevelGeometryMixin, models.Model):
|
|||
"""
|
||||
The outline of a building on a specific level
|
||||
"""
|
||||
new_serialize = True
|
||||
|
||||
geometry = GeometryField('polygon')
|
||||
|
||||
class Meta:
|
||||
|
@ -114,8 +112,6 @@ class Space(LevelGeometryMixin, SpecificLocation, models.Model):
|
|||
"""
|
||||
An accessible space. Shouldn't overlap with spaces on the same level.
|
||||
"""
|
||||
new_serialize = True
|
||||
|
||||
geometry = GeometryField('polygon')
|
||||
height = models.DecimalField(_('height'), max_digits=6, decimal_places=2, null=True, blank=True,
|
||||
validators=[MinValueValidator(Decimal('0'))])
|
||||
|
@ -150,8 +146,6 @@ class Door(LevelGeometryMixin, AccessRestrictionMixin, models.Model):
|
|||
"""
|
||||
A connection between two spaces
|
||||
"""
|
||||
new_serialize = True
|
||||
|
||||
geometry = GeometryField('polygon')
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -108,8 +108,6 @@ class Column(SpaceGeometryMixin, AccessRestrictionMixin, models.Model):
|
|||
"""
|
||||
An column in a space, also used to be able to create rooms within rooms.
|
||||
"""
|
||||
new_serialize = True
|
||||
|
||||
geometry = GeometryField('polygon')
|
||||
|
||||
class Meta:
|
||||
|
@ -122,8 +120,6 @@ class Area(SpaceGeometryMixin, SpecificLocation, models.Model):
|
|||
"""
|
||||
An area in a space.
|
||||
"""
|
||||
new_serialize = True
|
||||
|
||||
geometry = GeometryField('polygon')
|
||||
slow_down_factor = models.DecimalField(_('slow down factor'), max_digits=6, decimal_places=2, default=1,
|
||||
validators=[MinValueValidator(Decimal('0.01'))],
|
||||
|
@ -153,8 +149,6 @@ class Stair(SpaceGeometryMixin, models.Model):
|
|||
"""
|
||||
A stair
|
||||
"""
|
||||
new_serialize = True
|
||||
|
||||
geometry = GeometryField('linestring')
|
||||
|
||||
class Meta:
|
||||
|
@ -167,8 +161,6 @@ class Ramp(SpaceGeometryMixin, models.Model):
|
|||
"""
|
||||
A ramp
|
||||
"""
|
||||
new_serialize = True
|
||||
|
||||
geometry = GeometryField('polygon')
|
||||
|
||||
class Meta:
|
||||
|
@ -210,8 +202,6 @@ class Obstacle(SpaceGeometryMixin, models.Model):
|
|||
"""
|
||||
An obstacle
|
||||
"""
|
||||
new_serialize = True
|
||||
|
||||
group = models.ForeignKey(ObstacleGroup, null=True, blank=True, on_delete=models.SET_NULL)
|
||||
geometry = GeometryField('polygon')
|
||||
height = models.DecimalField(_('height'), max_digits=6, decimal_places=2, default=0.8,
|
||||
|
@ -250,8 +240,6 @@ class LineObstacle(SpaceGeometryMixin, models.Model):
|
|||
"""
|
||||
An obstacle that is a line with a specific width
|
||||
"""
|
||||
new_serialize = True
|
||||
|
||||
group = models.ForeignKey(ObstacleGroup, null=True, blank=True, on_delete=models.SET_NULL)
|
||||
geometry = GeometryField('linestring')
|
||||
width = models.DecimalField(_('width'), max_digits=4, decimal_places=2, default=0.15)
|
||||
|
@ -302,8 +290,6 @@ class POI(SpaceGeometryMixin, SpecificLocation, models.Model):
|
|||
"""
|
||||
A point of interest
|
||||
"""
|
||||
new_serialize = True
|
||||
|
||||
geometry = GeometryField('point')
|
||||
|
||||
class Meta:
|
||||
|
@ -336,8 +322,6 @@ class Hole(SpaceGeometryMixin, models.Model):
|
|||
"""
|
||||
A hole in the ground of a space, e.g. for stairs.
|
||||
"""
|
||||
new_serialize = True
|
||||
|
||||
geometry = GeometryField('polygon')
|
||||
|
||||
class Meta:
|
||||
|
@ -372,8 +356,6 @@ class LeaveDescription(SerializableMixin):
|
|||
"""
|
||||
A description for leaving a space to another space
|
||||
"""
|
||||
new_serialize = True
|
||||
|
||||
space = models.ForeignKey('mapdata.Space', on_delete=models.CASCADE, verbose_name=_('space'))
|
||||
target_space = models.ForeignKey('mapdata.Space', on_delete=models.CASCADE, verbose_name=_('target space'),
|
||||
related_name='enter_descriptions')
|
||||
|
@ -403,8 +385,6 @@ class CrossDescription(SerializableMixin):
|
|||
"""
|
||||
A description for crossing a space from one space to another space
|
||||
"""
|
||||
new_serialize = True
|
||||
|
||||
space = models.ForeignKey('mapdata.Space', on_delete=models.CASCADE, verbose_name=_('space'))
|
||||
origin_space = models.ForeignKey('mapdata.Space', on_delete=models.CASCADE, verbose_name=_('origin space'),
|
||||
related_name='leave_cross_descriptions')
|
||||
|
|
|
@ -18,8 +18,6 @@ class Level(SpecificLocation, models.Model):
|
|||
|
||||
A level is a specific location, and can therefore be routed to and from, as well as belong to location groups.
|
||||
"""
|
||||
new_serialize = True
|
||||
|
||||
base_altitude = models.DecimalField(_('base altitude'), null=False, unique=True, max_digits=6, decimal_places=2)
|
||||
default_height = models.DecimalField(_('default space height'), max_digits=6, decimal_places=2, default=3.0,
|
||||
validators=[MinValueValidator(Decimal('0'))])
|
||||
|
|
|
@ -254,8 +254,6 @@ class SpecificLocation(Location, models.Model):
|
|||
|
||||
|
||||
class LocationGroupCategory(SerializableMixin, models.Model):
|
||||
new_serialize = True
|
||||
|
||||
name = models.SlugField(_('Name'), unique=True, max_length=50)
|
||||
single = models.BooleanField(_('single selection'), default=False)
|
||||
title = I18nField(_('Title'), plural_name='titles', fallback_any=True)
|
||||
|
@ -303,8 +301,6 @@ class LocationGroupManager(models.Manager):
|
|||
|
||||
|
||||
class LocationGroup(Location, models.Model):
|
||||
new_serialize = True
|
||||
|
||||
class CanReportMissing(models.TextChoices):
|
||||
DONT_OFFER = "dont_offer", _("don't offer")
|
||||
REJECT = "reject", _("offer in first step, then reject")
|
||||
|
@ -411,8 +407,6 @@ class LocationGroup(Location, models.Model):
|
|||
|
||||
|
||||
class LocationRedirect(LocationSlug):
|
||||
new_serialize = True
|
||||
|
||||
target = models.ForeignKey(LocationSlug, related_name='redirects', on_delete=models.CASCADE,
|
||||
verbose_name=_('target'))
|
||||
|
||||
|
@ -427,8 +421,6 @@ class LocationRedirect(LocationSlug):
|
|||
|
||||
|
||||
class LabelSettings(SerializableMixin, models.Model):
|
||||
new_serialize = True
|
||||
|
||||
title = I18nField(_('Title'), plural_name='titles', fallback_any=True)
|
||||
min_zoom = models.DecimalField(_('min zoom'), max_digits=3, decimal_places=1, default=-10,
|
||||
validators=[MinValueValidator(Decimal('-10')),
|
||||
|
@ -474,8 +466,6 @@ class CustomLocationProxyMixin:
|
|||
|
||||
|
||||
class DynamicLocation(CustomLocationProxyMixin, SpecificLocation, models.Model):
|
||||
new_serialize = True
|
||||
|
||||
position_secret = models.CharField(_('position secret'), max_length=32, null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -12,8 +12,6 @@ from c3nav.mapdata.utils.json import format_geojson
|
|||
|
||||
|
||||
class DataOverlay(TitledMixin, models.Model):
|
||||
new_serialize = True
|
||||
|
||||
description = models.TextField(blank=True, verbose_name=_('Description'))
|
||||
stroke_color = models.TextField(blank=True, null=True, verbose_name=_('default stroke color'))
|
||||
stroke_width = models.FloatField(blank=True, null=True, verbose_name=_('default stroke width'))
|
||||
|
@ -30,8 +28,6 @@ class DataOverlay(TitledMixin, models.Model):
|
|||
|
||||
|
||||
class DataOverlayFeature(TitledMixin, GeometryMixin, models.Model):
|
||||
new_serialize = True
|
||||
|
||||
overlay = models.ForeignKey('mapdata.DataOverlay', on_delete=models.CASCADE, verbose_name=_('Overlay'), related_name='features')
|
||||
geometry = GeometryField()
|
||||
level = models.ForeignKey('mapdata.Level', on_delete=models.CASCADE, verbose_name=_('level'), related_name='data_overlay_features')
|
||||
|
|
|
@ -10,8 +10,6 @@ class Source(BoundsMixin, AccessRestrictionMixin, models.Model):
|
|||
"""
|
||||
A map source, images of levels that can be useful as backgrounds for the map editor
|
||||
"""
|
||||
new_serialize = True
|
||||
|
||||
name = models.CharField(_('Name'), unique=True, max_length=50) # a slugfield would forbid periods
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -275,8 +275,6 @@ def get_custom_location_for_request(slug: str, request):
|
|||
|
||||
@dataclass
|
||||
class CustomLocation:
|
||||
new_serialize: ClassVar = True
|
||||
|
||||
locationtype: ClassVar = "customlocation"
|
||||
|
||||
can_search = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue