Commit 2f5bd7d2 authored by Skia's avatar Skia

Fix Weekmail article creation view's rights

parent 23fe797a
Pipeline #991 passed with stage
in 4 minutes and 26 seconds
......@@ -351,7 +351,7 @@ class WeekmailArticleEditView(ComTabsMixin, QuickNotifMixin, CanEditPropMixin, U
quick_notif_url_arg = "qn_weekmail_article_edit"
current_tab = "weekmail"
class WeekmailArticleCreateView(QuickNotifMixin, CanViewMixin, CreateView): #XXX need to protect this view
class WeekmailArticleCreateView(QuickNotifMixin, CreateView):
"""Post an article"""
model = WeekmailArticle
fields = ['title', 'club', 'content']
......@@ -366,9 +366,22 @@ class WeekmailArticleCreateView(QuickNotifMixin, CanViewMixin, CreateView): #XXX
except: pass
return init
def post(self, request, *args, **kwargs):
form = self.get_form()
self.object = form.instance
form.is_valid() # Valid a first time to populate club field
m =
if m.role <= settings.SITH_MAXIMUM_FREE_ROLE:
form.add_error('club', ValidationError(_("You must be a board member of the selected club to post in the Weekmail.")))
if form.is_valid() and not 'preview' in request.POST.keys():
return self.form_valid(form)
return self.form_invalid(form)
def form_valid(self, form):
# club = get_object_or_404(Club, id=self.kwargs['club_id'])
# = club = self.request.user
return super(WeekmailArticleCreateView, self).form_valid(form)
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