Skip to content

Commit b489d37

Browse files
committed
patch: disable updating username
1 parent 39ba3b7 commit b489d37

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

weblate/accounts/forms.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,18 @@ def __init__(self, *args, **kwargs) -> None:
412412
self.helper.form_tag = False
413413
self.helper.template_pack = "bootstrap5"
414414

415+
def clean(self) -> None:
416+
cleaned_data = super().clean()
417+
418+
orig = User.objects.get(pk=self.instance.pk)
419+
orig_username = getattr(orig, "username")
420+
new_username = cleaned_data.get("username")
421+
422+
if orig_username != new_username:
423+
self.add_error("username", gettext("Username changed"))
424+
425+
return cleaned_data
426+
415427
@classmethod
416428
def from_request(cls, request: AuthenticatedHttpRequest):
417429
if request.method == "POST":

0 commit comments

Comments
 (0)