mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Move mailing list admin to com
This commit is contained in:
25
com/views.py
25
com/views.py
@ -2,6 +2,7 @@
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Skia <skia@libskia.so>
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
@ -34,6 +35,7 @@ from django.utils import timezone
|
||||
from django.conf import settings
|
||||
from django.db.models import Max
|
||||
from django.forms.models import modelform_factory
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django import forms
|
||||
|
||||
from datetime import timedelta
|
||||
@ -42,7 +44,7 @@ from com.models import Sith, News, NewsDate, Weekmail, WeekmailArticle
|
||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin, CanCreateMixin, QuickNotifMixin
|
||||
from core.views.forms import SelectDateTime
|
||||
from core.models import Notification, RealGroup
|
||||
from club.models import Club
|
||||
from club.models import Club, Mailing
|
||||
|
||||
|
||||
# Sith object
|
||||
@ -81,6 +83,11 @@ class ComTabsMixin(TabedViewMixin):
|
||||
'slug': 'alert',
|
||||
'name': _("Alert message"),
|
||||
})
|
||||
tab_list.append({
|
||||
'url': reverse('com:mailing_admin'),
|
||||
'slug': 'mailings',
|
||||
'name': _("Mailing lists administration"),
|
||||
})
|
||||
return tab_list
|
||||
|
||||
|
||||
@ -414,3 +421,19 @@ class WeekmailArticleDeleteView(CanEditPropMixin, DeleteView):
|
||||
template_name = 'core/delete_confirm.jinja'
|
||||
success_url = reverse_lazy('com:weekmail')
|
||||
pk_url_kwarg = "article_id"
|
||||
|
||||
|
||||
class MailingListAdminView(ComTabsMixin, ListView):
|
||||
template_name = "com/mailing_admin.jinja"
|
||||
model = Mailing
|
||||
current_tab = "mailings"
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if not request.user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID):
|
||||
raise PermissionDenied
|
||||
return super(MailingListAdminView, self).dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(MailingListAdminView, self).get_context_data(**kwargs)
|
||||
kwargs['has_objects'] = len(kwargs['object_list']) > 0
|
||||
return kwargs
|
||||
|
Reference in New Issue
Block a user