diff --git a/api/tests/test_skola_autocomplete.py b/api/tests/test_skola_autocomplete.py index 17c07e42..c552ad00 100644 --- a/api/tests/test_skola_autocomplete.py +++ b/api/tests/test_skola_autocomplete.py @@ -1,6 +1,6 @@ from django.test import TestCase from django.urls import reverse -from seminar.models.personalni import Skola +from personalni.models import Skola import seminar.views as v from seminar.utils import sync_skoly diff --git a/api/views/autocomplete.py b/api/views/autocomplete.py index 27ff3183..96b6af71 100644 --- a/api/views/autocomplete.py +++ b/api/views/autocomplete.py @@ -5,7 +5,7 @@ from dal import autocomplete from django.shortcuts import get_object_or_404 from django.db.models import Q -from seminar.models.personalni import Skola, Resitel +from personalni.models import Skola, Resitel from seminar.models.tvorba import Problem, Nastaveni from .helpers import LoginRequiredAjaxMixin diff --git a/api/views/exports.py b/api/views/exports.py index 1ccc7be5..09385cd3 100644 --- a/api/views/exports.py +++ b/api/views/exports.py @@ -1,4 +1,4 @@ -from seminar.models.personalni import Skola +from personalni.models import Skola from django.core import serializers as ser from django.http import HttpResponse def exportSkolView(request): diff --git a/korektury/models.py b/korektury/models.py index 5263f5f8..ca1bb877 100644 --- a/korektury/models.py +++ b/korektury/models.py @@ -16,12 +16,11 @@ import os from django.db import models from django.utils import timezone from django.conf import settings -from django.utils.encoding import force_text from django.core.exceptions import ObjectDoesNotExist from django.utils.functional import cached_property from django.utils.text import get_valid_filename -from seminar.models.personalni import Organizator +from personalni.models import Organizator import subprocess from reversion import revisions as reversion diff --git a/odevzdavatko/forms.py b/odevzdavatko/forms.py index 47bd68cc..d866e4b6 100644 --- a/odevzdavatko/forms.py +++ b/odevzdavatko/forms.py @@ -4,7 +4,7 @@ from django.forms import formset_factory from django.forms.models import inlineformset_factory from django.utils import timezone -from seminar.models.personalni import Resitel +from personalni.models import Resitel from seminar.models.tvorba import Problem, Deadline, Nastaveni from seminar.models.odevzdavatko import * diff --git a/odevzdavatko/templatetags/jmena.py b/odevzdavatko/templatetags/jmena.py index 59a0e5fe..996720bb 100644 --- a/odevzdavatko/templatetags/jmena.py +++ b/odevzdavatko/templatetags/jmena.py @@ -2,7 +2,7 @@ from django import template register = template.Library() from personalni.utils import normalizuj_jmeno -from seminar.models.personalni import Osoba # jen kvůli typové anotaci… +from personalni.models import Osoba # jen kvůli typové anotaci… @register.filter def jmeno_jako_prefix(o: Osoba): diff --git a/odevzdavatko/views.py b/odevzdavatko/views.py index a0261d2e..8cfa0e02 100644 --- a/odevzdavatko/views.py +++ b/odevzdavatko/views.py @@ -18,7 +18,7 @@ import logging from seminar.models.odevzdavatko import * from seminar.models.tvorba import Problem, Nastaveni, Rocnik, Deadline -from seminar.models.personalni import Resitel, Organizator, Osoba +from personalni.models import Resitel, Organizator, Osoba from . import forms as f from .forms import OdevzdavatkoTabulkaFiltrForm as FiltrForm from seminar.utils import resi_v_rocniku diff --git a/personalni/admin.py b/personalni/admin.py index 80ba7494..d61542c0 100644 --- a/personalni/admin.py +++ b/personalni/admin.py @@ -1,7 +1,7 @@ from django.contrib import admin from django.contrib.auth.models import Group from django_reverse_admin import ReverseModelAdmin -from seminar.models.personalni import * +from .models import * @admin.register(Osoba) diff --git a/personalni/forms.py b/personalni/forms.py index 4a14d964..49321601 100644 --- a/personalni/forms.py +++ b/personalni/forms.py @@ -4,7 +4,7 @@ from django.contrib.auth.forms import PasswordResetForm from django.core.exceptions import ObjectDoesNotExist from django.contrib.auth.models import User -from seminar.models.personalni import * +from .models import * from datetime import date import logging diff --git a/seminar/models/personalni.py b/personalni/models.py similarity index 98% rename from seminar/models/personalni.py rename to personalni/models.py index baa66ea5..48062cb6 100644 --- a/seminar/models/personalni.py +++ b/personalni/models.py @@ -11,7 +11,7 @@ from django_countries.fields import CountryField from reversion import revisions as reversion -from .base import SeminarModelBase +from seminar.models.base import SeminarModelBase logger = logging.getLogger(__name__) @@ -252,7 +252,7 @@ class Resitel(SeminarModelBase): def vsechny_body(self): "Spočítá body odjakživa." vsechna_reseni = self.reseni_set.all() - from .odevzdavatko import Hodnoceni + from seminar.models.odevzdavatko import Hodnoceni vsechna_hodnoceni = Hodnoceni.objects.filter( reseni__in=vsechna_reseni) return sum(h.body for h in list(vsechna_hodnoceni) if h.body is not None) @@ -299,7 +299,7 @@ class Resitel(SeminarModelBase): # - body z 25. ročníku a dříve byly shledány dvakrát hodnotnějšími # - proto se započítávají dvojnásobně a byly posunuté hranice titulů # - staré tituly se ale nemají odebrat, pokud řešitel v t.č. minulém (26.) ročníku měl titul, má ho mít pořád. - from .odevzdavatko import Hodnoceni + from seminar.models.odevzdavatko import Hodnoceni hodnoceni_do_25_rocniku = Hodnoceni.objects.filter(deadline_body__cislo__rocnik__rocnik__lte=25,reseni__in=self.reseni_set.all()) novejsi_hodnoceni = Hodnoceni.objects.filter(reseni__in=self.reseni_set.all()).difference(hodnoceni_do_25_rocniku) @@ -337,7 +337,7 @@ class Resitel(SeminarModelBase): else: return Titul.akad - from .odevzdavatko import Hodnoceni + from seminar.models.odevzdavatko import Hodnoceni hodnoceni_do_26_rocniku = Hodnoceni.objects.filter(deadline_body__cislo__rocnik__rocnik__lte=26,reseni__in=self.reseni_set.all()) novejsi_body = body_z_hodnoceni( Hodnoceni.objects.filter(reseni__in=self.reseni_set.all()) diff --git a/personalni/utils.py b/personalni/utils.py index 9642fc77..248f539a 100644 --- a/personalni/utils.py +++ b/personalni/utils.py @@ -1,4 +1,4 @@ -from seminar.models.personalni import * +from .models import * from various.utils import bez_diakritiky_translate import re diff --git a/personalni/views.py b/personalni/views.py index d22080bb..43c081b7 100644 --- a/personalni/views.py +++ b/personalni/views.py @@ -9,8 +9,8 @@ from django.contrib.auth.mixins import LoginRequiredMixin from django.db import transaction from django.http import HttpResponse -from seminar.models.odevzdavatko import * -from seminar.models.personalni import Organizator, Resitel, Osoba +from seminar.models.odevzdavatko import Hodnoceni +from .models import * from seminar.models.tvorba import Tema, Uloha, Clanek, Nastaveni from seminar.models.soustredeni import Soustredeni from .forms import PrihlaskaForm, ProfileEditForm, PoMaturiteProfileEditForm diff --git a/prednasky/models.py b/prednasky/models.py index b68c0642..172c067c 100644 --- a/prednasky/models.py +++ b/prednasky/models.py @@ -1,9 +1,8 @@ from django.db import models -from django.utils.encoding import force_text from seminar.models.soustredeni import Soustredeni -from seminar.models.personalni import Organizator +from personalni.models import Organizator STAV_NAVRH = 1 STAV_BUDE = 2 diff --git a/prednasky/views.py b/prednasky/views.py index ff94b119..17835bbe 100644 --- a/prednasky/views.py +++ b/prednasky/views.py @@ -7,7 +7,7 @@ from django.forms import Form from prednasky.models import Prednaska, Hlasovani, Seznam, STAV_NAVRH from seminar.models.soustredeni import Soustredeni -from seminar.models.personalni import Osoba +from personalni.models import Osoba def newPrednaska(request): # hlasovani se vztahuje k nejnovejsimu soustredeni diff --git a/seminar/admin.py b/seminar/admin.py index 67f16824..b0301bf3 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -10,7 +10,7 @@ from django.utils.safestring import mark_safe # Todo: reversion from seminar.models.tvorba import Rocnik, Cislo, Deadline, ZmrazenaVysledkovka, Problem, Uloha, Tema, Clanek, Nastaveni -from seminar.models.personalni import Resitel +from personalni.models import Resitel from seminar.models.soustredeni import Konfera from seminar.models.novinky import Novinky from seminar.models.pomocne import Text, Obrazek diff --git a/seminar/management/commands/testdata.py b/seminar/management/commands/testdata.py index ffcc261f..5297e9ed 100644 --- a/seminar/management/commands/testdata.py +++ b/seminar/management/commands/testdata.py @@ -7,7 +7,7 @@ from django.core.management.base import BaseCommand from django.core.management import call_command from django.conf import settings -from seminar.models.personalni import Skola, Resitel +from personalni.models import Skola, Resitel from seminar.models.tvorba import Rocnik, Cislo, Problem from seminar.models.odevzdavatko import Reseni from seminar.testutils import create_test_data diff --git a/seminar/models/__init__.py b/seminar/models/__init__.py index 34712ee4..40fb3857 100644 --- a/seminar/models/__init__.py +++ b/seminar/models/__init__.py @@ -1,7 +1,6 @@ from .tvorba import * from .odevzdavatko import * from .base import * -from .personalni import * from .soustredeni import * from .pomocne import * from .treenode import * diff --git a/seminar/models/novinky.py b/seminar/models/novinky.py index cee674a8..261e50ba 100644 --- a/seminar/models/novinky.py +++ b/seminar/models/novinky.py @@ -4,7 +4,8 @@ from imagekit.processors import ResizeToFit from reversion import revisions as reversion -from . import personalni as pm +from personalni.models import Organizator + @reversion.register(ignore_duplicates=True) class Novinky(models.Model): @@ -26,7 +27,7 @@ class Novinky(models.Model): ], options={'quality': 95}) - autor = models.ForeignKey(pm.Organizator, verbose_name='Autor novinky', null=True, + autor = models.ForeignKey(Organizator, verbose_name='Autor novinky', null=True, on_delete=models.SET_NULL) zverejneno = models.BooleanField('Zveřejněno', default=False) diff --git a/seminar/models/odevzdavatko.py b/seminar/models/odevzdavatko.py index 083e4f5b..e57d4722 100644 --- a/seminar/models/odevzdavatko.py +++ b/seminar/models/odevzdavatko.py @@ -10,7 +10,7 @@ from django.utils import timezone from django.conf import settings from seminar.models.tvorba import Cislo, Deadline, Problem, Uloha, aux_generate_filename -from seminar.models.personalni import Resitel +from personalni.models import Resitel from seminar.models.base import SeminarModelBase diff --git a/seminar/models/soustredeni.py b/seminar/models/soustredeni.py index 9e6736d5..a20c25a2 100644 --- a/seminar/models/soustredeni.py +++ b/seminar/models/soustredeni.py @@ -7,7 +7,7 @@ from reversion import revisions as reversion from django.conf import settings -from . import personalni as pm +from personalni.models import Resitel, Organizator from .base import SeminarModelBase from seminar.models.tvorba import Rocnik, Problem, aux_generate_filename @@ -41,10 +41,10 @@ class Soustredeni(SeminarModelBase): misto = models.CharField('místo soustředění', max_length=256, blank=True, default='', help_text='Místo (název obce, volitelně též objektu') - ucastnici = models.ManyToManyField(pm.Resitel, verbose_name='účastníci soustředění', + ucastnici = models.ManyToManyField(Resitel, verbose_name='účastníci soustředění', help_text='Seznam účastníků soustředění', through='Soustredeni_Ucastnici') - organizatori = models.ManyToManyField(pm.Organizator, + organizatori = models.ManyToManyField(Organizator, verbose_name='Organizátoři soustředění', help_text='Seznam organizátorů soustředění', through='Soustredeni_Organizatori') @@ -91,7 +91,7 @@ class Soustredeni_Ucastnici(SeminarModelBase): # Interní ID id = models.AutoField(primary_key = True) - resitel = models.ForeignKey(pm.Resitel, verbose_name='řešitel', on_delete=models.PROTECT) + resitel = models.ForeignKey(Resitel, verbose_name='řešitel', on_delete=models.PROTECT) soustredeni = models.ForeignKey(Soustredeni, verbose_name='soustředění', on_delete=models.PROTECT) @@ -117,7 +117,7 @@ class Soustredeni_Organizatori(SeminarModelBase): # Interní ID id = models.AutoField(primary_key = True) - organizator = models.ForeignKey(pm.Organizator, verbose_name='organizátor', + organizator = models.ForeignKey(Organizator, verbose_name='organizátor', on_delete=models.PROTECT) soustredeni = models.ForeignKey(Soustredeni, verbose_name='soustředění', @@ -162,7 +162,7 @@ class Konfera(Problem): help_text='Abstrakt konfery tak, jak byl uveden ve sborníku') # FIXME: Umíme omezit jen na účastníky daného soustřeďka? - ucastnici = models.ManyToManyField(pm.Resitel, verbose_name='účastníci konfery', + ucastnici = models.ManyToManyField(Resitel, verbose_name='účastníci konfery', help_text='Seznam účastníků konfery', through='Konfery_Ucastnici') soustredeni = models.ForeignKey(Soustredeni, verbose_name='soustředění', @@ -203,7 +203,7 @@ class Konfery_Ucastnici(models.Model): # Interní ID id = models.AutoField(primary_key = True) - resitel = models.ForeignKey(pm.Resitel, verbose_name='řešitel', on_delete=models.PROTECT) + resitel = models.ForeignKey(Resitel, verbose_name='řešitel', on_delete=models.PROTECT) konfera = models.ForeignKey(Konfera, verbose_name='konfera', on_delete=models.CASCADE) diff --git a/seminar/models/treenode.py b/seminar/models/treenode.py index 0dd69c06..04d668dc 100644 --- a/seminar/models/treenode.py +++ b/seminar/models/treenode.py @@ -8,7 +8,8 @@ from unidecode import unidecode # Používám pro získání ID odkazu (ještě from polymorphic.models import PolymorphicModel -from . import personalni as pm, Reseni +from .odevzdavatko import Reseni +from personalni.models import Organizator from .pomocne import Text @@ -165,7 +166,7 @@ class OrgTextNode(TreeNode): verbose_name = 'Organizátorský článek (Node)' verbose_name_plural = 'Organizátorské články (Node)' - organizator = models.ForeignKey(pm.Organizator, + organizator = models.ForeignKey(Organizator, null=False, blank=False, on_delete=models.DO_NOTHING, diff --git a/seminar/models/tvorba.py b/seminar/models/tvorba.py index 352a38bd..93944e99 100644 --- a/seminar/models/tvorba.py +++ b/seminar/models/tvorba.py @@ -31,7 +31,7 @@ from polymorphic.models import PolymorphicModel from django.core.mail import EmailMessage -from . import personalni as pm +from personalni.models import Prijemce, Organizator from .base import SeminarModelBase @@ -305,7 +305,7 @@ class Cislo(SeminarModelBase): resitele_vsichni.filter(zasilat_cislo_papirove=True)) paticka_prijemce = "---\nPokud tyto e-maily nechcete nadále dostávat, prosíme, ozvěte se nám na mam@matfyz.cz." - posli(predmet, text_mailu + paticka_prijemce, pm.Prijemce.objects.filter(zasilat_cislo_emailem=True)) + posli(predmet, text_mailu + paticka_prijemce, Prijemce.objects.filter(zasilat_cislo_emailem=True)) def save(self, *args, **kwargs): super().save(*args, **kwargs) @@ -461,15 +461,15 @@ class Problem(SeminarModelBase,PolymorphicModel): poznamka = models.TextField('org poznámky (HTML)', blank=True, help_text='Neveřejný návrh úlohy, návrh řešení, text zadání, poznámky ...') - autor = models.ForeignKey(pm.Organizator, verbose_name='autor problému', + autor = models.ForeignKey(Organizator, verbose_name='autor problému', related_name='autor_problemu_%(class)s', null=True, blank=True, on_delete=models.SET_NULL) - garant = models.ForeignKey(pm.Organizator, verbose_name='garant zadaného problému', + garant = models.ForeignKey(Organizator, verbose_name='garant zadaného problému', related_name='garant_problemu_%(class)s', null=True, blank=True, on_delete=models.SET_NULL) - opravovatele = models.ManyToManyField(pm.Organizator, verbose_name='opravovatelé', + opravovatele = models.ManyToManyField(Organizator, verbose_name='opravovatelé', blank=True, related_name='opravovatele_%(class)s') kod = models.CharField('lokální kód', max_length=32, blank=True, default='', @@ -693,7 +693,7 @@ class Pohadka(SeminarModelBase): id = models.AutoField(primary_key=True) autor = models.ForeignKey( - pm.Organizator, + Organizator, verbose_name="Autor pohádky", # Při nahrávání z TeXu není vyplnění vyžadováno, v adminu je diff --git a/seminar/testutils.py b/seminar/testutils.py index 2d57c08e..0248e694 100644 --- a/seminar/testutils.py +++ b/seminar/testutils.py @@ -12,7 +12,7 @@ import unidecode import logging from korektury.testutils import create_test_pdf -from seminar.models.personalni import * +from personalni.models import * from seminar.models.tvorba import * from seminar.models.odevzdavatko import * from seminar.models.soustredeni import * diff --git a/seminar/utils.py b/seminar/utils.py index e49a7002..8c32ae33 100644 --- a/seminar/utils.py +++ b/seminar/utils.py @@ -16,7 +16,7 @@ from django.core.exceptions import ObjectDoesNotExist import logging -from seminar.models.personalni import Organizator, Resitel, Skola, Prijemce +from personalni.models import Organizator, Resitel, Skola, Prijemce from seminar.models.tvorba import Clanek, Rocnik from seminar.models.treenode import CisloNode from seminar.models.soustredeni import Konfery_Ucastnici, Soustredeni_Ucastnici diff --git a/seminar/views/views_all.py b/seminar/views/views_all.py index ff379060..b77a5e44 100644 --- a/seminar/views/views_all.py +++ b/seminar/views/views_all.py @@ -10,7 +10,7 @@ from django.views.generic.base import RedirectView from django.core.exceptions import PermissionDenied from seminar.models.tvorba import Rocnik, Cislo, Nastaveni, Deadline, Problem, Tema, Clanek -from seminar.models.personalni import Resitel, Organizator +from personalni.models import Resitel, Organizator from seminar.models.novinky import Novinky #from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva from seminar import utils diff --git a/soustredeni/views.py b/soustredeni/views.py index f94ad0c0..1dbc23ed 100644 --- a/soustredeni/views.py +++ b/soustredeni/views.py @@ -4,7 +4,7 @@ from django.views import generic from django.conf import settings from django.contrib.staticfiles.finders import find from seminar.models.soustredeni import * -from seminar.models.personalni import Resitel +from personalni.models import Resitel from seminar.models.tvorba import Nastaveni import csv import tempfile diff --git a/vyroci/views.py b/vyroci/views.py index 3a19e054..50070a26 100644 --- a/vyroci/views.py +++ b/vyroci/views.py @@ -1,6 +1,6 @@ from django.views.generic import FormView, ListView -from seminar.models.personalni import Osoba +from personalni.models import Osoba from seminar.views import formularOKView from .forms import UcastnikVyrociForm from .models import UcastnikVyroci diff --git a/vysledkovky/utils.py b/vysledkovky/utils.py index c862e759..79dd4a3e 100644 --- a/vysledkovky/utils.py +++ b/vysledkovky/utils.py @@ -4,7 +4,7 @@ from typing import Union, Iterable # TODO: s pythonem 3.10 přepsat na '|' from seminar.models.tvorba import Rocnik, Cislo, Deadline, Problem, Clanek from seminar.models.odevzdavatko import Hodnoceni -from seminar.models.personalni import Resitel +from personalni.models import Resitel from seminar.models.soustredeni import Konfera from django.db.models import Q, Sum from seminar.utils import resi_v_rocniku