Compare commits

..

No commits in common. "c3b42e09f2f5139d64e2d0fa5253b5d2698165b9" and "e26df0172963cccb306084d667ff8301d33a735b" have entirely different histories.

3 changed files with 23 additions and 18 deletions

View file

@ -70,7 +70,20 @@ class PublicResitelAutocomplete(LoginRequiredAjaxMixin, autocomplete.Select2Quer
class OdevzdatelnyProblemAutocomplete(autocomplete.Select2QuerySetView):
""" View k :mod:`dal.autocomplete` pro vyhledávání problémů především v odevzdávátku. """
def get_queryset(self):
qs = m.Problem.objects.filter(stav=m.Problem.STAV_ZADANY)
nastaveni = get_object_or_404(m.Nastaveni)
rocnik = nastaveni.aktualni_rocnik
# Od tohoto místa dál jsem zkoušel spoustu variací podle https://django-polymorphic.readthedocs.io/en/stable/advanced.html
temaQ = Q(Tema___rocnik = rocnik, stav=m.Problem.STAV_ZADANY)
ulohaQ = Q(Uloha___cislo_zadani__rocnik = rocnik, stav=m.Problem.STAV_ZADANY)
clanekQ = Q(Clanek___cislo__rocnik = rocnik, stav=m.Problem.STAV_ZADANY)
qs = m.Problem.objects.filter(temaQ | ulohaQ | clanekQ)
#print(temata, ulohy, clanky)
#ulohy.union(temata, all=True)
#print(ulohy)
#ulohy.union(clanky, all=True)
#print(ulohy)
#qs = ulohy
print(qs)
if self.q:
qs = qs.filter(
Q(nazev__icontains=self.q))

View file

@ -1255,19 +1255,3 @@ div.gdpr {
label[for=id_skola] {
font-weight: bold;
}
/* Select2 používaný hlavně multiple selectem. Přidání checkboxů a změna barvy. */
.select2-results__option[aria-selected=true]:before {
content: '☑ ';
padding: 0 0 0 8px;
}
.select2-results__option[aria-selected=false]:before {
content: '◻ ';
padding: 0 0 0 8px;
}
.select2-results__option--highlighted {
background-color: #e84e10 !important;
}

View file

@ -386,7 +386,15 @@ class NahrajReseniNadproblemView(LoginRequiredMixin, ListView):
template_name = 'odevzdavatko/nahraj_reseni_nadproblem.html'
def get_queryset(self):
return super().get_queryset().filter(stav=m.Problem.STAV_ZADANY, nadproblem__isnull=True)
# COPY PASTE z api/views/autocomplete.py TODO hodit někam do utils?
nastaveni = get_object_or_404(m.Nastaveni)
rocnik = nastaveni.aktualni_rocnik
# Od tohoto místa dál jsem zkoušel spoustu variací podle https://django-polymorphic.readthedocs.io/en/stable/advanced.html
temaQ = Q(Tema___rocnik=rocnik, stav=m.Problem.STAV_ZADANY)
ulohaQ = Q(Uloha___cislo_zadani__rocnik=rocnik, stav=m.Problem.STAV_ZADANY)
clanekQ = Q(Clanek___cislo__rocnik=rocnik, stav=m.Problem.STAV_ZADANY)
qs = super().get_queryset().filter(temaQ | ulohaQ | clanekQ)
return qs.filter(nadproblem__isnull=True)
class NahrajReseniView(LoginRequiredMixin, CreateView):