Skip to content

Commit

Permalink
Merge pull request #980 from opengisch/QF-4457-fix-validaror-help-text
Browse files Browse the repository at this point in the history
Fix username form field help texts
  • Loading branch information
faebebin authored Jul 10, 2024
2 parents 9cb72f2 + 9c705a0 commit 62e3f85
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
38 changes: 38 additions & 0 deletions docker-app/qfieldcloud/core/migrations/0077_alter_user_username.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 3.2.25 on 2024-07-10 14:25

import django.core.validators
from django.db import migrations, models
import qfieldcloud.core.validators


class Migration(migrations.Migration):
dependencies = [
("core", "0076_project_restrict_project_modification"),
]

operations = [
migrations.AlterField(
model_name="user",
name="username",
field=models.CharField(
error_messages={"unique": "A user with that username already exists."},
help_text="Between 3 and 150 characters. Letters, digits, underscores '_' or hyphens '-' only. Must begin with a letter.",
max_length=150,
unique=True,
validators=[
django.core.validators.RegexValidator(
"^[-a-zA-Z0-9_]+$",
"Only letters, numbers, underscores '_' or hyphens '-' are allowed.",
),
django.core.validators.RegexValidator(
"^[a-zA-Z].*$", "Must begin with a letter."
),
django.core.validators.RegexValidator(
"^.{3,}$", "Must be at least 3 characters long."
),
qfieldcloud.core.validators.reserved_words_validator,
],
verbose_name="username",
),
),
]
10 changes: 4 additions & 6 deletions docker-app/qfieldcloud/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,15 @@ class Type(models.IntegerChoices):
max_length=150,
unique=True,
help_text=_(
"Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only."
"Between 3 and 150 characters. Letters, digits, underscores '_' or hyphens '-' only. Must begin with a letter."
),
validators=[
RegexValidator(
r"^[-a-zA-Z0-9_]+$",
"Only letters, numbers, underscores or hyphens are allowed.",
),
RegexValidator(r"^[a-zA-Z].*$", _("The name must begin with a letter.")),
RegexValidator(
r"^.{3,}$", _("The name must be at least 3 characters long.")
"Only letters, numbers, underscores '_' or hyphens '-' are allowed.",
),
RegexValidator(r"^[a-zA-Z].*$", _("Must begin with a letter.")),
RegexValidator(r"^.{3,}$", _("Must be at least 3 characters long.")),
validators.reserved_words_validator,
],
error_messages={
Expand Down

0 comments on commit 62e3f85

Please sign in to comment.