add missing api endpoints for descriptions and access restriction groups
This commit is contained in:
parent
a23be40cac
commit
303c4be485
4 changed files with 48 additions and 7 deletions
|
@ -28,6 +28,11 @@ class AccessRestriction(TitledMixin, models.Model):
|
|||
verbose_name_plural = _('Access Restrictions')
|
||||
default_related_name = 'accessrestrictions'
|
||||
|
||||
def _serialize(self, **kwargs):
|
||||
result = super()._serialize(**kwargs)
|
||||
result['groups'] = tuple(group.pk for group in self.groups.all())
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
def qs_for_request(cls, request):
|
||||
return cls.objects.filter(cls.q_for_request(request))
|
||||
|
|
|
@ -11,6 +11,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||
from shapely.geometry import CAP_STYLE, JOIN_STYLE, mapping
|
||||
|
||||
from c3nav.mapdata.fields import GeometryField, I18nField, JSONField
|
||||
from c3nav.mapdata.models.base import SerializableMixin
|
||||
from c3nav.mapdata.models.geometry.base import GeometryMixin
|
||||
from c3nav.mapdata.models.locations import SpecificLocation
|
||||
from c3nav.mapdata.utils.cache.changes import changed_geometries
|
||||
|
@ -247,7 +248,7 @@ class AltitudeMarker(SpaceGeometryMixin, models.Model):
|
|||
return '%s (%sm)' % (super().title, self.altitude)
|
||||
|
||||
|
||||
class LeaveDescription(models.Model):
|
||||
class LeaveDescription(SerializableMixin):
|
||||
"""
|
||||
A description for leaving a space to another space
|
||||
"""
|
||||
|
@ -264,12 +265,20 @@ class LeaveDescription(models.Model):
|
|||
('space', 'target_space')
|
||||
)
|
||||
|
||||
def _serialize(self, **kwargs):
|
||||
result = super()._serialize(**kwargs)
|
||||
result['space'] = self.space_id
|
||||
result['target_space'] = self.target_space_id
|
||||
result['description_i18n'] = self.description_i18n
|
||||
result['description'] = self.description
|
||||
return result
|
||||
|
||||
@cached_property
|
||||
def title(self):
|
||||
return self.target_space.title
|
||||
|
||||
|
||||
class CrossDescription(models.Model):
|
||||
class CrossDescription(SerializableMixin):
|
||||
"""
|
||||
A description for crossing a space from one space to another space
|
||||
"""
|
||||
|
@ -288,6 +297,15 @@ class CrossDescription(models.Model):
|
|||
('space', 'origin_space', 'target_space')
|
||||
)
|
||||
|
||||
def _serialize(self, **kwargs):
|
||||
result = super()._serialize(**kwargs)
|
||||
result['space'] = self.space_id
|
||||
result['origin_space'] = self.origin_space_id
|
||||
result['target_space'] = self.target_space_id
|
||||
result['description_i18n'] = self.description_i18n
|
||||
result['description'] = self.description
|
||||
return result
|
||||
|
||||
@cached_property
|
||||
def title(self):
|
||||
return '%s → %s' % (self.origin_space.title, self.target_space.title)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue