Commit dc9d1ad0ea5031ccc9aff7247f66db8424c73cd6

Authored by Alexis Koralewski
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 1 26-09-2023 (AKo): V0.6.31.0
2 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 6 13-09-2023 (AKo): V0.6.31.0
5 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 79 class Institute(models.Model):
80 80 name = models.CharField(max_length=100, blank=False,
81 81 null=False, unique=True)
  82 + # quota %
82 83 quota = models.IntegerField(
83 84 validators=[MinValueValidator(0), MaxValueValidator(100)])
84 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 423 today = timezone.now().date()
423 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 441 class Meta:
426 442 db_table = "period"
427 443  
... ... @@ -520,7 +536,9 @@ class SP_Period(models.Model):
520 536 token = models.PositiveIntegerField(default=0)
521 537 token_allocated = models.PositiveIntegerField(default=0, blank=True)
522 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 543 def is_currently_active(self):
526 544 return self.period.is_currently_active()
... ...