diff --git a/datenmanagement/models/models_complex.py b/datenmanagement/models/models_complex.py index 2b5edbe1..2875d806 100644 --- a/datenmanagement/models/models_complex.py +++ b/datenmanagement/models/models_complex.py @@ -2236,6 +2236,8 @@ class BasemodelMeta(ComplexModel.BasemodelMeta): description = 'Parkscheinautomaten der Hanse- und Universitätsstadt Rostock' as_overlay = True fields_with_foreign_key_to_linkify = ['parkscheinautomaten_tarif'] + object_title = 'der Parkscheinautomat' + foreign_key_label = 'Tarif' geometry_type = 'Point' list_fields = { 'aktiv': 'aktiv?', @@ -2699,6 +2701,8 @@ class BasemodelMeta(ComplexModel.BasemodelMeta): 'der Rostocker Straßenbahn AG in der Hanse- und Universitätsstadt Rostock' as_overlay = True fields_with_foreign_key_to_linkify = ['mast'] + object_title = 'der RSAG-Querträger' + foreign_key_label = 'RSAG-Mast' geometry_type = 'LineString' list_fields = { 'uuid': 'UUID', @@ -2756,6 +2760,8 @@ class BasemodelMeta(ComplexModel.BasemodelMeta): 'der Rostocker Straßenbahn AG in der Hanse- und Universitätsstadt Rostock' as_overlay = True fields_with_foreign_key_to_linkify = ['mast'] + object_title = 'der RSAG-Spanndraht' + foreign_key_label = 'RSAG-Mast' geometry_type = 'LineString' list_fields = { 'uuid': 'UUID', diff --git a/datenmanagement/tags.py b/datenmanagement/tags.py index 61663695..06fd5c7b 100644 --- a/datenmanagement/tags.py +++ b/datenmanagement/tags.py @@ -1,6 +1,7 @@ from django import template from django.apps import apps from django.template.defaultfilters import stringfilter +from django.urls import reverse from re import sub from datenmanagement.utils import is_address_related_field, is_geometry_field @@ -8,6 +9,29 @@ register = template.Library() +@register.filter +def build_change_link(model_name, object_id): + """ + builds link to form page for updating object with passed ID of passed model and returns it + + :param model_name: model name + :param object_id: object ID + :return: link to form page for updating object with passed ID of passed model + """ + return reverse('datenmanagement:' + model_name + '_change', args=[object_id]) + + +@register.filter +def build_geometry_link(model_name): + """ + builds link for querying the geometries of passed model and returns it + + :param model_name: model name + :return: link for querying the geometries of passed model + """ + return reverse('datenmanagement:' + model_name + '_geometry') + + @register.filter @stringfilter def clean_error_message(value): @@ -31,17 +55,6 @@ def clean_error_message(value): return 'Fehler bei der Eingabe' -@register.filter -def get_class_foreign_key_label(value): - """ - returns label of foreign key field of passed model - - :param value: model - :return: label of foreign key field of passed model - """ - return value.__class__.BasemodelMeta.foreign_key_label - - @register.filter def get_class_name(value): """ @@ -53,28 +66,6 @@ def get_class_name(value): return value.__class__.__name__ -@register.filter -def get_class_object_title(value): - """ - returns text module for deletion form view of passed model - - :param value: model - :return: text module for deletion form view of passed model - """ - return value.__class__.BasemodelMeta.object_title - - -@register.filter -def get_class_verbose_name_plural(value): - """ - returns verbose name plural of passed model - - :param value: model - :return: verbose name plural of passed model - """ - return value.__class__._meta.verbose_name_plural - - @register.filter def get_dict_value_by_key(arg_dict, key): """ @@ -174,7 +165,7 @@ def has_model_geometry_field(model_name): """ checks if passed model has a geometry related field - :param model_name: model class name + :param model_name: model class name :return: passed model has a geometry related field? """ model = apps.get_app_config('datenmanagement').get_model(model_name) diff --git a/datenmanagement/templates/datenmanagement/delete.html b/datenmanagement/templates/datenmanagement/delete.html index 661f465d..6f72ba3c 100644 --- a/datenmanagement/templates/datenmanagement/delete.html +++ b/datenmanagement/templates/datenmanagement/delete.html @@ -8,19 +8,12 @@ {% csrf_token %}
- {% if object|get_class_object_title or object|get_class_foreign_key_label %} - Möchten Sie {% if object|get_class_object_title %}{{object|get_class_object_title}}{% else %}den Datensatz{% endif %} zu {% if object|get_class_foreign_key_label %}{{object|get_class_foreign_key_label}}{% else %}Datensatz{% endif %} - {% else %} - Möchten Sie den Datensatz - {% endif %} - {{ object }} des Datenthemas {{object|get_class_verbose_name_plural}} wirklich löschen? + Möchten Sie den Datensatz {{ object }} des Datenthemas {{ model_verbose_name_plural }} wirklich löschen?
- {% with model_name=object|get_class_name %} - abbrechen - {% endwith %} + abbrechen
{% endblock %} diff --git a/datenmanagement/templates/datenmanagement/form.html b/datenmanagement/templates/datenmanagement/form.html index 8e28fa11..e8f31e41 100644 --- a/datenmanagement/templates/datenmanagement/form.html +++ b/datenmanagement/templates/datenmanagement/form.html @@ -60,7 +60,7 @@
assoziierte Datensätze
{% if object and associated_objects %}