describe locationgroup choices in editor forms

This commit is contained in:
Laura Klünder 2017-05-16 14:50:36 +02:00
parent d9a699719c
commit 4f2861308a
2 changed files with 21 additions and 0 deletions

View file

@ -24,6 +24,9 @@ class MapitemFormMixin(ModelForm):
if not creating:
self.initial['geometry'] = json.dumps(mapping(self.instance.geometry), separators=(',', ':'))
if 'groups' in self.fields:
self.fields['groups'].label_from_instance = lambda obj: obj.title_for_forms
# parse titles
self.titles = None
if hasattr(self.instance, 'titles'):

View file

@ -146,6 +146,24 @@ class LocationGroup(Location, EditorFormMixin, models.Model):
result['compiled_area'] = self.compiled_area
return result
@property
def title_for_forms(self):
attributes = []
if self.can_search:
attributes.append(_('search'))
if self.can_describe:
attributes.append(_('describe'))
if self.color:
attributes.append(_('color'))
if not attributes:
attributes.append(_('internal'))
if self.compiled_room:
attributes.append(_('comp. room'))
if self.compiled_area:
attributes.append(_('comp. area'))
return self.title + ' ('+', '.join(str(s) for s in attributes)+')'
class LocationRedirect(LocationSlug):
target = models.ForeignKey(LocationSlug, verbose_name=_('target'), related_name='redirects')