describe locationgroup choices in editor forms
This commit is contained in:
parent
d9a699719c
commit
4f2861308a
2 changed files with 21 additions and 0 deletions
|
@ -24,6 +24,9 @@ class MapitemFormMixin(ModelForm):
|
||||||
if not creating:
|
if not creating:
|
||||||
self.initial['geometry'] = json.dumps(mapping(self.instance.geometry), separators=(',', ':'))
|
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
|
# parse titles
|
||||||
self.titles = None
|
self.titles = None
|
||||||
if hasattr(self.instance, 'titles'):
|
if hasattr(self.instance, 'titles'):
|
||||||
|
|
|
@ -146,6 +146,24 @@ class LocationGroup(Location, EditorFormMixin, models.Model):
|
||||||
result['compiled_area'] = self.compiled_area
|
result['compiled_area'] = self.compiled_area
|
||||||
return result
|
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):
|
class LocationRedirect(LocationSlug):
|
||||||
target = models.ForeignKey(LocationSlug, verbose_name=_('target'), related_name='redirects')
|
target = models.ForeignKey(LocationSlug, verbose_name=_('target'), related_name='redirects')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue