Odevzdávátko: Odevzdatelné problémy jsou všechny zadané (včetně minulých ročníků)
This commit is contained in:
		
							parent
							
								
									e26df01729
								
							
						
					
					
						commit
						74a26affa7
					
				
					 2 changed files with 2 additions and 23 deletions
				
			
		|  | @ -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)) | ||||||
|  |  | ||||||
|  | @ -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): | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue