pyvckit #1

Merged
cayop merged 17 commits from pyvckit into release 2024-06-11 15:10:32 +00:00
1 changed files with 33 additions and 33 deletions
Showing only changes of commit 32ad6edd9d - Show all commits

View File

@ -96,7 +96,7 @@ class Event(models.Model):
message=msg, message=msg,
user=user user=user
) )
# Is required? # Is required?
@classmethod @classmethod
def set_EV_DATA_UPDATE_REQUESTED_BY_USER(cls, user): def set_EV_DATA_UPDATE_REQUESTED_BY_USER(cls, user):
@ -107,7 +107,7 @@ class Event(models.Model):
type=cls.Types.EV_DATA_UPDATE_REQUESTED_BY_USER, type=cls.Types.EV_DATA_UPDATE_REQUESTED_BY_USER,
message=msg, message=msg,
) )
# Is required? # Is required?
@classmethod @classmethod
def set_EV_DATA_UPDATE_REQUESTED(cls, user): def set_EV_DATA_UPDATE_REQUESTED(cls, user):
@ -118,7 +118,7 @@ class Event(models.Model):
message=msg, message=msg,
user=user user=user
) )
@classmethod @classmethod
def set_EV_USR_UPDATED_BY_ADMIN(cls, user): def set_EV_USR_UPDATED_BY_ADMIN(cls, user):
msg = "The admin has updated the following user 's information: " msg = "The admin has updated the following user 's information: "
@ -145,7 +145,7 @@ class Event(models.Model):
message=msg, message=msg,
user=user user=user
) )
@classmethod @classmethod
def set_EV_USR_DELETED_BY_ADMIN(cls, user): def set_EV_USR_DELETED_BY_ADMIN(cls, user):
msg = _("The admin has deleted the user: username: {username}").format( msg = _("The admin has deleted the user: username: {username}").format(
@ -155,7 +155,7 @@ class Event(models.Model):
type=cls.Types.EV_USR_DELETED_BY_ADMIN, type=cls.Types.EV_USR_DELETED_BY_ADMIN,
message=msg message=msg
) )
@classmethod @classmethod
def set_EV_DID_CREATED_BY_USER(cls, did): def set_EV_DID_CREATED_BY_USER(cls, did):
msg = _("New DID with DID-ID: '{did}' created by user '{username}'").format( msg = _("New DID with DID-ID: '{did}' created by user '{username}'").format(
@ -166,7 +166,7 @@ class Event(models.Model):
type=cls.Types.EV_DID_CREATED_BY_USER, type=cls.Types.EV_DID_CREATED_BY_USER,
message=msg, message=msg,
) )
@classmethod @classmethod
def set_EV_DID_CREATED(cls, did): def set_EV_DID_CREATED(cls, did):
msg = _("New DID with label: '{label}' and DID-ID: '{did}' was created'").format( msg = _("New DID with label: '{label}' and DID-ID: '{did}' was created'").format(
@ -178,10 +178,10 @@ class Event(models.Model):
message=msg, message=msg,
user=did.user user=did.user
) )
@classmethod @classmethod
def set_EV_DID_DELETED(cls, did): def set_EV_DID_DELETED(cls, did):
msg = _("The DID with label '{label}' and DID-ID: '{did}' was deleted from your wallet").format( msg = _("The DID with label '{label}' and DID-ID: '{did}' was deleted from your wallet").format(
label=did.label, label=did.label,
did=did.did did=did.did
) )
@ -190,7 +190,7 @@ class Event(models.Model):
message=msg, message=msg,
user=did.user user=did.user
) )
@classmethod @classmethod
def set_EV_CREDENTIAL_DELETED_BY_ADMIN(cls, cred): def set_EV_CREDENTIAL_DELETED_BY_ADMIN(cls, cred):
msg = _("The credential of type '{type}' and ID: '{id}' was deleted").format( msg = _("The credential of type '{type}' and ID: '{id}' was deleted").format(
@ -201,7 +201,7 @@ class Event(models.Model):
type=cls.Types.EV_CREDENTIAL_DELETED_BY_ADMIN, type=cls.Types.EV_CREDENTIAL_DELETED_BY_ADMIN,
message=msg, message=msg,
) )
@classmethod @classmethod
def set_EV_CREDENTIAL_DELETED(cls, cred): def set_EV_CREDENTIAL_DELETED(cls, cred):
msg = _("The credential of type '{type}' and ID: '{id}' was deleted from your wallet").format( msg = _("The credential of type '{type}' and ID: '{id}' was deleted from your wallet").format(
@ -213,7 +213,7 @@ class Event(models.Model):
message=msg, message=msg,
user=cred.user user=cred.user
) )
@classmethod @classmethod
def set_EV_CREDENTIAL_ISSUED_FOR_USER(cls, cred): def set_EV_CREDENTIAL_ISSUED_FOR_USER(cls, cred):
msg = _("The credential of type '{type}' and ID: '{id}' was issued for user {username}").format( msg = _("The credential of type '{type}' and ID: '{id}' was issued for user {username}").format(
@ -225,7 +225,7 @@ class Event(models.Model):
type=cls.Types.EV_CREDENTIAL_ISSUED_FOR_USER, type=cls.Types.EV_CREDENTIAL_ISSUED_FOR_USER,
message=msg, message=msg,
) )
@classmethod @classmethod
def set_EV_CREDENTIAL_ISSUED(cls, cred): def set_EV_CREDENTIAL_ISSUED(cls, cred):
msg = _("The credential of type '{type}' and ID: '{id}' was issued and stored in your wallet").format( msg = _("The credential of type '{type}' and ID: '{id}' was issued and stored in your wallet").format(
@ -237,7 +237,7 @@ class Event(models.Model):
message=msg, message=msg,
user=cred.user user=cred.user
) )
@classmethod @classmethod
def set_EV_CREDENTIAL_PRESENTED_BY_USER(cls, cred, verifier): def set_EV_CREDENTIAL_PRESENTED_BY_USER(cls, cred, verifier):
msg = "The credential of type '{type}' and ID: '{id}' " msg = "The credential of type '{type}' and ID: '{id}' "
@ -252,7 +252,7 @@ class Event(models.Model):
type=cls.Types.EV_CREDENTIAL_PRESENTED_BY_USER, type=cls.Types.EV_CREDENTIAL_PRESENTED_BY_USER,
message=msg, message=msg,
) )
@classmethod @classmethod
def set_EV_CREDENTIAL_PRESENTED(cls, cred, verifier): def set_EV_CREDENTIAL_PRESENTED(cls, cred, verifier):
msg = "The credential of type '{type}' and ID: '{id}' " msg = "The credential of type '{type}' and ID: '{id}' "
@ -267,7 +267,7 @@ class Event(models.Model):
message=msg, message=msg,
user=cred.user user=cred.user
) )
@classmethod @classmethod
def set_EV_CREDENTIAL_ENABLED(cls, cred): def set_EV_CREDENTIAL_ENABLED(cls, cred):
msg = _("The credential of type '{type}' was enabled for user {username}").format( msg = _("The credential of type '{type}' was enabled for user {username}").format(
@ -278,7 +278,7 @@ class Event(models.Model):
type=cls.Types.EV_CREDENTIAL_ENABLED, type=cls.Types.EV_CREDENTIAL_ENABLED,
message=msg, message=msg,
) )
@classmethod @classmethod
def set_EV_CREDENTIAL_CAN_BE_REQUESTED(cls, cred): def set_EV_CREDENTIAL_CAN_BE_REQUESTED(cls, cred):
msg = _("You can request the '{type}' credential").format( msg = _("You can request the '{type}' credential").format(
@ -289,7 +289,7 @@ class Event(models.Model):
message=msg, message=msg,
user=cred.user user=cred.user
) )
@classmethod @classmethod
def set_EV_CREDENTIAL_REVOKED_BY_ADMIN(cls, cred): def set_EV_CREDENTIAL_REVOKED_BY_ADMIN(cls, cred):
msg = _("The credential of type '{type}' and ID: '{id}' was revoked for ").format( msg = _("The credential of type '{type}' and ID: '{id}' was revoked for ").format(
@ -300,7 +300,7 @@ class Event(models.Model):
type=cls.Types.EV_CREDENTIAL_REVOKED_BY_ADMIN, type=cls.Types.EV_CREDENTIAL_REVOKED_BY_ADMIN,
message=msg, message=msg,
) )
@classmethod @classmethod
def set_EV_CREDENTIAL_REVOKED(cls, cred): def set_EV_CREDENTIAL_REVOKED(cls, cred):
msg = _("The credential of type '{type}' and ID: '{id}' was revoked by admin").format( msg = _("The credential of type '{type}' and ID: '{id}' was revoked by admin").format(
@ -312,7 +312,7 @@ class Event(models.Model):
message=msg, message=msg,
user=cred.user user=cred.user
) )
@classmethod @classmethod
def set_EV_ROLE_CREATED_BY_ADMIN(cls): def set_EV_ROLE_CREATED_BY_ADMIN(cls):
msg = _('A new role was created by admin') msg = _('A new role was created by admin')
@ -320,7 +320,7 @@ class Event(models.Model):
type=cls.Types.EV_ROLE_CREATED_BY_ADMIN, type=cls.Types.EV_ROLE_CREATED_BY_ADMIN,
message=msg, message=msg,
) )
@classmethod @classmethod
def set_EV_ROLE_MODIFIED_BY_ADMIN(cls): def set_EV_ROLE_MODIFIED_BY_ADMIN(cls):
msg = _('The role was modified by admin') msg = _('The role was modified by admin')
@ -328,7 +328,7 @@ class Event(models.Model):
type=cls.Types.EV_ROLE_MODIFIED_BY_ADMIN, type=cls.Types.EV_ROLE_MODIFIED_BY_ADMIN,
message=msg, message=msg,
) )
@classmethod @classmethod
def set_EV_ROLE_DELETED_BY_ADMIN(cls): def set_EV_ROLE_DELETED_BY_ADMIN(cls):
msg = _('The role was removed by admin') msg = _('The role was removed by admin')
@ -336,7 +336,7 @@ class Event(models.Model):
type=cls.Types.EV_ROLE_DELETED_BY_ADMIN, type=cls.Types.EV_ROLE_DELETED_BY_ADMIN,
message=msg, message=msg,
) )
@classmethod @classmethod
def set_EV_SERVICE_CREATED_BY_ADMIN(cls): def set_EV_SERVICE_CREATED_BY_ADMIN(cls):
msg = _('A new service was created by admin') msg = _('A new service was created by admin')
@ -344,7 +344,7 @@ class Event(models.Model):
type=cls.Types.EV_SERVICE_CREATED_BY_ADMIN, type=cls.Types.EV_SERVICE_CREATED_BY_ADMIN,
message=msg, message=msg,
) )
@classmethod @classmethod
def set_EV_SERVICE_MODIFIED_BY_ADMIN(cls): def set_EV_SERVICE_MODIFIED_BY_ADMIN(cls):
msg = _('The service was modified by admin') msg = _('The service was modified by admin')
@ -352,7 +352,7 @@ class Event(models.Model):
type=cls.Types.EV_SERVICE_MODIFIED_BY_ADMIN, type=cls.Types.EV_SERVICE_MODIFIED_BY_ADMIN,
message=msg, message=msg,
) )
@classmethod @classmethod
def set_EV_SERVICE_DELETED_BY_ADMIN(cls): def set_EV_SERVICE_DELETED_BY_ADMIN(cls):
msg = _('The service was removed by admin') msg = _('The service was removed by admin')
@ -360,7 +360,7 @@ class Event(models.Model):
type=cls.Types.EV_SERVICE_DELETED_BY_ADMIN, type=cls.Types.EV_SERVICE_DELETED_BY_ADMIN,
message=msg, message=msg,
) )
@classmethod @classmethod
def set_EV_ORG_DID_CREATED_BY_ADMIN(cls, did): def set_EV_ORG_DID_CREATED_BY_ADMIN(cls, did):
msg = _("New Organisational DID with label: '{label}' and DID-ID: '{did}' was created").format( msg = _("New Organisational DID with label: '{label}' and DID-ID: '{did}' was created").format(
@ -371,7 +371,7 @@ class Event(models.Model):
type=cls.Types.EV_ORG_DID_CREATED_BY_ADMIN, type=cls.Types.EV_ORG_DID_CREATED_BY_ADMIN,
message=msg, message=msg,
) )
@classmethod @classmethod
def set_EV_ORG_DID_DELETED_BY_ADMIN(cls, did): def set_EV_ORG_DID_DELETED_BY_ADMIN(cls, did):
msg = _("Organisational DID with label: '{label}' and DID-ID: '{did}' was removed").format( msg = _("Organisational DID with label: '{label}' and DID-ID: '{did}' was removed").format(
@ -382,7 +382,7 @@ class Event(models.Model):
type=cls.Types.EV_ORG_DID_DELETED_BY_ADMIN, type=cls.Types.EV_ORG_DID_DELETED_BY_ADMIN,
message=msg, message=msg,
) )
@classmethod @classmethod
def set_EV_USR_DEACTIVATED_BY_ADMIN(cls, user): def set_EV_USR_DEACTIVATED_BY_ADMIN(cls, user):
msg = "The user '{username}' was temporarily deactivated: " msg = "The user '{username}' was temporarily deactivated: "
@ -396,7 +396,7 @@ class Event(models.Model):
type=cls.Types.EV_USR_DEACTIVATED_BY_ADMIN, type=cls.Types.EV_USR_DEACTIVATED_BY_ADMIN,
message=msg, message=msg,
) )
@classmethod @classmethod
def set_EV_USR_ACTIVATED_BY_ADMIN(cls, user): def set_EV_USR_ACTIVATED_BY_ADMIN(cls, user):
msg = "The user '{username}' was activated: " msg = "The user '{username}' was activated: "
@ -418,7 +418,7 @@ class Event(models.Model):
message=msg, message=msg,
user=user user=user
) )
@classmethod @classmethod
def set_EV_USR_SEND_CREDENTIAL(cls, msg): def set_EV_USR_SEND_CREDENTIAL(cls, msg):
cls.objects.create( cls.objects.create(
@ -468,7 +468,7 @@ class DID(models.Model):
user.set_encrypted_sensitive_data() user.set_encrypted_sensitive_data()
user.save() user.save()
self.key_material = user.encrypt_data(value) self.key_material = user.encrypt_data(value)
def set_did(self): def set_did(self):
new_key_material = generate_keys() new_key_material = generate_keys()
self.set_key_material(new_key_material) self.set_key_material(new_key_material)
@ -772,7 +772,7 @@ class VerificableCredential(models.Model):
tmpl = get_template(template_name) tmpl = get_template(template_name)
d = json.loads(tmpl.render({})) d = json.loads(tmpl.render({}))
self.type = d.get('type')[-1] self.type = d.get('type')[-1]
def filter_dict(self, dic): def filter_dict(self, dic):
new_dict = OrderedDict() new_dict = OrderedDict()
@ -799,7 +799,7 @@ class File_datas(models.Model):
class Membership(models.Model): class Membership(models.Model):
""" """
This model represent the relation of this user with the ecosystem. This model represent the relation of this user with the ecosystem.
""" """
class Types(models.IntegerChoices): class Types(models.IntegerChoices):
BENEFICIARY = 1, _('Beneficiary') BENEFICIARY = 1, _('Beneficiary')
@ -849,7 +849,7 @@ class Service(models.Model):
if self.rol.exists(): if self.rol.exists():
return ", ".join([x.name for x in self.rol.order_by("name")]) return ", ".join([x.name for x in self.rol.order_by("name")])
return _("None") return _("None")
def __str__(self): def __str__(self):
return "{} -> {}".format(self.domain, self.get_roles()) return "{} -> {}".format(self.domain, self.get_roles())