Commit 176b1bf5 authored by Skia's avatar Skia

Fix QuickNotifMixin

parent 097d2389
......@@ -232,12 +232,10 @@ class WeekmailEditView(QuickNotifMixin, UpdateView):
if not weekmail.title:
now = timezone.now()
weekmail.title = _("Weekmail of the ") + (now + timedelta(days=6 - now.weekday())).strftime('%d/%m/%Y')
print(self.quick_notif_list)
return weekmail
def get(self, request, *args, **kwargs):
self.object = self.get_object()
print(self.quick_notif_list)
if 'up_article' in request.GET.keys():
art = get_object_or_404(WeekmailArticle, id=request.GET['up_article'], weekmail=self.object)
prev_art = self.object.articles.order_by('rank').filter(rank__lt=art.rank).last()
......@@ -267,7 +265,6 @@ class WeekmailEditView(QuickNotifMixin, UpdateView):
art.rank = -1
art.save()
self.quick_notif_list += ['qn_success']
print(self.quick_notif_list)
return super(WeekmailEditView, self).get(request, *args, **kwargs)
def get_context_data(self, **kwargs):
......
......@@ -66,6 +66,7 @@
<h4>{% trans %}Communication{% endtrans %}</h4>
<ul>
{% if user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) or user.is_root %}
<li><a href="{{ url('com:weekmail') }}">{% trans %}Weekmail{% endtrans %}</a></li>
<li><a href="{{ url('com:news_admin_list') }}">{% trans %}Moderate news{% endtrans %}</a></li>
<li><a href="{{ url('com:index_edit') }}">{% trans %}Edit index page{% endtrans %}</a></li>
<li><a href="{{ url('com:alert_edit') }}">{% trans %}Edit alert message{% endtrans %}</a></li>
......
......@@ -147,8 +147,13 @@ class TabedViewMixin(View):
kwargs['list_of_tabs'] = self.get_list_of_tabs()
return kwargs
class QuickNotifMixin():
class QuickNotifMixin:
quick_notif_list = []
def dispatch(self, request, *arg, **kwargs):
self.quick_notif_list = [] # In some cases, the class can stay instanciated, so we need to reset the list
return super(QuickNotifMixin, self).dispatch(request, *arg, **kwargs)
def get_success_url(self):
ret = super(QuickNotifMixin, self).get_success_url()
try:
......@@ -163,15 +168,12 @@ class QuickNotifMixin():
"""Add quick notifications to context"""
kwargs = super(QuickNotifMixin, self).get_context_data(**kwargs)
kwargs['quick_notifs'] = []
print(self.quick_notif_list)
for n in self.quick_notif_list:
kwargs['quick_notifs'].append(settings.SITH_QUICK_NOTIF[n])
self.quick_notif_list = [] # In some cases, the class can stay instanciated, so we need to reset the list
for k,v in settings.SITH_QUICK_NOTIF.items():
for gk in self.request.GET.keys():
if k == gk:
kwargs['quick_notifs'].append(v)
print(self.quick_notif_list)
return kwargs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment