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

Fix bug 1748145: Temporarily remove ability to change contributor email address #2399

Merged
merged 1 commit into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions pontoon/base/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,26 +201,10 @@ class UserProfileForm(forms.ModelForm):
max_length=30,
strip=True,
)
email = forms.EmailField(
help_text=(
"Changing your email address will cause a logout. "
"Make sure the new one is correct before saving!"
)
)

class Meta:
model = User
fields = ("first_name", "email")

def clean_email(self):
email = self.cleaned_data.get("email")
if email and (
User.objects.filter(email=email)
.exclude(username=self.instance.username)
.exists()
):
raise forms.ValidationError("Email address must be unique.")
return email
fields = ("first_name",)


class UserCustomHomepageForm(forms.ModelForm):
Expand Down
6 changes: 0 additions & 6 deletions pontoon/contributors/templates/contributors/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ <h3>Personal information</h3>
{{ profile_form.first_name }}
{{ profile_form.first_name.errors }}
</div>
<div class="field">
{{ profile_form.email.label_tag(label_suffix='') }}
{{ profile_form.email }}
{{ profile_form.email.errors }}
<p class="help">{{ profile_form.email.help_text }}</p>
</div>
</section>

<section>
Expand Down
9 changes: 1 addition & 8 deletions pontoon/contributors/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,11 @@ def test_profileform_invalid_first_name(member, settings_url):
assert b"Enter a valid value." in response.content


@pytest.mark.django_db
def test_profileform_invalid_email(member, settings_url):
response = member.client.post(settings_url, {"email": "usermail"})

assert b"Enter a valid email address." in response.content


@pytest.mark.django_db
def test_profileform_missing_profile_fields(member, settings_url):
response = member.client.post(settings_url, {})

assert response.content.count(b"This field is required.") == 2
assert response.content.count(b"This field is required.") == 1


@pytest.mark.django_db
Expand Down
8 changes: 1 addition & 7 deletions pontoon/contributors/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from dateutil.relativedelta import relativedelta
from django.conf import settings as django_settings
from django.contrib import messages
from django.contrib.auth import logout
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.core.paginator import Paginator, EmptyPage
Expand All @@ -15,7 +14,7 @@
HttpResponseBadRequest,
JsonResponse,
)
from django.shortcuts import get_object_or_404, render, redirect
from django.shortcuts import get_object_or_404, render
from django.utils import timezone
from django.views.decorators.http import require_POST
from django.views.generic import TemplateView
Expand Down Expand Up @@ -195,17 +194,12 @@ def settings(request):
request.POST,
instance=request.user,
)
user = get_object_or_404(User, username=request.user.username)

if locales_form.is_valid() and profile_form.is_valid():
locales_form.save()
profile_form.save()

messages.success(request, "Settings saved.")

if user.email != request.user.email:
logout(request)
return redirect(request.POST.get("return_url", "/"))
else:
profile_form = forms.UserProfileForm(instance=request.user)

Expand Down