remove everything about the editor from mapdata app
This commit is contained in:
parent
a2b993b27a
commit
7a9f4da4c1
11 changed files with 19 additions and 43 deletions
|
@ -1 +0,0 @@
|
|||
default_app_config = 'c3nav.editor.apps.EditorConfig'
|
|
@ -1,9 +0,0 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class EditorConfig(AppConfig):
|
||||
name = 'c3nav.editor'
|
||||
|
||||
def ready(self):
|
||||
from c3nav.editor.forms import create_editor_forms
|
||||
create_editor_forms()
|
|
@ -102,10 +102,5 @@ def create_editor_form(editor_model):
|
|||
model = editor_model
|
||||
fields = existing_fields
|
||||
|
||||
editor_model.EditorForm = EditorForm
|
||||
|
||||
|
||||
def create_editor_forms():
|
||||
from c3nav.mapdata.models.base import EDITOR_FORM_MODELS
|
||||
for mapitemtype in EDITOR_FORM_MODELS.values():
|
||||
create_editor_form(mapitemtype)
|
||||
EditorForm.__name__ = editor_model.__name__+'EditorForm'
|
||||
return EditorForm
|
||||
|
|
|
@ -6,7 +6,6 @@ from django.urls import reverse
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from c3nav.editor.views.base import sidebar_view
|
||||
from c3nav.mapdata.models.base import EDITOR_FORM_MODELS
|
||||
|
||||
|
||||
def child_model(model, kwargs=None, parent=None):
|
||||
|
@ -65,7 +64,7 @@ def space_detail(request, level, pk):
|
|||
|
||||
@sidebar_view
|
||||
def edit(request, pk=None, model=None, level=None, space=None, on_top_of=None, explicit_edit=False):
|
||||
model = request.changeset.wrap(EDITOR_FORM_MODELS[model])
|
||||
model = request.changeset.wrap(model)
|
||||
related_name = model._meta.default_related_name
|
||||
|
||||
Level = request.changeset.wrap('Level')
|
||||
|
@ -230,7 +229,7 @@ def list_objects(request, model=None, level=None, space=None, explicit_edit=Fals
|
|||
if not request.resolver_match.url_name.endswith('.list'):
|
||||
raise ValueError('url_name does not end with .list')
|
||||
|
||||
model = request.changeset.wrap(EDITOR_FORM_MODELS[model])
|
||||
model = request.changeset.wrap(model)
|
||||
|
||||
Level = request.changeset.wrap('Level')
|
||||
Space = request.changeset.wrap('Space')
|
||||
|
|
|
@ -10,6 +10,8 @@ from django.db.models.fields.related_descriptors import ForwardManyToOneDescript
|
|||
from django.db.models.query_utils import DeferredAttribute
|
||||
from django.utils.functional import cached_property
|
||||
|
||||
from c3nav.editor.forms import create_editor_form
|
||||
|
||||
|
||||
def is_created_pk(pk):
|
||||
return isinstance(pk, str) and pk.startswith('c') and pk[1:].isnumeric()
|
||||
|
@ -97,6 +99,10 @@ class ModelWrapper(BaseWrapper):
|
|||
return self._obj is other._obj
|
||||
return self._obj is other
|
||||
|
||||
@cached_property
|
||||
def EditorForm(self):
|
||||
return create_editor_form(self._obj)
|
||||
|
||||
@classmethod
|
||||
def get_submodels(cls, model):
|
||||
try:
|
||||
|
|
|
@ -18,10 +18,6 @@ class MapdataConfig(AppConfig):
|
|||
return submodels
|
||||
|
||||
def ready(self):
|
||||
from c3nav.mapdata.models.base import EditorFormMixin, EDITOR_FORM_MODELS
|
||||
for cls in self._get_submodels(EditorFormMixin):
|
||||
EDITOR_FORM_MODELS[cls.__name__] = cls
|
||||
|
||||
from c3nav.mapdata.models.geometry.base import GeometryMixin, GEOMETRY_MODELS
|
||||
for cls in self._get_submodels(GeometryMixin):
|
||||
GEOMETRY_MODELS[cls.__name__] = cls
|
||||
|
|
|
@ -3,8 +3,6 @@ from collections import OrderedDict
|
|||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
EDITOR_FORM_MODELS = OrderedDict()
|
||||
|
||||
|
||||
class SerializableMixin(models.Model):
|
||||
class Meta:
|
||||
|
@ -29,16 +27,9 @@ class SerializableMixin(models.Model):
|
|||
result['id'] = self.pk
|
||||
return result
|
||||
|
||||
|
||||
class EditorFormMixin(SerializableMixin, models.Model):
|
||||
EditorForm = None
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
return self._meta.verbose_name+' '+str(self.id)
|
||||
return self._meta.verbose_name + ' ' + str(self.id)
|
||||
|
||||
|
||||
class BoundsMixin(SerializableMixin, models.Model):
|
||||
|
|
|
@ -2,13 +2,13 @@ from collections import OrderedDict
|
|||
|
||||
from shapely.geometry import Point, mapping
|
||||
|
||||
from c3nav.mapdata.models.base import EditorFormMixin
|
||||
from c3nav.mapdata.models.base import SerializableMixin
|
||||
from c3nav.mapdata.utils.json import format_geojson
|
||||
|
||||
GEOMETRY_MODELS = OrderedDict()
|
||||
|
||||
|
||||
class GeometryMixin(EditorFormMixin):
|
||||
class GeometryMixin(SerializableMixin):
|
||||
"""
|
||||
A map feature with a geometry
|
||||
"""
|
||||
|
|
|
@ -6,12 +6,11 @@ from django.utils.translation import ugettext_lazy as _
|
|||
from shapely.geometry import JOIN_STYLE
|
||||
from shapely.ops import cascaded_union
|
||||
|
||||
from c3nav.mapdata.models.base import EditorFormMixin
|
||||
from c3nav.mapdata.models.locations import SpecificLocation
|
||||
from c3nav.mapdata.utils.svg import SVGImage
|
||||
|
||||
|
||||
class Level(SpecificLocation, EditorFormMixin, models.Model):
|
||||
class Level(SpecificLocation, models.Model):
|
||||
"""
|
||||
A map level
|
||||
"""
|
||||
|
|
|
@ -6,7 +6,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||
from django.utils.translation import get_language
|
||||
|
||||
from c3nav.mapdata.fields import JSONField
|
||||
from c3nav.mapdata.models.base import EditorFormMixin, SerializableMixin
|
||||
from c3nav.mapdata.models.base import SerializableMixin
|
||||
|
||||
LOCATION_MODELS = []
|
||||
|
||||
|
@ -54,7 +54,7 @@ class LocationSlug(SerializableMixin, models.Model):
|
|||
default_related_name = 'locationslugs'
|
||||
|
||||
|
||||
class Location(LocationSlug, EditorFormMixin, models.Model):
|
||||
class Location(LocationSlug, SerializableMixin, models.Model):
|
||||
titles = JSONField(default={})
|
||||
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'))
|
||||
|
@ -157,7 +157,7 @@ class SpecificLocation(Location, models.Model):
|
|||
return result
|
||||
|
||||
|
||||
class LocationGroup(Location, EditorFormMixin, models.Model):
|
||||
class LocationGroup(Location, models.Model):
|
||||
compiled_room = models.BooleanField(default=False, verbose_name=_('is a compiled room'))
|
||||
compiled_area = models.BooleanField(default=False, verbose_name=_('is a compiled area'))
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from c3nav.mapdata.models.base import BoundsMixin, EditorFormMixin
|
||||
from c3nav.mapdata.models.base import BoundsMixin
|
||||
|
||||
|
||||
class Source(EditorFormMixin, BoundsMixin, models.Model):
|
||||
class Source(BoundsMixin, models.Model):
|
||||
"""
|
||||
A map source, images of levels that can be useful as backgrounds for the map editor
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue