Skip to content

Commit

Permalink
App Datenmanagement: Navigation überarbeitet
Browse files Browse the repository at this point in the history
  • Loading branch information
gdmhrogut committed Dec 18, 2023
1 parent 600e665 commit 2616594
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ function setMapConstants(map, maxLayerZoom, highZoomMode = false) {
map._maxLayerZoom = maxLayerZoom;
if (highZoomMode === true)
(maxLayerZoom + 2 > 21) ? map._maxLayerZoom = maxLayerZoom + 2 : map._maxLayerZoom = 21;
console.log(map._maxLayerZoom);
map._minLayerZoomForWFSFeaturetypes = 16;
map._minLayerZoomForDataThemes = 13;
map._themaUrl = {};
Expand Down
4 changes: 3 additions & 1 deletion datenmanagement/templates/datenmanagement/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ <h5 class="alert-heading">assoziierte Datensätze</h5>
</div>
<div class="mb-4"></div>
{% endif %}
<form class="form" method="post" enctype="multipart/form-data" action="">
<form class="form" id="form" method="post" enctype="multipart/form-data" action="">
{% csrf_token %}
<input type="hidden" name="original_url_back" value="{{ url_back }}">
<div {% if model_geometry_type %}id="custom-form"{% endif %}>
<table class="table">
{% for field in form %}
Expand Down Expand Up @@ -552,6 +553,7 @@ <h5 class="alert-heading">assoziierte Datensätze</h5>
{% if user|user_has_model_change_permission:model_name_lower %}
window.userHasModelChangePermission = true
{% endif %}
window.doIt = false;

// if a group of users is set that should be used for the contact person/processor field in a corresponding selection list...
{% if group_with_users_for_choice_field %}
Expand Down
14 changes: 14 additions & 0 deletions datenmanagement/templates/datenmanagement/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
{% endblock %}

{% block content %}
{% if messages %}
{% for message in messages %}
{% if message.tags and message.tags == 'success' %}
<div class="alert alert-success" role="alert">
<i class="fa-solid fa-circle-check"></i>
{{ message|safe }}
</div>
{% endif %}
{% endfor %}
{% endif %}
<h2>{{ model_verbose_name_plural }}</h2>
<h4><small>{{ model_description }}</small></h4>
<h4 class="mt-3">
Expand Down Expand Up @@ -212,6 +222,10 @@ <h5>Adressensuche</h5>
{% include "modal-loading.html" %}
<script>
/* eslint no-unexpected-multiline: "off" */
setTimeout(function () {
$('.alert-success').alert('close');
}, 3000);

/**
* @function
* @name mapCallbackFunction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h5 id="action-delete-modal-title" class="modal-title"></h5>
</div>
<div id="action-delete-modal-body" class="modal-body">
<div class="text-center">
<p>Sie haben x Datensätze ausgewählt. Sollen diese wirklich gelöscht werden?</p>
<p></p>
</div>
</div>
<div class="modal-footer">
Expand Down
13 changes: 4 additions & 9 deletions datenmanagement/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,19 +225,16 @@ def generic_add_update_view_test(self, update_mode, model, object_filter,
request.user = self.test_user
request._messages = storage.default_storage(request)
template_name = 'datenmanagement/form.html'
success_url = reverse_lazy('datenmanagement:' + self.model.__name__ + '_start')
# try POSTing the view
if update_mode:
response = DataChangeView.as_view(
model=model,
template_name=template_name,
success_url=success_url
template_name=template_name
)(request, pk=model.objects.last().pk)
else:
response = DataAddView.as_view(
model=model,
template_name=template_name,
success_url=success_url
template_name=template_name
)(request)
# status code of response as expected?
self.assertEqual(response.status_code, status_code)
Expand Down Expand Up @@ -303,12 +300,10 @@ def generic_delete_view_test(self, immediately, model, object_filter, status_cod
)
request.user = self.test_user
request._messages = storage.default_storage(request)
template_name = 'datenmanagement/form.html'
success_url = reverse_lazy('datenmanagement:' + self.model.__name__ + '_start')
template_name = 'datenmanagement/delete.html'
response = DataDeleteView.as_view(
model=model,
template_name=template_name,
success_url=success_url
template_name=template_name
)(request, pk=deletion_object.pk)
# status code of response as expected?
self.assertEqual(response.status_code, status_code)
Expand Down
8 changes: 3 additions & 5 deletions datenmanagement/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.apps import apps
from django.contrib.auth.decorators import login_required, user_passes_test
from django.urls import path, reverse_lazy
from django.urls import path
from rest_framework.routers import DefaultRouter

from .views.api import DatenmanagementViewSet
Expand Down Expand Up @@ -199,8 +199,7 @@ def permission_required(*perms):
'datenmanagement.add_' + model_name_lower
)(DataAddView.as_view(
model=model,
template_name='datenmanagement/form.html',
success_url=reverse_lazy('datenmanagement:' + model_name + '_start')
template_name='datenmanagement/form.html'
)),
name=model_name + '_add'
)
Expand All @@ -216,8 +215,7 @@ def permission_required(*perms):
'datenmanagement.view_' + model_name_lower
)(DataChangeView.as_view(
model=model,
template_name='datenmanagement/form.html',
success_url=reverse_lazy('datenmanagement:' + model_name + '_start')
template_name='datenmanagement/form.html'
)),
name=model_name + '_change'
)
Expand Down
30 changes: 22 additions & 8 deletions datenmanagement/views/views_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from django.core.exceptions import PermissionDenied
from django.db import connections
from django.forms.models import modelform_factory
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.views.generic.edit import CreateView, DeleteView, UpdateView
from json import dumps
Expand Down Expand Up @@ -118,12 +117,19 @@ def form_valid(self, form):
:return: HTTP response if passed form is valid
"""
form.instance.user = self.request.user
referer = form.data.get('original_url_back', None)
self.success_url = get_url_back(
referer if referer else None,
'datenmanagement:' + self.model.__name__ + '_start',
True
)
success(
self.request,
'Der neue Datensatz <strong><em>%s</em></strong> '
'wurde erfolgreich angelegt!' % str(form.instance)
)
return super().form_valid(form)
response = super().form_valid(form)
return response

def form_invalid(self, form, **kwargs):
"""
Expand All @@ -150,7 +156,7 @@ def form_invalid(self, form, **kwargs):
geometry = form.data.get(field.name, None)
if geometry and '0,0' not in geometry and '[]' not in geometry:
context_data['geometry'] = geometry
context_data['form'] = form
context_data['form'], context_data['url_back'] = form, form.data.get('original_url_back', None)
return self.render_to_response(context_data)


Expand Down Expand Up @@ -356,12 +362,19 @@ def form_valid(self, form):
:return: HTTP response if passed form is valid
"""
form.instance.user = self.request.user
referer = form.data.get('original_url_back', None)
self.success_url = get_url_back(
referer if referer and '/list' in referer else None,
'datenmanagement:' + self.model.__name__ + '_start',
True
)
success(
self.request,
'Der Datensatz <strong><em>%s</em></strong> '
'wurde erfolgreich geändert!' % str(form.instance)
)
return super().form_valid(form)
response = super().form_valid(form)
return response

def form_invalid(self, form, **kwargs):
"""
Expand Down Expand Up @@ -390,7 +403,7 @@ def form_invalid(self, form, **kwargs):
geometry = form.data.get(field.name, None)
if geometry and '0,0' not in geometry and '[]' not in geometry:
context_data['geometry'] = geometry
context_data['form'] = form
context_data['form'], context_data['url_back'] = form, form.data.get('original_url_back', None)
return self.render_to_response(context_data)

def get_object(self, *args, **kwargs):
Expand Down Expand Up @@ -449,8 +462,8 @@ def form_valid(self, form, **kwargs):
:return: HTTP response if passed form is valid
"""
referer = form.data.get('original_url_back', None)
success_url = get_url_back(
referer if '/list' in referer else None,
self.success_url = get_url_back(
referer if referer and '/list' in referer else None,
'datenmanagement:' + self.model.__name__ + '_start',
True
)
Expand All @@ -459,4 +472,5 @@ def form_valid(self, form, **kwargs):
'Der Datensatz <strong><em>%s</em></strong> '
'wurde erfolgreich gelöscht!' % str(self.object)
)
return HttpResponseRedirect(success_url)
response = super().form_valid(form)
return response
2 changes: 1 addition & 1 deletion datenwerft/templates/modal-confirm-export.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="modal-dialog">
<div class="modal-content">
<div id="confirm-export-modal-header" class="modal-header">
<h5 id="confirmexport-modal-title" class="modal-title">Alle Datensätze exportieren?</h5>
<h5 id="confirm-export-modal-title" class="modal-title">Alle Datensätze exportieren?</h5>
</div>
<div id="confirm-export-modal-body" class="modal-body">
<div class="text-center">
Expand Down

0 comments on commit 2616594

Please sign in to comment.