Benachrichtungen Organizier QL fertig
This commit is contained in:
parent
69cb008fd1
commit
c1950648e4
|
|
@ -233,7 +233,7 @@ class UsersNotificationFormOrganizer(forms.ModelForm):
|
|||
"ql_delete_mail" : "Quicklink gelöscht",
|
||||
"contact_created_mail" : "Kontakt erstellt",
|
||||
"contact_update_mail" : "Kontakt aktualisiert",
|
||||
"contact_delete_push" : "Kontakt gelöscht",
|
||||
"contact_delete_mail" : "Kontakt gelöscht",
|
||||
"password_created_mail" : "Passwort erstellt",
|
||||
"password_update_mail" : "Passwort aktualisiert",
|
||||
"password_delete_mail" : "Passwort gelöscht",
|
||||
|
|
|
|||
|
|
@ -69,14 +69,6 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header" id="st_groups">
|
||||
<h5 class="mb-0">
|
||||
|
|
|
|||
172
users/signals.py
172
users/signals.py
|
|
@ -8,7 +8,7 @@ from notificsys.models import UserNotification
|
|||
from django.core.mail import send_mail
|
||||
from django.template.loader import render_to_string
|
||||
from tasks.models import Tasks
|
||||
from cloud.models import DataFile
|
||||
from cloud.models import DataFile, DataDir
|
||||
import os
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
|
|
@ -26,6 +26,11 @@ import channels.layers
|
|||
from asgiref.sync import async_to_sync
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from datetime import timedelta
|
||||
from django.core.signals import request_started
|
||||
from channels_presence.models import Room
|
||||
from channels_presence.models import Presence
|
||||
from channels_presence.signals import presence_changed
|
||||
from organizer.models import *
|
||||
|
||||
def loadingFreeDays(plz, year):
|
||||
# Getting land
|
||||
|
|
@ -365,20 +370,170 @@ def adjust_group_notifications_task(instance, action, reverse, model, pk_set, us
|
|||
notificationtext = "Sie wurden der Tätigkeit " + taskname + " zugeordnet."
|
||||
sendMailNoti(notificationtext, user_touched)
|
||||
|
||||
|
||||
# Signals for FILES
|
||||
@receiver(post_save, sender=DataFile)
|
||||
def save_file(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 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=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})
|
||||
|
||||
|
||||
|
||||
@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})
|
||||
|
||||
# Join eines Agenturverbunds
|
||||
@receiver(signal=post_save, sender=AgencyNetworkPreperation)
|
||||
def save_agjoin_prep(sender, instance, **kwargs):
|
||||
newnotification = UserNotification(touser=instance.target_network.creator, notificationtext="Eine Agentur möchte Ihrem Verbund beitreten.", notificationtype="wantedag", elementid=instance.pk)
|
||||
newnotification.save()
|
||||
|
||||
|
||||
from django.core.signals import request_started
|
||||
from channels_presence.models import Room
|
||||
from channels_presence.models import Presence
|
||||
from channels_presence.signals import presence_changed
|
||||
# REQUEST MAIN STUFF
|
||||
@receiver(signal=request_started)
|
||||
def receiver_function(sender, **kwargs):
|
||||
# DELETES ALL PRESENCE-OBJETS LOWER THAN 15 MINUTES
|
||||
# DELETES ALL PRESENCE-OBJECTS LOWER THAN 15 MINUTES
|
||||
now_minus = datetime.datetime.now() - datetime.timedelta(minutes=2)
|
||||
Presence.objects.filter(last_seen__lt=now_minus).delete()
|
||||
|
||||
|
|
@ -394,8 +549,7 @@ def receiver_function(sender, **kwargs):
|
|||
user_notification.save()
|
||||
|
||||
|
||||
|
||||
# PREENCE CHANGED
|
||||
# PRESENCE CHANGED
|
||||
@receiver(signal=presence_changed)
|
||||
def update_presence_live(sender, **kwargs):
|
||||
channel_layer = channels.layers.get_channel_layer()
|
||||
|
|
|
|||
Loading…
Reference in New Issue