From 3aded3aa94bb5245945923f2d82cc9c590e80397 Mon Sep 17 00:00:00 2001 From: Holger Trampe Date: Tue, 9 Jun 2020 10:55:58 +0200 Subject: [PATCH] =?UTF-8?q?Benachrichtigungen=20hinzugef=C3=BCgt,=20Logik?= =?UTF-8?q?=20folgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cred | 3 - .gitignore | 2 + dasettings/forms.py | 197 +++++++++- .../dasettings/notifications_content.html | 365 ++++++++++++++++-- .../dasettings/notifications_content_OLD.html | 64 +++ dasettings/views.py | 78 +++- timemanagement/models.py | 3 +- users/admin.py | 3 +- users/models.py | 134 ++++++- users/signals.py | 15 +- 10 files changed, 827 insertions(+), 37 deletions(-) delete mode 100644 .cred create mode 100644 dasettings/templates/dasettings/notifications_content_OLD.html diff --git a/.cred b/.cred deleted file mode 100644 index ea260ec..0000000 --- a/.cred +++ /dev/null @@ -1,3 +0,0 @@ -https://holger.trampe:Zerogoogle123_@git.vhevents.de/ -https://holger.trampe:Zerogoogle123_@git.vhevents.de/ -https://holger.trampe:Zerogoogle123_@git.vhevents.de/ diff --git a/.gitignore b/.gitignore index ec80125..7d9d49e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ media/agencydata/* digitaleagentur/__pycache__/* digitaleagentur/sec.py +.cred + collectedstatic/* media/userprofilepics/* diff --git a/dasettings/forms.py b/dasettings/forms.py index e8e82ae..54de4d8 100644 --- a/dasettings/forms.py +++ b/dasettings/forms.py @@ -1,7 +1,7 @@ from django import forms from django.db import models from django.contrib.auth.models import User -from users.models import AgencyGroup, Agency, Profile, AgencyJob, AgencyNetwork, UserTime +from users.models import AgencyGroup, Agency, Profile, AgencyJob, AgencyNetwork, UserTime, UserNotifications from PIL import Image from bootstrap_datepicker_plus import DatePickerInput from django.utils.translation import gettext as _ @@ -35,6 +35,7 @@ class UsersSelfChangeForm(forms.ModelForm): fields = ['email'] # Form für die Benachrichtigungseinstellungen +''' class UsersNotificationForm(forms.ModelForm): class Meta: @@ -49,6 +50,200 @@ class UsersNotificationForm(forms.ModelForm): } #fields = ['news_mail', 'news_push', 'user_standard_public_mail', 'user_standard_public_push', 'agency_new_standard_mail', 'agency_new_standard_push', 'add_new_group_mail', 'add_new_group_push', 'add_task_mail', 'add_task_push', 'user_messages_mail', 'user_messages_push'] fields = ['news_mail', 'news_push', 'agency_new_standard_mail', 'agency_new_standard_push', 'add_new_group_mail', 'add_new_group_push', 'add_task_mail', 'add_task_push', 'user_messages_mail', 'user_messages_push'] +''' +# Form für die Benachrichtigungseinstellungen STANDARDS +class UsersNotificationFormStandard(forms.ModelForm): + + class Meta: + model = UserNotifications + labels = { + "standard_created_mail" : "Neuer Standard", + "standard_update_mail" : "Standard verändert", + "standard_delete_mail" : "Standard gelöscht", + "standard_created_unpub_mail" : "Neuer, unveröffentlichter Standard" + + } + fields = [ + 'standard_created_mail', + 'standard_created_push', + 'standard_update_mail', + 'standard_update_push', + 'standard_delete_mail', + 'standard_delete_push', + 'standard_created_unpub_mail', + 'standard_created_unpub_push', + ] + + +# Form für die Benachrichtigungseinstellungen NEWS +class UsersNotificationFormNews(forms.ModelForm): + + class Meta: + model = UserNotifications + labels = { + "news_created_mail" : "Neuer Agenturnews", + + } + fields = [ + 'news_created_mail', + 'news_created_push', + ] + +# Form für die Benachrichtigungseinstellungen MESSAGES +class UsersNotificationFormMessages(forms.ModelForm): + + class Meta: + model = UserNotifications + labels = { + "message_received_mail" : "Neuer Mitteilung", + + } + fields = [ + 'message_received_mail', + 'message_received_push', + ] + +# Form für die Benachrichtigungseinstellungen CHAT +class UsersNotificationFormChat(forms.ModelForm): + + class Meta: + model = UserNotifications + labels = { + "chat_received_mail" : "Verpasste Chatnachrichten", + "chat_room_activity_mail" : "Raumaktivitäten", + + } + fields = [ + 'chat_received_mail', + 'chat_received_push', + 'chat_room_activity_mail', + 'chat_room_activity_push', + ] + +# Form für die Benachrichtigungseinstellungen FILES +class UsersNotificationFormFiles(forms.ModelForm): + + class Meta: + model = UserNotifications + labels = { + "filedir_created_mail" : "Datei/Ordner erstellt", + "filedir_update_mail" : "Datei/Ordner aktualisiert", + "filedir_delete_mail" : "Datei/Ordner gelöscht", + + } + fields = [ + 'filedir_created_mail', + 'filedir_created_push', + 'filedir_update_mail', + 'filedir_update_push', + 'filedir_delete_mail', + 'filedir_delete_push', + ] + +# Form für die Benachrichtigungseinstellungen ABSENCE AND TIME +class UsersNotificationFormAbTime(forms.ModelForm): + + class Meta: + model = UserNotifications + labels = { + "absence_created_mail" : "Anfrage erstellt", + "absence_user_is_rep_mail" : "Als Vertreter eingesetzt", + "absence_user_is_rep_reminder_mail" : "Erinnerung für Vertretung", + "time_data_changed_push" : "Datei/Ordner gelöscht", + } + fields = [ + 'absence_created_mail', + 'absence_created_push', + 'absence_user_is_rep_mail', + 'absence_user_is_rep_push', + 'absence_user_is_rep_reminder_mail', + 'absence_user_is_rep_reminder_push', + 'time_data_changed_mail', + 'time_data_changed_push', + ] + +# Form für die Benachrichtigungseinstellungen GRUPPEN +class UsersNotificationFormGroups(forms.ModelForm): + + class Meta: + model = UserNotifications + labels = { + "group_activity_mail" : "Mitgliedschaftsänderung", + "group_rights_mail" : "Rechteänderung", + + } + fields = [ + 'group_activity_mail', + 'group_activity_push', + 'group_rights_mail', + 'group_rights_push', + ] + +# Form für die Benachrichtigungseinstellungen GRUPPEN +class UsersNotificationFormAgn(forms.ModelForm): + + class Meta: + model = UserNotifications + labels = { + "agn_standard_created_mail" : "Neuer Standard", + "agn_standard_copied_mail" : "Standard wurde übernommen", + "agn_standard_comment_mail" : "Kommentar zu Standard aus meiner Agentur", + "agn_standard_comment_react_mail" : "Reaktion zu meinem Kommentar", + "agn_own_change_mail" : "Änderungen meiner Mitgliedschaften", + "agn_other_change_mail" : "Änderungen anderer Mitgliedschaften", + + } + fields = [ + 'agn_standard_created_mail', + 'agn_standard_created_push', + 'agn_standard_copied_mail', + 'agn_standard_copied_push', + 'agn_standard_comment_mail', + 'agn_standard_comment_push', + 'agn_standard_comment_react_mail', + 'agn_standard_comment_react_push', + 'agn_own_change_mail', + 'agn_own_change_push', + 'agn_other_change_mail', + 'agn_other_change_push', + ] + + +class UsersNotificationFormOrganizer(forms.ModelForm): + + class Meta: + model = UserNotifications + labels = { + "ql_created_mail" : "Quicklink erstellt", + "ql_update_mail" : "Quicklink aktualisiert", + "ql_delete_mail" : "Quicklink gelöscht", + "contact_created_mail" : "Kontakt erstellt", + "contact_update_mail" : "Kontakt aktualisiert", + "contact_delete_push" : "Kontakt gelöscht", + "password_created_mail" : "Passwort erstellt", + "password_update_mail" : "Passwort aktualisiert", + "password_delete_mail" : "Passwort gelöscht", + } + fields = [ + 'ql_created_mail', + 'ql_created_push', + 'ql_update_mail', + 'ql_update_push', + 'ql_delete_mail', + 'ql_delete_push', + 'contact_created_mail', + 'contact_created_push', + 'contact_update_mail', + 'contact_update_push', + 'contact_delete_mail', + 'contact_delete_push', + 'password_created_mail', + 'password_created_push', + 'password_update_mail', + 'password_update_push', + 'password_delete_mail', + 'password_delete_push', + ] diff --git a/dasettings/templates/dasettings/notifications_content.html b/dasettings/templates/dasettings/notifications_content.html index 6a1f722..75d5307 100644 --- a/dasettings/templates/dasettings/notifications_content.html +++ b/dasettings/templates/dasettings/notifications_content.html @@ -1,28 +1,347 @@ {% load crispy_forms_tags %}
- - - - - - - - - -{% for formfield in notificationform %} - {% if forloop.counter|divisibleby:2 %} - - - {% else %} - - - - {% endif %} -{% endfor %} - -
BenachrichtigungE-MailPush
{{formfield}}
{{formfield.label_tag}}{{formfield}}
- -
+ +
+ + +
+
+
+ +
+
+ +
+
+ + + + + + + + + + {% for formfield in notificationforms_standard %} + {% if forloop.counter|divisibleby:2 %} + + + {% else %} + + + + {% endif %} + {% endfor %} + +
BenachrichtigungE-MailPush
{{formfield}}
{{formfield.label_tag}}{{formfield}}
+
+
+
+ + +
+
+
+ +
+
+ +
+
+ + + + + + + + + + {% for formfield in notificationforms_news %} + {% if forloop.counter|divisibleby:2 %} + + + {% else %} + + + + {% endif %} + {% endfor %} + +
BenachrichtigungE-MailPush
{{formfield}}
{{formfield.label_tag}}{{formfield}}
+
+
+
+ + + +
+
+
+ +
+
+ +
+
+ + + + + + + + + + {% for formfield in notificationforms_groups %} + {% if forloop.counter|divisibleby:2 %} + + + {% else %} + + + + {% endif %} + {% endfor %} + +
BenachrichtigungE-MailPush
{{formfield}}
{{formfield.label_tag}}{{formfield}}
+
+
+
+ + + + +
+
+
+ +
+
+ +
+
+ + + + + + + + + + {% for formfield in notificationforms_files %} + {% if forloop.counter|divisibleby:2 %} + + + {% else %} + + + + {% endif %} + {% endfor %} + +
BenachrichtigungE-MailPush
{{formfield}}
{{formfield.label_tag}}{{formfield}}
+
+
+
+ + +
+
+
+ +
+
+ +
+
+ + + + + + + + + + {% for formfield in notificationforms_organizer %} + {% if forloop.counter|divisibleby:2 %} + + + {% else %} + + + + {% endif %} + {% endfor %} + +
BenachrichtigungE-MailPush
{{formfield}}
{{formfield.label_tag}}{{formfield}}
+
+
+
+ + +
+
+
+ +
+
+ +
+
+ + + + + + + + + + {% for formfield in notificationforms_messages %} + {% if forloop.counter|divisibleby:2 %} + + + {% else %} + + + + {% endif %} + {% endfor %} + +
BenachrichtigungE-MailPush
{{formfield}}
{{formfield.label_tag}}{{formfield}}
+
+
+
+ + +
+
+
+ +
+
+ +
+
+ + + + + + + + + + {% for formfield in notificationforms_chat %} + {% if forloop.counter|divisibleby:2 %} + + + {% else %} + + + + {% endif %} + {% endfor %} + +
BenachrichtigungE-MailPush
{{formfield}}
{{formfield.label_tag}}{{formfield}}
+
+
+
+ + +
+
+
+ +
+
+ +
+
+ + + + + + + + + + {% for formfield in notificationforms_abtime %} + {% if forloop.counter|divisibleby:2 %} + + + {% else %} + + + + {% endif %} + {% endfor %} + +
BenachrichtigungE-MailPush
{{formfield}}
{{formfield.label_tag}}{{formfield}}
+
+
+
+ + + +
+
+
+ +
+
+ +
+
+ + + + + + + + + + {% for formfield in notificationforms_agn %} + {% if forloop.counter|divisibleby:2 %} + + + {% else %} + + + + {% endif %} + {% endfor %} + +
BenachrichtigungE-MailPush
{{formfield}}
{{formfield.label_tag}}{{formfield}}
+
+
+
+ +
+ \ No newline at end of file diff --git a/dasettings/views.py b/dasettings/views.py index c08f71d..922282e 100644 --- a/dasettings/views.py +++ b/dasettings/views.py @@ -1,7 +1,7 @@ from django.shortcuts import render, redirect from django.contrib.auth.decorators import login_required from django.http import HttpResponseRedirect,HttpResponse, JsonResponse -from .forms import UsersSelfChangeForm, UsersNotificationForm, AgencyGroupPerms, AgencyModulsForm, UserNewUserForm, UserProfileForm, AgencyNetworkForm, AgencyOrganigrammForm, UserTimeForm, AbsenceReasonForm +from .forms import UsersSelfChangeForm, UsersNotificationFormStandard, AgencyGroupPerms, AgencyModulsForm, UserNewUserForm, UserProfileForm, AgencyNetworkForm, AgencyOrganigrammForm, UserTimeForm, AbsenceReasonForm, UsersNotificationFormNews, UsersNotificationFormFiles, UsersNotificationFormMessages ,UsersNotificationFormOrganizer, UsersNotificationFormChat, UsersNotificationFormAbTime, UsersNotificationFormGroups, UsersNotificationFormAgn from django.contrib import messages from django.contrib.auth import update_session_auth_hash from django.contrib.auth.forms import PasswordChangeForm @@ -57,9 +57,37 @@ def getAllForms(request, context): context.update({'passwordform' : passwordform}) # NOTIFICTAION FORMS - notificationform = UsersNotificationForm(instance=request.user.profile) - context.update({'notificationform' : notificationform}) + # STANDARDS + notificationforms_standard = UsersNotificationFormStandard(instance=request.user.profile) + context.update({'notificationforms_standard' : notificationforms_standard}) + notificationforms_news = UsersNotificationFormNews(instance=request.user.profile) + context.update({'notificationforms_news' : notificationforms_news}) + + notificationforms_files = UsersNotificationFormFiles(instance=request.user.profile) + context.update({'notificationforms_files' : notificationforms_files}) + + notificationforms_organizer = UsersNotificationFormOrganizer(instance=request.user.profile) + context.update({'notificationforms_organizer' : notificationforms_organizer}) + + notificationforms_messages = UsersNotificationFormMessages(instance=request.user.profile) + context.update({'notificationforms_messages' : notificationforms_messages}) + + notificationforms_chat = UsersNotificationFormChat(instance=request.user.profile) + context.update({'notificationforms_chat' : notificationforms_chat}) + + notificationforms_abtime = UsersNotificationFormAbTime(instance=request.user.profile) + context.update({'notificationforms_abtime' : notificationforms_abtime}) + + notificationforms_groups = UsersNotificationFormGroups(instance=request.user.profile) + context.update({'notificationforms_groups' : notificationforms_groups}) + + notificationforms_agn = UsersNotificationFormAgn(instance=request.user.profile) + context.update({'notificationforms_agn' : notificationforms_agn}) + + + + # AGENCY UPDATE FORMS agencyform = AgencyUpdateForm(instance=request.user.profile.agency) context.update({'agencyform' : agencyform}) @@ -176,9 +204,34 @@ def DASettings(request): context.update({'userform' : userform}) context.update({'passwordform' : passwordform}) - # NOTIFICTAION FORMS - notificationform = UsersNotificationForm(instance=request.user.profile) - context.update({'notificationform' : notificationform}) + ############################### NOTIFIFORMS START ########################################## + notificationforms_standard = UsersNotificationFormStandard(instance=request.user.profile) + context.update({'notificationforms_standard' : notificationforms_standard}) + + notificationforms_news = UsersNotificationFormNews(instance=request.user.profile) + context.update({'notificationforms_news' : notificationforms_news}) + + notificationforms_files = UsersNotificationFormFiles(instance=request.user.profile) + context.update({'notificationforms_files' : notificationforms_files}) + + notificationforms_organizer = UsersNotificationFormOrganizer(instance=request.user.profile) + context.update({'notificationforms_organizer' : notificationforms_organizer}) + + notificationforms_messages = UsersNotificationFormMessages(instance=request.user.profile) + context.update({'notificationforms_messages' : notificationforms_messages}) + + notificationforms_chat = UsersNotificationFormChat(instance=request.user.profile) + context.update({'notificationforms_chat' : notificationforms_chat}) + + notificationforms_abtime = UsersNotificationFormAbTime(instance=request.user.profile) + context.update({'notificationforms_abtime' : notificationforms_abtime}) + + notificationforms_groups = UsersNotificationFormGroups(instance=request.user.profile) + context.update({'notificationforms_groups' : notificationforms_groups}) + + notificationforms_agn = UsersNotificationFormAgn(instance=request.user.profile) + context.update({'notificationforms_agn' : notificationforms_agn}) + ############################### NOTIFIFORMS END ############################################ # AGENCY UPDATE FORMS agencyform = AgencyUpdateForm(instance=request.user.profile.agency) @@ -408,6 +461,7 @@ def SettingsAjaxRouter(request): success = False data = {} # UPDATE NOTIFICATIONS BY FIELDNAME AND NEW VALUE + ''' if request.method == 'GET' and request.GET['action'] == "update_notifications" : success = False new_stat = request.GET['new_stat'] @@ -419,6 +473,18 @@ def SettingsAjaxRouter(request): setattr(request.user.profile, request.GET['fieldname'], False) request.user.profile.save() success = True + ''' + if request.method == 'GET' and request.GET['action'] == "update_notifications" : + success = False + new_stat = request.GET['new_stat'] + field_to_change = getattr(request.user.usernotifications, request.GET['fieldname']) + if(field_to_change or not field_to_change): + if(new_stat == "1"): + setattr(request.user.usernotifications, request.GET['fieldname'], True) + else: + setattr(request.user.usernotifications, request.GET['fieldname'], False) + request.user.usernotifications.save() + success = True # UPDATE TOOLTUP elif request.method == 'GET' and request.GET['action'] == "change_showtooltips" : newtooltipvalue = False diff --git a/timemanagement/models.py b/timemanagement/models.py index 11aeef9..a4b6021 100644 --- a/timemanagement/models.py +++ b/timemanagement/models.py @@ -3,6 +3,7 @@ from django.contrib.auth.models import User from users.models import Agency from django.core.exceptions import ValidationError from colorful.fields import RGBColorField +from django.utils import timezone # Create your models here. class Workday(models.Model): @@ -45,7 +46,7 @@ class Absence(models.Model): end = models.DateField(default=None, null=True, blank=True) start_ishalf = models.BooleanField(default=False, blank=True) end_ishalf = models.BooleanField(default=False, blank=True) - + created_date = models.DateTimeField(default=timezone.now, blank=True) reason = models.ForeignKey("AbsenceReason", on_delete=models.PROTECT, null=True, blank=True) info = models.TextField(blank=True, verbose_name='Abwesenheitsbegründung', default="") ''' diff --git a/users/admin.py b/users/admin.py index b0c9f2e..0918076 100644 --- a/users/admin.py +++ b/users/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from .models import Profile, Agency, AgencyGroup, AgencyJob, AgencyNetwork, AgencyNetworkPreperation, UserTime, UserYearAbsenceInfo +from .models import Profile, Agency, AgencyGroup, AgencyJob, AgencyNetwork, AgencyNetworkPreperation, UserTime, UserYearAbsenceInfo, UserNotifications from .priomodel import Prio from standards.models import StandardCommentRate, StandardComments from django.contrib.auth.models import Permission @@ -30,3 +30,4 @@ admin.site.register(Absence) admin.site.register(FreeDays) admin.site.register(UserYearAbsenceInfo) admin.site.register(ChatRoom) +admin.site.register(UserNotifications) diff --git a/users/models.py b/users/models.py index a28523c..ee1cae9 100644 --- a/users/models.py +++ b/users/models.py @@ -264,6 +264,138 @@ class UserTime(models.Model): startdate = models.DateField(default=None, blank=True, null=True) usetime = models.BooleanField(default=False) usetime_start = models.DateField(default=None, blank=True, null=True) +''' + + UserNotifications + + Beherbergt alle Benachrichtigungseinstellungen für die User. Ehemals direkt im + User-Model gepflegt, aber da es zu viele sind hierher umgezogen + +''' +class UserNotifications(models.Model): + user = models.OneToOneField(User, on_delete=models.CASCADE, blank=True, null=True, default=None) + # NOTIFICATIONS + + # STANDARDS + standard_created_mail = models.BooleanField(default=False) + standard_created_push = models.BooleanField(default=True) + + standard_update_mail = models.BooleanField(default=False) + standard_update_push = models.BooleanField(default=True) + + standard_delete_mail = models.BooleanField(default=False) + standard_delete_push = models.BooleanField(default=True) + # Wenn neue Standards erstellt wurden, erhalten alle User mit entsprechenden Recht eine Info, dass neue, unveröffentlichte Standards vorhanden sind + standard_created_unpub_mail = models.BooleanField(default=False) + standard_created_unpub_push = models.BooleanField(default=True) + + # NEWS + news_created_mail = models.BooleanField(default=True) + news_created_push = models.BooleanField(default=True) + + # FILES + filedir_created_mail = models.BooleanField(default=False) + filedir_created_push = models.BooleanField(default=True) + + filedir_update_mail = models.BooleanField(default=False) + filedir_update_push = models.BooleanField(default=True) + + filedir_delete_mail = models.BooleanField(default=False) + filedir_delete_push = models.BooleanField(default=True) + + # Quicklinks + ql_created_mail = models.BooleanField(default=False) + ql_created_push = models.BooleanField(default=True) + + ql_update_mail = models.BooleanField(default=False) + ql_update_push = models.BooleanField(default=True) + + ql_delete_mail = models.BooleanField(default=False) + ql_delete_push = models.BooleanField(default=True) + + # Contacts + contact_created_mail = models.BooleanField(default=False) + contact_created_push = models.BooleanField(default=True) + + contact_update_mail = models.BooleanField(default=False) + contact_update_push = models.BooleanField(default=True) + + contact_delete_mail = models.BooleanField(default=False) + contact_delete_push = models.BooleanField(default=True) + + # Password + password_created_mail = models.BooleanField(default=False) + password_created_push = models.BooleanField(default=True) + + password_update_mail = models.BooleanField(default=False) + password_update_push = models.BooleanField(default=True) + + password_delete_mail = models.BooleanField(default=False) + password_delete_push = models.BooleanField(default=True) + + # MESSAGES + message_received_mail = models.BooleanField(default=True) + message_received_push = models.BooleanField(default=True) + + # CHAT + # Diese Einstellung sorgt dafür, dass User eine Mail/Push erhalten, wenn neue Chatnachrichten vorhanden sind. + chat_received_mail = models.BooleanField(default=True) + chat_received_push = models.BooleanField(default=True) + + # Benachrichtigunge, wenn es Raumaktivitäten gab + chat_room_activity_mail = models.BooleanField(default=False) + chat_room_activity_push = models.BooleanField(default=True) + + # TIMEMANAGEMENT + # Wenn neue Abwesenheitsanfragen kommen, Rechte werden gecheckt und dann wird gesendet + absence_created_mail = models.BooleanField(default=True) + absence_created_push = models.BooleanField(default=True) + + # Info, ob ein Nutzer als Vertreter eingesetzt worden ist. + absence_user_is_rep_mail = models.BooleanField(default=True) + absence_user_is_rep_push = models.BooleanField(default=True) + + # Info, ob ein Nutzer als Vertreter eingesetzt worden ist REMINDER CronJob zwei Tage vorher + absence_user_is_rep_reminder_mail = models.BooleanField(default=True) + absence_user_is_rep_reminder_push = models.BooleanField(default=True) + + # Zeiterfassung + # Info an den User, wenn seine Zeitdaten verändert wurden + time_data_changed_mail = models.BooleanField(default=True) + time_data_changed_push = models.BooleanField(default=True) + + # GRUPPEN + group_activity_mail = models.BooleanField(default=False) + group_activity_push = models.BooleanField(default=True) + + group_rights_mail = models.BooleanField(default=False) + group_rights_push = models.BooleanField(default=True) + + # AGENCYNETWORK + # Neuer Standard im Verbund + agn_standard_created_mail = models.BooleanField(default=False) + agn_standard_created_push = models.BooleanField(default=True) + + # Neuer Agenturstandard wurde von anderer Agentur übernommen + agn_standard_copied_mail = models.BooleanField(default=False) + agn_standard_copied_push = models.BooleanField(default=True) + + # Neuer Kommentar zu einem Standard aus meinem Verbund + agn_standard_comment_mail = models.BooleanField(default=False) + agn_standard_comment_push = models.BooleanField(default=True) + + # Reaktion auf einen Kommentar von mir + agn_standard_comment_react_mail = models.BooleanField(default=False) + agn_standard_comment_react_push = models.BooleanField(default=True) + + # Änderungen eigener Mitgliedsanfragen in anderen Verbünden + agn_own_change_mail = models.BooleanField(default=True) + agn_own_change_push = models.BooleanField(default=True) + + # Änderungen anderer Mitgliedschaften (Beitrittsanfragen!) + agn_other_change_mail = models.BooleanField(default=False) + agn_other_change_push = models.BooleanField(default=True) + class UserYearAbsenceInfo(models.Model): @@ -315,4 +447,4 @@ class UserFullName(User): return "placeholder" def __str__(self): - return f'{self.first_name + " " + self.last_name}' \ No newline at end of file + return f'{self.first_name + " " + self.last_name}' \ No newline at end of file diff --git a/users/signals.py b/users/signals.py index c6602a5..cb9c910 100644 --- a/users/signals.py +++ b/users/signals.py @@ -1,7 +1,7 @@ from django.db.models.signals import post_save, pre_delete, m2m_changed, pre_save from django.contrib.auth.models import User, Group from django.dispatch import receiver -from .models import Profile, Agency, AgencyGroup, AgencyNetworkPreperation, UserYearAbsenceInfo, UserTime +from .models import Profile, Agency, AgencyGroup, AgencyNetworkPreperation, UserYearAbsenceInfo, UserTime, UserNotifications from news.models import News from django.contrib.auth.models import Permission from notificsys.models import UserNotification @@ -389,6 +389,19 @@ def receiver_function(sender, **kwargs): now_minus = datetime.datetime.now() - datetime.timedelta(minutes=2) Presence.objects.filter(last_seen__lt=now_minus).delete() + users = User.objects.all() + + for user in users: + user_notification = [] + try: + user_notification = UserNotifications.objects.get(user=user) + except: + if(len(user_notification) == 0): + user_notification = UserNotifications(user=user) + user_notification.save() + + + # PREENCE CHANGED @receiver(signal=presence_changed) def update_presence_live(sender, **kwargs):