From dc9d1ad0ea5031ccc9aff7247f66db8424c73cd6 Mon Sep 17 00:00:00 2001 From: Alexis Koralewski Date: Tue, 26 Sep 2023 11:02:04 +0200 Subject: [PATCH] Add method to get period_id as str with the good format --- CHANGELOG | 2 ++ src/core/pyros_django/user_mgmt/models.py | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 4144434..32f6ed2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ 26-09-2023 (AKo): V0.6.31.0 - Add ephem_target2night in Agent.py + - Add Image table + - Add method to get period_id as str with the good format 13-09-2023 (AKo): V0.6.31.0 - Change algo to find agent script (first search in obs folder then in pyros') diff --git a/src/core/pyros_django/user_mgmt/models.py b/src/core/pyros_django/user_mgmt/models.py index 16d0ee1..4a15ac5 100644 --- a/src/core/pyros_django/user_mgmt/models.py +++ b/src/core/pyros_django/user_mgmt/models.py @@ -79,6 +79,7 @@ class Country(models.Model): class Institute(models.Model): name = models.CharField(max_length=100, blank=False, null=False, unique=True) + # quota % quota = models.IntegerField( validators=[MinValueValidator(0), MaxValueValidator(100)]) #representative_user = models.ForeignKey("PyrosUser", on_delete=models.DO_NOTHING,related_name="institutes",default=1) @@ -422,6 +423,21 @@ class Period(models.Model): today = timezone.now().date() return today >= self.notification_start_date + def get_period_id_as_str(self) -> str: + """ + Return period_id as P+period_id + + Returns: + str: P+period_id + """ + period_id = str(self.id) + if len(period_id) < 3: + while len(period_id) < 3: + period_id = "0" + period_id + period_id = "P" + period_id + return period_id + + class Meta: db_table = "period" @@ -520,7 +536,9 @@ class SP_Period(models.Model): token = models.PositiveIntegerField(default=0) token_allocated = models.PositiveIntegerField(default=0, blank=True) token_remaining = models.PositiveIntegerField(default=0, blank=True) - priority = models.PositiveIntegerField(default=0, blank=True) + # Unit PI donne un nombre de priorité (100 = alert) + priority = models.IntegerField( + validators=[MinValueValidator(0), MaxValueValidator(100)], blank=True, null=True) def is_currently_active(self): return self.period.is_currently_active() -- libgit2 0.21.2