mirror of
				https://github.com/ae-utbm/sith.git
				synced 2025-10-31 00:53:08 +00:00 
			
		
		
		
	Fix QuickNotifMixin
This commit is contained in:
		| @@ -232,12 +232,10 @@ class WeekmailEditView(QuickNotifMixin, UpdateView): | |||||||
|         if not weekmail.title: |         if not weekmail.title: | ||||||
|             now = timezone.now() |             now = timezone.now() | ||||||
|             weekmail.title = _("Weekmail of the ") + (now + timedelta(days=6 - now.weekday())).strftime('%d/%m/%Y') |             weekmail.title = _("Weekmail of the ") + (now + timedelta(days=6 - now.weekday())).strftime('%d/%m/%Y') | ||||||
|         print(self.quick_notif_list) |  | ||||||
|         return weekmail |         return weekmail | ||||||
|  |  | ||||||
|     def get(self, request, *args, **kwargs): |     def get(self, request, *args, **kwargs): | ||||||
|         self.object = self.get_object() |         self.object = self.get_object() | ||||||
|         print(self.quick_notif_list) |  | ||||||
|         if 'up_article' in request.GET.keys(): |         if 'up_article' in request.GET.keys(): | ||||||
|             art = get_object_or_404(WeekmailArticle, id=request.GET['up_article'], weekmail=self.object) |             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() |             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.rank = -1 | ||||||
|             art.save() |             art.save() | ||||||
|             self.quick_notif_list += ['qn_success'] |             self.quick_notif_list += ['qn_success'] | ||||||
|         print(self.quick_notif_list) |  | ||||||
|         return super(WeekmailEditView, self).get(request, *args, **kwargs) |         return super(WeekmailEditView, self).get(request, *args, **kwargs) | ||||||
|  |  | ||||||
|     def get_context_data(self, **kwargs): |     def get_context_data(self, **kwargs): | ||||||
|   | |||||||
| @@ -66,6 +66,7 @@ | |||||||
| <h4>{% trans %}Communication{% endtrans %}</h4> | <h4>{% trans %}Communication{% endtrans %}</h4> | ||||||
| <ul> | <ul> | ||||||
|     {% if user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) or user.is_root %} |     {% 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: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:index_edit') }}">{% trans %}Edit index page{% endtrans %}</a></li> | ||||||
|     <li><a href="{{ url('com:alert_edit') }}">{% trans %}Edit alert message{% 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() |         kwargs['list_of_tabs'] = self.get_list_of_tabs() | ||||||
|         return kwargs |         return kwargs | ||||||
|  |  | ||||||
| class QuickNotifMixin(): | class QuickNotifMixin: | ||||||
|     quick_notif_list = [] |     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): |     def get_success_url(self): | ||||||
|         ret = super(QuickNotifMixin, self).get_success_url() |         ret = super(QuickNotifMixin, self).get_success_url() | ||||||
|         try: |         try: | ||||||
| @@ -163,15 +168,12 @@ class QuickNotifMixin(): | |||||||
|         """Add quick notifications to context""" |         """Add quick notifications to context""" | ||||||
|         kwargs = super(QuickNotifMixin, self).get_context_data(**kwargs) |         kwargs = super(QuickNotifMixin, self).get_context_data(**kwargs) | ||||||
|         kwargs['quick_notifs'] = [] |         kwargs['quick_notifs'] = [] | ||||||
|         print(self.quick_notif_list) |  | ||||||
|         for n in self.quick_notif_list: |         for n in self.quick_notif_list: | ||||||
|             kwargs['quick_notifs'].append(settings.SITH_QUICK_NOTIF[n]) |             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 k,v in settings.SITH_QUICK_NOTIF.items(): | ||||||
|             for gk in self.request.GET.keys(): |             for gk in self.request.GET.keys(): | ||||||
|                 if k == gk: |                 if k == gk: | ||||||
|                     kwargs['quick_notifs'].append(v) |                     kwargs['quick_notifs'].append(v) | ||||||
|         print(self.quick_notif_list) |  | ||||||
|         return kwargs |         return kwargs | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user