add color field
This commit is contained in:
parent
e2624230a5
commit
e9f31f502a
2 changed files with 39 additions and 0 deletions
25
src/c3nav/mapdata/migrations/0034_auto_20161224_2104.py
Normal file
25
src/c3nav/mapdata/migrations/0034_auto_20161224_2104.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.4 on 2016-12-24 21:04
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mapdata', '0033_auto_20161224_1803'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='arealocation',
|
||||
name='color',
|
||||
field=models.CharField(blank=True, help_text='if set, has to be a valid color for svg images', max_length=16, null=True, verbose_name='background color'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='locationgroup',
|
||||
name='color',
|
||||
field=models.CharField(blank=True, help_text='if set, has to be a valid color for svg images', max_length=16, null=True, verbose_name='background color'),
|
||||
),
|
||||
]
|
|
@ -69,12 +69,22 @@ class LocationModelMixin(Location):
|
|||
raise ValueError('can_describe has to be boolean!')
|
||||
kwargs['can_describe'] = can_describe
|
||||
|
||||
if 'color' not in data:
|
||||
color = data['color']
|
||||
if not isinstance(color, str):
|
||||
raise ValueError('color has to be str!')
|
||||
if color:
|
||||
kwargs['color'] = color
|
||||
|
||||
return kwargs
|
||||
|
||||
def tofile(self, form=None):
|
||||
result = super().tofile(form=form)
|
||||
result['titles'] = OrderedDict(sorted(self.titles.items()))
|
||||
result['can_search'] = self.can_search
|
||||
result['can_describe'] = self.can_describe
|
||||
if self.color:
|
||||
result['color'] = self.color
|
||||
return result
|
||||
|
||||
@property
|
||||
|
@ -86,6 +96,8 @@ class LocationGroup(LocationModelMixin, MapItem):
|
|||
titles = JSONField()
|
||||
can_search = models.BooleanField(default=True, verbose_name=_('can be searched'))
|
||||
can_describe = models.BooleanField(default=True, verbose_name=_('can be used to describe a position'))
|
||||
color = models.CharField(null=True, blank=True, max_length=16, verbose_name=_('background color'),
|
||||
help_text=_('if set, has to be a valid color for svg images'))
|
||||
compiled_room = models.BooleanField(default=False, verbose_name=_('is a compiled room'))
|
||||
|
||||
class Meta:
|
||||
|
@ -176,6 +188,8 @@ class AreaLocation(LocationModelMixin, GeometryMapItemWithLevel):
|
|||
|
||||
can_search = models.BooleanField(default=True, verbose_name=_('can be searched'))
|
||||
can_describe = models.BooleanField(default=True, verbose_name=_('can be used to describe a position'))
|
||||
color = models.CharField(null=True, blank=True, max_length=16, verbose_name=_('background color'),
|
||||
help_text=_('if set, has to be a valid color for svg images'))
|
||||
routing_inclusion = models.CharField(max_length=20, choices=ROUTING_INCLUSIONS, default='default',
|
||||
verbose_name=_('Routing Inclusion'))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue