diff --git a/areas/models.py b/areas/models.py index 5a6fc8c..49f98dd 100644 --- a/areas/models.py +++ b/areas/models.py @@ -24,7 +24,7 @@ class Areas(models.Model): color = RGBColorField(colors=['#FFB900', '#E74856', '#0078D7', '#0099BC', '#7A7574'], default='#0099BC', blank=True) desc = models.TextField(max_length=3000, blank=True) usersfield = models.ManyToManyField(User, blank=True, related_name='users_in_area') - created_area_by = models.ForeignKey(User, on_delete=models.PROTECT) + created_area_by = models.ForeignKey(User, on_delete=models.SET_NULL, null=True) created_area_date = models.DateField(default=datetime.date.today, blank=True) visible = models.BooleanField(default=True) areaorder = models.IntegerField(default=0) diff --git a/chat/templates/chat/chat_allusers.html b/chat/templates/chat/chat_allusers.html index 4aabd00..24adbcb 100644 --- a/chat/templates/chat/chat_allusers.html +++ b/chat/templates/chat/chat_allusers.html @@ -6,14 +6,14 @@ width: 100%; } .icon-container { - width: 50px; - height: 50px; + width: 25px; + height: 25px; position: relative; } .status-circle { - width: 15px; - height: 15px; + width: 5px; + height: 5px; border-radius: 50%; bottom: 0; right: 0; @@ -22,22 +22,15 @@
-

Chat öffnen + + {% for user in usersofagency %} +

+
{{user.first_name}} {{user.last_name}} - - -
+ +
{% endfor %} - - + \ No newline at end of file diff --git a/chat/templates/chat/chatmanagement.html b/chat/templates/chat/chatmanagement.html index 73dd178..858368d 100644 --- a/chat/templates/chat/chatmanagement.html +++ b/chat/templates/chat/chatmanagement.html @@ -56,77 +56,19 @@

Chat  + + +


-
+
-
- - - -
-
-
-
- -
-
-
+
{% for user in usersofagency %} -
+
@@ -149,24 +91,10 @@
{% endfor %} -
-
-
-
-
-
- - -
-
-
-
- {% for chatroom in chatrooms %} + {% for chatroom in chatrooms %} {% if user in chatroom.chatmembers.all or user in chatroom.chatmembers_admin.all or user == chatroom.creator and chatroom.chatroomtype == 1 %} -
+
{{chatroom.roomname}} @@ -180,17 +108,13 @@
{% endif %} {% endfor %} -
-
-
+ + + +
+
- - - -
-
-
- Erstellt durch {{standard.created_standard_by.first_name}} {{standard.created_standard_by.last_name}} am {{standard.created_standard_date}} | Zuletzt bearbeitet von {{ standard.last_modified_by.first_name}} {{ standard.last_modified_by.last_name}} am {{ standard.last_modified_on}} + {% if not standard.created_standard_by %} Erstellt von gelöschtem Mitarbeiter {% else %} Erstellt durch {{standard.created_standard_by.first_name}} {{standard.created_standard_by.last_name}} {% endif %} am {{standard.created_standard_date}} | {% if not standard.last_modified_by %} Zuletzt bearbeitet von gelöschtem Benutzer {% else %} Zuletzt bearbeitet von {{ standard.last_modified_by.first_name}} {{ standard.last_modified_by.last_name}}{% endif %} am {{ standard.last_modified_on}} +
diff --git a/standards/templates/standards/standards_single_agn.html b/standards/templates/standards/standards_single_agn.html index 773b5e2..07719b6 100644 --- a/standards/templates/standards/standards_single_agn.html +++ b/standards/templates/standards/standards_single_agn.html @@ -124,9 +124,8 @@   {% getcommentsup comment.pk as cup %} {% if cup > 0 %}{{cup}}{% endif %} - - {% if comment.comment_by == request.user or standard.created_standard_by == request.user or standard.last_modified_by == request.user %} + {% if comment.comment_by == request.user or (standard.created_standard_by != none and standard.created_standard_by == request.user) or standard.last_modified_by == request.user %} diff --git a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc index e6341fb..20406bc 100644 Binary files a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc and b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc differ diff --git a/standards/templatetags/counter_tag.py b/standards/templatetags/counter_tag.py index ba57844..9ae4c5f 100644 --- a/standards/templatetags/counter_tag.py +++ b/standards/templatetags/counter_tag.py @@ -557,6 +557,19 @@ def gettimeoveralldiff(workday, user): Es werden nur Tage berücksichtigt, die in der Vergangenheit liegen! ''' +def format_timedelta(td): + hours, remainder = divmod(td.total_seconds(), 3600) + minutes, seconds = divmod(remainder, 60) + hours, minutes, seconds = int(hours), int(minutes), int(seconds) + if hours < 10: + hours = '0%s' % int(hours) + if minutes < 10: + minutes = '0%s' % minutes + if seconds < 10: + seconds = '0%s' % seconds + return '%s:%s:%s' % (hours, minutes, seconds) + + @register.simple_tag def loadaccounttime(user): status = 0 @@ -591,14 +604,13 @@ def loadaccounttime(user): # Wenn GLeitzeit NEGATIV ist if(finalaccounttimesum.total_seconds() < 0): status = 1 - final_info_data = str(datetime.timedelta(seconds=finalaccounttimesum.total_seconds()*(-1))).split(":") + final_info_data = format_timedelta(datetime.timedelta(seconds=finalaccounttimesum.total_seconds()*(-1))) else: status = 0 - final_info_data = str(datetime.timedelta(seconds=finalaccounttimesum.total_seconds())).split(":") + final_info_data = format_timedelta(datetime.timedelta(seconds=finalaccounttimesum.total_seconds())) - final_info = str(final_info_data[0]) + ":" + str(final_info_data[1]) - - return [final_info, status] + #final_info = str(final_info_data[0]) + ":" + str(final_info_data[1]) + return [final_info_data, status] ''' diff --git a/standards/views.py b/standards/views.py index 68e9264..31ea365 100644 --- a/standards/views.py +++ b/standards/views.py @@ -607,6 +607,7 @@ def StandardSingle(request, pk): 'active_link':'standards', 'standard' : standard } + return render(request, 'standards/standards_single.html', context) else: context = { diff --git a/tasks/models.py b/tasks/models.py index c4b2905..a89ac4a 100644 --- a/tasks/models.py +++ b/tasks/models.py @@ -18,7 +18,7 @@ class Tasks(models.Model): name = models.CharField(max_length=200, blank=False, default="") desc = models.TextField(max_length=3000, blank=True) usersfield = models.ManyToManyField(User, blank=True, related_name='users_in_task') - created_area_by = models.ForeignKey(User, on_delete=models.PROTECT) + created_area_by = models.ForeignKey(User, on_delete=models.SET_NULL, null=True) created_area_date = models.DateField(default=datetime.date.today, blank=True) visible = models.BooleanField(default=True) diff --git a/timemanagement/templates/timemanagement/rendered_table.html b/timemanagement/templates/timemanagement/rendered_table.html index b8e5a19..552348a 100644 --- a/timemanagement/templates/timemanagement/rendered_table.html +++ b/timemanagement/templates/timemanagement/rendered_table.html @@ -428,15 +428,14 @@ function recalculateChoosenDays(userid=false){ $("#id_start").data("DateTimePicker").date(date_start); $("#id_end").data("DateTimePicker").date(date_end); - - console.log(userid); + localStorage.setItem("ab_userid", userid); $.ajax({ type: "GET", url: "{% url 'tm-ajax' %}", data:{ action : "getrestholidays", - userid : userid, + userid : localStorage.getItem("ab_userid"), startdate : date_start.getFullYear() + "__" + (date_start.getMonth()+1) + "__" + date_start.getDate(), enddate : date_end.getFullYear() + "__" + (date_end.getMonth()+1) + "__" + date_end.getDate(), //start_half : $("#id_start_ishalf").prop("checked"), @@ -462,8 +461,6 @@ function recalculateChoosenDays(userid=false){ $("#ownholidays").hide(); } - - $("#startAbsenceProgress").modal("show"); @@ -504,8 +501,6 @@ function recalculateChoosenDays(userid=false){ } function recalculateChoosenDaysAfterInit(){ - console.log("CHANGE!") - console.log(userid); new_start = $("#id_start").datepicker().val(); new_end = $("#id_end").datepicker().val(); @@ -515,10 +510,10 @@ function recalculateChoosenDaysAfterInit(){ behindcheck_start = new Date(new_start[2], (parseInt(new_start[1])-1), new_start[0]); behindcheck_end = new Date(new_end[2], (parseInt(new_end[1])-1), new_end[0]); - if(sameday){ - behindcheck_end = behindcheck_start; - new_end = new_start; - } + //if(sameday){ + // behindcheck_end = behindcheck_start; + // new_end = new_start; + //} $.ajax({ @@ -526,7 +521,7 @@ function recalculateChoosenDaysAfterInit(){ url: "{% url 'tm-ajax' %}", data:{ action : "getrestholidays", - userid : userid, + userid : localStorage.getItem("ab_userid"), startdate : new_start[2] + "__" + new_start[1] + "__" + new_start[0], enddate : new_end[2] + "__" + new_end[1] + "__" + new_end[0], //start_half : $("#id_start_ishalf").prop("checked"), @@ -603,11 +598,11 @@ function recalculateChoosenDaysAfterInit(){ /* CHANGE LISTENER */ -$("#id_start").blur(function(){ +$("#id_start").blur(function(){ recalculateChoosenDaysAfterInit(); }) -$("#id_end").blur(function(){ +$("#id_end").blur(function(){ recalculateChoosenDaysAfterInit(); }) diff --git a/users/SAVE.py b/users/SAVE.py deleted file mode 100644 index a4ce900..0000000 --- a/users/SAVE.py +++ /dev/null @@ -1,229 +0,0 @@ - -''' -@receiver(post_save, sender=DataDir) -def save_dir(sender, instance, **kwargs): - usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk) - - # CREATED - if(kwargs["created"]): - for user in usersofagency: - if(user.usernotifications.filedir_created_mail): - notificationtext = " es gibt neue Ordner: " + instance.name - sendMailNoti(notificationtext, user) - - - if(user.usernotifications.filedir_created_push): - newnotification = UserNotification(touser=user, notificationtext="Neuer Ordner: " + instance.name, notificationtype="", elementid=instance.pk) - newnotification.save() - - channel_layer = channels.layers.get_channel_layer() - async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Ordner | Neuer Ordner: " + instance.name}) - # UPDATED - else: - for user in usersofagency: - if(user.usernotifications.filedir_update_mail): - notificationtext = " Ordner wurden aktualisiert: " + instance.name - sendMailNoti(notificationtext, user) - - - if(user.usernotifications.filedir_update_push): - newnotification = UserNotification(touser=user, notificationtext="Aktualisierter Ordner: " + instance.name, notificationtype="", elementid=instance.pk) - newnotification.save() - - channel_layer = channels.layers.get_channel_layer() - async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Ordner | Aktualisierter Ordner: " + instance.name}) -''' - -''' -@receiver(pre_delete, sender=DataDir) -def del_dir(sender, instance, **kwargs): - usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk) - - for user in usersofagency: - if(user.usernotifications.filedir_delete_mail): - notificationtext = " ein Ordner wurde gelöscht: " + instance.name - sendMailNoti(notificationtext, user) - - - if(user.usernotifications.filedir_delete_push): - newnotification = UserNotification(touser=user, notificationtext="Ordner gelöscht: " + instance.name, notificationtype="", elementid=instance.pk) - newnotification.save() - - channel_layer = channels.layers.get_channel_layer() - async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Ordner | Ordner gelöscht: " + instance.name}) -''' - - -@receiver(pre_delete, sender=DataFile) -def del_file(sender, instance, **kwargs): - usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk) - - for user in usersofagency: - if(user.usernotifications.filedir_delete_mail): - notificationtext = " eine Datei wurde gelöscht: " + instance.name - sendMailNoti(notificationtext, user) - - - if(user.usernotifications.filedir_delete_push): - newnotification = UserNotification(touser=user, notificationtext="Datei gelöscht: " + instance.name, notificationtype="", elementid=instance.pk) - newnotification.save() - - channel_layer = channels.layers.get_channel_layer() - async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Dateiein | Datei gelöscht: " + instance.name}) - # Signals for FILES -@receiver(post_save, sender=DataFile) -def save_file(sender, instance, **kwargs): - - if(kwargs["created"] and len(instance.name) > 0): - newNotifiyPush(0, instance, " es gibt eine neue Datei: ", "Neue Datei: ", "Dateien | ", "", "") - elif(len(instance.name) > 0): - newNotifiyPush(1, instance, " Datei wurde aktualisiert: ", "Aktualisierter Datei: ", "Dateien | ", "", "") - - - usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk) - - # CREATED - if(kwargs["created"]): - for user in usersofagency: - if(user.usernotifications.filedir_created_mail): - notificationtext = " es gibt eine neue Datei: " + instance.name - sendMailNoti(notificationtext, user) - - - if(user.usernotifications.filedir_created_push): - newnotification = UserNotification(touser=user, notificationtext="Neue Datei: " + instance.name, notificationtype="", elementid=instance.pk) - newnotification.save() - - channel_layer = channels.layers.get_channel_layer() - async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Dateien | Neue Datei: " + instance.name}) - # UPDATED - else: - for user in usersofagency: - if(user.usernotifications.filedir_update_mail): - notificationtext = " Datei wurden aktualisiert: " + instance.name - sendMailNoti(notificationtext, user) - - - if(user.usernotifications.filedir_update_push): - newnotification = UserNotification(touser=user, notificationtext="Aktualisierte Datei: " + instance.name, notificationtype="", elementid=instance.pk) - newnotification.save() - - channel_layer = channels.layers.get_channel_layer() - async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Dateien | Aktualisierte Datei: " + instance.name}) - - - -@receiver(post_save, sender=QuickLinks) -def save_ql(sender, instance, **kwargs): - usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk) - - # CREATED - if(kwargs["created"]): - for user in usersofagency: - if(user.usernotifications.ql_created_mail): - notificationtext = " es gibt einen neuen Quicklink: " + instance.name - sendMailNoti(notificationtext, user) - - - if(user.usernotifications.ql_created_push): - newnotification = UserNotification(touser=user, notificationtext="Neuer Quicklink: " + instance.name, notificationtype="", elementid=instance.pk) - newnotification.save() - - channel_layer = channels.layers.get_channel_layer() - async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Organizer | Neuer Quicklink: " + instance.name}) - # UPDATED - else: - for user in usersofagency: - if(user.usernotifications.ql_update_mail): - notificationtext = " Quicklink wurde aktualisiert: " + instance.name - sendMailNoti(notificationtext, user) - - - if(user.usernotifications.ql_update_push): - newnotification = UserNotification(touser=user, notificationtext="Quicklink aktualisiert: " + instance.name, notificationtype="", elementid=instance.pk) - newnotification.save() - - channel_layer = channels.layers.get_channel_layer() - async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Organizer | Aktualisierter Quicklink: " + instance.name}) - - -@receiver(pre_delete, sender=QuickLinks) -def del_ql(sender, instance, **kwargs): - usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk) - - for user in usersofagency: - if(user.usernotifications.ql_delete_mail): - notificationtext = " ein Quicklink wurde gelöscht: " + instance.name - sendMailNoti(notificationtext, user) - - - if(user.usernotifications.ql_delete_push): - newnotification = UserNotification(touser=user, notificationtext="Quicklink gelöscht: " + instance.name, notificationtype="", elementid=instance.pk) - newnotification.save() - - channel_layer = channels.layers.get_channel_layer() - async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Organizer | Quicklink gelöscht: " + instance.name}) -@receiver(post_save, sender=Standards) -def save_standard(sender, instance, **kwargs): - usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk) - targeturl = settings.BASE_URL + "standards/standard/" + str(instance.pk) + "/single" - # NEW STANDARD - if(kwargs["created"]): - if(instance.public): - for user in usersofagency: - - if(user.usernotifications.standard_created_mail): - notificationtext = " es wurde ein neuer Agenturstandard erstellt: " + instance.name - sendMailNoti(notificationtext, user) - - - if(user.usernotifications.standard_created_push): - newnotification = UserNotification(touser=user, notificationtext="Neuer Agenturstandard: " + instance.name, notificationtype="newstandard", elementid=instance.pk) - newnotification.save() - - channel_layer = channels.layers.get_channel_layer() - async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Standards | Neuer Agenturstandard: " + instance.name}) - else: - for user in usersofagency: - if(user.has_perm("users.standardmanager") and user.usernotifications.standard_created_unpub_push): - newnotification = UserNotification(touser=user, notificationtext="Neuer unveröffentlichter Agenturstandard: " + instance.name, notificationtype="newstandard", elementid=instance.pk) - newnotification.save() - - channel_layer = channels.layers.get_channel_layer() - async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Standards | Neuer unveröffentlichter Agenturstandard: " + instance.name}) - - if(user.has_perm("users.standardmanager") and user.usernotifications.standard_created_unpub_mail): - notificationtext = " es wurde ein neuer unveröffentlichter Agenturstandard erstellt: " + instance.name - sendMailNoti(notificationtext, user) - # Standard wurde aktualisiert - else: - for user in usersofagency: - - if(user.usernotifications.standard_update_mail): - notificationtext = " es wurde ein neuer Agenturstandard aktualisiert: " + instance.name - sendMailNoti(notificationtext, user) - - if(user.usernotifications.standard_update_push): - newnotification = UserNotification(touser=user, notificationtext="Agenturstandard aktualisiert: " + instance.name, notificationtype="newstandard", elementid=instance.pk) - newnotification.save() - - channel_layer = channels.layers.get_channel_layer() - async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Standards | Agenturstandard aktualisiert: " + instance.name}) - - -# DELETE -@receiver(pre_delete, sender=Standards) -def delete_standard(sender, instance, **kwargs): - usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk) - for user in usersofagency: - if(user.usernotifications.standard_delete_mail): - notificationtext = " es wurde ein neuer Agenturstandard gelöscht: " + instance.name - sendMailNoti(notificationtext, user) - - - if(user.usernotifications.standard_delete_push): - newnotification = UserNotification(touser=user, notificationtext="Agenturstandard gelöscht: " + instance.name, notificationtype="", elementid=instance.pk) - newnotification.save() - - channel_layer = channels.layers.get_channel_layer() - async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Standards | Agenturstandard gelöscht: " + instance.name}) \ No newline at end of file diff --git a/users/templates/users/chat_allusers.html b/users/templates/users/chat_allusers.html index c5da743..41876ea 100644 --- a/users/templates/users/chat_allusers.html +++ b/users/templates/users/chat_allusers.html @@ -23,9 +23,9 @@
-

Chat starten +

Chat starten -
+
{% for user in usersofagency %} diff --git a/users/templates/users/user_confirm_delete.html b/users/templates/users/user_confirm_delete.html index fd81060..de9882f 100644 --- a/users/templates/users/user_confirm_delete.html +++ b/users/templates/users/user_confirm_delete.html @@ -10,13 +10,22 @@
+
{% csrf_token %} -

Alle vom Benutzer erstellen Standards werden dem aktuellen Benutzer zugewiesen.
(Aktuller Benutzer: {{request.user.pre_name}} {{request.user.last_name}})

+

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.

+ Daten erneut herunterladen +
  Abbrechen
+ {% endblock content %} \ No newline at end of file diff --git a/users/urls.py b/users/urls.py index 1864935..cfb2149 100644 --- a/users/urls.py +++ b/users/urls.py @@ -23,6 +23,7 @@ urlpatterns = [ #path('usersman//', permission_required('users.usermanager')(ProfileUpdateView.as_view()), name='users-update'), path('usersman//perms', permission_required('users.usermanager')(UsersPermUpdateView.as_view()), name='users-perm-update'), path('usersman//delete', permission_required('users.usermanager')(ProfileDeleteView.as_view()), name='users-delete'), + path('usersman/gd/', views.getDataFromToDelUser, name="users-delete-getdata"), #path('agencyinfo/', views.agency, name='agencyinfo'), #path('agencyinfo//', permission_required('users.agency_change')(AgencyUpdateView.as_view()), name='agency-manage'), path('usersman//prio', views.UsersPrio, name='users-prio'), @@ -37,7 +38,8 @@ urlpatterns = [ path('sendpassmail/', views.sendpassmail, name="users-sendpassmail"), path('changeonlinestat/', views.changeonlinestat, name="users-updateonlinestat"), path('dacron/', views.cronactions, name="cronmain"), - path('dacrondaily/', views.cronactionsdaily, name="cronmaindaily") + path('dacrondaily/', views.cronactionsdaily, name="cronmaindaily"), + ] diff --git a/users/views.py b/users/views.py index a71e07b..b6fe10f 100644 --- a/users/views.py +++ b/users/views.py @@ -41,7 +41,7 @@ from channels_presence.models import Room from channels_presence.models import Presence import channels.layers from datetime import date, timedelta -from timemanagement.models import Workday, Absence +from timemanagement.models import Workday, Absence, Breaks import base64 import filetype from django.db.models.signals import m2m_changed @@ -507,15 +507,73 @@ def changeonlinestat(request): zugeschrieben, welcher eingeloggt ist. Das passiert VOR dem löschen! ''' + + +import csv + +@login_required +def getDataFromToDelUser(request, pk): + if(request.method == "GET"): + response = HttpResponse(content_type='text/csv') + response['Content-Disposition'] = 'attachment; filename="newfile.csv"' + + writer = csv.writer(response) + + # LOAD ABSENCE OBJECTES + user = User.objects.get(pk=pk) + # TASK: Hier besprechen, ob das Recht als Benutzermanager ausreicht! + if(request.user.has_perm("users.usermanager") and user.profile.agency == request.user.profile.agency): + + user_absences = Absence.objects.filter(agency=request.user.profile.agency, user=user).order_by("-start") + + for ab in user_absences: + status = "OK" + if(ab.confirm_status == 1 or ab.confirm_status == 2): + status = "Abgelehnt" + writer.writerow(['Abwesenheit', str(ab.start), str(ab.end), 'Grund: '+ab.reason.name, 'Status: '+status]) + + user_workdays = Workday.objects.filter(agency=request.user.profile.agency, user=user).order_by("-start") + for wd in user_workdays: + breaks = Breaks.objects.filter(agency=request.user.profile.agency, user=user, workday=wd) + breaks_string = "" + for b in breaks: + breaks_string += str(b.start) + " bis " + str(b.end) + ", " + + writer.writerow(['Arbeitstag', str(wd.start), str(wd.end), 'Pausen: ' + breaks_string]) + return response + else: + pass + + 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): + 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) + writer.writerow(['1001', 'John', 'Domil', 'CA']) + writer.writerow(['1002', 'Amit', 'Mukharji', 'LA', '"Testing"']) + context.update({"response" : response}) + print(response) + return context + def delete(self, request, *args, **kwargs): user = User.objects.get(pk=kwargs['pk']) logged_user = request.user + + ''' ALTER LÖSCHBEREICH - User wird einfach entfernt ''' + + ''' + areas_fs = Areas.objects.filter(created_area_by=user) for a in areas_fs: a.created_area_by = logged_user @@ -542,7 +600,8 @@ class ProfileDeleteView(LoginRequiredMixin, DeleteView): for a in standards_fs: a.published_by = logged_user a.save() - + ''' + response = super(ProfileDeleteView, self).delete(request, *args, **kwargs) name = user.first_name + " " + user.last_name messages.success(request, f'Benutzer ' +name+ ' wurde gelöscht!') @@ -615,7 +674,6 @@ def UsersPrioUpdate(request): else: return HttpResponse("Request method is not a GET") - import re