Skip to content

Commit

Permalink
App Datenmanagement: Bereinigungsarbeiten Code
Browse files Browse the repository at this point in the history
  • Loading branch information
gdmhrogut committed Sep 27, 2023
1 parent 71bc112 commit e7af20a
Show file tree
Hide file tree
Showing 7 changed files with 253 additions and 268 deletions.
6 changes: 6 additions & 0 deletions datenmanagement/models/models_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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?',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
59 changes: 25 additions & 34 deletions datenmanagement/tags.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
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

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):
Expand All @@ -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):
"""
Expand All @@ -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):
"""
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 2 additions & 9 deletions datenmanagement/templates/datenmanagement/delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@
{% csrf_token %}
<h5>
<small>
{% 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 %}
<strong><em>{{ object }}</em></strong> des Datenthemas <strong>{{object|get_class_verbose_name_plural}}</strong> wirklich löschen?
Möchten Sie den Datensatz <strong><em>{{ object }}</em></strong> des Datenthemas <strong>{{ model_verbose_name_plural }}</strong> wirklich löschen?
</small>
</h5>
<div class="d-grid mt-4 gap-2 d-md-block">
<button class="btn btn-danger" type="submit"><i class="fas fa-trash"></i> Datensatz löschen</button>
{% with model_name=object|get_class_name %}
<a class="btn btn-warning" href="{% url 'datenmanagement:'|add:model_name|add:'_start' %}"><i class="fas fa-hand"></i> abbrechen</a>
{% endwith %}
<a class="btn btn-warning" href="{{ url_back }}"><i class="fas fa-hand"></i> abbrechen</a>
</div>
</form>
{% endblock %}
Loading

0 comments on commit e7af20a

Please sign in to comment.