From 298ca23a5b19e29c17073d10c8b172712444abca Mon Sep 17 00:00:00 2001 From: Holger Trampe Date: Wed, 16 Sep 2020 16:48:03 +0200 Subject: [PATCH] QS Nach Deck --- areas/models.py | 2 +- chat/templates/chat/chat_allusers.html | 42 +-- chat/templates/chat/chat_allusers_SAVE.html | 86 +++++ chat/templates/chat/chatmanagement.html | 102 +----- chat/templates/chat/chatmanagement_SAVE.html | 340 ++++++++++++++++++ cloud/models.py | 6 +- news/models.py | 2 +- news/templates/news/news_addnews.html | 6 + organizer/models.py | 1 - standards/forms.py | 2 +- standards/models.py | 8 +- .../templates/standards/standards_single.html | 15 +- .../standards/standards_single_agn.html | 3 +- .../__pycache__/counter_tag.cpython-38.pyc | Bin 15937 -> 16205 bytes standards/templatetags/counter_tag.py | 22 +- standards/views.py | 1 + tasks/models.py | 2 +- .../timemanagement/rendered_table.html | 23 +- users/SAVE.py | 229 ------------ users/templates/users/chat_allusers.html | 4 +- .../templates/users/user_confirm_delete.html | 11 +- users/urls.py | 4 +- users/views.py | 64 +++- 23 files changed, 584 insertions(+), 391 deletions(-) create mode 100644 chat/templates/chat/chat_allusers_SAVE.html create mode 100644 chat/templates/chat/chatmanagement_SAVE.html delete mode 100644 users/SAVE.py 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 e6341fbea118f769f3dbecdbc0ee73647bc78ec0..20406bcf805e1e5332506affae28663bd154b866 100644 GIT binary patch delta 677 zcmYLG&ubGw7@cos64#`OYYef5G+-d$8li!jG+BrU-b6*wdMMHum{g)B+R5r6?$#g4 z)q~E(AD0HS2k{~~2;TeyL{AF2XpgBmd65=0ezPsOyYDgI``&!Knf>T~T8%D5A|ZlL zd9zmiaQaC!1>5g(&sk77;!cmKFD$*kp1yuqbi}B8coAT>2%GjU&iARhYalGt;R zSdRu7{(1I(0LO8}DMWh}$ssOTgFX?^rB|p29z}%;>Q~I;4t1dm$joQn1x6@AANE`j z>;{qN#jY!Xy32g+s^Bienz`JsZ)439r0Q`IaM9%QWo%=v;JJnwB}6{MEF*o|4$EiT z9V6Se{m)|Z1*-D9rdLQ-U`QPyzu|JYSJs=gMoZMC9P0j4)z2Qto6EOkv*uKtMzb#J zH=SCZ;$h=xAP|Enq`-hF#Lg>6YGZB&j;P7p7z{N&p5$J*HLc7-V#*7@n3YT1Jv`h%-4JtQQ%;rg}5qhn6~1nujgbD>YI1RVu=^ zvdU)PK!`E!g|a z_5T(Q613&$Zu`9*iM`cr1Wu3?@Y1S-uXcuJN2tiLrY%i>G)*)SG~pN|3Th*FP|a4N YK-G!L&!iFI5XvLc2$N&zP+$lD0NiY%x&QzG delta 479 zcmX?Gcd&*pl$V!_0SLl9&Eh#cC-TWKe%h!#lbI(~E=w_`B&D>4p_y^=DP}pr6o$ko zuwYe6HApaO@=s=2wiNbY2F-@eS}f=FCu^DVG6qbxFnv?cm%>@gSRz=$mc?GfvOr)V zLkfooLkd?fV>9Cdp%m_gjJ4c(aw&{xYEa}$1Z%ic7$t!grErTgfO(uCo;X7-R}EJU zV>%PiVjjODMxfg@nToW4RMAEd(Zj$nx!O#Nz34VbMtJgavoN*?APJ|*|IEtR444=g ziuEQ}nQL+>FtIR7G089$z1Y0koSBjF+2r*W3mKCp2U?mlex2MWFFSdeWdKn0yQLZ9 zx5;`|zKo5NYpf(0e@=eLE;8AcO>**KD+~T9AOl%|7BDb#Fc$p*%E?Yvx0Yi3HTf^A z#N;Sze*Req6)cQJe}O8rp|X3dd4(2$WPuo{zvv&3)QsDF+ggc9>IINp^c6(>1QEYM o#2*mxck+B|*~yl6e2ff}J?vgfurP8N0 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