make sources editable

This commit is contained in:
Laura Klünder 2017-05-26 21:37:53 +02:00
parent c1f92e5add
commit dcfab74f29
4 changed files with 9 additions and 2 deletions

View file

@ -63,7 +63,8 @@ class MapitemFormMixin(ModelForm):
def create_editor_form(editor_model):
possible_fields = ['name', 'altitude', 'level', 'category', 'width', 'groups', 'color', 'public',
'can_search', 'can_describe', 'outside', 'stuffed', 'geometry']
'can_search', 'can_describe', 'outside', 'stuffed', 'geometry',
'left', 'top', 'right', 'bottom']
field_names = [field.name for field in editor_model._meta.get_fields()]
existing_fields = [name for name in possible_fields if name in field_names]

View file

@ -35,6 +35,7 @@ urlpatterns = [
]
urlpatterns.extend(add_editor_urls('Section', with_list=False, explicit_edit=True))
urlpatterns.extend(add_editor_urls('LocationGroup'))
urlpatterns.extend(add_editor_urls('Source'))
urlpatterns.extend(add_editor_urls('Building', 'Section'))
urlpatterns.extend(add_editor_urls('Space', 'Section', explicit_edit=True))
urlpatterns.extend(add_editor_urls('Door', 'Section'))

View file

@ -2,7 +2,7 @@ from functools import wraps
from django.apps import apps
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.core.exceptions import FieldDoesNotExist, PermissionDenied
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse
@ -41,6 +41,7 @@ def main_index(request):
'sections': Section.objects.all(),
'child_models': [
child_model('LocationGroup'),
child_model('Source'),
],
})

View file

@ -16,6 +16,10 @@ class Source(EditorFormMixin, BoundsMixin, models.Model):
verbose_name_plural = _('Sources')
default_related_name = 'sources'
@property
def title(self):
return self.name
def _serialize(self, section=True, **kwargs):
result = super()._serialize(**kwargs)
result['name'] = self.name