remove new_serialize, this is now the new standard

This commit is contained in:
Laura Klünder 2024-12-04 15:48:48 +01:00
parent c1eb47a0e0
commit 3ab84b6e8d
9 changed files with 1 additions and 51 deletions

View file

@ -73,7 +73,7 @@ class BaseSchema(Schema):
@classmethod @classmethod
def _run_root_validator(cls, values: Any, handler: ModelWrapValidatorHandler[Schema], info: ValidationInfo) -> Any: 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 """ """ 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()) converted = make_serializable(values.serialize())
elif isinstance(values, Model): elif isinstance(values, Model):
converted = ModelDataForwarder( converted = ModelDataForwarder(

View file

@ -17,8 +17,6 @@ from c3nav.mapdata.models.base import SerializableMixin, TitledMixin
class AccessRestriction(TitledMixin, models.Model): class AccessRestriction(TitledMixin, models.Model):
new_serialize = True
""" """
An access restriction An access restriction
""" """
@ -59,8 +57,6 @@ class AccessRestriction(TitledMixin, models.Model):
class AccessRestrictionGroup(TitledMixin, models.Model): class AccessRestrictionGroup(TitledMixin, models.Model):
new_serialize = True
""" """
An access restriction group An access restriction group
""" """

View file

@ -100,8 +100,6 @@ class Building(LevelGeometryMixin, models.Model):
""" """
The outline of a building on a specific level The outline of a building on a specific level
""" """
new_serialize = True
geometry = GeometryField('polygon') geometry = GeometryField('polygon')
class Meta: class Meta:
@ -114,8 +112,6 @@ class Space(LevelGeometryMixin, SpecificLocation, models.Model):
""" """
An accessible space. Shouldn't overlap with spaces on the same level. An accessible space. Shouldn't overlap with spaces on the same level.
""" """
new_serialize = True
geometry = GeometryField('polygon') geometry = GeometryField('polygon')
height = models.DecimalField(_('height'), max_digits=6, decimal_places=2, null=True, blank=True, height = models.DecimalField(_('height'), max_digits=6, decimal_places=2, null=True, blank=True,
validators=[MinValueValidator(Decimal('0'))]) validators=[MinValueValidator(Decimal('0'))])
@ -150,8 +146,6 @@ class Door(LevelGeometryMixin, AccessRestrictionMixin, models.Model):
""" """
A connection between two spaces A connection between two spaces
""" """
new_serialize = True
geometry = GeometryField('polygon') geometry = GeometryField('polygon')
class Meta: class Meta:

View file

@ -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. An column in a space, also used to be able to create rooms within rooms.
""" """
new_serialize = True
geometry = GeometryField('polygon') geometry = GeometryField('polygon')
class Meta: class Meta:
@ -122,8 +120,6 @@ class Area(SpaceGeometryMixin, SpecificLocation, models.Model):
""" """
An area in a space. An area in a space.
""" """
new_serialize = True
geometry = GeometryField('polygon') geometry = GeometryField('polygon')
slow_down_factor = models.DecimalField(_('slow down factor'), max_digits=6, decimal_places=2, default=1, slow_down_factor = models.DecimalField(_('slow down factor'), max_digits=6, decimal_places=2, default=1,
validators=[MinValueValidator(Decimal('0.01'))], validators=[MinValueValidator(Decimal('0.01'))],
@ -153,8 +149,6 @@ class Stair(SpaceGeometryMixin, models.Model):
""" """
A stair A stair
""" """
new_serialize = True
geometry = GeometryField('linestring') geometry = GeometryField('linestring')
class Meta: class Meta:
@ -167,8 +161,6 @@ class Ramp(SpaceGeometryMixin, models.Model):
""" """
A ramp A ramp
""" """
new_serialize = True
geometry = GeometryField('polygon') geometry = GeometryField('polygon')
class Meta: class Meta:
@ -210,8 +202,6 @@ class Obstacle(SpaceGeometryMixin, models.Model):
""" """
An obstacle An obstacle
""" """
new_serialize = True
group = models.ForeignKey(ObstacleGroup, null=True, blank=True, on_delete=models.SET_NULL) group = models.ForeignKey(ObstacleGroup, null=True, blank=True, on_delete=models.SET_NULL)
geometry = GeometryField('polygon') geometry = GeometryField('polygon')
height = models.DecimalField(_('height'), max_digits=6, decimal_places=2, default=0.8, 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 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) group = models.ForeignKey(ObstacleGroup, null=True, blank=True, on_delete=models.SET_NULL)
geometry = GeometryField('linestring') geometry = GeometryField('linestring')
width = models.DecimalField(_('width'), max_digits=4, decimal_places=2, default=0.15) 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 A point of interest
""" """
new_serialize = True
geometry = GeometryField('point') geometry = GeometryField('point')
class Meta: class Meta:
@ -336,8 +322,6 @@ class Hole(SpaceGeometryMixin, models.Model):
""" """
A hole in the ground of a space, e.g. for stairs. A hole in the ground of a space, e.g. for stairs.
""" """
new_serialize = True
geometry = GeometryField('polygon') geometry = GeometryField('polygon')
class Meta: class Meta:
@ -372,8 +356,6 @@ class LeaveDescription(SerializableMixin):
""" """
A description for leaving a space to another space A description for leaving a space to another space
""" """
new_serialize = True
space = models.ForeignKey('mapdata.Space', on_delete=models.CASCADE, verbose_name=_('space')) 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'), target_space = models.ForeignKey('mapdata.Space', on_delete=models.CASCADE, verbose_name=_('target space'),
related_name='enter_descriptions') related_name='enter_descriptions')
@ -403,8 +385,6 @@ class CrossDescription(SerializableMixin):
""" """
A description for crossing a space from one space to another space 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')) 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'), origin_space = models.ForeignKey('mapdata.Space', on_delete=models.CASCADE, verbose_name=_('origin space'),
related_name='leave_cross_descriptions') related_name='leave_cross_descriptions')

View file

@ -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. 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) 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, default_height = models.DecimalField(_('default space height'), max_digits=6, decimal_places=2, default=3.0,
validators=[MinValueValidator(Decimal('0'))]) validators=[MinValueValidator(Decimal('0'))])

View file

@ -254,8 +254,6 @@ class SpecificLocation(Location, models.Model):
class LocationGroupCategory(SerializableMixin, models.Model): class LocationGroupCategory(SerializableMixin, models.Model):
new_serialize = True
name = models.SlugField(_('Name'), unique=True, max_length=50) name = models.SlugField(_('Name'), unique=True, max_length=50)
single = models.BooleanField(_('single selection'), default=False) single = models.BooleanField(_('single selection'), default=False)
title = I18nField(_('Title'), plural_name='titles', fallback_any=True) title = I18nField(_('Title'), plural_name='titles', fallback_any=True)
@ -303,8 +301,6 @@ class LocationGroupManager(models.Manager):
class LocationGroup(Location, models.Model): class LocationGroup(Location, models.Model):
new_serialize = True
class CanReportMissing(models.TextChoices): class CanReportMissing(models.TextChoices):
DONT_OFFER = "dont_offer", _("don't offer") DONT_OFFER = "dont_offer", _("don't offer")
REJECT = "reject", _("offer in first step, then reject") REJECT = "reject", _("offer in first step, then reject")
@ -411,8 +407,6 @@ class LocationGroup(Location, models.Model):
class LocationRedirect(LocationSlug): class LocationRedirect(LocationSlug):
new_serialize = True
target = models.ForeignKey(LocationSlug, related_name='redirects', on_delete=models.CASCADE, target = models.ForeignKey(LocationSlug, related_name='redirects', on_delete=models.CASCADE,
verbose_name=_('target')) verbose_name=_('target'))
@ -427,8 +421,6 @@ class LocationRedirect(LocationSlug):
class LabelSettings(SerializableMixin, models.Model): class LabelSettings(SerializableMixin, models.Model):
new_serialize = True
title = I18nField(_('Title'), plural_name='titles', fallback_any=True) title = I18nField(_('Title'), plural_name='titles', fallback_any=True)
min_zoom = models.DecimalField(_('min zoom'), max_digits=3, decimal_places=1, default=-10, min_zoom = models.DecimalField(_('min zoom'), max_digits=3, decimal_places=1, default=-10,
validators=[MinValueValidator(Decimal('-10')), validators=[MinValueValidator(Decimal('-10')),
@ -474,8 +466,6 @@ class CustomLocationProxyMixin:
class DynamicLocation(CustomLocationProxyMixin, SpecificLocation, models.Model): class DynamicLocation(CustomLocationProxyMixin, SpecificLocation, models.Model):
new_serialize = True
position_secret = models.CharField(_('position secret'), max_length=32, null=True, blank=True) position_secret = models.CharField(_('position secret'), max_length=32, null=True, blank=True)
class Meta: class Meta:

View file

@ -12,8 +12,6 @@ from c3nav.mapdata.utils.json import format_geojson
class DataOverlay(TitledMixin, models.Model): class DataOverlay(TitledMixin, models.Model):
new_serialize = True
description = models.TextField(blank=True, verbose_name=_('Description')) description = models.TextField(blank=True, verbose_name=_('Description'))
stroke_color = models.TextField(blank=True, null=True, verbose_name=_('default stroke color')) 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')) 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): class DataOverlayFeature(TitledMixin, GeometryMixin, models.Model):
new_serialize = True
overlay = models.ForeignKey('mapdata.DataOverlay', on_delete=models.CASCADE, verbose_name=_('Overlay'), related_name='features') overlay = models.ForeignKey('mapdata.DataOverlay', on_delete=models.CASCADE, verbose_name=_('Overlay'), related_name='features')
geometry = GeometryField() geometry = GeometryField()
level = models.ForeignKey('mapdata.Level', on_delete=models.CASCADE, verbose_name=_('level'), related_name='data_overlay_features') level = models.ForeignKey('mapdata.Level', on_delete=models.CASCADE, verbose_name=_('level'), related_name='data_overlay_features')

View file

@ -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 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 name = models.CharField(_('Name'), unique=True, max_length=50) # a slugfield would forbid periods
class Meta: class Meta:

View file

@ -275,8 +275,6 @@ def get_custom_location_for_request(slug: str, request):
@dataclass @dataclass
class CustomLocation: class CustomLocation:
new_serialize: ClassVar = True
locationtype: ClassVar = "customlocation" locationtype: ClassVar = "customlocation"
can_search = True can_search = True