From 35d7f014be1985d4b70b98d9183cd8e3bb29277c Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 9 Nov 2023 17:58:06 +0100 Subject: [PATCH 1/9] add events of the system --- idhub/admin/views.py | 65 +++- idhub/migrations/0002_event.py | 77 +++++ idhub/models.py | 381 ++++++++++++++++++++- idhub/templates/idhub/admin/dashboard.html | 127 +------ idhub/templates/idhub/user/dashboard.html | 127 +------ idhub/user/forms.py | 14 +- idhub/user/views.py | 18 +- 7 files changed, 548 insertions(+), 261 deletions(-) create mode 100644 idhub/migrations/0002_event.py diff --git a/idhub/admin/views.py b/idhub/admin/views.py index 0492f5d..fa11e6a 100644 --- a/idhub/admin/views.py +++ b/idhub/admin/views.py @@ -28,6 +28,7 @@ from idhub.email.views import NotifyActivateUserByEmail from idhub.admin.forms import ImportForm, SchemaForm from idhub.models import ( DID, + Event, File_datas, Membership, Rol, @@ -45,6 +46,13 @@ class DashboardView(AdminView, TemplateView): icon = 'bi bi-bell' section = "Home" + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context.update({ + 'events': Event.objects.filter(user=None), + }) + return context + class People(AdminView): title = _("People Management") section = "People" @@ -114,8 +122,10 @@ class PeopleActivateView(PeopleView): if self.object.is_active: self.object.is_active = False + Event.set_EV_USR_DEACTIVATED_BY_ADMIN(self.object) else: self.object.is_active = True + Event.set_EV_USR_ACTIVATED_BY_ADMIN(self.object) self.object.save() return redirect('idhub:admin_people', self.object.id) @@ -128,17 +138,27 @@ class PeopleDeleteView(PeopleView): self.object = get_object_or_404(self.model, pk=self.pk) if self.object != self.request.user: + Event.set_EV_USR_DELETED_BY_ADMIN(self.object) self.object.delete() else: messages.error(self.request, _('Is not possible delete your account!')) return redirect('idhub:admin_people_list') + class PeopleEditView(PeopleView, UpdateView): template_name = "idhub/admin/user_edit.html" fields = ('first_name', 'last_name', 'email') success_url = reverse_lazy('idhub:admin_people_list') + def form_valid(self, form): + user = form.save() + messages.success(self.request, _('The account is updated successfully')) + Event.set_EV_USR_UPDATED_BY_ADMIN(user) + Event.set_EV_USR_UPDATED(user) + + return super().form_valid(form) + class PeopleRegisterView(NotifyActivateUserByEmail, People, CreateView): template_name = "idhub/admin/people_register.html" @@ -158,6 +178,9 @@ class PeopleRegisterView(NotifyActivateUserByEmail, People, CreateView): def form_valid(self, form): user = form.save() messages.success(self.request, _('The account is created successfully')) + Event.set_EV_USR_REGISTERED(user) + Event.set_EV_USR_WELCOME(user) + if user.is_active: try: self.send_email(user) @@ -326,6 +349,12 @@ class RolRegisterView(AccessControl, CreateView): fields = ('name',) success_url = reverse_lazy('idhub:admin_roles') object = None + + def form_valid(self, form): + form.save() + messages.success(self.request, _('Rol created successfully')) + Event.set_EV_ROLE_CREATED_BY_ADMIN() + return super().form_valid(form) class RolEditView(AccessControl, CreateView): @@ -342,6 +371,12 @@ class RolEditView(AccessControl, CreateView): self.object = get_object_or_404(self.model, pk=pk) kwargs = super().get_form_kwargs() return kwargs + + def form_valid(self, form): + form.save() + messages.success(self.request, _('Rol updated successfully')) + Event.set_EV_ROLE_MODIFIED_BY_ADMIN() + return super().form_valid(form) class RolDeleteView(AccessControl): @@ -352,6 +387,8 @@ class RolDeleteView(AccessControl): self.object = get_object_or_404(self.model, pk=self.pk) self.object.delete() + messages.success(self.request, _('Rol deleted successfully')) + Event.set_EV_ROLE_DELETED_BY_ADMIN() return redirect('idhub:admin_roles') @@ -376,6 +413,12 @@ class ServiceRegisterView(AccessControl, CreateView): success_url = reverse_lazy('idhub:admin_services') object = None + def form_valid(self, form): + form.save() + messages.success(self.request, _('Service created successfully')) + Event.set_EV_SERVICE_CREATED_BY_ADMIN() + return super().form_valid(form) + class ServiceEditView(AccessControl, CreateView): template_name = "idhub/admin/service_register.html" @@ -392,6 +435,12 @@ class ServiceEditView(AccessControl, CreateView): kwargs = super().get_form_kwargs() return kwargs + def form_valid(self, form): + form.save() + messages.success(self.request, _('Service updated successfully')) + Event.set_EV_SERVICE_MODIFIED_BY_ADMIN() + return super().form_valid(form) + class ServiceDeleteView(AccessControl): model = Service @@ -401,6 +450,8 @@ class ServiceDeleteView(AccessControl): self.object = get_object_or_404(self.model, pk=self.pk) self.object.delete() + messages.success(self.request, _('Service deleted successfully')) + Event.set_EV_SERVICE_DELETED_BY_ADMIN() return redirect('idhub:admin_services') @@ -462,6 +513,8 @@ class RevokeCredentialsView(Credentials): self.object.status = VerificableCredential.Status.REVOKED self.object.save() messages.success(self.request, _('Credential revoked successfully')) + Event.set_EV_CREDENTIAL_REVOKED_BY_ADMIN(self.object) + Event.set_EV_CREDENTIAL_REVOKED(self.object) return redirect(self.success_url) @@ -482,6 +535,8 @@ class DeleteCredentialsView(Credentials): if self.object.status in status: self.object.delete() messages.success(self.request, _('Credential deleted successfully')) + Event.set_EV_CREDENTIAL_DELETED(self.object) + Event.set_EV_CREDENTIAL_DELETED_BY_ADMIN(self.object) return redirect(self.success_url) @@ -514,6 +569,7 @@ class DidRegisterView(Credentials, CreateView): form.instance.did = iota.issue_did() form.save() messages.success(self.request, _('DID created successfully')) + Event.set_EV_ORG_DID_CREATED_BY_ADMIN(form.instance) return super().form_valid(form) @@ -547,9 +603,9 @@ class DidDeleteView(Credentials, DeleteView): def get(self, request, *args, **kwargs): self.pk = kwargs['pk'] self.object = get_object_or_404(self.model, pk=self.pk) + Event.set_EV_ORG_DID_DELETED_BY_ADMIN(self.object) self.object.delete() messages.success(self.request, _('DID delete successfully')) - return redirect(self.success_url) @@ -738,9 +794,12 @@ class ImportAddView(ImportExport, FormView): return kwargs def form_valid(self, form): - cred = form.save() - if cred: + creds = form.save() + if creds: messages.success(self.request, _("The file import was successfully!")) + for cred in creds: + Event.set_EV_CREDENTIAL_ENABLED(cred) + Event.set_EV_CREDENTIAL_CAN_BE_REQUESTED(cred) else: messages.error(self.request, _("Error importing the file!")) return super().form_valid(form) diff --git a/idhub/migrations/0002_event.py b/idhub/migrations/0002_event.py new file mode 100644 index 0000000..d79ffd1 --- /dev/null +++ b/idhub/migrations/0002_event.py @@ -0,0 +1,77 @@ +# Generated by Django 4.2.5 on 2023-11-09 13:54 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('idhub', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Event', + fields=[ + ( + 'id', + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), + ('created', models.DateTimeField(auto_now=True)), + ('message', models.CharField(max_length=350)), + ( + 'type', + models.PositiveSmallIntegerField( + choices=[ + (1, 'EV_USR_REGISTERED'), + (2, 'EV_USR_WELCOME'), + (3, 'EV_DATA_UPDATE_REQUESTED_BY_USER'), + (4, 'EV_DATA_UPDATE_REQUESTED'), + (5, 'EV_USR_UPDATED_BY_ADMIN'), + (6, 'EV_USR_UPDATED'), + (7, 'EV_USR_DELETED_BY_ADMIN'), + (8, 'EV_DID_CREATED_BY_USER'), + (9, 'EV_DID_CREATED'), + (10, 'EV_DID_DELETED'), + (11, 'EV_CREDENTIAL_DELETED_BY_ADMIN'), + (12, 'EV_CREDENTIAL_DELETED'), + (13, 'EV_CREDENTIAL_ISSUED_FOR_USER'), + (14, 'EV_CREDENTIAL_ISSUED'), + (15, 'EV_CREDENTIAL_PRESENTED_BY_USER'), + (16, 'EV_CREDENTIAL_PRESENTED'), + (17, 'EV_CREDENTIAL_ENABLED'), + (18, 'EV_CREDENTIAL_CAN_BE_REQUESTED'), + (19, 'EV_CREDENTIAL_REVOKED_BY_ADMIN'), + (20, 'EV_CREDENTIAL_REVOKED'), + (21, 'EV_ROLE_CREATED_BY_ADMIN'), + (22, 'EV_ROLE_MODIFIED_BY_ADMIN'), + (23, 'EV_ROLE_DELETED_BY_ADMIN'), + (24, 'EV_SERVICE_CREATED_BY_ADMIN'), + (25, 'EV_SERVICE_MODIFIED_BY_ADMIN'), + (26, 'EV_SERVICE_DELETED_BY_ADMIN'), + (27, 'EV_ORG_DID_CREATED_BY_ADMIN'), + (28, 'EV_ORG_DID_DELETED_BY_ADMIN'), + (29, 'EV_USR_DEACTIVATED_BY_ADMIN'), + (30, 'EV_USR_ACTIVATED_BY_ADMIN'), + ] + ), + ), + ( + 'user', + models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name='events', + to=settings.AUTH_USER_MODEL, + ), + ), + ], + ), + ] diff --git a/idhub/models.py b/idhub/models.py index 8a805d4..30eba0a 100644 --- a/idhub/models.py +++ b/idhub/models.py @@ -5,12 +5,383 @@ from django.utils.translation import gettext_lazy as _ from idhub_auth.models import User -# class Event(models.Model): - # Para los "audit logs" que se requieren en las pantallas. - # timestamp = models.DateTimeField() - # Los eventos no tienen relación con otros objetos a nivel de BBDD. - # event_data = models.CharField(max_length=250) +class Event(models.Model): + class Types(models.IntegerChoices): + EV_USR_REGISTERED = 1, "EV_USR_REGISTERED" + EV_USR_WELCOME = 2, "EV_USR_WELCOME" + EV_DATA_UPDATE_REQUESTED_BY_USER = 3, "EV_DATA_UPDATE_REQUESTED_BY_USER" + EV_DATA_UPDATE_REQUESTED = 4, "EV_DATA_UPDATE_REQUESTED" + EV_USR_UPDATED_BY_ADMIN = 5, "EV_USR_UPDATED_BY_ADMIN" + EV_USR_UPDATED = 6, "EV_USR_UPDATED" + EV_USR_DELETED_BY_ADMIN = 7, "EV_USR_DELETED_BY_ADMIN" + EV_DID_CREATED_BY_USER = 8, "EV_DID_CREATED_BY_USER" + EV_DID_CREATED = 9, "EV_DID_CREATED" + EV_DID_DELETED = 10, "EV_DID_DELETED" + EV_CREDENTIAL_DELETED_BY_ADMIN = 11, "EV_CREDENTIAL_DELETED_BY_ADMIN" + EV_CREDENTIAL_DELETED = 12, "EV_CREDENTIAL_DELETED" + EV_CREDENTIAL_ISSUED_FOR_USER = 13, "EV_CREDENTIAL_ISSUED_FOR_USER" + EV_CREDENTIAL_ISSUED = 14, "EV_CREDENTIAL_ISSUED" + EV_CREDENTIAL_PRESENTED_BY_USER = 15, "EV_CREDENTIAL_PRESENTED_BY_USER" + EV_CREDENTIAL_PRESENTED = 16, "EV_CREDENTIAL_PRESENTED" + EV_CREDENTIAL_ENABLED = 17, "EV_CREDENTIAL_ENABLED" + EV_CREDENTIAL_CAN_BE_REQUESTED = 18, "EV_CREDENTIAL_CAN_BE_REQUESTED" + EV_CREDENTIAL_REVOKED_BY_ADMIN = 19, "EV_CREDENTIAL_REVOKED_BY_ADMIN" + EV_CREDENTIAL_REVOKED = 20, "EV_CREDENTIAL_REVOKED" + EV_ROLE_CREATED_BY_ADMIN = 21, "EV_ROLE_CREATED_BY_ADMIN" + EV_ROLE_MODIFIED_BY_ADMIN = 22, "EV_ROLE_MODIFIED_BY_ADMIN" + EV_ROLE_DELETED_BY_ADMIN = 23, "EV_ROLE_DELETED_BY_ADMIN" + EV_SERVICE_CREATED_BY_ADMIN = 24, "EV_SERVICE_CREATED_BY_ADMIN" + EV_SERVICE_MODIFIED_BY_ADMIN = 25, "EV_SERVICE_MODIFIED_BY_ADMIN" + EV_SERVICE_DELETED_BY_ADMIN = 26, "EV_SERVICE_DELETED_BY_ADMIN" + EV_ORG_DID_CREATED_BY_ADMIN = 27, "EV_ORG_DID_CREATED_BY_ADMIN" + EV_ORG_DID_DELETED_BY_ADMIN = 28, "EV_ORG_DID_DELETED_BY_ADMIN" + EV_USR_DEACTIVATED_BY_ADMIN = 29, "EV_USR_DEACTIVATED_BY_ADMIN" + EV_USR_ACTIVATED_BY_ADMIN = 30, "EV_USR_ACTIVATED_BY_ADMIN" + created = models.DateTimeField(auto_now=True) + message = models.CharField(max_length=350) + type = models.PositiveSmallIntegerField( + choices=Types.choices, + ) + user = models.ForeignKey( + User, + on_delete=models.CASCADE, + related_name='events', + null=True, + ) + + def get_type(self): + return self.Types(self.type).label + + @classmethod + def set_EV_USR_REGISTERED(cls, user): + msg = "The user {} was registered: name: {}, last name: {}".format( + user.username, + user.first_name, + user.last_name + ) + cls.objects.create( + type=cls.Types.EV_USR_REGISTERED, + message=msg + ) + + @classmethod + def set_EV_USR_WELCOME(cls, user): + msg = "Welcome. You has been registered: name: {}, last name: {}".format( + user.first_name, + user.last_name + ) + cls.objects.create( + type=cls.Types.EV_USR_WELCOME, + message=msg, + user=user + ) + + # Is required? + @classmethod + def set_EV_DATA_UPDATE_REQUESTED_BY_USER(cls, user): + msg = "The user '{}' has request the update of the following information: " + msg += "['field1':'value1', 'field2':'value2'>,...]".format( + user.username, + ) + cls.objects.create( + type=cls.Types.EV_DATA_UPDATE_REQUESTED_BY_USER, + message=msg, + ) + + # Is required? + @classmethod + def set_EV_DATA_UPDATE_REQUESTED(cls, user): + msg = "You have requested the update of the following information: " + msg += "['field1':'value1', 'field2':'value2'>,...]" + cls.objects.create( + type=cls.Types.EV_DATA_UPDATE_REQUESTED, + message=msg, + user=user + ) + + @classmethod + def set_EV_USR_UPDATED_BY_ADMIN(cls, user): + msg = "The admin has updated the following user 's information: " + msg += "name: {}, last name: {}".format( + user.first_name, + user.last_name + ) + cls.objects.create( + type=cls.Types.EV_USR_UPDATED_BY_ADMIN, + message=msg + ) + + @classmethod + def set_EV_USR_UPDATED(cls, user): + msg = "The admin has updated your personal information: " + msg += "name: {}, last name: {}".format( + user.first_name, + user.last_name + ) + cls.objects.create( + type=cls.Types.EV_USR_UPDATED, + message=msg, + user=user + ) + + @classmethod + def set_EV_USR_DELETED_BY_ADMIN(cls, user): + msg = "The admin has deleted the user: username: {}".format( + user.username, + ) + cls.objects.create( + type=cls.Types.EV_USR_DELETED_BY_ADMIN, + message=msg + ) + + @classmethod + def set_EV_DID_CREATED_BY_USER(cls, did): + msg = "New DID with DID-ID: '{}' created by user '{}'".format( + did.did, + did.user.username + ) + cls.objects.create( + type=cls.Types.EV_DID_CREATED_BY_USER, + message=msg, + ) + + @classmethod + def set_EV_DID_CREATED(cls, did): + msg = "New DID with label: '{}' and DID-ID: '{}' was created'".format( + did.label, + did.did + ) + cls.objects.create( + type=cls.Types.EV_DID_CREATED, + message=msg, + user=did.user + ) + + @classmethod + def set_EV_DID_DELETED(cls, did): + msg = "The DID with label '{}' and DID-ID: '{}' was deleted from your wallet".format( + did.label, + did.did + ) + cls.objects.create( + type=cls.Types.EV_DID_DELETED, + message=msg, + user=did.user + ) + + @classmethod + def set_EV_CREDENTIAL_DELETED_BY_ADMIN(cls, cred): + msg = "The credential of type '{}' and ID: '{}' was deleted".format( + cred.type(), + cred.id, + ) + cls.objects.create( + type=cls.Types.EV_CREDENTIAL_DELETED_BY_ADMIN, + message=msg, + ) + + @classmethod + def set_EV_CREDENTIAL_DELETED(cls, cred): + msg = "The credential of type '{}' and ID: '{}' was deleted from your wallet".format( + cred.type(), + cred.id + ) + cls.objects.create( + type=cls.Types.EV_CREDENTIAL_DELETED, + message=msg, + user=cred.user + ) + + @classmethod + def set_EV_CREDENTIAL_ISSUED_FOR_USER(cls, cred): + msg = "The credential of type '{}' and ID: '{}' was issued for user {}".format( + cred.type(), + cred.id, + cred.user.username + ) + cls.objects.create( + type=cls.Types.EV_CREDENTIAL_ISSUED_FOR_USER, + message=msg, + ) + + @classmethod + def set_EV_CREDENTIAL_ISSUED(cls, cred): + msg = "The credential of type '{}' and ID: '{}' was issued and stored in your wallet".format( + cred.type(), + cred.id + ) + cls.objects.create( + type=cls.Types.EV_CREDENTIAL_ISSUED, + message=msg, + user=cred.user + ) + + @classmethod + def set_EV_CREDENTIAL_PRESENTED_BY_USER(cls, cred, verifier): + msg = "The credential of type '{}' and ID: '{}' was presented by user {} to verifier '{}".format( + cred.type(), + cred.id, + cred.user.username, + verifier + ) + cls.objects.create( + type=cls.Types.EV_CREDENTIAL_PRESENTED_BY_USER, + message=msg, + ) + + @classmethod + def set_EV_CREDENTIAL_PRESENTED(cls, cred, verifier): + msg = "The credential of type '{}' and ID: '{}' was presented to verifier '{}'".format( + cred.type(), + cred.id, + verifier + ) + cls.objects.create( + type=cls.Types.EV_CREDENTIAL_PRESENTED, + message=msg, + user=cred.user + ) + + @classmethod + def set_EV_CREDENTIAL_ENABLED(cls, cred): + msg = "The credential of type '{}' was enabled for user {}".format( + cred.type(), + cred.user.username + ) + cls.objects.create( + type=cls.Types.EV_CREDENTIAL_ENABLED, + message=msg, + ) + + @classmethod + def set_EV_CREDENTIAL_CAN_BE_REQUESTED(cls, cred): + msg = "You can request the '{}' credential".format( + cred.type() + ) + cls.objects.create( + type=cls.Types.EV_CREDENTIAL_CAN_BE_REQUESTED, + message=msg, + user=cred.user + ) + + @classmethod + def set_EV_CREDENTIAL_REVOKED_BY_ADMIN(cls, cred): + msg = "The credential of type '{}' and ID: '{}' was revoked for ".format( + cred.type(), + cred.id + ) + cls.objects.create( + type=cls.Types.EV_CREDENTIAL_REVOKED_BY_ADMIN, + message=msg, + ) + + @classmethod + def set_EV_CREDENTIAL_REVOKED(cls, cred): + msg = "The credential of type '{}' and ID: '{}' was revoked by admin".format( + cred.type(), + cred.id + ) + cls.objects.create( + type=cls.Types.EV_CREDENTIAL_REVOKED, + message=msg, + user=cred.user + ) + + @classmethod + def set_EV_ROLE_CREATED_BY_ADMIN(cls): + msg = 'A new role was created by admin' + cls.objects.create( + type=cls.Types.EV_ROLE_CREATED_BY_ADMIN, + message=msg, + ) + + @classmethod + def set_EV_ROLE_MODIFIED_BY_ADMIN(cls): + msg = 'The role was modified by admin' + cls.objects.create( + type=cls.Types.EV_ROLE_MODIFIED_BY_ADMIN, + message=msg, + ) + + @classmethod + def set_EV_ROLE_DELETED_BY_ADMIN(cls): + msg = 'The role was removed by admin' + cls.objects.create( + type=cls.Types.EV_ROLE_DELETED_BY_ADMIN, + message=msg, + ) + + @classmethod + def set_EV_SERVICE_CREATED_BY_ADMIN(cls): + msg = 'A new service was created by admin' + cls.objects.create( + type=cls.Types.EV_SERVICE_CREATED_BY_ADMIN, + message=msg, + ) + + @classmethod + def set_EV_SERVICE_MODIFIED_BY_ADMIN(cls): + msg = 'The service was modified by admin' + cls.objects.create( + type=cls.Types.EV_SERVICE_MODIFIED_BY_ADMIN, + message=msg, + ) + + @classmethod + def set_EV_SERVICE_DELETED_BY_ADMIN(cls): + msg = 'The service was removed by admin' + cls.objects.create( + type=cls.Types.EV_SERVICE_DELETED_BY_ADMIN, + message=msg, + ) + + @classmethod + def set_EV_ORG_DID_CREATED_BY_ADMIN(cls, did): + msg = "New Organisational DID with label: '{}' and DID-ID: '{}' was created".format( + did.label, + did.did + ) + cls.objects.create( + type=cls.Types.EV_ORG_DID_CREATED_BY_ADMIN, + message=msg, + ) + + @classmethod + def set_EV_ORG_DID_DELETED_BY_ADMIN(cls, did): + msg = "Organisational DID with label: '{}' and DID-ID: '{}' was removed".format( + did.label, + did.did + ) + cls.objects.create( + type=cls.Types.EV_ORG_DID_DELETED_BY_ADMIN, + message=msg, + ) + + @classmethod + def set_EV_USR_DEACTIVATED_BY_ADMIN(cls, user): + msg = "The user '{}' was temporarily deactivated: [name:'{}', last name:'{}']".format( + user.username, + user.first_name, + user.last_name + ) + cls.objects.create( + type=cls.Types.EV_USR_DEACTIVATED_BY_ADMIN, + message=msg, + ) + + @classmethod + def set_EV_USR_ACTIVATED_BY_ADMIN(cls, user): + msg = "The user '{}' was activated: [name:'{}', last name:'{}']".format( + user.username, + user.first_name, + user.last_name + ) + cls.objects.create( + type=cls.Types.EV_USR_ACTIVATED_BY_ADMIN, + message=msg, + ) + class DID(models.Model): created_at = models.DateTimeField(auto_now=True) diff --git a/idhub/templates/idhub/admin/dashboard.html b/idhub/templates/idhub/admin/dashboard.html index 90f0050..a94bffb 100644 --- a/idhub/templates/idhub/admin/dashboard.html +++ b/idhub/templates/idhub/admin/dashboard.html @@ -10,131 +10,20 @@ - - - - - + + + + {% for ev in events %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + {% endfor %}
#
1,001randomdataplaceholdertext
1,002placeholderirrelevantvisuallayout
1,003datarichdashboardtabular
1,003informationplaceholderillustrativedata
1,004textrandomlayoutdashboard
1,005dashboardirrelevanttextplaceholder
1,006dashboardillustrativerichdata
1,007placeholdertabularinformationirrelevant
1,008randomdataplaceholdertext
1,009placeholderirrelevantvisuallayout
1,010datarichdashboardtabular
1,011informationplaceholderillustrativedata
1,012textplaceholderlayoutdashboard
1,013dashboardirrelevanttextvisual
1,014dashboardillustrativerichdata
1,015randomtabularinformationtext{{ ev.get_type }}{{ ev.message }}{{ ev.created }}
-
-
-
-
{% endblock %} diff --git a/idhub/templates/idhub/user/dashboard.html b/idhub/templates/idhub/user/dashboard.html index 29154f4..4586035 100644 --- a/idhub/templates/idhub/user/dashboard.html +++ b/idhub/templates/idhub/user/dashboard.html @@ -10,131 +10,20 @@ - - - - - + + + + {% for ev in user.events.all %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + {% endfor %}
#
1,001randomdataplaceholdertext
1,002placeholderirrelevantvisuallayout
1,003datarichdashboardtabular
1,003informationplaceholderillustrativedata
1,004textrandomlayoutdashboard
1,005dashboardirrelevanttextplaceholder
1,006dashboardillustrativerichdata
1,007placeholdertabularinformationirrelevant
1,008randomdataplaceholdertext
1,009placeholderirrelevantvisuallayout
1,010datarichdashboardtabular
1,011informationplaceholderillustrativedata
1,012textplaceholderlayoutdashboard
1,013dashboardirrelevanttextvisual
1,014dashboardillustrativerichdata
1,015randomtabularinformationtext{{ ev.get_type }}{{ ev.message }}{{ ev.created }}
-
-
-
-
{% endblock %} diff --git a/idhub/user/forms.py b/idhub/user/forms.py index a8f6997..62ca3a0 100644 --- a/idhub/user/forms.py +++ b/idhub/user/forms.py @@ -72,23 +72,23 @@ class CredentialPresentationForm(forms.Form): ] def save(self, commit=True): - org = Organization.objects.filter( + self.org = Organization.objects.filter( id=self.data['organization'] ) - cred = VerificableCredential.objects.filter( + self.cred = VerificableCredential.objects.filter( user=self.user, id=self.data['credential'], status=VerificableCredential.Status.ISSUED ) - if not all([org.exists(), cred.exists()]): + if not all([self.org.exists(), self.cred.exists()]): return - org =org[0] - cred = cred[0] + self.org = self.org[0] + self.cred = self.cred[0] if commit: - org.send(cred) - return cred + self.org.send(self.cred) + return self.cred return diff --git a/idhub/user/views.py b/idhub/user/views.py index f45f7e6..11f43ab 100644 --- a/idhub/user/views.py +++ b/idhub/user/views.py @@ -15,7 +15,7 @@ from django.contrib import messages from utils.apiregiter import iota from idhub.user.forms import ProfileForm, RequestCredentialForm, CredentialPresentationForm from idhub.mixins import UserView -from idhub.models import DID, VerificableCredential +from idhub.models import DID, VerificableCredential, Event class MyProfile(UserView): @@ -125,6 +125,8 @@ class CredentialsRequestView(MyWallet, FormView): cred = form.save() if cred: messages.success(self.request, _("The credential was required successfully!")) + Event.set_EV_CREDENTIAL_ISSUED_FOR_USER(cred) + Event.set_EV_CREDENTIAL_ISSUED(cred) else: messages.error(self.request, _("Not exists the credential!")) return super().form_valid(form) @@ -145,6 +147,8 @@ class CredentialsPresentationView(MyWallet, FormView): def form_valid(self, form): cred = form.save() if cred: + Event.set_EV_CREDENTIAL_PRESENTED_BY_USER(cred, form.org) + Event.set_EV_CREDENTIAL_PRESENTED(cred, form.org) messages.success(self.request, _("The credential was presented successfully!")) else: messages.error(self.request, _("Error sending credential!")) @@ -174,18 +178,14 @@ class DidRegisterView(MyWallet, CreateView): success_url = reverse_lazy('idhub:user_dids') object = None - # def get_form_kwargs(self): - # kwargs = super().get_form_kwargs() - # kwargs['initial'] = { - # 'user': self.request.user - # } - # return kwargs - def form_valid(self, form): form.instance.user = self.request.user form.instance.did = iota.issue_did() form.save() messages.success(self.request, _('DID created successfully')) + + Event.set_EV_DID_CREATED(form.instance) + Event.set_EV_DID_CREATED_BY_USER(form.instance) return super().form_valid(form) @@ -219,7 +219,9 @@ class DidDeleteView(MyWallet, DeleteView): def get(self, request, *args, **kwargs): self.pk = kwargs['pk'] self.object = get_object_or_404(self.model, pk=self.pk) + Event.set_EV_DID_DELETED(self.object) self.object.delete() messages.success(self.request, _('DID delete successfully')) return redirect(self.success_url) + From 7096e97c3961e42e97291c0eedd18b17f40cf908 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 9 Nov 2023 18:09:10 +0100 Subject: [PATCH 2/9] disable form of user profile --- idhub/templates/idhub/user/profile.html | 5 ----- idhub/user/views.py | 10 ++++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/idhub/templates/idhub/user/profile.html b/idhub/templates/idhub/user/profile.html index da1597a..fe5d6e8 100644 --- a/idhub/templates/idhub/user/profile.html +++ b/idhub/templates/idhub/user/profile.html @@ -31,11 +31,6 @@
{% endif %} {% bootstrap_form form %} - -
diff --git a/idhub/user/views.py b/idhub/user/views.py index 11f43ab..16df7b9 100644 --- a/idhub/user/views.py +++ b/idhub/user/views.py @@ -47,6 +47,16 @@ class ProfileView(MyProfile, UpdateView): def get_object(self): return self.request.user + def get_form(self): + form = super().get_form() + form.fields['first_name'].disabled = True + form.fields['last_name'].disabled = True + form.fields['email'].disabled = True + return form + + def form_valid(self, form): + return super().form_valid(form) + class RolesView(MyProfile, TemplateView): template_name = "idhub/user/roles.html" From 2d5077129d89d4a43483c068edb76b6d3b529713 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 10 Nov 2023 16:22:41 +0100 Subject: [PATCH 3/9] fix translate --- idhub/models.py | 170 ++++++++++++++++++----------------- trustchain_idhub/settings.py | 7 +- 2 files changed, 93 insertions(+), 84 deletions(-) diff --git a/idhub/models.py b/idhub/models.py index 30eba0a..fdbf587 100644 --- a/idhub/models.py +++ b/idhub/models.py @@ -55,10 +55,10 @@ class Event(models.Model): @classmethod def set_EV_USR_REGISTERED(cls, user): - msg = "The user {} was registered: name: {}, last name: {}".format( - user.username, - user.first_name, - user.last_name + msg = _("The user {username} was registered: name: {first_name}, last name: {last_name}").format( + username=user.username, + first_name=user.first_name, + last_name=user.last_name ) cls.objects.create( type=cls.Types.EV_USR_REGISTERED, @@ -67,9 +67,9 @@ class Event(models.Model): @classmethod def set_EV_USR_WELCOME(cls, user): - msg = "Welcome. You has been registered: name: {}, last name: {}".format( - user.first_name, - user.last_name + msg = _("Welcome. You has been registered: name: {first_name}, last name: {last_name}").format( + first_name=user.first_name, + last_name=user.last_name ) cls.objects.create( type=cls.Types.EV_USR_WELCOME, @@ -80,9 +80,9 @@ class Event(models.Model): # Is required? @classmethod def set_EV_DATA_UPDATE_REQUESTED_BY_USER(cls, user): - msg = "The user '{}' has request the update of the following information: " + msg = _("The user '{username}' has request the update of the following information: ") msg += "['field1':'value1', 'field2':'value2'>,...]".format( - user.username, + username=user.username, ) cls.objects.create( type=cls.Types.EV_DATA_UPDATE_REQUESTED_BY_USER, @@ -92,7 +92,7 @@ class Event(models.Model): # Is required? @classmethod def set_EV_DATA_UPDATE_REQUESTED(cls, user): - msg = "You have requested the update of the following information: " + msg = _("You have requested the update of the following information: ") msg += "['field1':'value1', 'field2':'value2'>,...]" cls.objects.create( type=cls.Types.EV_DATA_UPDATE_REQUESTED, @@ -103,9 +103,10 @@ class Event(models.Model): @classmethod def set_EV_USR_UPDATED_BY_ADMIN(cls, user): msg = "The admin has updated the following user 's information: " - msg += "name: {}, last name: {}".format( - user.first_name, - user.last_name + msg += "name: {first_name}, last name: {last_name}" + msg = _(msg).format( + first_name=user.first_name, + last_name=user.last_name ) cls.objects.create( type=cls.Types.EV_USR_UPDATED_BY_ADMIN, @@ -115,9 +116,10 @@ class Event(models.Model): @classmethod def set_EV_USR_UPDATED(cls, user): msg = "The admin has updated your personal information: " - msg += "name: {}, last name: {}".format( - user.first_name, - user.last_name + msg += "name: {first_name}, last name: {last_name}" + msg = _(msg).format( + first_name=user.first_name, + last_name=user.last_name ) cls.objects.create( type=cls.Types.EV_USR_UPDATED, @@ -127,8 +129,8 @@ class Event(models.Model): @classmethod def set_EV_USR_DELETED_BY_ADMIN(cls, user): - msg = "The admin has deleted the user: username: {}".format( - user.username, + msg = _("The admin has deleted the user: username: {username}").format( + username=user.username, ) cls.objects.create( type=cls.Types.EV_USR_DELETED_BY_ADMIN, @@ -137,9 +139,9 @@ class Event(models.Model): @classmethod def set_EV_DID_CREATED_BY_USER(cls, did): - msg = "New DID with DID-ID: '{}' created by user '{}'".format( - did.did, - did.user.username + msg = _("New DID with DID-ID: '{did}' created by user '{username}'").format( + did=did.did, + username=did.user.username ) cls.objects.create( type=cls.Types.EV_DID_CREATED_BY_USER, @@ -148,9 +150,9 @@ class Event(models.Model): @classmethod def set_EV_DID_CREATED(cls, did): - msg = "New DID with label: '{}' and DID-ID: '{}' was created'".format( - did.label, - did.did + msg = _("New DID with label: '{label}' and DID-ID: '{did}' was created'").format( + label=did.label, + did=did.did ) cls.objects.create( type=cls.Types.EV_DID_CREATED, @@ -160,9 +162,9 @@ class Event(models.Model): @classmethod def set_EV_DID_DELETED(cls, did): - msg = "The DID with label '{}' and DID-ID: '{}' was deleted from your wallet".format( - did.label, - did.did + msg = _("The DID with label '{label}' and DID-ID: '{did}' was deleted from your wallet").format( + label=did.label, + did=did.did ) cls.objects.create( type=cls.Types.EV_DID_DELETED, @@ -172,9 +174,9 @@ class Event(models.Model): @classmethod def set_EV_CREDENTIAL_DELETED_BY_ADMIN(cls, cred): - msg = "The credential of type '{}' and ID: '{}' was deleted".format( - cred.type(), - cred.id, + msg = _("The credential of type '{type}' and ID: '{id}' was deleted").format( + type=cred.type(), + id=cred.id, ) cls.objects.create( type=cls.Types.EV_CREDENTIAL_DELETED_BY_ADMIN, @@ -183,9 +185,9 @@ class Event(models.Model): @classmethod def set_EV_CREDENTIAL_DELETED(cls, cred): - msg = "The credential of type '{}' and ID: '{}' was deleted from your wallet".format( - cred.type(), - cred.id + msg = _("The credential of type '{type}' and ID: '{id}' was deleted from your wallet").format( + type=cred.type(), + id=cred.id ) cls.objects.create( type=cls.Types.EV_CREDENTIAL_DELETED, @@ -195,10 +197,10 @@ class Event(models.Model): @classmethod def set_EV_CREDENTIAL_ISSUED_FOR_USER(cls, cred): - msg = "The credential of type '{}' and ID: '{}' was issued for user {}".format( - cred.type(), - cred.id, - cred.user.username + msg = _("The credential of type '{type}' and ID: '{id}' was issued for user {username}").format( + type=cred.type(), + id=cred.id, + username=cred.user.username ) cls.objects.create( type=cls.Types.EV_CREDENTIAL_ISSUED_FOR_USER, @@ -207,9 +209,9 @@ class Event(models.Model): @classmethod def set_EV_CREDENTIAL_ISSUED(cls, cred): - msg = "The credential of type '{}' and ID: '{}' was issued and stored in your wallet".format( - cred.type(), - cred.id + msg = _("The credential of type '{type}' and ID: '{id}' was issued and stored in your wallet").format( + type=cred.type(), + id=cred.id ) cls.objects.create( type=cls.Types.EV_CREDENTIAL_ISSUED, @@ -219,11 +221,13 @@ class Event(models.Model): @classmethod def set_EV_CREDENTIAL_PRESENTED_BY_USER(cls, cred, verifier): - msg = "The credential of type '{}' and ID: '{}' was presented by user {} to verifier '{}".format( - cred.type(), - cred.id, - cred.user.username, - verifier + msg = "The credential of type '{type}' and ID: '{id}' " + msg += "was presented by user {username} to verifier '{verifier}" + msg = _(msg).format( + type=cred.type(), + id=cred.id, + username=cred.user.username, + verifier=verifier ) cls.objects.create( type=cls.Types.EV_CREDENTIAL_PRESENTED_BY_USER, @@ -232,10 +236,12 @@ class Event(models.Model): @classmethod def set_EV_CREDENTIAL_PRESENTED(cls, cred, verifier): - msg = "The credential of type '{}' and ID: '{}' was presented to verifier '{}'".format( - cred.type(), - cred.id, - verifier + msg = "The credential of type '{type}' and ID: '{id}' " + msg += "was presented to verifier '{verifier}'" + msg = _(msg).format( + type=cred.type(), + id=cred.id, + verifier=verifier ) cls.objects.create( type=cls.Types.EV_CREDENTIAL_PRESENTED, @@ -245,9 +251,9 @@ class Event(models.Model): @classmethod def set_EV_CREDENTIAL_ENABLED(cls, cred): - msg = "The credential of type '{}' was enabled for user {}".format( - cred.type(), - cred.user.username + msg = _("The credential of type '{type}' was enabled for user {username}").format( + type=cred.type(), + username=cred.user.username ) cls.objects.create( type=cls.Types.EV_CREDENTIAL_ENABLED, @@ -256,8 +262,8 @@ class Event(models.Model): @classmethod def set_EV_CREDENTIAL_CAN_BE_REQUESTED(cls, cred): - msg = "You can request the '{}' credential".format( - cred.type() + msg = _("You can request the '{type}' credential").format( + type=cred.type() ) cls.objects.create( type=cls.Types.EV_CREDENTIAL_CAN_BE_REQUESTED, @@ -267,9 +273,9 @@ class Event(models.Model): @classmethod def set_EV_CREDENTIAL_REVOKED_BY_ADMIN(cls, cred): - msg = "The credential of type '{}' and ID: '{}' was revoked for ".format( - cred.type(), - cred.id + msg = _("The credential of type '{type}' and ID: '{id}' was revoked for ").format( + type=cred.type(), + id=cred.id ) cls.objects.create( type=cls.Types.EV_CREDENTIAL_REVOKED_BY_ADMIN, @@ -278,9 +284,9 @@ class Event(models.Model): @classmethod def set_EV_CREDENTIAL_REVOKED(cls, cred): - msg = "The credential of type '{}' and ID: '{}' was revoked by admin".format( - cred.type(), - cred.id + msg = _("The credential of type '{type}' and ID: '{id}' was revoked by admin").format( + type=cred.type(), + id=cred.id ) cls.objects.create( type=cls.Types.EV_CREDENTIAL_REVOKED, @@ -290,7 +296,7 @@ class Event(models.Model): @classmethod def set_EV_ROLE_CREATED_BY_ADMIN(cls): - msg = 'A new role was created by admin' + msg = _('A new role was created by admin') cls.objects.create( type=cls.Types.EV_ROLE_CREATED_BY_ADMIN, message=msg, @@ -298,7 +304,7 @@ class Event(models.Model): @classmethod def set_EV_ROLE_MODIFIED_BY_ADMIN(cls): - msg = 'The role was modified by admin' + msg = _('The role was modified by admin') cls.objects.create( type=cls.Types.EV_ROLE_MODIFIED_BY_ADMIN, message=msg, @@ -306,7 +312,7 @@ class Event(models.Model): @classmethod def set_EV_ROLE_DELETED_BY_ADMIN(cls): - msg = 'The role was removed by admin' + msg = _('The role was removed by admin') cls.objects.create( type=cls.Types.EV_ROLE_DELETED_BY_ADMIN, message=msg, @@ -314,7 +320,7 @@ class Event(models.Model): @classmethod def set_EV_SERVICE_CREATED_BY_ADMIN(cls): - msg = 'A new service was created by admin' + msg = _('A new service was created by admin') cls.objects.create( type=cls.Types.EV_SERVICE_CREATED_BY_ADMIN, message=msg, @@ -322,7 +328,7 @@ class Event(models.Model): @classmethod def set_EV_SERVICE_MODIFIED_BY_ADMIN(cls): - msg = 'The service was modified by admin' + msg = _('The service was modified by admin') cls.objects.create( type=cls.Types.EV_SERVICE_MODIFIED_BY_ADMIN, message=msg, @@ -330,7 +336,7 @@ class Event(models.Model): @classmethod def set_EV_SERVICE_DELETED_BY_ADMIN(cls): - msg = 'The service was removed by admin' + msg = _('The service was removed by admin') cls.objects.create( type=cls.Types.EV_SERVICE_DELETED_BY_ADMIN, message=msg, @@ -338,9 +344,9 @@ class Event(models.Model): @classmethod def set_EV_ORG_DID_CREATED_BY_ADMIN(cls, did): - msg = "New Organisational DID with label: '{}' and DID-ID: '{}' was created".format( - did.label, - did.did + msg = _("New Organisational DID with label: '{label}' and DID-ID: '{did}' was created").format( + label=did.label, + did=did.did ) cls.objects.create( type=cls.Types.EV_ORG_DID_CREATED_BY_ADMIN, @@ -349,9 +355,9 @@ class Event(models.Model): @classmethod def set_EV_ORG_DID_DELETED_BY_ADMIN(cls, did): - msg = "Organisational DID with label: '{}' and DID-ID: '{}' was removed".format( - did.label, - did.did + msg = _("Organisational DID with label: '{label}' and DID-ID: '{did}' was removed").format( + label=did.label, + did=did.did ) cls.objects.create( type=cls.Types.EV_ORG_DID_DELETED_BY_ADMIN, @@ -360,10 +366,12 @@ class Event(models.Model): @classmethod def set_EV_USR_DEACTIVATED_BY_ADMIN(cls, user): - msg = "The user '{}' was temporarily deactivated: [name:'{}', last name:'{}']".format( - user.username, - user.first_name, - user.last_name + msg = "The user '{username}' was temporarily deactivated: " + msg += "[name:'{first_name}', last name:'{last_name}']" + msg = _(msg).format( + username=user.username, + first_name=user.first_name, + last_name=user.last_name ) cls.objects.create( type=cls.Types.EV_USR_DEACTIVATED_BY_ADMIN, @@ -372,10 +380,12 @@ class Event(models.Model): @classmethod def set_EV_USR_ACTIVATED_BY_ADMIN(cls, user): - msg = "The user '{}' was activated: [name:'{}', last name:'{}']".format( - user.username, - user.first_name, - user.last_name + msg = "The user '{username}' was activated: " + msg += "name:'{first_name}', last name:'{last_name}']" + msg = _(msg).format( + username=user.username, + first_name=user.first_name, + last_name=user.last_name ) cls.objects.create( type=cls.Types.EV_USR_ACTIVATED_BY_ADMIN, diff --git a/trustchain_idhub/settings.py b/trustchain_idhub/settings.py index 2537456..fb1c4c3 100644 --- a/trustchain_idhub/settings.py +++ b/trustchain_idhub/settings.py @@ -143,12 +143,8 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization # https://docs.djangoproject.com/en/4.2/topics/i18n/ -LANGUAGE_CODE = 'en-us' - TIME_ZONE = config('TIME_ZONE', 'UTC') -USE_I18N = True - USE_TZ = True @@ -181,5 +177,8 @@ MESSAGE_TAGS = { LOCALE_PATHS = [ os.path.join(BASE_DIR, 'locale'), ] +LANGUAGE_CODE="es" +USE_I18N = True +USE_L10N = True AUTH_USER_MODEL = 'idhub_auth.User' From a6d5fc8c86471aa3569de8f7d1106fee76fc01bb Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 13 Nov 2023 10:15:52 +0100 Subject: [PATCH 4/9] fix translate --- idhub/admin/forms.py | 5 +- idhub/admin/views.py | 59 +- idhub/models.py | 4 +- idhub/templates/idhub/admin/credentials.html | 2 +- idhub/templates/idhub/admin/dids.html | 2 +- idhub/templates/idhub/admin/import.html | 4 +- idhub/templates/idhub/admin/roles.html | 4 +- idhub/templates/idhub/admin/schemas.html | 4 +- .../templates/idhub/admin/schemas_import.html | 2 +- idhub/templates/idhub/admin/services.html | 2 +- idhub/templates/idhub/admin/user.html | 2 +- idhub/templates/idhub/admin/user_edit.html | 4 +- idhub/templates/idhub/user/credentials.html | 2 +- idhub/templates/idhub/user/roles.html | 2 +- idhub/user/views.py | 22 +- locale/ca_ES/LC_MESSAGES/django.po | 487 ++-- locale/es/LC_MESSAGES/django-corregido.po | 2565 +++++++++++++++++ locale/es/LC_MESSAGES/django.mo | Bin 0 -> 465 bytes locale/es/LC_MESSAGES/django.po | 468 ++- 19 files changed, 3252 insertions(+), 388 deletions(-) create mode 100644 locale/es/LC_MESSAGES/django-corregido.po create mode 100644 locale/es/LC_MESSAGES/django.mo diff --git a/idhub/admin/forms.py b/idhub/admin/forms.py index 83c167c..d20d6d7 100644 --- a/idhub/admin/forms.py +++ b/idhub/admin/forms.py @@ -1,6 +1,5 @@ import csv import json -import copy import pandas as pd from jsonschema import validate @@ -104,14 +103,14 @@ class ImportForm(forms.Form): user = User.objects.filter(email=row.get('email')) if not user: - txt = _('The user not exist!') + txt = _('The user does not exist!') msg = "line {}: {}".format(line+1, txt) self.exception(msg) return user.first() def create_credential(self, user, row): - d = copy.copy(self.json_schema) + d = self.json_schema.copy() d['instance'] = row return VerificableCredential( verified=False, diff --git a/idhub/admin/views.py b/idhub/admin/views.py index fa11e6a..2a9a87e 100644 --- a/idhub/admin/views.py +++ b/idhub/admin/views.py @@ -1,6 +1,5 @@ import os import json -import copy import logging import pandas as pd from pathlib import Path @@ -54,33 +53,33 @@ class DashboardView(AdminView, TemplateView): return context class People(AdminView): - title = _("People Management") + title = _("User Management") section = "People" class AccessControl(AdminView, TemplateView): - title = _("Access Control Management") + title = _("Access control management") section = "AccessControl" class Credentials(AdminView, TemplateView): - title = _("Credentials Management") - section = "Credentials" + title = _("Credential Management") + section = "Credential" class SchemasMix(AdminView, TemplateView): - title = _("Templates Management") - section = "Templates" + title = _("Template Management") + section = "Template" class ImportExport(AdminView): - title = _("Massive Data Management") + title = _("Data file management") section = "ImportExport" class PeopleListView(People, TemplateView): template_name = "idhub/admin/people.html" - subtitle = _('People list') + subtitle = _('View users') icon = 'bi bi-person' def get_context_data(self, **kwargs): @@ -93,7 +92,7 @@ class PeopleListView(People, TemplateView): class PeopleView(People, TemplateView): template_name = "idhub/admin/user.html" - subtitle = _('User Profile') + subtitle = _('User personal information') icon = 'bi bi-person' model = User @@ -177,7 +176,7 @@ class PeopleRegisterView(NotifyActivateUserByEmail, People, CreateView): def form_valid(self, form): user = form.save() - messages.success(self.request, _('The account is created successfully')) + messages.success(self.request, _('The account was created successfully')) Event.set_EV_USR_REGISTERED(user) Event.set_EV_USR_WELCOME(user) @@ -191,7 +190,7 @@ class PeopleRegisterView(NotifyActivateUserByEmail, People, CreateView): class PeopleMembershipRegisterView(People, CreateView): template_name = "idhub/admin/people_membership_register.html" - subtitle = _('People add membership') + subtitle = _('Associate a membership to the user') icon = 'bi bi-person' model = Membership fields = ('type', 'start_date', 'end_date') @@ -266,7 +265,7 @@ class PeopleMembershipDeleteView(PeopleView): class PeopleRolRegisterView(People, CreateView): template_name = "idhub/admin/people_rol_register.html" - subtitle = _('Add Rol to User') + subtitle = _('Add a user role to access a service') icon = 'bi bi-person' model = UserRol fields = ('service',) @@ -296,7 +295,7 @@ class PeopleRolRegisterView(People, CreateView): class PeopleRolEditView(People, CreateView): template_name = "idhub/admin/people_rol_register.html" - subtitle = _('Edit Rol to User') + subtitle = _('Modify a user role to access a service') icon = 'bi bi-person' model = UserRol fields = ('service',) @@ -331,7 +330,7 @@ class PeopleRolDeleteView(PeopleView): class RolesView(AccessControl): template_name = "idhub/admin/roles.html" - subtitle = _('Roles Management') + subtitle = _('Role Management') icon = '' def get_context_data(self, **kwargs): @@ -343,7 +342,7 @@ class RolesView(AccessControl): class RolRegisterView(AccessControl, CreateView): template_name = "idhub/admin/rol_register.html" - subtitle = _('Add Rol') + subtitle = _('Add Role') icon = '' model = Rol fields = ('name',) @@ -352,14 +351,14 @@ class RolRegisterView(AccessControl, CreateView): def form_valid(self, form): form.save() - messages.success(self.request, _('Rol created successfully')) + messages.success(self.request, _('Role created successfully')) Event.set_EV_ROLE_CREATED_BY_ADMIN() return super().form_valid(form) class RolEditView(AccessControl, CreateView): template_name = "idhub/admin/rol_register.html" - subtitle = _('Edit Rol') + subtitle = _('Edit Role') icon = '' model = Rol fields = ('name',) @@ -374,7 +373,7 @@ class RolEditView(AccessControl, CreateView): def form_valid(self, form): form.save() - messages.success(self.request, _('Rol updated successfully')) + messages.success(self.request, _('Role updated successfully')) Event.set_EV_ROLE_MODIFIED_BY_ADMIN() return super().form_valid(form) @@ -387,14 +386,14 @@ class RolDeleteView(AccessControl): self.object = get_object_or_404(self.model, pk=self.pk) self.object.delete() - messages.success(self.request, _('Rol deleted successfully')) + messages.success(self.request, _('Role deleted successfully')) Event.set_EV_ROLE_DELETED_BY_ADMIN() return redirect('idhub:admin_roles') class ServicesView(AccessControl): template_name = "idhub/admin/services.html" - subtitle = _('Service Management') + subtitle = _('Service management') icon = '' def get_context_data(self, **kwargs): @@ -406,7 +405,7 @@ class ServicesView(AccessControl): class ServiceRegisterView(AccessControl, CreateView): template_name = "idhub/admin/service_register.html" - subtitle = _('Add Service') + subtitle = _('Add service') icon = '' model = Service fields = ('domain', 'description', 'rol') @@ -422,7 +421,7 @@ class ServiceRegisterView(AccessControl, CreateView): class ServiceEditView(AccessControl, CreateView): template_name = "idhub/admin/service_register.html" - subtitle = _('Edit Service') + subtitle = _('Modify service') icon = '' model = Service fields = ('domain', 'description', 'rol') @@ -457,7 +456,7 @@ class ServiceDeleteView(AccessControl): class CredentialsView(Credentials): template_name = "idhub/admin/credentials.html" - subtitle = _('Credentials list') + subtitle = _('Credential list') icon = '' def get_context_data(self, **kwargs): @@ -611,21 +610,21 @@ class DidDeleteView(Credentials, DeleteView): class WalletCredentialsView(Credentials): template_name = "idhub/admin/wallet_credentials.html" - subtitle = _('Credentials') + subtitle = _('Credential management') icon = 'bi bi-patch-check-fill' wallet = True class WalletConfigIssuesView(Credentials): template_name = "idhub/admin/wallet_issues.html" - subtitle = _('Configure Issues') + subtitle = _('Configure credential issuance') icon = 'bi bi-patch-check-fill' wallet = True class SchemasView(SchemasMix): template_name = "idhub/admin/schemas.html" - subtitle = _('Template List') + subtitle = _('View credential templates') icon = '' def get_context_data(self, **kwargs): @@ -659,7 +658,7 @@ class SchemasDownloadView(SchemasMix): class SchemasNewView(SchemasMix): template_name = "idhub/admin/schemas_new.html" - subtitle = _('Upload Template') + subtitle = _('Upload template') icon = '' success_url = reverse_lazy('idhub:admin_schemas') @@ -704,7 +703,7 @@ class SchemasNewView(SchemasMix): class SchemasImportView(SchemasMix): template_name = "idhub/admin/schemas_import.html" - subtitle = _('Import Template') + subtitle = _('Import template') icon = '' def get_context_data(self, **kwargs): @@ -732,7 +731,7 @@ class SchemasImportAddView(SchemasMix): schema = self.create_schema(file_name) if schema: - messages.success(self.request, _("The schema add successfully!")) + messages.success(self.request, _("The schema was added sucessfully")) return redirect('idhub:admin_schemas_import') def create_schema(self, file_name): diff --git a/idhub/models.py b/idhub/models.py index fdbf587..88b098c 100644 --- a/idhub/models.py +++ b/idhub/models.py @@ -498,7 +498,7 @@ class Membership(models.Model): class Types(models.IntegerChoices): BENEFICIARY = 1, _('Beneficiary') EMPLOYEE = 2, _('Employee') - PARTNER = 3, _('Partner') + MEMBER = 3, _('Member') type = models.PositiveSmallIntegerField(_('Type of membership'), choices=Types.choices) start_date = models.DateField( @@ -509,7 +509,7 @@ class Membership(models.Model): ) end_date = models.DateField( _('End date'), - help_text=_('What date did the membership end?'), + help_text=_('What date will the membership end?'), blank=True, null=True ) diff --git a/idhub/templates/idhub/admin/credentials.html b/idhub/templates/idhub/admin/credentials.html index 0d7e84c..819535e 100644 --- a/idhub/templates/idhub/admin/credentials.html +++ b/idhub/templates/idhub/admin/credentials.html @@ -14,7 +14,7 @@ - + diff --git a/idhub/templates/idhub/admin/dids.html b/idhub/templates/idhub/admin/dids.html index 0bac4c5..88cff01 100644 --- a/idhub/templates/idhub/admin/dids.html +++ b/idhub/templates/idhub/admin/dids.html @@ -32,7 +32,7 @@
diff --git a/idhub/templates/idhub/admin/import.html b/idhub/templates/idhub/admin/import.html index 0b74600..288c872 100644 --- a/idhub/templates/idhub/admin/import.html +++ b/idhub/templates/idhub/admin/import.html @@ -14,7 +14,7 @@ - + @@ -28,7 +28,7 @@
- {% translate "Import Datas" %} + {% translate "Import data" %}
diff --git a/idhub/templates/idhub/admin/roles.html b/idhub/templates/idhub/admin/roles.html index feed044..dbb5277 100644 --- a/idhub/templates/idhub/admin/roles.html +++ b/idhub/templates/idhub/admin/roles.html @@ -12,7 +12,7 @@ - + @@ -28,7 +28,7 @@
- {% translate "Add Rol" %} + {% translate "Add Role" %}
diff --git a/idhub/templates/idhub/admin/schemas.html b/idhub/templates/idhub/admin/schemas.html index 2aa2e88..2696b01 100644 --- a/idhub/templates/idhub/admin/schemas.html +++ b/idhub/templates/idhub/admin/schemas.html @@ -34,7 +34,7 @@
- {% translate "Add Template" %} + {% translate "Add template" %}
@@ -45,7 +45,7 @@