add more translate texts

This commit is contained in:
Cayo Puigdefabregas 2024-03-20 13:02:50 +01:00
parent 1d4596b267
commit 58474f8111
5 changed files with 52 additions and 35 deletions

View File

@ -1,5 +1,6 @@
import django_tables2 as tables import django_tables2 as tables
from django.utils.html import format_html from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _
from idhub.models import ( from idhub.models import (
Rol, Rol,
@ -33,6 +34,7 @@ class ButtonColumn(tables.Column):
class UserTable(tables.Table): class UserTable(tables.Table):
view_user = ButtonColumn( view_user = ButtonColumn(
verbose_name=_("View"),
linkify={ linkify={
"viewname": "idhub:admin_people", "viewname": "idhub:admin_people",
"args": [tables.A("pk")] "args": [tables.A("pk")]
@ -40,8 +42,8 @@ class UserTable(tables.Table):
orderable=False orderable=False
) )
membership = tables.Column(empty_values=()) membership = tables.Column(verbose_name=_("Membership"), empty_values=())
role = tables.Column(empty_values=()) role = tables.Column(verbose_name=_("Role"), empty_values=())
def render_view_user(self): def render_view_user(self):
return format_html('<i class="bi bi-eye"></i>') return format_html('<i class="bi bi-eye"></i>')
@ -76,6 +78,7 @@ class UserTable(tables.Table):
class RolesTable(tables.Table): class RolesTable(tables.Table):
view_role = ButtonColumn( view_role = ButtonColumn(
verbose_name=_("View"),
linkify={ linkify={
"viewname": "idhub:admin_rol_edit", "viewname": "idhub:admin_rol_edit",
"args": [tables.A("pk")] "args": [tables.A("pk")]
@ -84,6 +87,7 @@ class RolesTable(tables.Table):
) )
delete_role = ButtonColumn( delete_role = ButtonColumn(
verbose_name=_("Delete"),
linkify={ linkify={
"viewname": "idhub:admin_rol_del", "viewname": "idhub:admin_rol_del",
"args": [tables.A("pk")] "args": [tables.A("pk")]
@ -107,6 +111,7 @@ class ServicesTable(tables.Table):
domain = tables.Column(verbose_name="Service") domain = tables.Column(verbose_name="Service")
role = tables.Column(empty_values=()) role = tables.Column(empty_values=())
edit_service = ButtonColumn( edit_service = ButtonColumn(
verbose_name=_("Edit"),
linkify={ linkify={
"viewname": "idhub:admin_service_edit", "viewname": "idhub:admin_service_edit",
"args": [tables.A("pk")] "args": [tables.A("pk")]
@ -115,6 +120,7 @@ class ServicesTable(tables.Table):
) )
delete_service = ButtonColumn( delete_service = ButtonColumn(
verbose_name=_("Delete"),
linkify={ linkify={
"viewname": "idhub:admin_service_del", "viewname": "idhub:admin_service_del",
"args": [tables.A("pk")] "args": [tables.A("pk")]
@ -154,11 +160,12 @@ class DashboardTable(tables.Table):
class CredentialTable(tables.Table): class CredentialTable(tables.Table):
type = tables.Column(empty_values=()) type = tables.Column(verbose_name=_("Type"), empty_values=())
# Pending VerificableCredential description fix # Pending VerificableCredential description fix
details = tables.Column(empty_values=(), orderable=False) details = tables.Column(_("Details"), empty_values=(), orderable=False)
issued_on = tables.Column(verbose_name="Issued") issued_on = tables.Column(verbose_name=_("Issued"))
view_credential = ButtonColumn( view_credential = ButtonColumn(
verbose_name=_("View"),
linkify={ linkify={
"viewname": "idhub:admin_credential", "viewname": "idhub:admin_credential",
"args": [tables.A("pk")] "args": [tables.A("pk")]
@ -187,7 +194,7 @@ class DIDTable(tables.Table):
"args": [tables.A("pk")] "args": [tables.A("pk")]
}, },
orderable=False, orderable=False,
verbose_name="Edit DID" verbose_name="Edit"
) )
delete_template_code = """<a class="text-danger" delete_template_code = """<a class="text-danger"
href="javascript:void()" href="javascript:void()"
@ -197,7 +204,7 @@ class DIDTable(tables.Table):
><i class="bi bi-trash"></i></a>""" ><i class="bi bi-trash"></i></a>"""
delete_did = tables.TemplateColumn(template_code=delete_template_code, delete_did = tables.TemplateColumn(template_code=delete_template_code,
orderable=False, orderable=False,
verbose_name="Delete DID") verbose_name="Delete")
def render_edit_did(self): def render_edit_did(self):
return format_html('<i class="bi bi-pencil-square"></i>') return format_html('<i class="bi bi-pencil-square"></i>')
@ -209,15 +216,15 @@ class DIDTable(tables.Table):
class DataTable(tables.Table): class DataTable(tables.Table):
created_at = tables.Column(verbose_name="Date") created_at = tables.Column(verbose_name=_("Date"))
file_name = tables.Column(verbose_name="File") file_name = tables.Column(verbose_name=_("File"))
delete_template_code = """<a class="text-danger" delete_template_code = """<a class="text-danger"
href="{% url 'idhub:admin_import_del' record.id %}" href="{% url 'idhub:admin_import_del' record.id %}"
title="Remove" title="Remove"
><i class="bi bi-trash"></i></a>""" ><i class="bi bi-trash"></i></a>"""
delete_data = tables.TemplateColumn(template_code=delete_template_code, delete_data = tables.TemplateColumn(template_code=delete_template_code,
orderable=False, orderable=False,
verbose_name="Delete") verbose_name=_("Delete"))
class Meta: class Meta:
model = File_datas model = File_datas
@ -227,6 +234,7 @@ class DataTable(tables.Table):
class TemplateTable(tables.Table): class TemplateTable(tables.Table):
view_schema = ButtonColumn( view_schema = ButtonColumn(
verbose_name=_("View"),
linkify={ linkify={
"viewname": "idhub:admin_schemas_download", "viewname": "idhub:admin_schemas_download",
"args": [tables.A("pk")] "args": [tables.A("pk")]
@ -241,10 +249,10 @@ class TemplateTable(tables.Table):
><i class="bi bi-trash"></i></a>""" ><i class="bi bi-trash"></i></a>"""
delete_schema = tables.TemplateColumn(template_code=delete_template_code, delete_schema = tables.TemplateColumn(template_code=delete_template_code,
orderable=False, orderable=False,
verbose_name="Delete schema") verbose_name=_("Delete"))
name = tables.Column() name = tables.Column(verbose_name=_("Name"))
description = tables.Column() description = tables.Column(verbose_name=_("Description"))
def order_name(self, queryset, is_descending): def order_name(self, queryset, is_descending):
queryset = Schemas.objects.order_by( queryset = Schemas.objects.order_by(

View File

@ -489,9 +489,9 @@ class Schemas(models.Model):
type = models.CharField(max_length=250) type = models.CharField(max_length=250)
file_schema = models.CharField(_('Schema'), max_length=250) file_schema = models.CharField(_('Schema'), max_length=250)
data = models.TextField() data = models.TextField()
created_at = models.DateTimeField(_("Created at"), auto_now=True) created_at = models.DateTimeField(_("Date"), auto_now=True)
_name = models.TextField(_("Name"), null=True, db_column='name') _name = models.TextField(_("Name"), null=True, db_column='name')
_description = models.CharField(_("Descriptions"), max_length=250, null=True, db_column='description') _description = models.CharField(_("Description"), max_length=250, null=True, db_column='description')
template_description = models.TextField(null=True) template_description = models.TextField(null=True)
@property @property
@ -595,15 +595,16 @@ class VerificableCredential(models.Model):
REVOKED = 3, _("Revoked") REVOKED = 3, _("Revoked")
EXPIRED = 4, _("Expired") EXPIRED = 4, _("Expired")
type = models.CharField(max_length=250) type = models.CharField(_("Type"), max_length=250)
id_string = models.CharField(max_length=250) id_string = models.CharField(max_length=250)
verified = models.BooleanField() verified = models.BooleanField()
created_on = models.DateTimeField(auto_now=True) created_on = models.DateTimeField(auto_now=True)
issued_on = models.DateTimeField(null=True) issued_on = models.DateTimeField(_("Issued on"), null=True)
data = models.TextField() data = models.TextField()
csv_data = models.TextField() csv_data = models.TextField()
hash = models.CharField(max_length=260) hash = models.CharField(max_length=260)
status = models.PositiveSmallIntegerField( status = models.PositiveSmallIntegerField(
_("Status"),
choices=Status.choices, choices=Status.choices,
default=Status.ENABLED default=Status.ENABLED
) )
@ -611,6 +612,7 @@ class VerificableCredential(models.Model):
User, User,
on_delete=models.CASCADE, on_delete=models.CASCADE,
related_name='vcredentials', related_name='vcredentials',
verbose_name=_("User")
) )
subject_did = models.ForeignKey( subject_did = models.ForeignKey(
DID, DID,
@ -779,9 +781,9 @@ class VCTemplate(models.Model):
class File_datas(models.Model): class File_datas(models.Model):
file_name = models.CharField(max_length=250) file_name = models.CharField(_("File"), max_length=250)
success = models.BooleanField(default=True) success = models.BooleanField(_("Success"), default=True)
created_at = models.DateTimeField(auto_now=True) created_at = models.DateTimeField(_("Date"), auto_now=True)
class Membership(models.Model): class Membership(models.Model):

View File

@ -1,6 +1,7 @@
from django.utils.html import format_html from django.utils.html import format_html
import django_tables2 as tables import django_tables2 as tables
from idhub.models import Event, Membership, UserRol, DID, VerificableCredential from idhub.models import Event, Membership, UserRol, DID, VerificableCredential
from django.utils.translation import gettext_lazy as _
class ButtonColumn(tables.Column): class ButtonColumn(tables.Column):
@ -19,9 +20,9 @@ class ButtonColumn(tables.Column):
class DashboardTable(tables.Table): class DashboardTable(tables.Table):
type = tables.Column(verbose_name="Event") type = tables.Column(verbose_name=_("Event"))
message = tables.Column(verbose_name="Description") message = tables.Column(verbose_name=_("Description"))
created = tables.Column(verbose_name="Date") created = tables.Column(verbose_name=_("Date"))
class Meta: class Meta:
model = Event model = Event
@ -31,8 +32,9 @@ class DashboardTable(tables.Table):
class PersonalInfoTable(tables.Table): class PersonalInfoTable(tables.Table):
type = tables.Column(verbose_name="Membership") type = tables.Column(verbose_name=_("Membership"))
credential = ButtonColumn( credential = ButtonColumn(
verbose_name=_("Credential"),
# TODO: See where this should actually link # TODO: See where this should actually link
linkify="idhub:user_credentials", linkify="idhub:user_credentials",
orderable=False orderable=False
@ -48,9 +50,9 @@ class PersonalInfoTable(tables.Table):
class RolesTable(tables.Table): class RolesTable(tables.Table):
name = tables.Column(verbose_name="Role", empty_values=()) name = tables.Column(verbose_name=_("Role"), empty_values=())
description = tables.Column(empty_values=()) description = tables.Column(verbose_name=_("Description"), empty_values=())
service = tables.Column() service = tables.Column(verbose_name=_("Service"))
def render_name(self, record): def render_name(self, record):
return record.service.get_roles() return record.service.get_roles()
@ -89,9 +91,10 @@ class RolesTable(tables.Table):
class DIDTable(tables.Table): class DIDTable(tables.Table):
created_at = tables.Column(verbose_name="Date") created_at = tables.Column(verbose_name=_("Date"))
did = tables.Column(verbose_name="ID") did = tables.Column(verbose_name="ID")
edit = ButtonColumn( edit = ButtonColumn(
verbose_name=_("Edit"),
linkify={ linkify={
"viewname": "idhub:user_dids_edit", "viewname": "idhub:user_dids_edit",
"args": [tables.A("pk")] "args": [tables.A("pk")]
@ -104,8 +107,11 @@ class DIDTable(tables.Table):
data-bs-target="#confirm-delete-{{ record.id }}" data-bs-target="#confirm-delete-{{ record.id }}"
title="Remove" title="Remove"
><i class="bi bi-trash"></i></a>""" ><i class="bi bi-trash"></i></a>"""
delete = tables.TemplateColumn(template_code=delete_template_code, delete = tables.TemplateColumn(
orderable=False) verbose_name=_("Delete"),
template_code=delete_template_code,
orderable=False
)
def render_edit(self): def render_edit(self):
return format_html('<i class="bi bi-pencil-square"></i>') return format_html('<i class="bi bi-pencil-square"></i>')
@ -117,8 +123,9 @@ class DIDTable(tables.Table):
class CredentialsTable(tables.Table): class CredentialsTable(tables.Table):
description = tables.Column(verbose_name="Details", empty_values=()) description = tables.Column(verbose_name=_("Details"), empty_values=())
view_credential = ButtonColumn( view_credential = ButtonColumn(
verbose_name=_("View"),
linkify={ linkify={
"viewname": "idhub:user_credential", "viewname": "idhub:user_credential",
"args": [tables.A("pk")] "args": [tables.A("pk")]

View File

@ -6,8 +6,8 @@ from idhub_auth.models import User
class ProfileForm(forms.ModelForm): class ProfileForm(forms.ModelForm):
first_name = forms.CharField(required=True) first_name = forms.CharField(label=_("First name"), required=True)
last_name = forms.CharField(required=True) last_name = forms.CharField(label=_("Last name"), required=True)
class Meta: class Meta:
model = User model = User

View File

@ -45,8 +45,8 @@ class User(AbstractBaseUser):
max_length=255, max_length=255,
unique=True, unique=True,
) )
is_active = models.BooleanField(default=True) is_active = models.BooleanField(_("is active"), default=True)
is_admin = models.BooleanField(default=False) is_admin = models.BooleanField(_("is admin"), default=False)
first_name = models.CharField(_("First name"), max_length=255, blank=True, null=True) first_name = models.CharField(_("First name"), max_length=255, blank=True, null=True)
last_name = models.CharField(_("Last name"), max_length=255, blank=True, null=True) last_name = models.CharField(_("Last name"), max_length=255, blank=True, null=True)
encrypted_sensitive_data = models.CharField(max_length=255) encrypted_sensitive_data = models.CharField(max_length=255)