Quicklink anlegen
@@ -86,4 +88,7 @@ function saveDefQL(){
});
}
+{% else %}
+
Das Modul Quicklinks wurden in ihrer Agentur deaktiviert.
+{% endif %}
{% endblock content %}
diff --git a/quicklinks/templates/quicklinks/ql_update.html b/quicklinks/templates/quicklinks/ql_update.html
index 5608ca4..7188b02 100644
--- a/quicklinks/templates/quicklinks/ql_update.html
+++ b/quicklinks/templates/quicklinks/ql_update.html
@@ -1,6 +1,7 @@
{% extends "users/base.html" %}
{% load crispy_forms_tags %}
{% block content %}
+{% if request.user.profile.agency.module_quicklinks %}
Quicklink aktualisieren
@@ -15,4 +16,7 @@
Abbrechen
+{% else %}
+
Das Modul Quicklinks wurden in ihrer Agentur deaktiviert.
+{% endif %}
{% endblock content %}
diff --git a/quicklinks/urls.py b/quicklinks/urls.py
index 6a0ffa1..2b140a4 100644
--- a/quicklinks/urls.py
+++ b/quicklinks/urls.py
@@ -6,11 +6,10 @@ from . import views
'''
Permissions definiert in models.py bei USERS und dann hier vor die View geschrieben!
'''
-
urlpatterns = [
path('', QlManagement.as_view(template_name="quicklinks/ql_management.html"), name='ql-management'),
- path('addql/', permission_required('users.ql_management')(QlAdd.as_view(template_name="quicklinks/ql_add.html")), name='ql-addql'),
- path('addql/
/delete', permission_required('users.ql_management')(QlDeleteView.as_view()), name='ql-delete'),
- path('addql//', permission_required('users.ql_management')(QlUpdateView.as_view()), name='ql-update'),
+ path('addql/', permission_required('users.modulequicklinks')(QlAdd.as_view(template_name="quicklinks/ql_add.html")), name='ql-addql'),
+ path('addql//delete', permission_required('users.modulequicklinks')(QlDeleteView.as_view()), name='ql-delete'),
+ path('addql//', permission_required('users.modulequicklinks')(QlUpdateView.as_view()), name='ql-update'),
path('lerg/', views.loaddefaultql, name="ql-ajaxloaddef"),
]
diff --git a/quicklinks/views.py b/quicklinks/views.py
index 8b6de6b..9da12ab 100644
--- a/quicklinks/views.py
+++ b/quicklinks/views.py
@@ -5,12 +5,11 @@ from .models import QuickLinks
from .forms import QlAddQlForm
from django.contrib import messages
from django.shortcuts import redirect
-from django.http import HttpResponse
+from django.http import HttpResponse, HttpResponseRedirect
# Create your views here.
class QlManagement(LoginRequiredMixin, ListView):
model = QuickLinks
-
# Adding active_link
# Loading only user same agency
# Change context and return for template-data
diff --git a/users/__pycache__/models.cpython-38.pyc b/users/__pycache__/models.cpython-38.pyc
index 3a59937..9784006 100644
Binary files a/users/__pycache__/models.cpython-38.pyc and b/users/__pycache__/models.cpython-38.pyc differ
diff --git a/users/__pycache__/signals.cpython-38.pyc b/users/__pycache__/signals.cpython-38.pyc
index 32d517a..0694505 100644
Binary files a/users/__pycache__/signals.cpython-38.pyc and b/users/__pycache__/signals.cpython-38.pyc differ
diff --git a/users/models.py b/users/models.py
index a0dc16c..97208ec 100644
--- a/users/models.py
+++ b/users/models.py
@@ -48,6 +48,12 @@ class Agency(models.Model):
balance = models.FloatField(default=0.0, max_length=9, blank=True)
nextdebiting = models.DateTimeField(default=timezone.now, blank=True)
+ # MODULEEINSTELLUNGEN FÜR DIE AGENTUR
+ module_news = models.BooleanField(default=True)
+ module_quicklinks = models.BooleanField(default=True)
+ module_files = models.BooleanField(default=True)
+ module_organigramm = models.BooleanField(default=True)
+
def __str__(self):
return f'{self.name}'
@@ -192,5 +198,5 @@ class AgencyGroup(models.Model):
('standardmanager', 'Standards bearbeiten und freischalten'),
('modulenews', 'News bearbeiten und veröffentlichen'),
('modulesconfig', 'Module verwalten'),
- ('modulequicklinks', 'Quicklinks bearbeiten und erstellen')
+ ('modulequicklinks', 'Quicklinks bearbeiten')
]
diff --git a/users/signals.py b/users/signals.py
index ec19d32..c9ead81 100644
--- a/users/signals.py
+++ b/users/signals.py
@@ -3,6 +3,9 @@ from django.contrib.auth.models import User, Group
from django.dispatch import receiver
from .models import Profile, Agency, AgencyGroup
from django.contrib.auth.models import Permission
+from notificsys.models import UserNotification
+from django.core.mail import send_mail
+from django.template.loader import render_to_string
# SIGNALS FOR USER
@receiver(post_save, sender=User)
def create_profile(sender, instance, created, **kwargs):
@@ -28,17 +31,59 @@ def save_profile(sender, instance, **kwargs):
# SIGNALS FOR GROUPS
-
@receiver(signal=m2m_changed, sender=User.groups.through)
def adjust_group_notifications(instance, action, reverse, model, pk_set, using, *args, **kwargs):
- # USERGROUP IS CHANGED
+
+ # IF FALSE NO MAILS WILL BE SEND - IN PRODUCTIVITY CHANGE TO TRUE #
+ GLOBALSENDMAILS = True
+
+
+ # GROUPSETTINGS FOR SOME USER WAS CHANGED
if isinstance(instance, Group):
group_touched = AgencyGroup.objects.get(group=instance)
user_touched = User.objects.get(pk=list(pk_set)[0])
- # A USER WAS REMOVED FROM A GROUP
- if(action == 'post_remove'):
- print("USER REMOVED " + user_touched.first_name + " FROM GROUP " + group_touched.agencygroupname)
- # A USER WAS ADDED TO A GROUP
- elif(action == 'post_add'):
- print("USER ADDED " + user_touched.first_name + " TO GROUP " + group_touched.agencygroupname)
+
+ # PUSH NOTIFICATION FOR GROUOPCHANGES
+ if(user_touched.profile.add_new_group_push):
+ if(action == 'post_remove'):
+ newnotification = UserNotification(touser=user_touched, notificationtext="Sie wurden aus der Gruppe " + group_touched.agencygroupname + " entfernt.", notificationtype="groupchanges")
+ newnotification.save()
+ # A USER WAS ADDED TO A GROUP
+ elif(action == 'post_add'):
+ newnotification = UserNotification(touser=user_touched, notificationtext="Sie wurden zur Gruppe " + group_touched.agencygroupname + " hinzugefügt.", notificationtype="groupchanges")
+ newnotification.save()
+
+ # E-MAILNOTIFICATIONS FOR GROUPCHANGES
+ if(user_touched.profile.add_new_group_mail):
+ notificationtext = ""
+ if(action == 'post_remove'):
+ notificationtext = "Sie wurden aus der Gruppe " + group_touched.agencygroupname + " 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,
+ 'support@digitale-agentur.com',
+ [user_touched.email],
+ html_message=msg_html,
+ fail_silently=False
+ )
+
+ # A USER WAS ADDED TO A GROUP
+ elif(action == 'post_add'):
+ notificationtext = "Sie wurden zur Gruppe " + group_touched.agencygroupname + " hinzugefügt."
+
+ 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,
+ 'support@digitale-agentur.com',
+ [user_touched.email],
+ html_message=msg_html,
+ fail_silently=False
+ )
\ No newline at end of file
diff --git a/users/templates/users/base.html b/users/templates/users/base.html
index 61b2e2d..0eb012d 100644
--- a/users/templates/users/base.html
+++ b/users/templates/users/base.html
@@ -46,13 +46,10 @@
- {% if perms.users.agencyinfo %}
-
- {% endif %}
-
+
@@ -374,6 +395,7 @@
+