+{% endif %}
{% endblock content %}
\ No newline at end of file
diff --git a/news/templates/news/news_management.html b/news/templates/news/news_management.html
index baa7359..ed9b4c2 100644
--- a/news/templates/news/news_management.html
+++ b/news/templates/news/news_management.html
@@ -1,5 +1,6 @@
{% extends "users/base.html" %}
{% block content %}
+{% if request.user.profile.agency.module_news %}
News
@@ -162,4 +163,7 @@ $('#news_tabs a').on('click', function (e) {
});
+{% else %}
+
Das Modul News wurde in ihrer Agentur deaktiviert.
+{% endif %}
{% endblock content %}
diff --git a/news/templates/news/news_single.html b/news/templates/news/news_single.html
index 228a5d4..36f0844 100644
--- a/news/templates/news/news_single.html
+++ b/news/templates/news/news_single.html
@@ -1,5 +1,6 @@
{% extends "users/base.html" %}
{% block content %}
+{% if request.user.profile.agency.module_news %}
{{news.name}}
@@ -12,4 +13,7 @@
{{news.media}}
{{news.content|safe}}
+{% else %}
+
Das Modul News wurde in ihrer Agentur deaktiviert.
+{% endif %}
{% endblock content %}
\ No newline at end of file
diff --git a/news/templates/news/news_update.html b/news/templates/news/news_update.html
index da53bfc..9c0d3d1 100644
--- a/news/templates/news/news_update.html
+++ b/news/templates/news/news_update.html
@@ -1,6 +1,7 @@
{% extends "users/base.html" %}
{% load crispy_forms_tags %}
{% block content %}
+{% if request.user.profile.agency.module_news %}
News bearbeiten
@@ -20,4 +21,7 @@ $(document).ready(function() {
});
});
+{% else %}
+
Das Modul News wurde in ihrer Agentur deaktiviert.
+{% endif %}
{% endblock content %}
\ No newline at end of file
diff --git a/news/urls.py b/news/urls.py
index 6e3ca0e..9cbd455 100644
--- a/news/urls.py
+++ b/news/urls.py
@@ -1,5 +1,6 @@
from django.urls import path
from .views import NewsManagement, NewsAdd, NewsDeleteView
+from django.contrib.auth.decorators import login_required, permission_required
from . import views
'''
Permissions definiert in models.py bei USERS und dann hier vor die View geschrieben!
@@ -7,9 +8,9 @@ Permissions definiert in models.py bei USERS und dann hier vor die View geschrie
urlpatterns = [
path('', NewsManagement.as_view(template_name="news/news_management.html"), name='news-management'),
- path('newsadd/', views.NewsAdd, name='news-add'),
- path('newsupdate/
/', views.NewsUpdate, name='news-update'),
- path('news//delete', NewsDeleteView.as_view(), name='news-delete'),
+ path('newsadd/', permission_required('users.modulenews')(views.NewsAdd), name='news-add'),
+ path('newsupdate//', permission_required('users.modulenews')(views.NewsUpdate), name='news-update'),
+ path('news//delete', permission_required('users.modulenews')(NewsDeleteView.as_view()), name='news-delete'),
#path('ajax/loadtasks/', views.load_tasks, name='ajax_loadtasks'),
#path('standard//changestat', views.StandardChangePublic, name="standard-status"),
path('news//single', views.NewsSingle, name="news-single"),
diff --git a/users/__pycache__/signals.cpython-38.pyc b/users/__pycache__/signals.cpython-38.pyc
index 0694505..67bc5a7 100644
Binary files a/users/__pycache__/signals.cpython-38.pyc and b/users/__pycache__/signals.cpython-38.pyc differ
diff --git a/users/signals.py b/users/signals.py
index c9ead81..0fddb1c 100644
--- a/users/signals.py
+++ b/users/signals.py
@@ -2,6 +2,7 @@ from django.db.models.signals import post_save, pre_delete, m2m_changed
from django.contrib.auth.models import User, Group
from django.dispatch import receiver
from .models import Profile, Agency, AgencyGroup
+from news.models import News
from django.contrib.auth.models import Permission
from notificsys.models import UserNotification
from django.core.mail import send_mail
@@ -86,4 +87,29 @@ def adjust_group_notifications(instance, action, reverse, model, pk_set, using,
html_message=msg_html,
fail_silently=False
)
-
\ No newline at end of file
+
+# 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)
+ 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})
+ if(GLOBALSENDMAILS):
+ send_mail(
+ 'Agentur-Benachrichtigung',
+ 'Hallo ' + user.first_name + ' ' + user.last_name + '! ' + notificationtext,
+ 'support@digitale-agentur.com',
+ [user.email],
+ html_message=msg_html,
+ fail_silently=False
+ )
+
+ if(user.profile.news_push):
+ newnotification = UserNotification(touser=user, notificationtext="Neue Agenturnews: " + instance.name, notificationtype="agencynews")
+ newnotification.save()
diff --git a/users/templates/users/base.html b/users/templates/users/base.html
index 0eb012d..baf8a9d 100644
--- a/users/templates/users/base.html
+++ b/users/templates/users/base.html
@@ -25,8 +25,8 @@
-
-
+
+
diff --git a/users/templates/users/dashboard.html b/users/templates/users/dashboard.html
index a03cb9e..5f751fc 100644
--- a/users/templates/users/dashboard.html
+++ b/users/templates/users/dashboard.html
@@ -8,7 +8,7 @@
-
+ {% if request.user.profile.agency.module_news %}
+ {% endif %}
+
+ {% if request.user.profile.agency.module_news %}
+ {% endif %}
+
+ {% if not request.user.profile.agency.module_news %}
+
+ {% else %}
+ {% endif %}
+
Neueste Standards
@@ -58,9 +68,17 @@
{% endfor %}
-
+
+ {% if not request.user.profile.agency.module_news %}
+
+
+

+
+
+ {% endif %}
+
{% endblock content %}