Skip to content

Commit

Permalink
BEMAS: Verbesserungen Benutzerführung
Browse files Browse the repository at this point in the history
  • Loading branch information
gdmhrogut committed Feb 14, 2024
1 parent d7176dd commit 4099375
Show file tree
Hide file tree
Showing 16 changed files with 152 additions and 88 deletions.
3 changes: 2 additions & 1 deletion bemas/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class Meta(Basemodel.Meta):
abstract = True

class BasemodelMeta(Basemodel.BasemodelMeta):
table_exclusion_fields = ['created_at', 'updated_at', 'search_content']
table_exclusion_fields = Basemodel.BasemodelMeta.table_exclusion_fields
table_exclusion_fields.append('search_content')


class GeometryObjectclass(Objectclass):
Expand Down
10 changes: 8 additions & 2 deletions bemas/models/models_objectclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class Meta(Objectclass.Meta):
verbose_name_plural = 'Organisationen'

class BasemodelMeta(Objectclass.BasemodelMeta):
table_exclusion_fields = Objectclass.BasemodelMeta.table_exclusion_fields
table_exclusion_fields += ['address_house_number', 'address_postal_code', 'address_place']
description = 'Betreiberinnen oder Beschwerdeführerinnen'
definite_article = 'die'
indefinite_article = 'eine'
Expand Down Expand Up @@ -275,6 +277,8 @@ class Meta(Objectclass.Meta):
verbose_name_plural = 'Personen'

class BasemodelMeta(Objectclass.BasemodelMeta):
table_exclusion_fields = Objectclass.BasemodelMeta.table_exclusion_fields
table_exclusion_fields += ['address_house_number', 'address_postal_code', 'address_place']
description = 'Beschwerdeführer:innen oder Ansprechpartner:innen'
definite_article = 'die'
indefinite_article = 'eine'
Expand Down Expand Up @@ -442,7 +446,8 @@ class Meta(GeometryObjectclass.Meta):
verbose_name_plural = 'Verursacher'

class BasemodelMeta(GeometryObjectclass.BasemodelMeta):
table_exclusion_fields = ['created_at', 'updated_at', 'search_content', 'emission_point']
table_exclusion_fields = Objectclass.BasemodelMeta.table_exclusion_fields
table_exclusion_fields += ['operator_organization', 'operator_person', 'emission_point']
geometry_field = 'emission_point'
description = 'Verursacher von Emissionen'
definite_article = 'der'
Expand Down Expand Up @@ -565,7 +570,8 @@ class Meta(GeometryObjectclass.Meta):
verbose_name_plural = 'Beschwerden'

class BasemodelMeta(GeometryObjectclass.BasemodelMeta):
table_exclusion_fields = ['created_at', 'updated_at', 'search_content', 'immission_point']
table_exclusion_fields = Objectclass.BasemodelMeta.table_exclusion_fields
table_exclusion_fields.append('immission_point')
geometry_field = 'immission_point'
description = 'Folgen von Immissionen'
definite_article = 'die'
Expand Down
5 changes: 3 additions & 2 deletions bemas/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@


@register.filter
def beautify_model_string(model_name):
def beautify_model_string(model_name, plural=True):
"""
turns passed model name into model verbose name plural with prefixed icon
:param model_name: model name
:param plural: title shall be model verbose name plural?
:return: passed model name turned into model verbose name plural with prefixed icon
"""
icon = '<i class="fas fa-{}"></i>'.format(get_icon_from_settings(model_name.lower()))
model = apps.get_app_config('bemas').get_model(model_name)
model_title = model._meta.verbose_name_plural
model_title = model._meta.verbose_name_plural if plural else model._meta.verbose_name
return icon + ' ' + model_title


Expand Down
5 changes: 3 additions & 2 deletions bemas/templates/bemas/codelist-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ <h4 class="mt-3">
{% if is_bemas_admin %}
<a class="btn btn-primary" role="button" href="{{ codelist_creation_url }}"><i class="fas fa-{{ 'create'|get_icon }}"></i> neuen Codelisteneintrag anlegen</a>
{% endif %}
<a class="btn btn-warning" role="button" href="{% url 'bemas:codelists' %}"><i class="fas fa-{{ 'back'|get_icon }}"></i> zurück</a>
<a class="btn btn-warning" role="button" href="{% url 'bemas:codelists' %}"><i class="fas fa-{{ 'back'|get_icon }}"></i> Codelisten</a>
<a class="btn btn-warning" role="button" href="{% url 'bemas:index' %}"><i class="fas fa-{{ 'index'|get_icon }}"></i> Startseite</a>
</div>
{% if objects_count > 0 %}
<div class="d-grid mt-5 mb-3 gap-2 mx-auto">
Expand All @@ -41,7 +42,7 @@ <h4 class="mt-3">
<thead>
<tr>
{% for column_title in column_titles %}
<th>{{ column_title }}</th>
<th{% if column_title == 'Icon' %} class="no-export no-search no-sort"{% endif %}>{{ column_title }}</th>
{% endfor %}
{% if is_bemas_admin %}
<th class="no-export no-search no-sort">Aktionen</th>
Expand Down
2 changes: 1 addition & 1 deletion bemas/templates/bemas/codelists.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h5><small>{{ codelist.description }}</small></h5>
</a>
{% endfor %}
</div>
<a class="btn btn-warning mb-3" role="button" href="{% url 'bemas:index' %}"><i class="fas fa-{{ 'back'|get_icon }}"></i> zurück</a>
<a class="btn btn-warning mb-3" role="button" href="{% url 'bemas:index' %}"><i class="fas fa-{{ 'index'|get_icon }}"></i> Startseite</a>
{% else %}
{% include "bemas/notice-norights.html" %}
{% endif %}
Expand Down
1 change: 1 addition & 0 deletions bemas/templates/bemas/generic-objectclass-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ <h2><i class="fas fa-{{ objectclass_name|lower|get_icon }}"></i> <em>{{ objectcl
{% endif %}
<form class="form mt-4" method="post" action="">
{% csrf_token %}
<input type="hidden" name="original_referer" value="{{ objectclass_cancel_url }}">
<div {% if objectclass_is_geometry_model %}id="custom-form"{% endif %}>
<table class="table">
{% for field in form %}
Expand Down
10 changes: 9 additions & 1 deletion bemas/templates/bemas/generic-objectclass-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ <h4 class="mt-3">
{% if objects_count > 0 and objectclass_name == 'Complaint' or objects_count > 0 and objectclass_name == 'Originator' %}
<button id="subsetter" class="btn btn-secondary" type="button"><i class="fas fa-{{ 'map'|get_icon }}"></i> <i class="fas fa-{{ 'filter_on'|get_icon }}"></i> aktuell gefilterte {{ objectclass_verbose_name_plural }}</button>
{% endif %}
<a class="btn btn-warning" role="button" href="{% url 'bemas:index' %}"><i class="fas fa-{{ 'back'|get_icon }}"></i> zurück</a>
{% if objectclass_name == 'LogEntry' and model and reference_table_url %}
{% if object_pk and reference_object_url %}
<a class="btn btn-warning" role="button" href="{{ reference_object_url }}"><i class="fas fa-{{ 'back'|get_icon }}"></i> <em>{{ model|beautify_model_string:False|safe }}</em> mit der ID <em>{{ object_pk }}</em></a>
{% endif %}
<a class="btn btn-warning" role="button" href="{{ reference_table_url }}"><i class="fas fa-{{ 'back'|get_icon }}"></i> <em>{{ model|beautify_model_string|safe }}</em></a>
{% elif objectclass_name == 'Event' and complaint_pk and complaint_url %}
<a class="btn btn-warning" role="button" href="{{ complaint_url }}"><i class="fas fa-{{ 'back'|get_icon }}"></i> <em><i class="fas fa-{{ 'complaint'|get_icon }}"></i> Beschwerde</em> mit der ID <em>{{ complaint_pk }}</em></a>
{% endif %}
<a class="btn btn-warning" role="button" href="{% url 'bemas:index' %}"><i class="fas fa-{{ 'index'|get_icon }}"></i> Startseite</a>
</div>
{% if objects_count > 0 %}
<div class="d-grid mt-5 mb-3 gap-2 mx-auto">
Expand Down
8 changes: 8 additions & 0 deletions bemas/templates/bemas/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

{% block content %}
{% if is_bemas_user %}
{% if messages %}
{% include "bemas/container-messages.html" %}
{% endif %}
{% if not is_mobile %}
<div class="row g-4">
<div class="col-4">
Expand Down Expand Up @@ -163,6 +166,11 @@
</div>
</div>
{% endif %}
<script>
setTimeout(function () {
$('.alert-success').alert('close');
}, 3000);
</script>
{% else %}
{% include "bemas/notice-norights.html" %}
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion bemas/templates/bemas/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h4 class="mt-3">
<button id="complaints-subsetter" class="btn btn-secondary" type="button" disabled><i class="fas fa-{{ 'table'|get_icon }}"></i> <i class="fas fa-{{ 'filter_on'|get_icon }}"></i> aktuell gefilterte Beschwerden</button>
<a class="btn btn-secondary" role="button" href="{% url 'bemas:originator_table' %}"><i class="fas fa-{{ 'table'|get_icon }}"></i> alle Verursacher</a>
<button id="originators-subsetter" class="btn btn-secondary" type="button" disabled><i class="fas fa-{{ 'table'|get_icon }}"></i> <i class="fas fa-{{ 'filter_on'|get_icon }}"></i> aktuell gefilterte Verursacher</button>
<a class="btn btn-warning" role="button" href="{% url 'bemas:index' %}"><i class="fas fa-{{ 'back'|get_icon }}"></i> zurück</a>
<a class="btn btn-warning" role="button" href="{% url 'bemas:index' %}"><i class="fas fa-{{ 'index'|get_icon }}"></i> Startseite</a>
</div>
{% if objects_count > 0 %}
{% if model and subset_pk %}
Expand Down
2 changes: 1 addition & 1 deletion bemas/templates/bemas/orphaned-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h5 class="alert-heading"><i class="fas fa-{{ 'originator'|get_icon }}"></i> Ver
keine verwaisten Verursacher vorhanden
{% endif %}
</div>
<a class="btn btn-warning mb-3" role="button" href="{% url 'bemas:index' %}"><i class="fas fa-{{ 'back'|get_icon }}"></i> zurück</a>
<a class="btn btn-warning mb-3" role="button" href="{% url 'bemas:index' %}"><i class="fas fa-{{ 'index'|get_icon }}"></i> Startseite</a>
{% else %}
{% include "bemas/notice-norights.html" %}
{% endif %}
Expand Down
54 changes: 18 additions & 36 deletions bemas/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@
path(
'organization/create',
view=login_required(GenericObjectclassCreateView.as_view(
model=model,
success_url=reverse_lazy('bemas:organization_table')
model=model
)),
name='organization_create'
)
Expand All @@ -170,8 +169,7 @@
path(
'organization/update/<pk>',
view=login_required(GenericObjectclassUpdateView.as_view(
model=model,
success_url=reverse_lazy('bemas:organization_table')
model=model
)),
name='organization_update'
)
Expand All @@ -182,8 +180,7 @@
path(
'organization/delete/<pk>',
view=login_required(OrganizationDeleteView.as_view(
model=model,
success_url=reverse_lazy('bemas:organization_table')
model=model
)),
name='organization_delete'
)
Expand Down Expand Up @@ -221,8 +218,7 @@
path(
'person/create',
view=login_required(GenericObjectclassCreateView.as_view(
model=model,
success_url=reverse_lazy('bemas:person_table')
model=model
)),
name='person_create'
)
Expand All @@ -233,8 +229,7 @@
path(
'person/update/<pk>',
view=login_required(GenericObjectclassUpdateView.as_view(
model=model,
success_url=reverse_lazy('bemas:person_table')
model=model
)),
name='person_update'
)
Expand All @@ -245,8 +240,7 @@
path(
'person/delete/<pk>',
view=login_required(PersonDeleteView.as_view(
model=model,
success_url=reverse_lazy('bemas:person_table')
model=model
)),
name='person_delete'
)
Expand All @@ -262,8 +256,7 @@
path(
'contact/create',
view=login_required(ContactCreateView.as_view(
model=model,
success_url=reverse_lazy('bemas:organization_table')
model=model
)),
name='contact_create'
)
Expand All @@ -274,8 +267,7 @@
path(
'contact/update/<pk>',
view=login_required(ContactUpdateView.as_view(
model=model,
success_url=reverse_lazy('bemas:organization_table')
model=model
)),
name='contact_update'
)
Expand All @@ -286,8 +278,7 @@
path(
'contact/delete/<pk>',
view=login_required(ContactDeleteView.as_view(
model=model,
success_url=reverse_lazy('bemas:organization_table')
model=model
)),
name='contact_delete'
)
Expand Down Expand Up @@ -349,8 +340,7 @@
path(
'originator/create',
view=login_required(GenericObjectclassCreateView.as_view(
model=model,
success_url=reverse_lazy('bemas:originator_table')
model=model
)),
name='originator_create'
)
Expand All @@ -361,8 +351,7 @@
path(
'originator/update/<pk>',
view=login_required(GenericObjectclassUpdateView.as_view(
model=model,
success_url=reverse_lazy('bemas:originator_table')
model=model
)),
name='originator_update'
)
Expand All @@ -373,8 +362,7 @@
path(
'originator/delete/<pk>',
view=login_required(GenericObjectclassDeleteView.as_view(
model=model,
success_url=reverse_lazy('bemas:originator_table')
model=model
)),
name='originator_delete'
)
Expand Down Expand Up @@ -459,8 +447,7 @@
path(
'complaint/create',
view=login_required(GenericObjectclassCreateView.as_view(
model=model,
success_url=reverse_lazy('bemas:complaint_table')
model=model
)),
name='complaint_create'
)
Expand All @@ -471,8 +458,7 @@
path(
'complaint/update/<pk>',
view=login_required(GenericObjectclassUpdateView.as_view(
model=model,
success_url=reverse_lazy('bemas:complaint_table')
model=model
)),
name='complaint_update'
)
Expand All @@ -483,8 +469,7 @@
path(
'complaint/delete/<pk>',
view=login_required(ComplaintDeleteView.as_view(
model=model,
success_url=reverse_lazy('bemas:complaint_table')
model=model
)),
name='complaint_delete'
)
Expand Down Expand Up @@ -644,8 +629,7 @@
path(
'event/create',
view=login_required(GenericObjectclassCreateView.as_view(
model=model,
success_url=reverse_lazy('bemas:event_table')
model=model
)),
name='event_create'
)
Expand All @@ -656,8 +640,7 @@
path(
'event/update/<pk>',
view=login_required(GenericObjectclassUpdateView.as_view(
model=model,
success_url=reverse_lazy('bemas:event_table')
model=model
)),
name='event_update'
)
Expand All @@ -668,8 +651,7 @@
path(
'event/delete/<pk>',
view=login_required(ComplaintDeleteView.as_view(
model=model,
success_url=reverse_lazy('bemas:event_table')
model=model
)),
name='event_delete'
)
Expand Down
2 changes: 2 additions & 0 deletions bemas/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ def ordering(self, qs):
column_names.append(column.name)
# handle addresses
elif column.name.startswith('address_') and not address_handled:
# append one column for address string
# instead of appending individual columns for all address related values
column_names.append(column.name)
address_handled = True
column_name = column_names[int(order_column)]
Expand Down
Loading

0 comments on commit 4099375

Please sign in to comment.