Commit dc9d1ad0ea5031ccc9aff7247f66db8424c73cd6
1 parent
e060d7af
Exists in
dev
Add method to get period_id as str with the good format
Showing
2 changed files
with
21 additions
and
1 deletions
Show diff stats
CHANGELOG
1 | 26-09-2023 (AKo): V0.6.31.0 | 1 | 26-09-2023 (AKo): V0.6.31.0 |
2 | - Add ephem_target2night in Agent.py | 2 | - Add ephem_target2night in Agent.py |
3 | + - Add Image table | ||
4 | + - Add method to get period_id as str with the good format | ||
3 | 5 | ||
4 | 13-09-2023 (AKo): V0.6.31.0 | 6 | 13-09-2023 (AKo): V0.6.31.0 |
5 | - Change algo to find agent script (first search in obs folder then in pyros') | 7 | - Change algo to find agent script (first search in obs folder then in pyros') |
src/core/pyros_django/user_mgmt/models.py
@@ -79,6 +79,7 @@ class Country(models.Model): | @@ -79,6 +79,7 @@ class Country(models.Model): | ||
79 | class Institute(models.Model): | 79 | class Institute(models.Model): |
80 | name = models.CharField(max_length=100, blank=False, | 80 | name = models.CharField(max_length=100, blank=False, |
81 | null=False, unique=True) | 81 | null=False, unique=True) |
82 | + # quota % | ||
82 | quota = models.IntegerField( | 83 | quota = models.IntegerField( |
83 | validators=[MinValueValidator(0), MaxValueValidator(100)]) | 84 | validators=[MinValueValidator(0), MaxValueValidator(100)]) |
84 | #representative_user = models.ForeignKey("PyrosUser", on_delete=models.DO_NOTHING,related_name="institutes",default=1) | 85 | #representative_user = models.ForeignKey("PyrosUser", on_delete=models.DO_NOTHING,related_name="institutes",default=1) |
@@ -422,6 +423,21 @@ class Period(models.Model): | @@ -422,6 +423,21 @@ class Period(models.Model): | ||
422 | today = timezone.now().date() | 423 | today = timezone.now().date() |
423 | return today >= self.notification_start_date | 424 | return today >= self.notification_start_date |
424 | 425 | ||
426 | + def get_period_id_as_str(self) -> str: | ||
427 | + """ | ||
428 | + Return period_id as P+period_id | ||
429 | + | ||
430 | + Returns: | ||
431 | + str: P+period_id | ||
432 | + """ | ||
433 | + period_id = str(self.id) | ||
434 | + if len(period_id) < 3: | ||
435 | + while len(period_id) < 3: | ||
436 | + period_id = "0" + period_id | ||
437 | + period_id = "P" + period_id | ||
438 | + return period_id | ||
439 | + | ||
440 | + | ||
425 | class Meta: | 441 | class Meta: |
426 | db_table = "period" | 442 | db_table = "period" |
427 | 443 | ||
@@ -520,7 +536,9 @@ class SP_Period(models.Model): | @@ -520,7 +536,9 @@ class SP_Period(models.Model): | ||
520 | token = models.PositiveIntegerField(default=0) | 536 | token = models.PositiveIntegerField(default=0) |
521 | token_allocated = models.PositiveIntegerField(default=0, blank=True) | 537 | token_allocated = models.PositiveIntegerField(default=0, blank=True) |
522 | token_remaining = models.PositiveIntegerField(default=0, blank=True) | 538 | token_remaining = models.PositiveIntegerField(default=0, blank=True) |
523 | - priority = models.PositiveIntegerField(default=0, blank=True) | 539 | + # Unit PI donne un nombre de priorité (100 = alert) |
540 | + priority = models.IntegerField( | ||
541 | + validators=[MinValueValidator(0), MaxValueValidator(100)], blank=True, null=True) | ||
524 | 542 | ||
525 | def is_currently_active(self): | 543 | def is_currently_active(self): |
526 | return self.period.is_currently_active() | 544 | return self.period.is_currently_active() |