From 34f4cde15772219281ff132b7ff8ee1dab74d2a3 Mon Sep 17 00:00:00 2001 From: kovacspe Date: Fri, 8 Dec 2023 23:10:24 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Umo=C5=BEnen=C3=A9=20ulo=C5=BEi=C5=A5=20NUL?= =?UTF-8?q?L=20v=20django=20admine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- competition/models.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/competition/models.py b/competition/models.py index 6dff6385..caea9723 100644 --- a/competition/models.py +++ b/competition/models.py @@ -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) @@ -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' @@ -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 From f133539990f6db78402e97575d99e9b0498da52e Mon Sep 17 00:00:00 2001 From: kovacspe Date: Fri, 8 Dec 2023 23:20:39 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Pridan=C3=A1=20mo=C5=BEnos=C5=A5=20pomenova?= =?UTF-8?q?=C5=A5=20publik=C3=A1ciu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- competition/models.py | 2 +- competition/views.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/competition/models.py b/competition/models.py index 6dff6385..7bf523b2 100644 --- a/competition/models.py +++ b/competition/models.py @@ -625,7 +625,7 @@ def generate_name(self, forced=False): if self.order: self.name = f'{self.order}' else: - self.name = type.name + self.name = self.publication_type.name self.save() def __str__(self): diff --git a/competition/views.py b/competition/views.py index 548b6a3c..ad6f743a 100644 --- a/competition/views.py +++ b/competition/views.py @@ -850,7 +850,7 @@ def download_publication(self, request, pk=None): return response @action(methods=['post'], detail=False, url_path='upload', permission_classes=[IsAdminUser]) - def upload_publication(self, request): + def upload_publication(self, request: Request): """Nahrá súbor publikácie""" if 'file' not in request.data: raise exceptions.ParseError(detail='Request neobsahoval súbor') @@ -868,6 +868,7 @@ def upload_publication(self, request): event=event, order=order).first() if publication is None: publication = Publication.objects.create( + name=request.data.get('name'), file=file, event=event, order=order,