Have the validator catch users who aren't editors, since that would throw a 500 error otherwise.
@@ -274,10 +274,9 @@ class PartnerSuggestionView(FormView):
return context
def form_valid(self, form):
- # Adding an extra check to ensure the user is logged in
- # so as to not break things.
+ # Adding an extra check to ensure the user is a wikipedia editor.
try:
- assert self.request.user.is_authenticated()
+ assert self.request.user.editor
suggestion = Suggestion()
suggestion.suggested_company_name = form.cleaned_data['suggested_company_name']
suggestion.description = form.cleaned_data['description']
@@ -289,10 +288,10 @@ class PartnerSuggestionView(FormView):
# Translators: Shown to users when they successfully add a new partner suggestion.
_('Your suggestion has been added.'))
return HttpResponseRedirect(reverse('suggest'))
- except AssertionError:
+ except (AssertionError, AttributeError) as e:
messages.add_message (self.request, messages.WARNING,
- # Translators: This message is shown to users who attempt to post data to suggestion form without logging in
- _('You must be logged in to do that.'))
+ # Translators: This message is shown to non-wikipedia editors who attempt to post data to suggestion form.
+ _('You must be a Wikipedia editor to do that.'))
raise PermissionDenied
return self.request.user.editor
