Skip to content

Commit

Permalink
Merge branch 'aci.main' into bergman/split-processing
Browse files Browse the repository at this point in the history
  • Loading branch information
wowkalucky committed Apr 10, 2024
2 parents 9c8326e + a20a71b commit d7ddecb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion credentials/apps/badges/admin_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if self.instance and hasattr(self.instance, "template") and self.instance.template.is_active:
for field_name in self.fields:
if field_name in ("template", "event_type", "description"):
if field_name in ("template", "event_type", "description", "group"):
self.fields[field_name].disabled = True


Expand Down
18 changes: 17 additions & 1 deletion credentials/apps/badges/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ def __str__(self):

def save(self, *args, **kwargs):
# Check if the related BadgeTemplate is active
if not self.id:
super().save(*args, **kwargs)
return
if not self.template.is_active:
super().save(*args, **kwargs)
else:
Expand Down Expand Up @@ -265,6 +268,16 @@ class BadgePenalty(models.Model):
class Meta:
verbose_name_plural = "Badge penalties"

def save(self, *args, **kwargs):
if not self.id:
super().save(*args, **kwargs)
return
# Check if the related BadgeTemplate is active
if not self.template.is_active:
super().save(*args, **kwargs)
else:
raise ValidationError("Cannot update BadgePenalty for active BadgeTemplate")

def __str__(self):
return f"BadgePenalty:{self.id}:{self.template.uuid}"

Expand Down Expand Up @@ -296,10 +309,13 @@ def save(self, *args, **kwargs):
super().save(*args, **kwargs)
else:
raise ValidationError("Cannot update PenaltyDataRule for active BadgeTemplate")

def __str__(self):
return f"{self.penalty.template.uuid}:{self.data_path}:{self.operator}:{self.value}"

class Meta:
unique_together = ("penalty", "data_path", "operator", "value")


class BadgeProgress(models.Model):
"""
Expand Down

0 comments on commit d7ddecb

Please sign in to comment.