Skip to content
Snippets Groups Projects
Commit 9884735b authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB
Browse files

Require one verified contact to create a notification

parent 029f0a52
No related branches found
No related tags found
No related merge requests found
......@@ -79,6 +79,19 @@ class CreateNotificationView(MultipleFormView):
n=form.instance.description))
return super(CreateNotificationView, self).form_valid(form)
def get(self, request, *args, **kwargs):
# Make sure user has at least one verified contact; if not, redirect
# and display an error message
user_has_verified_contact = request.user.contact_set.filter(
verified=True).exists()
if not user_has_verified_contact:
messages.error(request, ('Error: you have no verified contacts. '
'Create and verify a contact before creating a notification.'))
return HttpResponseRedirect(reverse('alerts:index'))
return super(CreateNotificationView, self).get(request, *args,
**kwargs)
superevent_form_valid = event_form_valid = form_valid
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment