From 9ae75b00ab0528df0809bf808da8d1d0bb18cc1a Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 14 Dec 2023 17:15:22 +0100 Subject: [PATCH] fix translate --- idhub/admin/forms.py | 6 +++--- idhub/admin/tables.py | 4 ---- idhub/models.py | 7 ++++--- idhub/templates/idhub/admin/roles.html | 2 +- idhub/templates/idhub/admin/services.html | 2 +- idhub/templates/idhub/admin/user.html | 6 +++--- idhub/templates/idhub/admin/user_edit.html | 4 ++-- idhub_auth/forms.py | 11 +++++++---- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/idhub/admin/forms.py b/idhub/admin/forms.py index 4682579..1919a62 100644 --- a/idhub/admin/forms.py +++ b/idhub/admin/forms.py @@ -19,9 +19,9 @@ from idhub_auth.models import User class ImportForm(forms.Form): - did = forms.ChoiceField(choices=[]) - schema = forms.ChoiceField(choices=[]) - file_import = forms.FileField() + did = forms.ChoiceField(label=_("Did"), choices=[]) + schema = forms.ChoiceField(label=_("Schema"), choices=[]) + file_import = forms.FileField(label=_("File import")) def __init__(self, *args, **kwargs): self._schema = None diff --git a/idhub/admin/tables.py b/idhub/admin/tables.py index 078217c..79c22ba 100644 --- a/idhub/admin/tables.py +++ b/idhub/admin/tables.py @@ -19,10 +19,6 @@ class RolesTable(tables.Table): class DashboardTable(tables.Table): - type = tables.Column(verbose_name=_("Event")) - message = tables.Column(verbose_name=_("Description")) - created = tables.Column(verbose_name=_("Date")) - class Meta: model = Event template_name = "idhub/custom_table.html" diff --git a/idhub/models.py b/idhub/models.py index ee7ebed..3aa6ec8 100644 --- a/idhub/models.py +++ b/idhub/models.py @@ -46,9 +46,10 @@ class Event(models.Model): EV_USR_DEACTIVATED_BY_ADMIN = 29, "User deactivated" EV_USR_ACTIVATED_BY_ADMIN = 30, "User activated" - created = models.DateTimeField(auto_now=True) - message = models.CharField(max_length=350) + created = models.DateTimeField(_("Date"), auto_now=True) + message = models.CharField(_("Description"), max_length=350) type = models.PositiveSmallIntegerField( + _("Event"), choices=Types.choices, ) user = models.ForeignKey( @@ -403,7 +404,7 @@ class Event(models.Model): class DID(models.Model): created_at = models.DateTimeField(auto_now=True) - label = models.CharField(max_length=50) + label = models.CharField(_("Label"), max_length=50) did = models.CharField(max_length=250) # In JWK format. Must be stored as-is and passed whole to library functions. # Example key material: diff --git a/idhub/templates/idhub/admin/roles.html b/idhub/templates/idhub/admin/roles.html index 25bfd93..d3d6593 100644 --- a/idhub/templates/idhub/admin/roles.html +++ b/idhub/templates/idhub/admin/roles.html @@ -24,7 +24,7 @@ {{ rol.name }} {{ rol.description|default:""}} - + {% endfor %} diff --git a/idhub/templates/idhub/admin/services.html b/idhub/templates/idhub/admin/services.html index cea981d..639d1c1 100644 --- a/idhub/templates/idhub/admin/services.html +++ b/idhub/templates/idhub/admin/services.html @@ -26,7 +26,7 @@ {{ service.description }} {{ service.get_roles }} - + {% endfor %} diff --git a/idhub/templates/idhub/admin/user.html b/idhub/templates/idhub/admin/user.html index aacd509..fbb04d1 100644 --- a/idhub/templates/idhub/admin/user.html +++ b/idhub/templates/idhub/admin/user.html @@ -21,7 +21,7 @@
- First Name: + {% trans "First name" %}:
{{ object.first_name|default:'' }} @@ -29,7 +29,7 @@
- Last Name: + {% trans "Last name" %}:
{{ object.last_name|default:'' }} @@ -37,7 +37,7 @@
- Email: + {% trans "Email address" %}:
{{ object.email }} diff --git a/idhub/templates/idhub/admin/user_edit.html b/idhub/templates/idhub/admin/user_edit.html index 9bc0a48..5198cca 100644 --- a/idhub/templates/idhub/admin/user_edit.html +++ b/idhub/templates/idhub/admin/user_edit.html @@ -52,7 +52,7 @@ {{ membership.start_date|default:'' }} {{ membership.end_date|default:'' }} - + {% endfor %} @@ -84,7 +84,7 @@ {{ rol.service.description }} {{ rol.service.domain }} - + {% endfor %} diff --git a/idhub_auth/forms.py b/idhub_auth/forms.py index f292182..f4297b7 100644 --- a/idhub_auth/forms.py +++ b/idhub_auth/forms.py @@ -6,17 +6,20 @@ from idhub_auth.models import User class ProfileForm(forms.ModelForm): - first_name = forms.CharField(required=True) - last_name = forms.CharField(required=True) + first_name = forms.CharField(label=_("First name"), required=True) + last_name = forms.CharField(label=_("Last name"), required=True) class Meta: model = User fields = ['first_name', 'last_name', 'email'] + labels = { + 'email': _('Email address'), + } def clean_first_name(self): first_name = super().clean()['first_name'] match = r'^[a-zA-ZäöüßÄÖÜáéíóúàèìòùÀÈÌÒÙÁÉÍÓÚßñÑçÇ\s\'-]+' - if not re.match(match, first_name): + if not re.fullmatch(match, first_name): txt = _("The string must contain only characters and spaces") raise forms.ValidationError(txt) @@ -25,7 +28,7 @@ class ProfileForm(forms.ModelForm): def clean_last_name(self): last_name = super().clean()['last_name'] match = r'^[a-zA-ZäöüßÄÖÜáéíóúàèìòùÀÈÌÒÙÁÉÍÓÚßñÑçÇ\s\'-]+' - if not re.match(match, last_name): + if not re.fullmatch(match, last_name): txt = _("The string must contain only characters and spaces") raise forms.ValidationError(txt)