2023-09-26 07:15:28 +00:00
|
|
|
from django.db import models
|
2023-10-16 17:08:18 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from django.contrib.auth.models import User
|
2023-09-26 07:15:28 +00:00
|
|
|
|
2023-09-28 09:01:14 +00:00
|
|
|
|
2023-10-16 17:08:18 +00:00
|
|
|
# class AppUser(models.Model):
|
2023-09-28 09:01:14 +00:00
|
|
|
# Ya incluye "first_name", "last_name", "email", y "date_joined" heredando de la clase User de django.
|
|
|
|
# Falta ver que más información hay que añadir a nuestros usuarios, como los roles etc.
|
2023-10-16 17:08:18 +00:00
|
|
|
# django_user = models.OneToOneField(DjangoUser, on_delete=models.CASCADE)
|
2023-10-03 03:47:00 +00:00
|
|
|
|
|
|
|
# Extra data, segun entidad/organizacion
|
2023-10-16 17:08:18 +00:00
|
|
|
# pass
|
2023-09-28 09:01:14 +00:00
|
|
|
|
|
|
|
|
2023-10-16 17:08:18 +00:00
|
|
|
# class Event(models.Model):
|
2023-09-28 09:01:14 +00:00
|
|
|
# Para los "audit logs" que se requieren en las pantallas.
|
2023-10-16 17:08:18 +00:00
|
|
|
# timestamp = models.DateTimeField()
|
2023-10-10 06:43:08 +00:00
|
|
|
# Los eventos no tienen relación con otros objetos a nivel de BBDD.
|
2023-10-16 17:08:18 +00:00
|
|
|
# event_data = models.CharField(max_length=250)
|
2023-09-28 09:01:14 +00:00
|
|
|
|
|
|
|
|
2023-10-10 06:43:08 +00:00
|
|
|
class DID(models.Model):
|
2023-09-28 09:01:14 +00:00
|
|
|
did_string = models.CharField(max_length=250)
|
2023-10-10 06:43:08 +00:00
|
|
|
label = models.CharField(max_length=50)
|
2023-10-16 17:08:18 +00:00
|
|
|
user = models.ForeignKey(
|
|
|
|
User,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
related_name='dids',
|
|
|
|
)
|
2023-10-10 06:43:08 +00:00
|
|
|
# kind = "KEY|WEB"
|
2023-09-28 09:01:14 +00:00
|
|
|
|
|
|
|
|
2023-10-10 06:43:08 +00:00
|
|
|
class VerifiableCredential(models.Model):
|
2023-09-28 09:01:14 +00:00
|
|
|
id_string = models.CharField(max_length=250)
|
|
|
|
verified = models.BooleanField()
|
|
|
|
created_on = models.DateTimeField()
|
2023-10-10 06:43:08 +00:00
|
|
|
did_issuer = models.CharField(max_length=250)
|
|
|
|
did_subject = models.CharField(max_length=250)
|
2023-10-16 17:08:18 +00:00
|
|
|
user = models.ForeignKey(
|
|
|
|
User,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
related_name='vcredentials',
|
|
|
|
)
|
2023-10-10 06:43:08 +00:00
|
|
|
data = models.TextField()
|
|
|
|
|
|
|
|
|
|
|
|
class VCTemplate(models.Model):
|
|
|
|
wkit_template_id = models.CharField(max_length=250)
|
|
|
|
data = models.TextField()
|
|
|
|
|
|
|
|
|
2023-10-16 17:08:18 +00:00
|
|
|
class Membership(models.Model):
|
|
|
|
"""
|
|
|
|
This model represent the relation of this user with the ecosystem.
|
|
|
|
"""
|
|
|
|
class Types(models.IntegerChoices):
|
|
|
|
BENEFICIARY = 1, _('Beneficiary')
|
|
|
|
EMPLOYEE = 2, _('Employee')
|
|
|
|
PARTNER = 3, _('Partner')
|
|
|
|
|
|
|
|
type = models.PositiveSmallIntegerField(_('Type of membership'), choices=Types.choices)
|
|
|
|
start_date = models.DateField(
|
|
|
|
_('Start date'),
|
|
|
|
help_text=_('What date did the membership start?'),
|
|
|
|
blank=True,
|
|
|
|
null=True
|
|
|
|
)
|
|
|
|
end_date = models.DateField(
|
|
|
|
_('End date'),
|
|
|
|
help_text=_('What date did the membership end?'),
|
|
|
|
blank=True,
|
|
|
|
null=True
|
|
|
|
)
|
|
|
|
|
|
|
|
user = models.ForeignKey(
|
|
|
|
User,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
related_name='memberships',
|
|
|
|
)
|
2023-10-17 08:53:03 +00:00
|
|
|
|
|
|
|
def get_type(self):
|
|
|
|
return dict(self.Types.choices).get(self.type)
|