Benachrichtungen Organizer fertig und mainfunciotn umgebaut
This commit is contained in:
parent
5331dad88a
commit
814b087b42
|
|
@ -149,7 +149,7 @@ class UsersNotificationFormAbTime(forms.ModelForm):
|
||||||
"absence_created_mail" : "Anfrage erstellt",
|
"absence_created_mail" : "Anfrage erstellt",
|
||||||
"absence_user_is_rep_mail" : "Als Vertreter eingesetzt",
|
"absence_user_is_rep_mail" : "Als Vertreter eingesetzt",
|
||||||
"absence_user_is_rep_reminder_mail" : "Erinnerung für Vertretung",
|
"absence_user_is_rep_reminder_mail" : "Erinnerung für Vertretung",
|
||||||
"time_data_changed_push" : "Datei/Ordner gelöscht",
|
"time_data_changed_mail" : "Abwesenheit bearbeitet",
|
||||||
}
|
}
|
||||||
fields = [
|
fields = [
|
||||||
'absence_created_mail',
|
'absence_created_mail',
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ from django.contrib import messages
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
from notificsys.models import UserNotification
|
from notificsys.models import UserNotification
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
|
import channels.layers
|
||||||
|
from asgiref.sync import async_to_sync
|
||||||
|
|
||||||
|
|
||||||
# ALLE STANDARDS EINER AGENTUR
|
# ALLE STANDARDS EINER AGENTUR
|
||||||
@login_required
|
@login_required
|
||||||
|
|
@ -26,7 +29,6 @@ def mainmessageview(request):
|
||||||
if formtocheck.is_valid():
|
if formtocheck.is_valid():
|
||||||
|
|
||||||
targetuser_ids = formtocheck.cleaned_data["target_user"]
|
targetuser_ids = formtocheck.cleaned_data["target_user"]
|
||||||
print(targetuser_ids)
|
|
||||||
for user in targetuser_ids:
|
for user in targetuser_ids:
|
||||||
targetuser = User.objects.get(pk=user)
|
targetuser = User.objects.get(pk=user)
|
||||||
messagecontent = formtocheck.cleaned_data["message_content"]
|
messagecontent = formtocheck.cleaned_data["message_content"]
|
||||||
|
|
@ -35,9 +37,7 @@ def mainmessageview(request):
|
||||||
targeturl = request.build_absolute_uri() + "sl/" + str(message.id)
|
targeturl = request.build_absolute_uri() + "sl/" + str(message.id)
|
||||||
notificationtext = "Sie haben eine neue Mitteilung erhalten: " + message.content
|
notificationtext = "Sie haben eine neue Mitteilung erhalten: " + message.content
|
||||||
|
|
||||||
|
if(targetuser.usernotifications.message_received_mail):
|
||||||
if(targetuser.profile.user_messages_mail):
|
|
||||||
|
|
||||||
username = targetuser.first_name + " " + targetuser.last_name
|
username = targetuser.first_name + " " + targetuser.last_name
|
||||||
msg_html = render_to_string('notificsys/notification_mail.html', {'username': username, 'notificationtext' : notificationtext, 'linktarget' : targeturl})
|
msg_html = render_to_string('notificsys/notification_mail.html', {'username': username, 'notificationtext' : notificationtext, 'linktarget' : targeturl})
|
||||||
send_mail(
|
send_mail(
|
||||||
|
|
@ -49,10 +49,13 @@ def mainmessageview(request):
|
||||||
fail_silently=True
|
fail_silently=True
|
||||||
)
|
)
|
||||||
|
|
||||||
if(targetuser.profile.user_messages_push):
|
if(targetuser.usernotifications.message_received_push):
|
||||||
newnotification = UserNotification(touser=targetuser, elementid=message.id, notificationtext='Hallo ' + targetuser.first_name + ' ' + targetuser.last_name + '! ' + notificationtext, notificationtype="messagereceived")
|
newnotification = UserNotification(touser=targetuser, elementid=message.id, notificationtext='Hallo ' + targetuser.first_name + ' ' + targetuser.last_name + '! ' + notificationtext, notificationtype="messagereceived")
|
||||||
newnotification.save()
|
newnotification.save()
|
||||||
|
|
||||||
|
channel_layer = channels.layers.get_channel_layer()
|
||||||
|
async_to_sync(channel_layer.group_send)("user_" + str(targetuser.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Mitteilung | Neue Mitteilung erhalten: " + message.content})
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
messages.warning(request, f'Bitte valide Daten eingeben!')
|
messages.warning(request, f'Bitte valide Daten eingeben!')
|
||||||
|
|
|
||||||
|
|
@ -93,13 +93,6 @@ def AbsenceUpdate(request, pk):
|
||||||
is_nextyear = True
|
is_nextyear = True
|
||||||
abinfo_nextyear = abinfo_nextyear[0]
|
abinfo_nextyear = abinfo_nextyear[0]
|
||||||
|
|
||||||
|
|
||||||
print(formtocheck.cleaned_data["holidays_normal"])
|
|
||||||
print(formtocheck.cleaned_data["holidays_rest"])
|
|
||||||
|
|
||||||
print(formtocheck.cleaned_data["startday_info"])
|
|
||||||
print(formtocheck.cleaned_data["endday_info"])
|
|
||||||
|
|
||||||
abinfo.days_inuse -= formtocheck.cleaned_data["holidays_normal"]
|
abinfo.days_inuse -= formtocheck.cleaned_data["holidays_normal"]
|
||||||
abinfo.restdays -= formtocheck.cleaned_data["holidays_rest"]
|
abinfo.restdays -= formtocheck.cleaned_data["holidays_rest"]
|
||||||
abinfo.save()
|
abinfo.save()
|
||||||
|
|
@ -124,9 +117,7 @@ def AbsenceUpdate(request, pk):
|
||||||
absence.holidays_rest = 0.0
|
absence.holidays_rest = 0.0
|
||||||
absence.holidays_normal_next = 0.0
|
absence.holidays_normal_next = 0.0
|
||||||
absence.holidays_rest_next = 0.0
|
absence.holidays_rest_next = 0.0
|
||||||
|
|
||||||
absence.save()
|
absence.save()
|
||||||
|
|
||||||
messages.success(request, f'Abwesenheit aktualisiert!')
|
messages.success(request, f'Abwesenheit aktualisiert!')
|
||||||
else:
|
else:
|
||||||
messages.success(request, f'Fehler bei Abwesenheitsaktualisierung!')
|
messages.success(request, f'Fehler bei Abwesenheitsaktualisierung!')
|
||||||
|
|
|
||||||
|
|
@ -334,16 +334,16 @@ class UserNotifications(models.Model):
|
||||||
password_delete_push = models.BooleanField(default=True)
|
password_delete_push = models.BooleanField(default=True)
|
||||||
|
|
||||||
# MESSAGES
|
# MESSAGES
|
||||||
message_received_mail = models.BooleanField(default=True)
|
message_received_mail = models.BooleanField(default=False)
|
||||||
message_received_push = models.BooleanField(default=True)
|
message_received_push = models.BooleanField(default=True)
|
||||||
|
|
||||||
# TASKS
|
# TASKS
|
||||||
task_activity_mail = models.BooleanField(default=True)
|
task_activity_mail = models.BooleanField(default=False)
|
||||||
task_activity_push = models.BooleanField(default=True)
|
task_activity_push = models.BooleanField(default=True)
|
||||||
|
|
||||||
# CHAT
|
# CHAT
|
||||||
# Diese Einstellung sorgt dafür, dass User eine Mail/Push erhalten, wenn neue Chatnachrichten vorhanden sind.
|
# 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_mail = models.BooleanField(default=False)
|
||||||
chat_received_push = models.BooleanField(default=True)
|
chat_received_push = models.BooleanField(default=True)
|
||||||
|
|
||||||
# Benachrichtigunge, wenn es Raumaktivitäten gab
|
# Benachrichtigunge, wenn es Raumaktivitäten gab
|
||||||
|
|
|
||||||
|
|
@ -345,13 +345,66 @@ def newNotifiyPush(mode, instance, mailtext, notifytext, pushtext, notifytype, t
|
||||||
usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk)
|
usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk)
|
||||||
|
|
||||||
# CREATED
|
# CREATED
|
||||||
if(mode == 0):
|
|
||||||
for user in usersofagency:
|
for user in usersofagency:
|
||||||
if(user.usernotifications.filedir_created_mail):
|
|
||||||
|
# LOAD USERNOTIFICATIONS
|
||||||
|
created_mail = False
|
||||||
|
created_push = False
|
||||||
|
update_mail = False
|
||||||
|
update_push = False
|
||||||
|
delete_mail = False
|
||||||
|
delete_push = False
|
||||||
|
|
||||||
|
|
||||||
|
if isinstance(instance, Standards):
|
||||||
|
created_mail = user.usernotifications.standard_created_mail
|
||||||
|
created_push = user.usernotifications.standard_created_push
|
||||||
|
update_mail = user.usernotifications.standard_update_mail
|
||||||
|
update_push = user.usernotifications.standard_update_push
|
||||||
|
delete_mail = user.usernotifications.standard_delete_mail
|
||||||
|
delete_push = user.usernotifications.standard_delete_push
|
||||||
|
elif isinstance(instance, News):
|
||||||
|
created_mail = user.usernotifications.news_created_mail
|
||||||
|
created_push = user.usernotifications.news_created_push
|
||||||
|
elif isinstance(instance, DataFile) or isinstance(instance, DataDir):
|
||||||
|
created_mail = user.usernotifications.filedir_created_mail
|
||||||
|
created_push = user.usernotifications.filedir_created_push
|
||||||
|
update_mail = user.usernotifications.filedir_update_mail
|
||||||
|
update_push = user.usernotifications.filedir_update_push
|
||||||
|
delete_mail = user.usernotifications.filedir_delete_mail
|
||||||
|
delete_push = user.usernotifications.filedir_delete_push
|
||||||
|
elif isinstance(instance, QuickLinks):
|
||||||
|
created_mail = user.usernotifications.ql_created_mail
|
||||||
|
created_push = user.usernotifications.ql_created_push
|
||||||
|
update_mail = user.usernotifications.ql_update_mail
|
||||||
|
update_push = user.usernotifications.ql_update_push
|
||||||
|
delete_mail = user.usernotifications.ql_delete_mail
|
||||||
|
delete_push = user.usernotifications.ql_delete_push
|
||||||
|
elif isinstance(instance, AGContacts):
|
||||||
|
created_mail = user.usernotifications.contact_created_mail
|
||||||
|
created_push = user.usernotifications.contact_created_push
|
||||||
|
update_mail = user.usernotifications.contact_update_mail
|
||||||
|
update_push = user.usernotifications.contact_update_push
|
||||||
|
delete_mail = user.usernotifications.contact_delete_mail
|
||||||
|
delete_push = user.usernotifications.contact_delete_push
|
||||||
|
elif isinstance(instance, AGPassword):
|
||||||
|
created_mail = user.usernotifications.password_created_mail
|
||||||
|
created_push = user.usernotifications.password_created_push
|
||||||
|
update_mail = user.usernotifications.password_update_mail
|
||||||
|
update_push = user.usernotifications.password_update_push
|
||||||
|
delete_mail = user.usernotifications.password_delete_mail
|
||||||
|
delete_push = user.usernotifications.password_delete_push
|
||||||
|
elif isinstance(instance, Message):
|
||||||
|
created_mail = user.usernotifications.message_received_mail
|
||||||
|
created_push = user.usernotifications.message_received_push
|
||||||
|
|
||||||
|
|
||||||
|
if(mode == 0):
|
||||||
|
if(created_mail):
|
||||||
notificationtext = mailtext + instance.name
|
notificationtext = mailtext + instance.name
|
||||||
sendMailNoti(notificationtext, user, targeturl)
|
sendMailNoti(notificationtext, user, targeturl)
|
||||||
|
|
||||||
if(user.usernotifications.filedir_created_push):
|
if(created_push):
|
||||||
newnotification = UserNotification(touser=user, notificationtext=notifytext + instance.name, notificationtype="", elementid=instance.pk)
|
newnotification = UserNotification(touser=user, notificationtext=notifytext + instance.name, notificationtype="", elementid=instance.pk)
|
||||||
newnotification.save()
|
newnotification.save()
|
||||||
|
|
||||||
|
|
@ -359,13 +412,11 @@ def newNotifiyPush(mode, instance, mailtext, notifytext, pushtext, notifytype, t
|
||||||
async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__"+ pushtext + notifytext + instance.name})
|
async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__"+ pushtext + notifytext + instance.name})
|
||||||
# UPDATED
|
# UPDATED
|
||||||
elif(mode == 1):
|
elif(mode == 1):
|
||||||
for user in usersofagency:
|
if(update_mail):
|
||||||
if(user.usernotifications.filedir_update_mail):
|
|
||||||
notificationtext = mailtext + instance.name
|
notificationtext = mailtext + instance.name
|
||||||
sendMailNoti(notificationtext, user, targeturl)
|
sendMailNoti(notificationtext, user, targeturl)
|
||||||
|
|
||||||
|
if(update_push):
|
||||||
if(user.usernotifications.filedir_update_push):
|
|
||||||
newnotification = UserNotification(touser=user, notificationtext=notifytext + instance.name, notificationtype="", elementid=instance.pk)
|
newnotification = UserNotification(touser=user, notificationtext=notifytext + instance.name, notificationtype="", elementid=instance.pk)
|
||||||
newnotification.save()
|
newnotification.save()
|
||||||
|
|
||||||
|
|
@ -373,15 +424,12 @@ def newNotifiyPush(mode, instance, mailtext, notifytext, pushtext, notifytype, t
|
||||||
async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__" + pushtext + notifytext + instance.name})
|
async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__" + pushtext + notifytext + instance.name})
|
||||||
#DELETE
|
#DELETE
|
||||||
elif(mode == 2):
|
elif(mode == 2):
|
||||||
usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk)
|
if(delete_mail):
|
||||||
|
|
||||||
for user in usersofagency:
|
|
||||||
if(user.usernotifications.filedir_delete_mail):
|
|
||||||
notificationtext = mailtext + instance.name
|
notificationtext = mailtext + instance.name
|
||||||
sendMailNoti(notificationtext, user, targeturl)
|
sendMailNoti(notificationtext, user, targeturl)
|
||||||
|
|
||||||
|
|
||||||
if(user.usernotifications.filedir_delete_push):
|
if(delete_push):
|
||||||
newnotification = UserNotification(touser=user, notificationtext=notifytext + instance.name, notificationtype="", elementid=instance.pk)
|
newnotification = UserNotification(touser=user, notificationtext=notifytext + instance.name, notificationtype="", elementid=instance.pk)
|
||||||
newnotification.save()
|
newnotification.save()
|
||||||
|
|
||||||
|
|
@ -564,6 +612,8 @@ def save_newabsence(sender, instance, **kwargs):
|
||||||
instance.holidays_rest_next = newdata[3][3]
|
instance.holidays_rest_next = newdata[3][3]
|
||||||
instance.save()
|
instance.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Absence-Object is no holiday...")
|
print("Absence-Object is no holiday...")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -628,10 +628,12 @@ function loadUnsendNotifications(){
|
||||||
},
|
},
|
||||||
success: function( data )
|
success: function( data )
|
||||||
{
|
{
|
||||||
|
$("#notification_items").html("");
|
||||||
notifications = data['unknownnotification'];
|
notifications = data['unknownnotification'];
|
||||||
var i = 0;
|
var i = 0;
|
||||||
for (var key in notifications) {
|
for (var key in notifications) {
|
||||||
$("#notification_items").append('<a href="/'+notifications[i]['elelink']+'" id="notifyid_'+notifications[i]['not_id']+'" class="dropdown-item d-flex align-items-center"><div><div class="small text-gray-500">'+notifications[i]['date']+'</div>'+notifications[i]['text']+'</div></a>')
|
|
||||||
|
$("#notification_items").append('<span><a href="/'+notifications[i]['elelink']+'" id="notifyid_'+notifications[i]['not_id']+'" class="dropdown-item d-flex align-items-center"><div><div class="small text-gray-500">'+notifications[i]['date']+'</div>'+notifications[i]['text']+'</div></a></span>')
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
newunknownotificationscounter = newunknownotificationscounter + 1;
|
newunknownotificationscounter = newunknownotificationscounter + 1;
|
||||||
}
|
}
|
||||||
|
|
@ -654,6 +656,7 @@ function loadUnviewnNotifications(){
|
||||||
{
|
{
|
||||||
notifications = data['oldnotifications'];
|
notifications = data['oldnotifications'];
|
||||||
i = 0;
|
i = 0;
|
||||||
|
$("#notification_items").html("");
|
||||||
for (var key in notifications) {
|
for (var key in notifications) {
|
||||||
if(newunknownotificationscounter <= 5){
|
if(newunknownotificationscounter <= 5){
|
||||||
$("#notification_items").append('<a href="/'+notifications[i]['elelink']+'" id="notifyid_'+notifications[i]['not_id']+'" class="dropdown-item d-flex align-items-center"><div><div class="small text-gray-500">'+notifications[i]['date']+'</div>'+notifications[i]['text']+'</div></a>')
|
$("#notification_items").append('<a href="/'+notifications[i]['elelink']+'" id="notifyid_'+notifications[i]['not_id']+'" class="dropdown-item d-flex align-items-center"><div><div class="small text-gray-500">'+notifications[i]['date']+'</div>'+notifications[i]['text']+'</div></a>')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue