Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prohibit setting fcpsschools.net as an email #682

Merged
merged 7 commits into from Jul 21, 2019
Merged

Prohibit setting fcpsschools.net as an email #682

merged 7 commits into from Jul 21, 2019

Conversation

theo-o
Copy link
Member

@theo-o theo-o commented Jul 20, 2019

Blocks users from setting an fcpsschools.net address via preferences.

Fixes #599

@theo-o theo-o requested a review from a user July 20, 2019 23:53
@coveralls
Copy link

coveralls commented Jul 21, 2019

Coverage Status

Coverage increased (+0.05%) to 49.685% when pulling 7301540 on email-validation into 46cc7ba on dev.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nitpick, and I would recommend adding this to intranet/apps/preferences/views.py:

@ -52,6 +52,9 @@ def save_personal_info(request, user):
     if email_formset.is_valid():
         email_formset.save()
     else:
+        for error in email_formset.errors:
+            if isinstance(error.get("address"), list):
+                errors.append(error["address"][0])
         errors.append('Could not set emails.')
     if website_formset.is_valid():
         website_formset.save()

Tested locally, it makes the ValidationError's error message ("You cannot provide an fcpsschools.net address.") appear as a notification, which makes it more obvious to the user what's going on.

intranet/apps/preferences/forms.py Outdated Show resolved Hide resolved
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@theo-o theo-o merged commit e8b55ba into dev Jul 21, 2019
@theo-o theo-o deleted the email-validation branch July 21, 2019 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants