views: zprovoznění views řešitelských článků
This commit is contained in:
		
							parent
							
								
									f5871457c9
								
							
						
					
					
						commit
						645163cec8
					
				
					 1 changed files with 30 additions and 1 deletions
				
			
		|  | @ -951,12 +951,41 @@ def soustredeniUcastniciExportView(request,soustredeni): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| ### Články | ### Články | ||||||
|  | def group_by_rocnik(clanky): | ||||||
|  | 	''' Vezme zadaný seznam článků a seskupí je podle ročníku. | ||||||
|  | 	Vrátí seznam seznamů článků ze stejného ročníku.''' | ||||||
|  | 	clanky.order_by('cislo__rocnik__rocnik') | ||||||
|  | 	skupiny_clanku = [] | ||||||
|  | 	skupina = [] | ||||||
|  | 
 | ||||||
|  | 	rocnik = clanky.first().cislo.rocnik.rocnik # první ročník | ||||||
|  | 	for clanek in clanky: | ||||||
|  | 		if clanek.cislo.rocnik.rocnik == rocnik: | ||||||
|  | 			skupina.append(clanek) | ||||||
|  | 		else: | ||||||
|  | 			skupiny_clanku.append(skupina) | ||||||
|  | 			skupina = [] | ||||||
|  | 			skupina.append(clanek) | ||||||
|  | 			rocnik = clanek.cislo.rocnik.rocnik | ||||||
|  | 	skupiny_clanku.append(skupina) | ||||||
|  | 	return skupiny_clanku | ||||||
|  | 	 | ||||||
| 
 | 
 | ||||||
| # FIXME: clanky jsou vsechny, pokud budou i neresitelske, tak se take zobrazi | # FIXME: clanky jsou vsechny, pokud budou i neresitelske, tak se take zobrazi | ||||||
| class ClankyResitelView(generic.ListView): | class ClankyResitelView(generic.ListView): | ||||||
| 	model = Problem | 	model = Problem | ||||||
| 	template_name = 'seminar/clanky/resitelske_clanky.html' | 	template_name = 'seminar/clanky/resitelske_clanky.html' | ||||||
| 	queryset = Clanek.objects.filter(stav=Problem.STAV_ZADANY).select_related('cislo_zadani__rocnik').order_by('-cislo_zadani__rocnik__rocnik', 'kod') | 	#queryset | ||||||
|  | 	clanky = Clanek.objects.filter(stav=Problem.STAV_ZADANY).select_related('cislo__rocnik').order_by('-cislo__rocnik__rocnik') | ||||||
|  | 	queryset = [] | ||||||
|  | 	skupiny_clanku = group_by_rocnik(clanky) | ||||||
|  | 	for skupina in skupiny_clanku: | ||||||
|  | 		skupina.sort(key=lambda clanek: clanek.kod_v_rocniku()) | ||||||
|  | 		for clanek in skupina: | ||||||
|  | 			queryset.append(clanek) | ||||||
|  | 	#XXX | ||||||
|  | 
 | ||||||
|  | 	#zadani__rocnik').order_by('-cislo_zadani__rocnik__rocnik', 'kod') | ||||||
| 
 | 
 | ||||||
| # FIXME: pokud chceme orgoclanky, tak nejak zavest do modelu a podle toho odkomentovat a upravit | # FIXME: pokud chceme orgoclanky, tak nejak zavest do modelu a podle toho odkomentovat a upravit | ||||||
| #class ClankyOrganizatorView(generic.ListView)<F12>: | #class ClankyOrganizatorView(generic.ListView)<F12>: | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Anet
						Anet