Skip to content

Commit

Permalink
profile: Improve e-mail configuration
Browse files Browse the repository at this point in the history
- use radio instead of select to make all choices directly visible
  (there won't be much of them)
- clarify how each e-mail address is used (fixes WeblateOrg#10352)
- add shared text about e-mail verification
- rename "add e-mail" to "verify e-mail" as that better describes what
  it does
  • Loading branch information
nijel committed Nov 6, 2023
1 parent 7892dec commit 3328503
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
22 changes: 10 additions & 12 deletions weblate/accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
get_all_user_mails,
invalidate_reset_codes,
)
from weblate.auth.models import Group, User, get_auth_keys
from weblate.auth.models import Group, User
from weblate.lang.models import Language
from weblate.logger import LOGGER
from weblate.trans.defines import FULLNAME_LENGTH
Expand Down Expand Up @@ -173,8 +173,11 @@ class CommitForm(ProfileBaseForm):
commit_email = forms.ChoiceField(
label=gettext_lazy("Commit e-mail"),
choices=[("", gettext_lazy("Use account e-mail address"))],
help_text=gettext_lazy("Choose commit e-mail from verified addresses."),
help_text=gettext_lazy(
"Used for version control commits. The address will stay in the repository forever once changes are commited by Weblate."
),
required=False,
widget=forms.RadioSelect,
)

class Meta:
Expand All @@ -197,10 +200,6 @@ def __init__(self, *args, **kwargs):
self.helper = FormHelper(self)
self.helper.disable_csrf = True
self.helper.form_tag = False
layout = ["commit_email"]
if "email" in get_auth_keys():
layout.append(Div(template="accounts/add-mail.html"))
self.helper.layout = Layout(*layout)


class ProfileForm(ProfileBaseForm):
Expand Down Expand Up @@ -342,10 +341,13 @@ class UserForm(forms.ModelForm):

username = UniqueUsernameField()
email = forms.ChoiceField(
label=gettext_lazy("E-mail"),
help_text=gettext_lazy("Choose primary e-mail from verified addresses."),
label=gettext_lazy("Account e-mail"),
help_text=gettext_lazy(
"Used for e-mail notifications and as a commit e-mail if it is not not configured below."
),
choices=(("", ""),),
required=True,
widget=forms.RadioSelect,
)
full_name = FullNameField()

Expand All @@ -364,10 +366,6 @@ def __init__(self, *args, **kwargs):
self.helper = FormHelper(self)
self.helper.disable_csrf = True
self.helper.form_tag = False
layout = ["username", "email", "full_name"]
if "email" in get_auth_keys():
layout.insert(2, Div(template="accounts/add-mail.html"))
self.helper.layout = Layout(*layout)

@classmethod
def from_request(cls, request):
Expand Down
5 changes: 0 additions & 5 deletions weblate/templates/accounts/add-mail.html

This file was deleted.

2 changes: 1 addition & 1 deletion weblate/templates/accounts/email.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<form action="{% url 'email_login' %}" method="post" accept-charset="utf-8">

<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title">{% trans "Add new e-mail address" %}</h4></div>
<div class="panel-heading"><h4 class="panel-title">{% trans "Verify new e-mail address" %}</h4></div>
<div class="panel-body">

{% csrf_token %}
Expand Down
6 changes: 6 additions & 0 deletions weblate/templates/accounts/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@
<div class="panel-body">
{% crispy userform %}
{% crispy commitform %}
<p class="help-block">
{% if has_email_auth %}
<a href="" class="link-post pull-right flip btn btn-link" data-href="{% url 'social:begin' 'email' %}?next={% url 'profile' %}%23account">{% translate "Verify new e-mail address" %}</a>
{% endif %}
{% trans "The e-mail address can be chosen from verified addresses only." %}
</p>
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Save" %}" class="btn btn-primary" />
Expand Down

0 comments on commit 3328503

Please sign in to comment.