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(auth): improve account form strings #13607

Merged
merged 1 commit into from
Feb 6, 2025
Merged
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
24 changes: 14 additions & 10 deletions weblate/accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@
existing = User.objects.filter(username=value)
if existing.exists() and value != self.valid:
raise forms.ValidationError(
gettext("This username is already taken. Please choose another.")
gettext(
"This username is already taken. Please pick something else."
)
)

return super().clean(value)
Expand Down Expand Up @@ -170,16 +172,16 @@
# Remove empty choice from the form. We need it at the database level
# to initialize user profile, but it is filled in later based on
# languages configured in the browser.
self.fields["language"].choices = [

Check failure on line 175 in weblate/accounts/forms.py

View workflow job for this annotation

GitHub Actions / mypy

"Field" has no attribute "choices"
choice for choice in self.fields["language"].choices if choice[0]

Check failure on line 176 in weblate/accounts/forms.py

View workflow job for this annotation

GitHub Actions / mypy

"Field" has no attribute "choices"
]
# Limit languages to ones which have translation, do this by generating choices
# instead of queryset as the queryset would be evaluated twice as
# ModelChoiceField copies the queryset
languages = Language.objects.have_translation()
choices = list(languages.as_choices(use_code=False))
self.fields["languages"].choices = choices

Check failure on line 183 in weblate/accounts/forms.py

View workflow job for this annotation

GitHub Actions / mypy

"Field" has no attribute "choices"
self.fields["secondary_languages"].choices = choices

Check failure on line 184 in weblate/accounts/forms.py

View workflow job for this annotation

GitHub Actions / mypy

"Field" has no attribute "choices"
self.helper = FormHelper(self)
self.helper.disable_csrf = True
self.helper.form_tag = False
Expand All @@ -195,7 +197,7 @@
label=gettext_lazy("Commit e-mail"),
choices=[("", gettext_lazy("Use account e-mail address"))],
help_text=gettext_lazy(
"Used in version control commits. The address will stay in the repository forever once changes are committed by Weblate."
"Used in version-control commits. The address stays in the repository forever once changes are committed by Weblate."
),
required=False,
widget=forms.RadioSelect,
Expand All @@ -212,11 +214,11 @@
site_commit_email = self.instance.get_site_commit_email()
if site_commit_email:
if not settings.PRIVATE_COMMIT_EMAIL_OPT_IN:
self.fields["commit_email"].choices = [("", site_commit_email)]

Check failure on line 217 in weblate/accounts/forms.py

View workflow job for this annotation

GitHub Actions / mypy

"Field" has no attribute "choices"
else:
commit_emails.add(site_commit_email)

self.fields["commit_email"].choices += [(x, x) for x in sorted(commit_emails)]

Check failure on line 221 in weblate/accounts/forms.py

View workflow job for this annotation

GitHub Actions / mypy

"Field" has no attribute "choices"

self.helper = FormHelper(self)
self.helper.disable_csrf = True
Expand All @@ -228,7 +230,7 @@

public_email = forms.ChoiceField(
label=gettext_lazy("Public e-mail"),
choices=[("", gettext_lazy("Do not publicly display e-mail address"))],
choices=[("", gettext_lazy("Hide e-mail address from public view"))],
required=False,
)

Expand All @@ -251,7 +253,7 @@
super().__init__(*args, **kwargs)
emails = get_all_user_mails(self.instance.user)

self.fields["public_email"].choices += [(x, x) for x in sorted(emails)]

Check failure on line 256 in weblate/accounts/forms.py

View workflow job for this annotation

GitHub Actions / mypy

"Field" has no attribute "choices"

self.helper = FormHelper(self)
self.helper.disable_csrf = True
Expand All @@ -273,7 +275,7 @@
super().__init__(*args, **kwargs)
user = kwargs["instance"].user
self.fields["watched"].required = False
self.fields["watched"].queryset = user.allowed_projects

Check failure on line 278 in weblate/accounts/forms.py

View workflow job for this annotation

GitHub Actions / mypy

"Field" has no attribute "queryset"
self.helper = FormHelper(self)
self.helper.disable_csrf = True
self.helper.form_tag = False
Expand All @@ -298,7 +300,7 @@

def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.fields["special_chars"].strip = False

Check failure on line 303 in weblate/accounts/forms.py

View workflow job for this annotation

GitHub Actions / mypy

"Field" has no attribute "strip"
self.helper = FormHelper(self)
self.helper.disable_csrf = True
self.helper.form_tag = False
Expand All @@ -321,7 +323,7 @@
self.helper.disable_csrf = True
self.helper.form_tag = False
component_lists = self.instance.allowed_dashboard_component_lists
self.fields["dashboard_component_list"].queryset = component_lists

Check failure on line 326 in weblate/accounts/forms.py

View workflow job for this annotation

GitHub Actions / mypy

"Field" has no attribute "queryset"
choices = [
choice
for choice in self.fields["dashboard_view"].choices
Expand Down Expand Up @@ -567,8 +569,8 @@
label=gettext_lazy("Message"),
required=True,
help_text=gettext_lazy(
"Please contact us in English, otherwise we might "
"be unable to process your request."
"Please contact us in English. Otherwise, we might "
"not process your request."
),
max_length=2000,
widget=forms.Textarea,
Expand All @@ -585,7 +587,7 @@

email = EmailField(
label=gettext_lazy("E-mail"),
help_text=gettext_lazy("E-mail with a confirmation link will be sent here."),
help_text=gettext_lazy("An e-mail with a confirmation link will be sent here."),
)

field_order = ["email", "captcha"]
Expand Down Expand Up @@ -679,7 +681,7 @@
class PasswordConfirmForm(EmptyConfirmForm):
password = PasswordField(
label=gettext_lazy("Current password"),
help_text=gettext_lazy("Leave empty if you have not yet set a password."),
help_text=gettext_lazy("Leave empty if you have not set a password yet."),
required=False,
)

Expand Down Expand Up @@ -1008,7 +1010,9 @@
sort_by = self.cleaned_data.get("sort_by")
if sort_by:
if sort_by not in self.sort_values:
raise forms.ValidationError(gettext("Chosen sorting is not supported."))
raise forms.ValidationError(
gettext("The chosen sorting is not supported.")
)
return sort_by
return None

Expand Down Expand Up @@ -1067,7 +1071,7 @@
)

error_messages = {
"invalid_token": gettext_lazy("Entered token is not valid."),
"invalid_token": gettext_lazy("The entered token is not valid."),
}

def __init__(self, key, user, metadata=None, **kwargs):
Expand Down Expand Up @@ -1137,7 +1141,7 @@
otp_token = forms.CharField(
label=gettext("Recovery token"),
help_text=gettext(
"Recovery token can be used just once, mark your token as used after using it."
"Recovery codes can only be used once. Remember to mark used ones as expired."
),
)
device_class: type[Device] = StaticDevice
Expand Down
Loading