add new data and editor permissions
This commit is contained in:
parent
8ffa982882
commit
b88b6c3a29
18 changed files with 160 additions and 60 deletions
|
@ -250,8 +250,8 @@ class AccessRestrictionMixin(SerializableMixin, models.Model):
|
|||
result['access_restriction'] = self.access_restriction_id
|
||||
return result
|
||||
|
||||
def details_display(self):
|
||||
result = super().details_display()
|
||||
def details_display(self, **kwargs):
|
||||
result = super().details_display(**kwargs)
|
||||
result['display'].extend([
|
||||
(_('Access Restriction'), self.access_restriction_id and self.access_restriction.title),
|
||||
])
|
||||
|
|
|
@ -33,7 +33,7 @@ class SerializableMixin(models.Model):
|
|||
result['id'] = self.pk
|
||||
return result
|
||||
|
||||
def details_display(self):
|
||||
def details_display(self, **kwargs):
|
||||
return {
|
||||
'id': self.pk,
|
||||
'display': [
|
||||
|
@ -72,8 +72,8 @@ class TitledMixin(SerializableMixin, models.Model):
|
|||
result['title'] = self.title
|
||||
return result
|
||||
|
||||
def details_display(self):
|
||||
result = super().details_display()
|
||||
def details_display(self, **kwargs):
|
||||
result = super().details_display(**kwargs)
|
||||
for lang, title in sorted(self.titles.items(), key=lambda item: item[0] != get_language()):
|
||||
language = _('Title ({lang})').format(lang=get_language_info(lang)['name_translated'])
|
||||
result['display'].append((language, title))
|
||||
|
|
|
@ -2,7 +2,7 @@ import math
|
|||
from collections import OrderedDict
|
||||
|
||||
from django.utils.functional import cached_property
|
||||
from shapely.geometry import Point, mapping
|
||||
from shapely.geometry import Point, box, mapping
|
||||
from shapely.ops import unary_union
|
||||
|
||||
from c3nav.mapdata.models.base import SerializableMixin
|
||||
|
@ -78,9 +78,12 @@ class GeometryMixin(SerializableMixin):
|
|||
(int(math.ceil(maxx)), int(math.ceil(maxy))))
|
||||
return result
|
||||
|
||||
def details_display(self):
|
||||
result = super().details_display()
|
||||
result['geometry'] = format_geojson(mapping(self.geometry), round=False)
|
||||
def details_display(self, detailed_geometry=True, **kwargs):
|
||||
result = super().details_display(**kwargs)
|
||||
if detailed_geometry:
|
||||
result['geometry'] = format_geojson(mapping(self.geometry), round=False)
|
||||
else:
|
||||
result['geometry'] = format_geojson(mapping(box(*self.geometry.bounds)), round=False)
|
||||
return result
|
||||
|
||||
def get_shadow_geojson(self):
|
||||
|
|
|
@ -49,8 +49,8 @@ class LevelGeometryMixin(GeometryMixin):
|
|||
result['level'] = self.level_id
|
||||
return result
|
||||
|
||||
def details_display(self):
|
||||
result = super().details_display()
|
||||
def details_display(self, **kwargs):
|
||||
result = super().details_display(**kwargs)
|
||||
result['display'].insert(3, (
|
||||
_('Level'),
|
||||
{
|
||||
|
@ -126,13 +126,14 @@ class Space(LevelGeometryMixin, SpecificLocation, models.Model):
|
|||
result['height'] = None if self.height is None else float(str(self.height))
|
||||
return result
|
||||
|
||||
def details_display(self):
|
||||
result = super().details_display()
|
||||
def details_display(self, editor_url=True, **kwargs):
|
||||
result = super().details_display(**kwargs)
|
||||
result['display'].extend([
|
||||
(_('height'), self.height),
|
||||
(_('outside only'), _('Yes') if self.outside else _('No')),
|
||||
])
|
||||
result['editor_url'] = reverse('editor.spaces.detail', kwargs={'level': self.level_id, 'pk': self.pk})
|
||||
if editor_url:
|
||||
result['editor_url'] = reverse('editor.spaces.detail', kwargs={'level': self.level_id, 'pk': self.pk})
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
@ -73,8 +73,8 @@ class SpaceGeometryMixin(GeometryMixin):
|
|||
self.geometry if force else self.get_changed_geometry()
|
||||
))
|
||||
|
||||
def details_display(self):
|
||||
result = super().details_display()
|
||||
def details_display(self, **kwargs):
|
||||
result = super().details_display(**kwargs)
|
||||
result['display'].insert(3, (
|
||||
_('Space'),
|
||||
{
|
||||
|
@ -125,9 +125,10 @@ class Area(SpaceGeometryMixin, SpecificLocation, models.Model):
|
|||
result = super()._serialize(**kwargs)
|
||||
return result
|
||||
|
||||
def details_display(self):
|
||||
result = super().details_display()
|
||||
result['editor_url'] = reverse('editor.areas.edit', kwargs={'space': self.space_id, 'pk': self.pk})
|
||||
def details_display(self, editor_url=True, **kwargs):
|
||||
result = super().details_display(**kwargs)
|
||||
if editor_url:
|
||||
result['editor_url'] = reverse('editor.areas.edit', kwargs={'space': self.space_id, 'pk': self.pk})
|
||||
return result
|
||||
|
||||
|
||||
|
@ -224,9 +225,10 @@ class POI(SpaceGeometryMixin, SpecificLocation, models.Model):
|
|||
verbose_name_plural = _('Points of Interest')
|
||||
default_related_name = 'pois'
|
||||
|
||||
def details_display(self):
|
||||
result = super().details_display()
|
||||
result['editor_url'] = reverse('editor.pois.edit', kwargs={'space': self.space_id, 'pk': self.pk})
|
||||
def details_display(self, editor_url=True, **kwargs):
|
||||
result = super().details_display(**kwargs)
|
||||
if editor_url:
|
||||
result['editor_url'] = reverse('editor.pois.edit', kwargs={'space': self.space_id, 'pk': self.pk})
|
||||
return result
|
||||
|
||||
@property
|
||||
|
|
|
@ -77,14 +77,15 @@ class Level(SpecificLocation, models.Model):
|
|||
result['door_height'] = float(str(self.door_height))
|
||||
return result
|
||||
|
||||
def details_display(self):
|
||||
result = super().details_display()
|
||||
def details_display(self, editor_url=True, **kwargs):
|
||||
result = super().details_display(**kwargs)
|
||||
result['display'].insert(3, (_('short label'), self.short_label))
|
||||
result['display'].extend([
|
||||
(_('outside only'), self.base_altitude),
|
||||
(_('default height'), self.default_height),
|
||||
])
|
||||
result['editor_url'] = reverse('editor.levels.detail', kwargs={'pk': self.pk})
|
||||
if editor_url:
|
||||
result['editor_url'] = reverse('editor.levels.detail', kwargs={'pk': self.pk})
|
||||
return result
|
||||
|
||||
@cached_property
|
||||
|
|
|
@ -60,8 +60,8 @@ class LocationSlug(SerializableMixin, models.Model):
|
|||
result['slug'] = self.get_slug()
|
||||
return result
|
||||
|
||||
def details_display(self):
|
||||
result = super().details_display()
|
||||
def details_display(self, **kwargs):
|
||||
result = super().details_display(**kwargs)
|
||||
result['display'].insert(2, (_('Slug'), str(self.get_slug())))
|
||||
return result
|
||||
|
||||
|
@ -96,8 +96,8 @@ class Location(LocationSlug, AccessRestrictionMixin, TitledMixin, models.Model):
|
|||
result['can_describe'] = self.can_search
|
||||
return result
|
||||
|
||||
def details_display(self):
|
||||
result = super().details_display()
|
||||
def details_display(self, **kwargs):
|
||||
result = super().details_display(**kwargs)
|
||||
result['display'].extend([
|
||||
(_('searchable'), _('Yes') if self.can_search else _('No')),
|
||||
(_('can describe'), _('Yes') if self.can_describe else _('No'))
|
||||
|
@ -143,8 +143,8 @@ class SpecificLocation(Location, models.Model):
|
|||
result['groups'] = groups
|
||||
return result
|
||||
|
||||
def details_display(self):
|
||||
result = super().details_display()
|
||||
def details_display(self, **kwargs):
|
||||
result = super().details_display(**kwargs)
|
||||
|
||||
groupcategories = {}
|
||||
for group in self.groups.all():
|
||||
|
@ -258,14 +258,15 @@ class LocationGroup(Location, models.Model):
|
|||
result['locations'] = tuple(obj.pk for obj in getattr(self, 'locations', ()))
|
||||
return result
|
||||
|
||||
def details_display(self):
|
||||
result = super().details_display()
|
||||
def details_display(self, editor_url=True, **kwargs):
|
||||
result = super().details_display(**kwargs)
|
||||
result['display'].insert(3, (_('Category'), self.category.title))
|
||||
result['display'].extend([
|
||||
(_('color'), self.color),
|
||||
(_('priority'), self.priority),
|
||||
])
|
||||
result['editor_url'] = reverse('editor.locationgroups.edit', kwargs={'pk': self.pk})
|
||||
if editor_url:
|
||||
result['editor_url'] = reverse('editor.locationgroups.edit', kwargs={'pk': self.pk})
|
||||
return result
|
||||
|
||||
@property
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue