-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ | |
"dashboard", | ||
"apps", | ||
"apps.auth", | ||
"apps.core", | ||
"apps.home", | ||
"apps.consent", | ||
] | ||
|