Skip to content

Commit

Permalink
✨(dashboard) rebase main
Browse files Browse the repository at this point in the history
  • Loading branch information
ssorin committed Nov 21, 2024
1 parent 273b65a commit 1e0f78b
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
59 changes: 59 additions & 0 deletions src/dashboard/apps/consent/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""Dashboard consent app models."""

from django.db import models
from django.utils.translation import gettext_lazy as _

from apps.auth.models import DashboardUser as User
from apps.core.models import DeliveryPoint
from apps.core.models.abstract import DateBase


class Consent(DateBase):
"""Represents the consent given by a user for a specific charge point.
Attributes:
AWAITING: Status indicating that the consent is awaiting validation.
VALIDATED: Status indicating that the consent has been validated.
REVOKED: Status indicating that the consent has been revoked.
delivery_point: Foreign key relation to the charge point associated with the
consent.
user: Foreign key relation to the user giving the consent.
status: CharField storing the status of the consent, with a maximum length of 20
characters and restricted to choices defined in CONSENT_STATUS_CHOICE.
date_added: DateTimeField recording the date and time when the consent was
created.
date_updated: DateTimeField recording the date and time when the consent was
last updated.
"""

AWAITING = "AWAITING"
VALIDATED = "VALIDATED"
REVOKED = "REVOKED"
CONSENT_STATUS_CHOICE = [
(AWAITING, _("Awaiting")),
(VALIDATED, _("Validated")),
(REVOKED, _("Revoked")),
]

delivery_point = models.ForeignKey(DeliveryPoint, on_delete=models.CASCADE)
user = models.ForeignKey(
User, on_delete=models.SET_NULL, null=True, verbose_name=_("user")
)
status = models.CharField(
_("status"), max_length=20, choices=CONSENT_STATUS_CHOICE, default=AWAITING
)

# Validity period
validity_date_begin = models.DateTimeField(_("begin date"))
validity_date_expiration = models.DateTimeField(_("expiration date"))
revoked_at = models.DateTimeField(_("revoked at"), null=True, blank=True)

class Meta:
"""."""

ordering = ["delivery_point"]

def __str__(self):
"""."""
return f"{self.delivery_point} - {self.date_updated} - {self.status}"
25 changes: 25 additions & 0 deletions src/dashboard/apps/core/models/entity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Dashboard core app models."""

from django.db import models

from apps.auth.models import DashboardUser as User
from apps.core.models.abstract import DateBase


class Entity(DateBase):
"""Represents an operator in the system."""

name = models.CharField(max_length=64, unique=True)
user = models.ManyToManyField(User)
is_enabled = models.BooleanField(default=True)

class Meta:
"""."""

verbose_name = "Entity"
verbose_name_plural = "Entities"
ordering = ["name"]

def __str__(self):
"""."""
return self.name
1 change: 1 addition & 0 deletions src/dashboard/dashboard/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"dashboard",
"apps",
"apps.auth",
"apps.core",
"apps.home",
"apps.consent",
]
Expand Down

0 comments on commit 1e0f78b

Please sign in to comment.