PUSH immer langhin
This commit is contained in:
parent
0d01666996
commit
69cb008fd1
|
|
@ -179,6 +179,20 @@ class UsersNotificationFormGroups(forms.ModelForm):
|
|||
'group_rights_push',
|
||||
]
|
||||
|
||||
# Form für die Benachrichtigungseinstellungen Tätigkeitsbereiche
|
||||
class UsersNotificationFormTasks(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = UserNotifications
|
||||
labels = {
|
||||
"task_activity_mail" : "Tätigkeiten",
|
||||
|
||||
}
|
||||
fields = [
|
||||
'task_activity_mail',
|
||||
'task_activity_push',
|
||||
]
|
||||
|
||||
# Form für die Benachrichtigungseinstellungen GRUPPEN
|
||||
class UsersNotificationFormAgn(forms.ModelForm):
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,43 @@
|
|||
</div>
|
||||
</div><!-- END GROUPS -->
|
||||
|
||||
<!-- Tasks -->
|
||||
<div class="card">
|
||||
<div class="card-header" id="notification_task_acc">
|
||||
<h5 class="mb-0">
|
||||
<button class="btn btn-link" data-toggle="collapse" data-target="#notification_task" aria-expanded="true" aria-controls="notification_task">
|
||||
Tätigkeiten
|
||||
</button>
|
||||
</h5>
|
||||
</div>
|
||||
|
||||
<div id="notification_task" class="collapse" aria-labelledby="notification_task_acc" data-parent="#accordion">
|
||||
<div class="card-body">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Benachrichtigung</th>
|
||||
<th scope="col">E-Mail</th>
|
||||
<th scope="col">Push</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for formfield in notificationforms_task %}
|
||||
{% if forloop.counter|divisibleby:2 %}
|
||||
<td>{{formfield}}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td>{{formfield.label_tag}}</td>
|
||||
<td>{{formfield}}</td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- END Tasks -->
|
||||
|
||||
|
||||
|
||||
<!-- FILES -->
|
||||
|
|
@ -362,6 +399,7 @@
|
|||
},
|
||||
success: function( data )
|
||||
{
|
||||
console.log(data);
|
||||
if(data['success']){
|
||||
$('#notchange_done').toast('show');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, UsersNotificationFormStandard, AgencyGroupPerms, AgencyModulsForm, UserNewUserForm, UserProfileForm, AgencyNetworkForm, AgencyOrganigrammForm, UserTimeForm, AbsenceReasonForm, UsersNotificationFormNews, UsersNotificationFormFiles, UsersNotificationFormMessages ,UsersNotificationFormOrganizer, UsersNotificationFormChat, UsersNotificationFormAbTime, UsersNotificationFormGroups, UsersNotificationFormAgn
|
||||
from .forms import UsersSelfChangeForm, UsersNotificationFormStandard, AgencyGroupPerms, AgencyModulsForm, UserNewUserForm, UserProfileForm, AgencyNetworkForm, AgencyOrganigrammForm, UserTimeForm, AbsenceReasonForm, UsersNotificationFormNews, UsersNotificationFormFiles, UsersNotificationFormMessages ,UsersNotificationFormOrganizer, UsersNotificationFormChat, UsersNotificationFormAbTime, UsersNotificationFormGroups, UsersNotificationFormAgn, UsersNotificationFormTasks
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import update_session_auth_hash
|
||||
from django.contrib.auth.forms import PasswordChangeForm
|
||||
|
|
@ -58,33 +58,35 @@ def getAllForms(request, context):
|
|||
|
||||
# NOTIFICTAION FORMS
|
||||
# STANDARDS
|
||||
notificationforms_standard = UsersNotificationFormStandard(instance=request.user.profile)
|
||||
notificationforms_standard = UsersNotificationFormStandard(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_standard' : notificationforms_standard})
|
||||
|
||||
notificationforms_news = UsersNotificationFormNews(instance=request.user.profile)
|
||||
notificationforms_news = UsersNotificationFormNews(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_news' : notificationforms_news})
|
||||
|
||||
notificationforms_files = UsersNotificationFormFiles(instance=request.user.profile)
|
||||
notificationforms_files = UsersNotificationFormFiles(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_files' : notificationforms_files})
|
||||
|
||||
notificationforms_organizer = UsersNotificationFormOrganizer(instance=request.user.profile)
|
||||
notificationforms_organizer = UsersNotificationFormOrganizer(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_organizer' : notificationforms_organizer})
|
||||
|
||||
notificationforms_messages = UsersNotificationFormMessages(instance=request.user.profile)
|
||||
notificationforms_messages = UsersNotificationFormMessages(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_messages' : notificationforms_messages})
|
||||
|
||||
notificationforms_chat = UsersNotificationFormChat(instance=request.user.profile)
|
||||
notificationforms_chat = UsersNotificationFormChat(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_chat' : notificationforms_chat})
|
||||
|
||||
notificationforms_abtime = UsersNotificationFormAbTime(instance=request.user.profile)
|
||||
notificationforms_abtime = UsersNotificationFormAbTime(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_abtime' : notificationforms_abtime})
|
||||
|
||||
notificationforms_groups = UsersNotificationFormGroups(instance=request.user.profile)
|
||||
notificationforms_groups = UsersNotificationFormGroups(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_groups' : notificationforms_groups})
|
||||
|
||||
notificationforms_agn = UsersNotificationFormAgn(instance=request.user.profile)
|
||||
notificationforms_agn = UsersNotificationFormAgn(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_agn' : notificationforms_agn})
|
||||
|
||||
notificationforms_task = UsersNotificationFormTasks(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_task' : notificationforms_task})
|
||||
|
||||
|
||||
|
||||
|
|
@ -205,32 +207,35 @@ def DASettings(request):
|
|||
context.update({'passwordform' : passwordform})
|
||||
|
||||
############################### NOTIFIFORMS START ##########################################
|
||||
notificationforms_standard = UsersNotificationFormStandard(instance=request.user.profile)
|
||||
notificationforms_standard = UsersNotificationFormStandard(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_standard' : notificationforms_standard})
|
||||
|
||||
notificationforms_news = UsersNotificationFormNews(instance=request.user.profile)
|
||||
notificationforms_news = UsersNotificationFormNews(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_news' : notificationforms_news})
|
||||
|
||||
notificationforms_files = UsersNotificationFormFiles(instance=request.user.profile)
|
||||
notificationforms_files = UsersNotificationFormFiles(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_files' : notificationforms_files})
|
||||
|
||||
notificationforms_organizer = UsersNotificationFormOrganizer(instance=request.user.profile)
|
||||
notificationforms_organizer = UsersNotificationFormOrganizer(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_organizer' : notificationforms_organizer})
|
||||
|
||||
notificationforms_messages = UsersNotificationFormMessages(instance=request.user.profile)
|
||||
notificationforms_messages = UsersNotificationFormMessages(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_messages' : notificationforms_messages})
|
||||
|
||||
notificationforms_chat = UsersNotificationFormChat(instance=request.user.profile)
|
||||
notificationforms_chat = UsersNotificationFormChat(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_chat' : notificationforms_chat})
|
||||
|
||||
notificationforms_abtime = UsersNotificationFormAbTime(instance=request.user.profile)
|
||||
notificationforms_abtime = UsersNotificationFormAbTime(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_abtime' : notificationforms_abtime})
|
||||
|
||||
notificationforms_groups = UsersNotificationFormGroups(instance=request.user.profile)
|
||||
notificationforms_groups = UsersNotificationFormGroups(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_groups' : notificationforms_groups})
|
||||
|
||||
notificationforms_agn = UsersNotificationFormAgn(instance=request.user.profile)
|
||||
notificationforms_agn = UsersNotificationFormAgn(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_agn' : notificationforms_agn})
|
||||
|
||||
notificationforms_task = UsersNotificationFormTasks(instance=request.user.usernotifications)
|
||||
context.update({'notificationforms_task' : notificationforms_task})
|
||||
############################### NOTIFIFORMS END ############################################
|
||||
|
||||
# AGENCY UPDATE FORMS
|
||||
|
|
|
|||
|
|
@ -337,6 +337,10 @@ class UserNotifications(models.Model):
|
|||
message_received_mail = models.BooleanField(default=True)
|
||||
message_received_push = models.BooleanField(default=True)
|
||||
|
||||
# TASKS
|
||||
task_activity_mail = models.BooleanField(default=True)
|
||||
task_activity_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)
|
||||
|
|
|
|||
164
users/signals.py
164
users/signals.py
|
|
@ -113,10 +113,10 @@ def checkDefaultAbsenceReasons(sender, user, request, **kwargs):
|
|||
FUNKTION ZUM SENDEN VON MAILS AUS EINEM SIGNAL
|
||||
|
||||
'''
|
||||
def sendMailNoti(notificationtext, user_touched):
|
||||
def sendMailNoti(notificationtext, user_touched, linktarget=""):
|
||||
|
||||
username = user_touched.first_name + " " + user_touched.last_name
|
||||
msg_html = render_to_string('notificsys/notification_mail.html', {'username': username, 'notificationtext' : notificationtext})
|
||||
msg_html = render_to_string('notificsys/notification_mail.html', {'username': username, 'notificationtext' : notificationtext, 'linktarget' : linktarget})
|
||||
send_mail(
|
||||
'Agentur-Benachrichtigung',
|
||||
'Hallo ' + user_touched.first_name + ' ' + user_touched.last_name + '! ' + notificationtext,
|
||||
|
|
@ -172,10 +172,6 @@ def adjust_group_notifications_permission(instance, action, reverse, model, pk_s
|
|||
channel_layer = channels.layers.get_channel_layer()
|
||||
async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Gruppenaktivität | Der Gruppe " + group_touched.agencygroupname + " wurden Rechte entzogen."})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Signal, wenn ein Nutzer aus der Gruppe entfernt/hinzugefügt wird
|
||||
@receiver(signal=m2m_changed, sender=User.groups.through)
|
||||
def adjust_group_notifications(instance, action, reverse, model, pk_set, using, *args, **kwargs):
|
||||
|
|
@ -235,158 +231,139 @@ def adjust_group_notifications(instance, action, reverse, model, pk_set, using,
|
|||
)
|
||||
|
||||
|
||||
# SIGNAL FOR STANDARDS POST SAVE
|
||||
# SIGNALS FOR STANDARDS
|
||||
# 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})
|
||||
|
||||
# SAVE AND UPDATE
|
||||
@receiver(post_save, sender=Standards)
|
||||
def save_standard(sender, instance, **kwargs):
|
||||
GLOBALSENDMAILS = True
|
||||
# NEW STANDARD AND DIRECT PUBLIC
|
||||
if(kwargs["created"]):
|
||||
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.profile.agency_new_standard_mail):
|
||||
notificationtext = "Neuer Agenturstandard: " + instance.name
|
||||
if(user.usernotifications.standard_created_mail):
|
||||
notificationtext = " es wurde ein neuer Agenturstandard erstellt: " + instance.name
|
||||
sendMailNoti(notificationtext, user)
|
||||
|
||||
username = user.first_name + " " + user.last_name
|
||||
msg_html = render_to_string('notificsys/notification_mail.html', {'username': username, 'notificationtext' : notificationtext, 'linktarget' : targeturl})
|
||||
|
||||
if(GLOBALSENDMAILS):
|
||||
send_mail(
|
||||
'Agentur-Benachrichtigung',
|
||||
'Hallo ' + user.first_name + ' ' + user.last_name + '! ' + notificationtext,
|
||||
'noreply@digitale-agentur.com',
|
||||
[user.email],
|
||||
html_message=msg_html,
|
||||
fail_silently=True
|
||||
)
|
||||
|
||||
if(user.profile.agency_new_standard_push):
|
||||
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")):
|
||||
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()
|
||||
else:
|
||||
|
||||
channel_layer = channels.layers.get_channel_layer()
|
||||
async_to_sync(channel_layer.group_send)("agency_" + str(instance.agency.pk), {'type' : 'update_standard'})
|
||||
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})
|
||||
|
||||
|
||||
|
||||
# SIGNAL FOR NEWS
|
||||
@receiver(post_save, sender=News)
|
||||
def save_news(sender, instance, **kwargs):
|
||||
GLOBALSENDMAILS = True
|
||||
if(kwargs["created"]):
|
||||
|
||||
# Hier wird an alle in der Agentur geschickt, lokal wird geprüft, ob der User diese Push-Info haben will
|
||||
channel_layer = channels.layers.get_channel_layer()
|
||||
async_to_sync(channel_layer.group_send)("agency_" + str(instance.agency.pk), {'type' : 'agency_newnews', 'pushtext' : "Neue Agenturnews | " + instance.name})
|
||||
|
||||
usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk)
|
||||
|
||||
targeturl = settings.BASE_URL + "news/news/" + str(instance.pk) + "/single"
|
||||
|
||||
# Prüfung, ob die News SOFORT online geht oder später
|
||||
if(instance.go_online_on < timezone.now() and instance.agnotify):
|
||||
|
||||
for user in usersofagency:
|
||||
|
||||
if(user.profile.news_mail):
|
||||
notificationtext = "Neue Agenturnews: " + instance.name
|
||||
|
||||
username = user.first_name + " " + user.last_name
|
||||
msg_html = render_to_string('notificsys/notification_mail.html', {'username': username, 'notificationtext' : notificationtext, 'linktarget' : targeturl})
|
||||
if(user.usernotifications.news_created_mail):
|
||||
notificationtext = " es gibt neue Agenturnews: " + instance.name
|
||||
sendMailNoti(notificationtext, user, targeturl)
|
||||
|
||||
|
||||
if(GLOBALSENDMAILS):
|
||||
send_mail(
|
||||
'Agentur-Benachrichtigung',
|
||||
'Hallo ' + user.first_name + ' ' + user.last_name + '! ' + notificationtext,
|
||||
'noreply@digitale-agentur.com',
|
||||
[user.email],
|
||||
html_message=msg_html,
|
||||
fail_silently=True
|
||||
)
|
||||
|
||||
if(user.profile.news_push):
|
||||
newnotification = UserNotification(touser=user, notificationtext="Neue Agenturnews: " + instance.name, notificationtype="agencynews", elementid=instance.pk)
|
||||
if(user.usernotifications.news_created_push):
|
||||
newnotification = UserNotification(touser=user, notificationtext="Neue Agenturnews: " + 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__News | Neue Agenturnews: " + instance.name})
|
||||
|
||||
else:
|
||||
instance.agnotify = False
|
||||
instance.save()
|
||||
# News wurden aktualisiert
|
||||
else:
|
||||
pass
|
||||
# Hier wird an alle in der Agentur geschickt, lokal wird geprüft, ob der User diese Push-Info haben will
|
||||
#channel_layer = channels.layers.get_channel_layer()
|
||||
#async_to_sync(channel_layer.group_send)("agency_" + str(instance.agency.pk), {'type' : 'agency_newnews', 'pushtext' : "Neue Agenturnews | " + instance.name})
|
||||
|
||||
|
||||
|
||||
# SIGNALS FOR TASK
|
||||
@receiver(signal=m2m_changed, sender=Tasks.usersfield.through)
|
||||
def adjust_group_notifications_task(instance, action, reverse, model, pk_set, using, *args, **kwargs):
|
||||
|
||||
# IF FALSE NO MAILS WILL BE SEND - IN PRODUCTIVITY CHANGE TO TRUE #
|
||||
GLOBALSENDMAILS = True
|
||||
|
||||
# A USER WAS TOUCHED ATT HIS TASKS
|
||||
user_touched = User.objects.get(pk=list(pk_set)[0])
|
||||
taskname = instance.name
|
||||
|
||||
# PUSH NOTIFICATION FOR GROUOPCHANGES
|
||||
if(user_touched.profile.add_task_push):
|
||||
if(user_touched.usernotifications.task_activity_push):
|
||||
if(action == 'post_remove'):
|
||||
newnotification = UserNotification(touser=user_touched, notificationtext="Sie wurden von der Tätigkeit " + taskname + " entfernt.", notificationtype="taskchange")
|
||||
newnotification.save()
|
||||
|
||||
channel_layer = channels.layers.get_channel_layer()
|
||||
async_to_sync(channel_layer.group_send)("user_" + str(user_touched.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Tätigkeitsbereich | Sie wurden von der Tätigkeitn " + instance.name + " entfernt."})
|
||||
|
||||
# A USER WAS ADDED TO A GROUP
|
||||
elif(action == 'post_add'):
|
||||
newnotification = UserNotification(touser=user_touched, notificationtext="Sie wurden der Tätigkeit " + taskname + " zugeordnet.", notificationtype="taskchange")
|
||||
newnotification.save()
|
||||
|
||||
channel_layer = channels.layers.get_channel_layer()
|
||||
async_to_sync(channel_layer.group_send)("user_" + str(user_touched.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Tätigkeitsbereich | Sie wurden der Tätigkeitn " + instance.name + " zugeordnet."})
|
||||
|
||||
# E-MAILNOTIFICATIONS FOR GROUPCHANGES
|
||||
if(user_touched.profile.add_task_mail):
|
||||
if(user_touched.usernotifications.task_activity_mail):
|
||||
notificationtext = ""
|
||||
if(action == 'post_remove'):
|
||||
notificationtext = "Sie wurden von der Tätigkeit " + taskname + " entfernt."
|
||||
|
||||
username = user_touched.first_name + " " + user_touched.last_name
|
||||
msg_html = render_to_string('notificsys/notification_mail.html', {'username': username, 'notificationtext' : notificationtext})
|
||||
if(GLOBALSENDMAILS):
|
||||
send_mail(
|
||||
'Agentur-Benachrichtigung',
|
||||
'Hallo ' + user_touched.first_name + ' ' + user_touched.last_name + '! ' + notificationtext,
|
||||
'noreply@digitale-agentur.com',
|
||||
[user_touched.email],
|
||||
html_message=msg_html,
|
||||
fail_silently=True
|
||||
)
|
||||
sendMailNoti(notificationtext, user_touched)
|
||||
|
||||
# A USER WAS ADDED TO A GROUP
|
||||
elif(action == 'post_add'):
|
||||
notificationtext = "Sie wurden der Tätigkeit " + taskname + " zugeordnet."
|
||||
|
||||
username = user_touched.first_name + " " + user_touched.last_name
|
||||
msg_html = render_to_string('notificsys/notification_mail.html', {'username': username, 'notificationtext' : notificationtext})
|
||||
if(GLOBALSENDMAILS):
|
||||
send_mail(
|
||||
'Agentur-Benachrichtigung',
|
||||
'Hallo ' + user_touched.first_name + ' ' + user_touched.last_name + '! ' + notificationtext,
|
||||
'noreply@digitale-agentur.com',
|
||||
[user_touched.email],
|
||||
html_message=msg_html,
|
||||
fail_silently=True
|
||||
)
|
||||
sendMailNoti(notificationtext, user_touched)
|
||||
|
||||
@receiver(signal=post_save, sender=AgencyNetworkPreperation)
|
||||
def save_agjoin_prep(sender, instance, **kwargs):
|
||||
|
|
@ -429,7 +406,6 @@ def update_presence_live(sender, **kwargs):
|
|||
|
||||
ABWESENHEIT BERECHNUNG UND SPEICHERUNG DER NEUEN URLAUBSTAGE - VERWEIS AUF timemenagement.views
|
||||
|
||||
|
||||
'''
|
||||
@receiver(signal=post_save, sender=Absence)
|
||||
def save_newabsence(sender, instance, **kwargs):
|
||||
|
|
|
|||
|
|
@ -717,8 +717,6 @@ $(document).ready(function(){
|
|||
//HANDLER FOR ALL PUSHNOTIFICATIONS
|
||||
if(e["data"].split("__")[0] == "pushnotification"){
|
||||
|
||||
console.log(e["data"].split("__"))
|
||||
|
||||
var notify = new Notification('Digitale Agentur', {
|
||||
body: e["data"].split("__")[1]
|
||||
});
|
||||
|
|
@ -808,7 +806,7 @@ window.onerror = function (msg, url, line) {
|
|||
Notification.requestPermission().then(function(p) {
|
||||
if(p === 'granted') {
|
||||
// show notification here
|
||||
console.log("OK!")
|
||||
console.log("User receive notifications.")
|
||||
} else {
|
||||
console.log('User blocked notifications.');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ from django.db.models.signals import m2m_changed
|
|||
from django.contrib.auth.models import User, Group
|
||||
from users.signals import adjust_group_notifications_permission
|
||||
|
||||
|
||||
def randomString(stringLength=10):
|
||||
"""Generate a random string of fixed length """
|
||||
letters = string.ascii_lowercase
|
||||
|
|
@ -881,12 +882,12 @@ def cronactions(request, code):
|
|||
allusers = User.objects.all()
|
||||
for news in all_unnotifc_news:
|
||||
targeturl = settings.BASE_URL + "news/news/" + str(news.pk) + "/single"
|
||||
|
||||
# NEW NEWS FOUND WHICH HAVE TO GO ONLINE NOW!
|
||||
news.agnotify = True
|
||||
news.save()
|
||||
|
||||
for user in allusers:
|
||||
if(user.profile.news_mail and news.agency == user.profile.agency):
|
||||
# SEMI-SIGNAL FOR NEWS GOING ONLINE
|
||||
if(user.usernotifications.news_created_mail and news.agency == user.profile.agency):
|
||||
notificationtext = "Neue Agenturnews: " + news.name
|
||||
username = user.first_name + " " + user.last_name
|
||||
msg_html = render_to_string('notificsys/notification_mail.html', {'username': username, 'notificationtext' : notificationtext, 'linktarget' : targeturl})
|
||||
|
|
@ -899,9 +900,14 @@ def cronactions(request, code):
|
|||
fail_silently=True
|
||||
)
|
||||
|
||||
if(user.profile.news_push and news.agency == user.profile.agency):
|
||||
if(user.usernotifications.news_created_push and news.agency == user.profile.agency):
|
||||
newnotification = UserNotification(touser=user, notificationtext="Neue Agenturnews: " + news.name, notificationtype="agencynews", elementid=news.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__News | Neue Agenturnews: " + news.name})
|
||||
|
||||
|
||||
else:
|
||||
print("API CODE FAILED")
|
||||
data.update({"status" : "failed"})
|
||||
|
|
|
|||
Loading…
Reference in New Issue