Benachrichtungen Organizer fertig und mainfunciotn umgebaut

This commit is contained in:
Holger Trampe 2020-06-20 10:40:45 +02:00
parent c1950648e4
commit 5331dad88a
12 changed files with 356 additions and 197 deletions

View File

@ -205,8 +205,8 @@ a.disabled {
Mit dem Löschen fortfahren? Alle Dateien in diesem Verzeichnis werden ebenfalls gelöscht!
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal" onclick="javascript:doDelDataDir()">Löschen</button>&nbsp;&nbsp;
<button type="button" class="btn btn-success" data-dismiss="modal">Abbrechen</button>
<button type="button" class="btn btn-primary" data-dismiss="modal" onclick="javascript:doDelDataDir()">Löschen</button>&nbsp;&nbsp;
<button type="button" class="btn" data-dismiss="modal">Abbrechen</button>
</div>
</div>
</div>

View File

@ -32,7 +32,7 @@ class OrganizerAddContact(forms.ModelForm):
model = AGContacts
labels = {
'personname' : "Ansprechpartner",
'company' : "Organisation",
'name' : "Organisation",
'mail' : "E-Mailadresse",
'phone1' : "Telefon 1",
'phone2' : "Telefon 2",
@ -43,12 +43,12 @@ class OrganizerAddContact(forms.ModelForm):
'desc' : "Anmerkungen"
}
fields = ['company', 'personname', 'mail', 'phone1', 'phone2', 'street', 'plz', 'city', "category", 'desc']
fields = ['name', 'personname', 'mail', 'phone1', 'phone2', 'street', 'plz', 'city', "category", 'desc']
def __init__(self, user, *args, **kwargs):
super(OrganizerAddContact, self).__init__(*args, **kwargs)
self.fields['company'].required = False
self.fields['name'].required = False
self.fields['personname'].required = False
self.fields['mail'].required = False
self.fields['phone1'].required = False
@ -65,7 +65,7 @@ class OrganizerUpdateContact(forms.ModelForm):
model = AGContacts
labels = {
'personname' : "Ansprechpartner",
'company' : "Organisation",
'name' : "Organisation",
'mail' : "E-Mailadresse",
'phone1' : "Telefon 1",
'phone2' : "Telefon 2",
@ -76,12 +76,12 @@ class OrganizerUpdateContact(forms.ModelForm):
'desc' : "Anmerkungen"
}
fields = ['company', 'personname', 'mail', 'phone1', 'phone2', 'street', 'plz', 'city', "category", 'desc']
fields = ['name', 'personname', 'mail', 'phone1', 'phone2', 'street', 'plz', 'city', "category", 'desc']
def __init__(self, user, *args, **kwargs):
super(OrganizerUpdateContact, self).__init__(*args, **kwargs)
self.fields['company'].required = False
self.fields['name'].required = False
self.fields['personname'].required = False
self.fields['mail'].required = False
self.fields['phone1'].required = False

View File

@ -47,7 +47,7 @@ class AGContactsCagetory(models.Model):
class AGContacts(models.Model):
agency = models.ForeignKey(Agency, on_delete=models.PROTECT)
personname = models.CharField(default="", max_length=200, blank=False)
company = models.CharField(default="", max_length=200, blank=False)
name = models.CharField(default="", max_length=200, blank=False)
mail = models.CharField(default="", max_length=200, blank=False)
phone1 = models.CharField(default="", max_length=200, blank=False)
phone2 = models.CharField(default="", max_length=200, blank=False)
@ -58,7 +58,7 @@ class AGContacts(models.Model):
category = models.ForeignKey("AGContactsCagetory", default=None, on_delete=models.SET_DEFAULT, null=True, blank=True)
def __str__(self):
return f'{self.company}'
return f'{self.name}'
def get_absolute_url(self):
return reverse('cont-update', kwargs={'pk':self.pk})

View File

@ -26,7 +26,7 @@
{% for agc in contacts %}
<tr>
<td>
<a href="#" onclick="javascript:$('#infos_{{agc.pk}}').modal('toggle');">{{agc.company}}</a>
<a href="#" onclick="javascript:$('#infos_{{agc.pk}}').modal('toggle');">{{agc.name}}</a>
</td>
<td>
{% if agc.mail|length > 0 %}
@ -68,7 +68,7 @@
<div class="modal-dialog " role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">{{agc.company}}</h5>
<h5 class="modal-title" id="exampleModalLongTitle">{{agc.name}}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Schließen">
<span aria-hidden="true">&times;</span>
</button>

View File

@ -42,7 +42,7 @@
{% for agc in contacts %}
<tr>
<td>
<a href="#" onclick="javascript:$('#infos_{{agc.pk}}').modal('toggle');">{{agc.company}}</a>
<a href="#" onclick="javascript:$('#infos_{{agc.pk}}').modal('toggle');">{{agc.name}}</a>
</td>
<td>
{% if agc.mail|length > 0 %}
@ -83,7 +83,7 @@
<div class="modal-dialog " role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">{{agc.company}}</h5>
<h5 class="modal-title" id="exampleModalLongTitle">{{agc.name}}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Schließen">
<span aria-hidden="true">&times;</span>
</button>

View File

@ -509,11 +509,11 @@
<datalist id="poss_contacts">
{% if update == True %}
{% for q in possible_contacts %}
<option id="contacts_{{q.pk}}" value="{{q.company}}">{{q.company}}</option>
<option id="contacts_{{q.pk}}" value="{{q.name}}">{{q.name}}</option>
{% endfor %}
{% else %}
{% for q in contacts %}
<option id="contacts_{{q.pk}}" value="{{q.company}}">{{q.company}}</option>
<option id="contacts_{{q.pk}}" value="{{q.name}}">{{q.name}}</option>
{% endfor %}
{% endif %}
</datalist>
@ -522,7 +522,7 @@
<table id="linked_contacts" class="table table-hover table-sm">
{% if update == True %}
{% for q in standard.addedcontacts.all %}
<tr id="added_contacts_{{q.pk}}"><td>{{q.company}}</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remEle('contacts',{{q.pk}}, '{{q.company}}')" style="float: right;" ><i class="fas fa-trash"></i></button></td></tr>
<tr id="added_contacts_{{q.pk}}"><td>{{q.name}}</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remEle('contacts',{{q.pk}}, '{{q.name}}')" style="float: right;" ><i class="fas fa-trash"></i></button></td></tr>
{% endfor %}
{% endif %}
</table>

View File

@ -133,7 +133,7 @@
<h5 class="card-title">Kontakte</h5>
<p class="card-text">
{% for agc in standard.addedcontacts.all %}
<a href="#/" onclick="javascript:$('#infos_{{agc.pk}}').modal('toggle');">{{agc.company}}</a><br />
<a href="#/" onclick="javascript:$('#infos_{{agc.pk}}').modal('toggle');">{{agc.name}}</a><br />
{% endfor %}
</p>
</div>
@ -248,7 +248,7 @@
<div class="modal-dialog " role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">{{agc.company}}</h5>
<h5 class="modal-title" id="exampleModalLongTitle">{{agc.name}}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Schließen">
<span aria-hidden="true">&times;</span>
</button>

229
users/SAVE.py Normal file
View File

@ -0,0 +1,229 @@
'''
@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})
# Signals for FILES
@receiver(post_save, sender=DataFile)
def save_file(sender, instance, **kwargs):
if(kwargs["created"] and len(instance.name) > 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})

View File

@ -240,42 +240,20 @@ def adjust_group_notifications(instance, action, reverse, model, pk_set, using,
# 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})
newNotifiyPush(2, instance, " es wurde ein neuer Agenturstandard gelöscht: ", "Agenturstandard gelöscht: ", "Standards | ", "", "")
# SAVE AND UPDATE
@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(kwargs["created"] and len(instance.name) > 0):
if(instance.public):
for user in usersofagency:
newNotifiyPush(0, instance, " es wurde ein neuer Agenturstandard erstellt: ", "Neuer Agenturstandard: ", "Standards | ", "newstandard", targeturl)
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:
usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk)
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)
@ -289,45 +267,18 @@ def save_standard(sender, instance, **kwargs):
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})
newNotifiyPush(1, instance, " es wurde ein neuer Agenturstandard aktualisiert: ", "Agenturstandard aktualisiert: ", "Standards | ", "newstandard", targeturl)
# SIGNAL FOR NEWS
@receiver(post_save, sender=News)
def save_news(sender, instance, **kwargs):
if(kwargs["created"]):
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.usernotifications.news_created_mail):
notificationtext = " es gibt neue Agenturnews: " + instance.name
sendMailNoti(notificationtext, user, targeturl)
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})
newNotifiyPush(0, instance, " es gibt neue Agenturnews: ", "Neue Agenturnews: ", "News | ", "", targeturl)
else:
instance.agnotify = False
instance.save()
@ -371,158 +322,137 @@ def adjust_group_notifications_task(instance, action, reverse, model, pk_set, us
sendMailNoti(notificationtext, user_touched)
# Signals for FILES
@receiver(post_save, sender=DataFile)
def save_file(sender, instance, **kwargs):
'''
newNotifiyPush
@param:
instance - Objekt des Signals
mode - Modus 0 --> CREATED, 1 --> UPDATE, 3 --> DELETE
mailtext - Text in der Benachrichtigung
zB " es gibt neue Ordner: "
notifytext - Text in der PUSH-Nachricht
zB "Neuer Ordner: "
pushtext - Typ bei PUSH (hinter pushnotification__)
zB "Ordner | " + notifytext
notifytype - Typ für Verlinkung
targeturl - URL für Verlinkung, Default = ""
'''
def newNotifiyPush(mode, instance, mailtext, notifytext, pushtext, notifytype, targeturl=""):
usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk)
# CREATED
if(kwargs["created"]):
if(mode == 0):
for user in usersofagency:
if(user.usernotifications.filedir_created_mail):
notificationtext = " es gibt eine neue Datei: " + instance.name
sendMailNoti(notificationtext, user)
notificationtext = mailtext + instance.name
sendMailNoti(notificationtext, user, targeturl)
if(user.usernotifications.filedir_created_push):
newnotification = UserNotification(touser=user, notificationtext="Neue Datei: " + instance.name, notificationtype="", elementid=instance.pk)
newnotification = UserNotification(touser=user, notificationtext=notifytext + 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})
async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__"+ pushtext + notifytext + instance.name})
# UPDATED
else:
elif(mode == 1):
for user in usersofagency:
if(user.usernotifications.filedir_update_mail):
notificationtext = " Datei wurden aktualisiert: " + instance.name
sendMailNoti(notificationtext, user)
notificationtext = mailtext + instance.name
sendMailNoti(notificationtext, user, targeturl)
if(user.usernotifications.filedir_update_push):
newnotification = UserNotification(touser=user, notificationtext="Aktualisierte Datei: " + instance.name, notificationtype="", elementid=instance.pk)
newnotification = UserNotification(touser=user, notificationtext=notifytext + 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})
async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__" + pushtext + notifytext + instance.name})
#DELETE
elif(mode == 2):
usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk)
for user in usersofagency:
if(user.usernotifications.filedir_delete_mail):
notificationtext = mailtext + instance.name
sendMailNoti(notificationtext, user, targeturl)
if(user.usernotifications.filedir_delete_push):
newnotification = UserNotification(touser=user, notificationtext=notifytext + 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__" + pushtext + notifytext + instance.name})
# DIRS
@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})
if(kwargs["created"] and len(instance.name) > 0):
newNotifiyPush(0, instance, " es gibt neue Ordner: ", "Neuer Ordner: ", "Ordner | ", "", "")
elif(len(instance.name) > 0):
newNotifiyPush(1, instance, " Ordner wurden aktualisiert: ", "Aktualisierter Ordner: ", "Ordner | ", "", "")
@receiver(pre_delete, sender=DataDir)
def del_dir(sender, instance, **kwargs):
usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk)
newNotifiyPush(2, instance, " ein Ordner wurde gelöscht: ", "Ordner gelöscht: ", "Ordner | ", "", "")
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})
# Signals for FILES
@receiver(post_save, sender=DataFile)
def save_file(sender, instance, **kwargs):
if(kwargs["created"] and len(instance.name) > 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 | ", "", "")
@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})
newNotifiyPush(2, instance, " eine Datei wurde gelöscht: ", "Datei gelöscht: ", "Dateien | ", "", "")
# QUICKLINKS
@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})
if(kwargs["created"] and len(instance.name) > 0):
newNotifiyPush(0, instance, " es gibt einen neuen Quicklink: ", "Neuer Quicklink: ", "Quicklinks | ", "", "")
elif(len(instance.name) > 0):
newNotifiyPush(1, instance, " Quicklink wurde aktualisiert: ", "Aktualisierter Quicklink: ", "Quicklinks | ", "", "")
@receiver(pre_delete, sender=QuickLinks)
def del_ql(sender, instance, **kwargs):
usersofagency = User.objects.filter(profile__agency__pk=instance.agency.pk)
newNotifiyPush(2, instance, " ein Quicklink wurde gelöscht: ", "Quicklink gelöscht: ", "Quicklinks | ", "", "")
# CONTACTS
@receiver(post_save, sender=AGContacts)
def save_contact(sender, instance, **kwargs):
if(kwargs["created"] and len(instance.name) > 0):
newNotifiyPush(0, instance, " es gibt einen neuen Kontakt: ", "Neuer Kontakt: ", "Kontakte | ", "", "")
elif(len(instance.name) > 0):
newNotifiyPush(1, instance, " Kontakt wurde aktualisiert: ", "Aktualisierter Kontakt: ", "Kontakte | ", "", "")
@receiver(pre_delete, sender=AGContacts)
def del_contact(sender, instance, **kwargs):
newNotifiyPush(2, instance, " ein Kontakt wurde gelöscht: ", "Kontakt gelöscht: ", "Kontakte | ", "", "")
# PASSWORDS
@receiver(post_save, sender=AGPassword)
def save_password(sender, instance, **kwargs):
if(kwargs["created"] and len(instance.name) > 0):
newNotifiyPush(0, instance, " es gibt ein neues Passwort: ", "Neues Passwort: ", "Passwörter | ", "", "")
elif(len(instance.name) > 0):
newNotifiyPush(1, instance, " Passwort wurde aktualisiert: ", "Aktualisiertes Passwort: ", "Passwörter | ", "", "")
@receiver(pre_delete, sender=AGPassword)
def del_password(sender, instance, **kwargs):
newNotifiyPush(2, instance, " ein Passwort wurde gelöscht: ", "Passwort gelöscht: ", "Passwörter | ", "", "")
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)

View File

@ -31,4 +31,4 @@ learn about Font Awesome.
All brand icons are trademarks of their respective owners. The use of these
trademarks does not indicate endorsement of the trademark holder by Font
Awesome, nor vice versa. **Please do not use brand logos for any purpose except
to represent the company, product, or service to which they refer.**
to represent the name, product, or service to which they refer.**

View File

@ -74,7 +74,7 @@
<h4>Kontakte</h4>
{% if res_contacts|length > 0 %}
{% for s in res_contacts %}
<i class="fas fa-users"></i>&nbsp;&nbsp;<a onclick="javascript:$('#infos_searchres_agc_{{s.pk}}').modal('toggle');" href="#\" ><b>{{s.company}}</b></a><br /><br />
<i class="fas fa-users"></i>&nbsp;&nbsp;<a onclick="javascript:$('#infos_searchres_agc_{{s.pk}}').modal('toggle');" href="#\" ><b>{{s.name}}</b></a><br /><br />
{% endfor %}
{% else %}
<p>Keine Ergebnisse in Kontakten</p>
@ -96,7 +96,7 @@
<div class="modal-dialog " role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">{{agc.company}}</h5>
<h5 class="modal-title" id="exampleModalLongTitle">{{agc.name}}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Schließen">
<span aria-hidden="true">&times;</span>
</button>

View File

@ -635,7 +635,7 @@ def GlobalSearch(request):
res_news = News.objects.filter(agency__pk=ag).filter(name__icontains=searchfor) | News.objects.filter(agency__pk=ag).filter(content__icontains=searchfor) | News.objects.filter(agency__pk=ag).filter(created_by__last_name__icontains=searchfor)|News.objects.filter(agency__pk=ag).filter(created_by__first_name__icontains=searchfor)
res_pass = AGPassword.objects.filter(agency__pk=ag).filter(name__icontains=searchfor)
res_contacts = AGContacts.objects.filter(agency__pk=ag).filter(personname__icontains=searchfor) | AGContacts.objects.filter(agency__pk=ag).filter(company__icontains=searchfor)
res_contacts = AGContacts.objects.filter(agency__pk=ag).filter(personname__icontains=searchfor) | AGContacts.objects.filter(agency__pk=ag).filter(name__icontains=searchfor)
res_areas = Areas.objects.filter(agency__pk=ag).filter(name__icontains=searchfor)