Upgrade odevzdavatka #30
					 2 changed files with 2 additions and 23 deletions
				
			
		| 
						 | 
				
			
			@ -70,20 +70,7 @@ 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):
 | 
			
		||||
		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)
 | 
			
		||||
		qs = m.Problem.objects.filter(stav=m.Problem.STAV_ZADANY)
 | 
			
		||||
		if self.q:
 | 
			
		||||
			qs = qs.filter(
 | 
			
		||||
					Q(nazev__icontains=self.q))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -386,15 +386,7 @@ class NahrajReseniNadproblemView(LoginRequiredMixin, ListView):
 | 
			
		|||
	template_name = 'odevzdavatko/nahraj_reseni_nadproblem.html'
 | 
			
		||||
 | 
			
		||||
	def get_queryset(self):
 | 
			
		||||
		# 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)
 | 
			
		||||
		return super().get_queryset().filter(stav=m.Problem.STAV_ZADANY, nadproblem__isnull=True)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class NahrajReseniView(LoginRequiredMixin, CreateView):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue