2023-12-04 16:12:39 +00:00
|
|
|
from django.db import models
|
2023-12-07 17:10:04 +00:00
|
|
|
from django.urls import reverse_lazy
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from oidc4vp.models import Authorization
|
2023-12-04 16:12:39 +00:00
|
|
|
|
2023-12-07 17:10:04 +00:00
|
|
|
|
|
|
|
class Promotion(models.Model):
|
|
|
|
class Types(models.IntegerChoices):
|
|
|
|
VULNERABLE = 1, _("Financial vulnerability")
|
|
|
|
|
|
|
|
name = models.CharField(max_length=250)
|
|
|
|
discount = models.PositiveSmallIntegerField(
|
|
|
|
choices=Types.choices,
|
|
|
|
)
|
|
|
|
authorize = models.ForeignKey(
|
|
|
|
Authorization,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
related_name='promotions',
|
|
|
|
null=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
def get_url(self, code):
|
|
|
|
url = "{}?code={}".format(
|
|
|
|
reverse_lazy("promotion:show_promotion"),
|
|
|
|
code
|
|
|
|
)
|