Titulní stránka: Zobrazení novinek podle přihlášení
This commit is contained in:
		
							parent
							
								
									330763f216
								
							
						
					
					
						commit
						3e94572e6e
					
				
					 1 changed files with 8 additions and 2 deletions
				
			
		|  | @ -228,9 +228,15 @@ class AktualniZadaniView(TreeNodeView): | ||||||
| ### Titulni strana | ### Titulni strana | ||||||
| 
 | 
 | ||||||
| class TitulniStranaView(generic.ListView): | class TitulniStranaView(generic.ListView): | ||||||
| 	model = Novinky |  | ||||||
| 	template_name='seminar/titulnistrana.html' | 	template_name='seminar/titulnistrana.html' | ||||||
| 	queryset = Novinky.objects.order_by('-datum')[:5] | 
 | ||||||
|  | 	def get_queryset(self): | ||||||
|  | 		# Pro nepřihlášené uživatele chceme novinky jen veřejné | ||||||
|  | 		# Využíváme líné vyhodnocování QuerySetů | ||||||
|  | 		qs = Novinky.objects.all() | ||||||
|  | 		if not self.request.user.is_authenticated: | ||||||
|  | 			qs = qs.filter(zverejneno=True) | ||||||
|  | 		return qs.order_by('-datum')[:5] | ||||||
| 
 | 
 | ||||||
| 	def get_context_data(self, **kwargs): | 	def get_context_data(self, **kwargs): | ||||||
| 		context = super(TitulniStranaView, self).get_context_data(**kwargs) | 		context = super(TitulniStranaView, self).get_context_data(**kwargs) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Pavel 'LEdoian' Turinsky
						Pavel 'LEdoian' Turinsky