Skip to content

Commit

Permalink
Umožnené uložiť NULL v django admine
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacspe committed Dec 8, 2023
1 parent 0bb0a06 commit 34f4cde
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions competition/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ class Meta:
blank=True,
default=None)

def save(self, *args, **kwargs) -> None:
if not self.frozen_results:
self.frozen_results = None
return super().save(*args, **kwargs)

def get_first_series(self):
return self.series_set.get(order=1)

Expand Down Expand Up @@ -257,6 +262,11 @@ class Meta:
blank=True,
default=None)

def save(self, *args, **kwargs) -> None:
if not self.frozen_results:
self.frozen_results = None
return super().save(*args, **kwargs)

def __str__(self):
return f'{self.semester} - {self.order}. séria'

Expand Down Expand Up @@ -421,6 +431,11 @@ class Meta:
hidden_response = models.TextField(
null=True, blank=True, verbose_name='Skrytá odpoveď na komentár')

def save(self, *args, **kwargs) -> None:
if not self.hidden_response:
self.hidden_response = None
return super().save(*args, **kwargs)

def publish(self):
self.state = CommentPublishState.PUBLISHED
self.hidden_response = None
Expand Down

0 comments on commit 34f4cde

Please sign in to comment.