move Area.stuffed into a Location Group
This commit is contained in:
parent
09fe696b49
commit
d2859f1452
3 changed files with 33 additions and 9 deletions
|
@ -142,7 +142,7 @@ class EditorFormBase(ModelForm):
|
|||
|
||||
def create_editor_form(editor_model):
|
||||
possible_fields = ['slug', 'name', 'altitude', 'category', 'width', 'groups', 'color', 'priority',
|
||||
'public', 'can_search', 'can_describe', 'outside', 'stuffed', 'geometry',
|
||||
'public', 'can_search', 'can_describe', 'outside', 'geometry',
|
||||
'single', 'allow_levels', 'allow_spaces', 'allow_areas', 'allow_pois',
|
||||
'left', 'top', 'right', 'bottom']
|
||||
field_names = [field.name for field in editor_model._meta.get_fields() if not field.one_to_many]
|
||||
|
|
32
src/c3nav/mapdata/migrations/0025_remove_area_stuffed.py
Normal file
32
src/c3nav/mapdata/migrations/0025_remove_area_stuffed.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.2 on 2017-07-13 10:31
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def convert_stuffed_area_to_location_group(apps, schema_editor):
|
||||
LocationGroupCategory = apps.get_model('mapdata', 'LocationGroupCategory')
|
||||
Area = apps.get_model('mapdata', 'Area')
|
||||
|
||||
category = LocationGroupCategory.objects.get(name='groups')
|
||||
group = category.groups.create(can_search=False, can_describe=False, color='rgba(0, 0, 0, 0.04)', titles={
|
||||
'en': 'Stuffed area',
|
||||
'de': 'Vollgestopfter Bereich',
|
||||
}, priority=-1)
|
||||
group.areas.set(Area.objects.filter(stuffed=True))
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mapdata', '0024_remove_compiled_room_area'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(convert_stuffed_area_to_location_group),
|
||||
migrations.RemoveField(
|
||||
model_name='area',
|
||||
name='stuffed',
|
||||
),
|
||||
]
|
|
@ -50,7 +50,6 @@ class Area(SpecificLocation, SpaceGeometryMixin, models.Model):
|
|||
An area in a space.
|
||||
"""
|
||||
geometry = GeometryField('polygon')
|
||||
stuffed = models.BooleanField(verbose_name=_('stuffed area'), default=False)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Area')
|
||||
|
@ -59,15 +58,8 @@ class Area(SpecificLocation, SpaceGeometryMixin, models.Model):
|
|||
|
||||
def _serialize(self, **kwargs):
|
||||
result = super()._serialize(**kwargs)
|
||||
result['stuffed'] = self.stuffed
|
||||
return result
|
||||
|
||||
def get_color(self, *args, **kwargs):
|
||||
color = super().get_color(*args, **kwargs)
|
||||
if not color and self.stuffed:
|
||||
color = 'rgba(0, 0, 0, 0.04)'
|
||||
return color
|
||||
|
||||
|
||||
class Stair(SpaceGeometryMixin, models.Model):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue