add new data and editor permissions
This commit is contained in:
parent
8ffa982882
commit
b88b6c3a29
18 changed files with 160 additions and 60 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue