Compare commits

..

2 commits

3 changed files with 18 additions and 23 deletions

View file

@ -70,20 +70,7 @@ class PublicResitelAutocomplete(LoginRequiredAjaxMixin, autocomplete.Select2Quer
class OdevzdatelnyProblemAutocomplete(autocomplete.Select2QuerySetView): class OdevzdatelnyProblemAutocomplete(autocomplete.Select2QuerySetView):
""" View k :mod:`dal.autocomplete` pro vyhledávání problémů především v odevzdávátku. """ """ View k :mod:`dal.autocomplete` pro vyhledávání problémů především v odevzdávátku. """
def get_queryset(self): def get_queryset(self):
nastaveni = get_object_or_404(m.Nastaveni) qs = m.Problem.objects.filter(stav=m.Problem.STAV_ZADANY)
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: if self.q:
qs = qs.filter( qs = qs.filter(
Q(nazev__icontains=self.q)) Q(nazev__icontains=self.q))

View file

@ -1255,3 +1255,19 @@ div.gdpr {
label[for=id_skola] { label[for=id_skola] {
font-weight: bold; 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,15 +386,7 @@ class NahrajReseniNadproblemView(LoginRequiredMixin, ListView):
template_name = 'odevzdavatko/nahraj_reseni_nadproblem.html' template_name = 'odevzdavatko/nahraj_reseni_nadproblem.html'
def get_queryset(self): def get_queryset(self):
# COPY PASTE z api/views/autocomplete.py TODO hodit někam do utils? return super().get_queryset().filter(stav=m.Problem.STAV_ZADANY, nadproblem__isnull=True)
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): class NahrajReseniView(LoginRequiredMixin, CreateView):