Organigrammlöschfehler behoben bzw der Nutzer wird informiert, was er tun muss um den User löschen zu können.

This commit is contained in:
holger.trampe 2021-01-29 10:33:45 +01:00
parent ae8367cf6d
commit 0c94683111
7 changed files with 233 additions and 241 deletions

View File

@ -1039,3 +1039,7 @@ def getBaseURLIcsExAll(agency):

View File

@ -1,15 +1,11 @@
{% load counter_tag %}
<div class="btn-group" role="group" aria-label="" style="min-width: 100% !important">
<div class="btn-group" role="group" aria-label="" style="min-width: 100% !important;">
<a type="button" class="btn btn-primary mr-1" href="{% url 'tm-management' prev_month prev_year %}" ><i class="fas fa-arrow-circle-left"></i></a>
<button type="button" class="btn btn-primary mr-1" style="min-width: 150px !important;" onclick="javascript:fastChangeModal()">{{active_month}} {{active_year}}</button>
<a type="button" class="btn btn-primary mr-1" href="{% url 'tm-management' next_month next_year %}"><i class="fas fa-arrow-circle-right"></i></a>
<span style="float: right !important; text-align: right; min-width: 82%; margin-bottom: -20px; margin-top: -10px; ">
<span style="text-align: right !important; width: 100%">
{% loadmonthwork next_month user as monthwork %}
Gesamtarbeitszeit dieser Monat: {{monthwork}} Stunden<br />
{% loadaccounttime user as actualaccounttime %}
Gleitzeitkonto:
@ -18,7 +14,7 @@
{% else %}
<b><span style="color: red">-{{actualaccounttime.0}}&nbsp;Stunden</span></b>
{% endif %}
</span>
</span>
</div>
@ -31,9 +27,9 @@
<th scope="col"></th>
<th scope="col">Start</th>
<th scope="col">Ende</th>
<th scope="col">Gesamtzeit</th>
<th scope="col">Pausen</th>
<th scope="col">Arbeitszeit</th>
<th scope="col">Pausen</th>
<th scope="col">Gesamtzeit</th>
<th scope="col">Gleitzeit</th>
<!--<th scope="col">Gleitzeitstand</th>-->
<th scope="col">&nbsp;</th>
@ -41,9 +37,7 @@
</thead>
<tbody id="table_contacts" >
{% for da in days_this_month %}
{% getabscenceday request.user request.user da as abday %}
<tr id="da_{{da|date:"d-m-y"}}"
{% if da.weekday == 5 or da.weekday == 6 %}
style="background-color: #d3d3d3;"
@ -59,12 +53,15 @@
{% endif %}
{% endfor %}
{% endif %}>
<!-- Datum Wochentag -->
<td>
{{da|date:"l"}}
</td>
<!-- Komplettes Datum -->
<td>
{{da|date:"d.m.y"}}
</td>
<!-- START -->
<td {% if abday != False %} colspan="3" {% endif %}>
{% if abday != False %}
{{abday.reason}}
@ -218,6 +215,7 @@
{% endif %}
</td>
{% if abday == False %}
<!-- ENDE -->
<td>
{% counterWDreset %}
{% for workday in workdays %}
@ -235,8 +233,44 @@
{{workday.end|date:"H:i"}}
{% endif %}
{% endfor %}
</td>
<!-- ARBEITSZEIT -->
<td>
{% counterWDreset %}
{% for workday in workdays %}
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
{% getCounterWD as wd_counter %}
{% if wd_counter > 0 %}
<br />
{% endif %}
{% counterWDUp %}
{% getsumworkday workday as sumwd %}
{{sumwd}}
{% endif %}
{% endfor %}
</td>
<!-- PAUSEN -->
<td>
{% counterWDreset %}
{% for workday in workdays %}
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
{% getCounterWD as wd_counter %}
{% if wd_counter > 0 %}
<br />
{% endif %}
{% counterWDUp %}
{% getsumbreak workday as sumbreakofday %}
{{sumbreakofday}} min. ({{workday.breaks.all|length}})
{% endif %}
{% endfor %}
</td>
<!-- GESAMT -->
<td>
{% counterWDreset %}
{% for workday in workdays %}
@ -255,8 +289,8 @@
{{ sumworkday }}
{% endif %}
{% endfor %}
</td>
<!-- Gleitzeit -->
<td>
{% counterWDreset %}
{% for workday in workdays %}
@ -264,47 +298,6 @@
{% getCounterWD as wd_counter %}
{% if wd_counter > 0 %}
<br />
{% endif %}
{% counterWDUp %}
{% getsumbreak workday as sumbreakofday %}
{{sumbreakofday}} min. ({{workday.breaks.all|length}})
{% endif %}
{% endfor %}
</td>
<td>
{% counterWDreset %}
{% for workday in workdays %}
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
{% getCounterWD as wd_counter %}
{% if wd_counter > 0 %}
<br />
{% endif %}
{% counterWDUp %}
{% getsumworkday workday as sumwd %}
{{sumwd}}
{% endif %}
{% endfor %}
</td>
<td>
{% counterWDreset %}
{% for workday in workdays %}
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
{% getCounterWD as wd_counter %}
{% if wd_counter > 0 %}
<br />
{% endif %}
@ -319,30 +312,21 @@
{% endif %}
{% endif %}
{% endfor %}
</td>
<!-- <td style="text-align: center;">
</td>-->
<!-- BUTTONS -->
<td style="text-align: right;">
{% counterWDreset %}
{% for workday in workdays %}
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
{% getCounterWD as wd_counter %}
{% if wd_counter > 0 %}
<br />
{% endif %}
{% counterWDUp %}
{% getWorkDayHistory workday as wd_history %}
{% if wd_history.history_user != None %}
<a href="#/" onclick="javascript:$('#wd_history_{{workday.pk}}').modal('toggle');"><i class="fas fa-user-edit"></i></a>
<div class="modal fade" id="wd_history_{{workday.pk}}" tabindex="-1" role="dialog" data-backdrop="static">
<div class="modal-dialog" role="document">
@ -363,10 +347,7 @@
</div>
</div>
{% endif %}
{% if workday.freefield != "" %}
<a href="#/" onclick="javascript:$('#wd_freefield_{{workday.pk}}').modal('toggle');"><i class="fas fa-eye"></i></a>
<div class="modal fade" id="wd_freefield_{{workday.pk}}" tabindex="-1" role="dialog" data-backdrop="static">
<div class="modal-dialog" role="document">
@ -386,9 +367,7 @@
</div>
</div>
</div>
{% endif %}
{% if breakmonthline < da %}
<button class="btn btn-secondary btn-sm ml-2" onclick="window.location.href='{% url 'tm-update' workday.pk %}'"><small><i class="fas fa-pen"></i></small></button>
<button class="btn btn-secondary btn-sm " onclick="javascript:$('#confirm-delete_{{workday.pk}}').modal('toggle')"><small><i class="fas fa-trash"></i></small></button>

View File

@ -31,9 +31,9 @@
<th scope="col"></th>
<th scope="col">Start</th>
<th scope="col">Ende</th>
<th scope="col">Gesamtzeit</th>
<th scope="col">Pausen</th>
<th scope="col">Arbeitszeit</th>
<th scope="col">Pausen</th>
<th scope="col">Gesamtzeit</th>
<th scope="col">Gleitzeit</th>
<th scope="col">&nbsp;</th>
</tr>
@ -58,13 +58,17 @@
{% endif %}
{% endfor %}
{% endif %}>
<!-- Wochentag -->
<td>
{{da|date:"l"}}
</td>
<!-- Komplettes Datum -->
<td>
{{da|date:"d.m.y"}}
</td>
<!-- START -->
<td {% if abday != False %} colspan="3" {% endif %}>
{% if abday != False %}
{{abday.reason}}
{% if abday.start == da%}
@ -215,93 +219,71 @@
{% endif %}
</td>
{% if abday == False %}
<!-- ENDE -->
<td>
{% counterWDreset %}
{% for workday in workdays %}
{% if workday.end|date:"d-m-y" == da|date:"d-m-y" %}
{% getCounterWD as wd_counter %}
{% if wd_counter > 0 %}
<br />
{% endif %}
{% counterWDUp %}
{{workday.end|date:"H:i"}}
{% endif %}
{% endfor %}
</td>
<!-- Arbeitszeit -->
<td>
{% counterWDreset %}
{% for workday in workdays %}
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
{% getCounterWD as wd_counter %}
{% if wd_counter > 0 %}
<br />
{% endif %}
{% counterWDUp %}
{% getsumworkdayexcludebreak workday as sumworkday %}
{{ sumworkday }}
{% endif %}
{% endfor %}
</td>
<td>
{% counterWDreset %}
{% for workday in workdays %}
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
{% getCounterWD as wd_counter %}
{% if wd_counter > 0 %}
<br />
{% endif %}
{% counterWDUp %}
{% getsumbreak workday as sumbreakofday %}
{{sumbreakofday}} min. ({{workday.breaks.all|length}})
{% endif %}
{% endfor %}
</td>
<td>
{% counterWDreset %}
{% for workday in workdays %}
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
{% getCounterWD as wd_counter %}
{% if wd_counter > 0 %}
<br />
{% endif %}
{% counterWDUp %}
{% getsumworkday workday as sumwd %}
{{sumwd}}
{% endif %}
{% endfor %}
</td>
<!-- PAUSEN -->
<td>
{% counterWDreset %}
{% for workday in workdays %}
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
{% getCounterWD as wd_counter %}
{% if wd_counter > 0 %}
<br />
{% endif %}
{% counterWDUp %}
{% getsumbreak workday as sumbreakofday %}
{{sumbreakofday}} min. ({{workday.breaks.all|length}})
{% endif %}
{% endfor %}
</td>
<!-- GESAMTZEIT -->
<td>
{% counterWDreset %}
{% for workday in workdays %}
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
{% getCounterWD as wd_counter %}
{% if wd_counter > 0 %}
<br />
{% endif %}
{% counterWDUp %}
{% getsumworkdayexcludebreak workday as sumworkday %}
{{ sumworkday }}
{% endif %}
{% endfor %}
</td>
<!-- Gleitzeit -->
<td>
{% counterWDreset %}
{% for workday in workdays %}
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
{% getCounterWD as wd_counter %}
{% if wd_counter > 0 %}
<br />
{% endif %}
@ -316,10 +298,9 @@
{% endif %}
{% endif %}
{% endfor %}
</td>
<!-- BUTTONS -->
<td style="text-align: right;">
{% counterWDreset %}
{% for workday in workdays %}
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}

View File

@ -488,7 +488,7 @@
<a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="mr-2 d-none d-lg-inline text-gray-600 small">{{request.user.first_name}} {{request.user.last_name}}
</span>
<img id="userbaseprofilepicture" class="img-profile roundimg_base ml-2" src="{{ user.profile.get_photo_url }}">
<img id="userbaseprofilepicture" class="img-profile roundimg_base ml-2" src="{{ request.user.profile.get_photo_url }}">
</a>
<!-- Dropdown - User Information -->
<div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="userDropdown">

View File

@ -1,18 +1,24 @@
{% extends "users/base.html" %}
{% load crispy_forms_tags %}
{% load counter_tag %}
{% block content %}
<div class="content-section">
<div class="media">
<div class="media-body">
<h2 class="account-heading">Benutzer {{ user.first_name }} {{ user.last_name }} löschen?</h2>
<h2 class="account-heading">
{% if orgaerror == True %}
Benutzer {{ user.first_name }} {{ user.last_name }} löschen?
{% else %}
Benutzer {{ user.first_name }} {{ user.last_name }} kann nicht gelöscht werden - Organigrammfehler
{% endif %}
</h2>
<hr>
</div>
</div>
<!-- Für das Speichern der Bilder enctype -->
<!-- TASK: Hinzufügen von Zeiterfassung und Urlaub! -->
<form method="POST">
{% csrf_token %}
{% if orgaerror == True %}
<p>Alle vom Benutzer erstellen Informationen (Standards, Dateien usw.) bleiben bestehen, jedoch werden die Verweise auf einen Nutzer entfernt. Alle Chat-Nachrichten werden unwiederruflich gelöscht! Soeben wurden alle Vertragsdaten (Abwesenheit und Zeiterfassung), wenn vorhanden, als CSV heruntergeladen. Diese können Sie archivieren und entsprechend Ihrer agenturinternen Gegebenheiten bzgl. Datenspeicherung aufbewahren.<br /></p>
<a href="{% url 'users-delete-getdata' user.pk %}" id="downloadFileAction" download>Daten erneut herunterladen</a>
<hr>
@ -20,12 +26,20 @@
<button type="submit" class="btn btn-primary">Benutzer löschen</button>&nbsp;
<a href="{% url 'dasettings' %}" class="btn">Abbrechen</a>
</div>
{% else %}
<p>Achtung! Dieser Nutzer kann nicht gelöscht werden, da im Organigramm andere Mitarbeiter diesem untergeordnet ist. Bitte prüfen Sie die Einstellungen Ihrer Mitarbeiter unter Einstellungen, Mitarbeiter im Bereich <b>Übergeordneter Mitarbeiter</b>. <br /><br /><b>Es können nur ein Mitarbeiter gelöscht werden, wenn diesem kein Mitarbeiter untergeordnet sind.</b></p>
<div class="form-group">
<a href="{% url 'dasettings' %}" class="btn">Abbrechen</a>
</div>
{% endif %}
</form>
</div>
<script type="text/javascript">
//Auto-Download the file
{% if orgaerror == True %}
$(document).ready(function(){
location.href = "{% url 'users-delete-getdata' user.pk %}"
})
{% endif %}
</script>
{% endblock content %}

View File

@ -958,17 +958,27 @@ def getDataFromToDelUser(request, pk):
pass
# Gibt zurück, ob übergebener Nutzer einem anderen Nutzer im Organigramm als Parent zugeordnet ist
# TRUE - User hat keinen Parent und kann gelöscht werden
# FALSE - User hat Parent und kann nicht direkt gelöscht werden
def checkOrgaParent(user):
returnvalue = True
for u in User.objects.filter(profile__agency=user.profile.agency):
if u.profile.parent == user:
returnvalue = False
return returnvalue
class ProfileDeleteView(LoginRequiredMixin, DeleteView):
model = User
success_url = '/dasettings/main'
template_name = 'users/user_confirm_delete.html'
# Adding active_link
def get_context_data(self, **kwargs):
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(**kwargs)
# Hier Daten zusammenstellen, damit alle Daten bzgl Vertrag nicht verloren gehen (Zeiterfassung, Urlaub und Abwesenheiten)
'''
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename="file.csv"'
writer = csv.writer(response)
@ -976,6 +986,10 @@ class ProfileDeleteView(LoginRequiredMixin, DeleteView):
writer.writerow(['1002', 'Amit', 'Mukharji', 'LA', '"Testing"'])
context.update({"response" : response})
#print(response)
'''
# Prüft, ob der Nutzer ein Parent im Organigramm ist. Gibt True oder False zurück. Das Template verhindert dann das löschen und informiert den Nutzer.
context.update({"orgaerror" : checkOrgaParent(kwargs["object"])})
return context