make sources editable
This commit is contained in:
parent
c1f92e5add
commit
dcfab74f29
4 changed files with 9 additions and 2 deletions
|
@ -63,7 +63,8 @@ class MapitemFormMixin(ModelForm):
|
||||||
|
|
||||||
def create_editor_form(editor_model):
|
def create_editor_form(editor_model):
|
||||||
possible_fields = ['name', 'altitude', 'level', 'category', 'width', 'groups', 'color', 'public',
|
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()]
|
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]
|
existing_fields = [name for name in possible_fields if name in field_names]
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ urlpatterns = [
|
||||||
]
|
]
|
||||||
urlpatterns.extend(add_editor_urls('Section', with_list=False, explicit_edit=True))
|
urlpatterns.extend(add_editor_urls('Section', with_list=False, explicit_edit=True))
|
||||||
urlpatterns.extend(add_editor_urls('LocationGroup'))
|
urlpatterns.extend(add_editor_urls('LocationGroup'))
|
||||||
|
urlpatterns.extend(add_editor_urls('Source'))
|
||||||
urlpatterns.extend(add_editor_urls('Building', 'Section'))
|
urlpatterns.extend(add_editor_urls('Building', 'Section'))
|
||||||
urlpatterns.extend(add_editor_urls('Space', 'Section', explicit_edit=True))
|
urlpatterns.extend(add_editor_urls('Space', 'Section', explicit_edit=True))
|
||||||
urlpatterns.extend(add_editor_urls('Door', 'Section'))
|
urlpatterns.extend(add_editor_urls('Door', 'Section'))
|
||||||
|
|
|
@ -2,7 +2,7 @@ from functools import wraps
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.conf import settings
|
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.http import HttpResponseRedirect
|
||||||
from django.shortcuts import get_object_or_404, redirect, render
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
@ -41,6 +41,7 @@ def main_index(request):
|
||||||
'sections': Section.objects.all(),
|
'sections': Section.objects.all(),
|
||||||
'child_models': [
|
'child_models': [
|
||||||
child_model('LocationGroup'),
|
child_model('LocationGroup'),
|
||||||
|
child_model('Source'),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,10 @@ class Source(EditorFormMixin, BoundsMixin, models.Model):
|
||||||
verbose_name_plural = _('Sources')
|
verbose_name_plural = _('Sources')
|
||||||
default_related_name = 'sources'
|
default_related_name = 'sources'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def title(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
def _serialize(self, section=True, **kwargs):
|
def _serialize(self, section=True, **kwargs):
|
||||||
result = super()._serialize(**kwargs)
|
result = super()._serialize(**kwargs)
|
||||||
result['name'] = self.name
|
result['name'] = self.name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue