Rozstřílení seminářové aplikace #60
					 9 changed files with 39 additions and 21 deletions
				
			
		|  | @ -39,6 +39,9 @@ urlpatterns = [ | |||
| 	# Autentizační aplikace (ma vlastni podadresare) | ||||
| 	path('', include('various.autentizace.urls')), | ||||
| 
 | ||||
| 	# Novinková aplikace (ma vlastni podadresare) | ||||
| 	path('', include('novinky.urls')), | ||||
| 
 | ||||
| 	# Api (ma vlastni podadresare) (autocomplete apod.) | ||||
| 	path('', include('api.urls')), | ||||
| 
 | ||||
|  |  | |||
|  | @ -0,0 +1,3 @@ | |||
| """ | ||||
| Obsahuje vše okolo novinek (zpráv „Co je nového?“ na titulní straně). | ||||
| """ | ||||
|  | @ -8,6 +8,6 @@ | |||
|     {% endblock %} | ||||
|   </h1> | ||||
| 
 | ||||
|   {% include 'seminar/novinky.html' %} | ||||
|   {% include 'novinky/novinky.html' %} | ||||
| 
 | ||||
| {% endblock %} | ||||
							
								
								
									
										7
									
								
								novinky/urls.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								novinky/urls.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,7 @@ | |||
| from django.urls import path | ||||
| 
 | ||||
| from .views import StareNovinkyView | ||||
| 
 | ||||
| urlpatterns = [ | ||||
| 	path('stare-novinky/', StareNovinkyView.as_view(), name='stare_novinky'), | ||||
| ] | ||||
|  | @ -0,0 +1,23 @@ | |||
| from django.views import generic | ||||
| 
 | ||||
| from .models import Novinky | ||||
| 
 | ||||
| 
 | ||||
| def spravne_novinky(request): | ||||
| 	""" | ||||
| 	Vrátí správný QuerySet novinek, tedy ten, který daný uživatel smí vidět. | ||||
| 	Tj. Organizátorům všechny, ostatním jen veřejné | ||||
| 	""" | ||||
| 	user = request.user | ||||
| 	# Využíváme líné vyhodnocování QuerySetů | ||||
| 	qs = Novinky.objects.all() | ||||
| 	if not user.je_org: | ||||
| 		qs = qs.filter(zverejneno=True) | ||||
| 	return qs.order_by('-datum') | ||||
| 
 | ||||
| 
 | ||||
| class StareNovinkyView(generic.ListView): | ||||
| 	template_name = 'novinky/stare_novinky.html' | ||||
| 
 | ||||
| 	def get_queryset(self): | ||||
| 		return spravne_novinky(self.request) | ||||
|  | @ -95,7 +95,7 @@ function sousdeadline() { | |||
| 
 | ||||
|   {# Novinky #} | ||||
|   <h1>Co je nového?</h1> | ||||
|   {% include 'seminar/novinky.html' %} | ||||
|   {% include 'novinky/novinky.html' %} | ||||
| 
 | ||||
|   <a href='/stare-novinky/'>Archiv novinek</a> | ||||
| 
 | ||||
|  |  | |||
|  | @ -77,7 +77,6 @@ urlpatterns = [ | |||
| 
 | ||||
| 	path('', views.TitulniStranaView.as_view(), name='titulni_strana'), | ||||
| 	path('jak-resit/', views.JakResitView.as_view(), name='jak_resit'), | ||||
| 	path('stare-novinky/', views.StareNovinkyView.as_view(), name='stare_novinky'), | ||||
| 
 | ||||
| 	# Dočasné & neodladěné: | ||||
| 	path( | ||||
|  |  | |||
|  | @ -18,6 +18,7 @@ from seminar.models import Problem, Cislo, Reseni, Nastaveni, Rocnik, \ | |||
| #from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva | ||||
| from seminar import utils | ||||
| from treenode import treelib | ||||
| from novinky.views import spravne_novinky | ||||
| import treenode.templatetags as tnltt | ||||
| import treenode.serializers as vr | ||||
| from vysledkovky.utils import body_resitelu, VysledkovkaCisla, \ | ||||
|  | @ -218,18 +219,6 @@ def ZadaniAktualniVysledkovkaView(request): | |||
| 
 | ||||
| ### Titulni strana | ||||
| 
 | ||||
| def spravne_novinky(request): | ||||
| 	""" | ||||
| 	Vrátí správný QuerySet novinek, tedy ten, který daný uživatel smí vidět. | ||||
| 	Tj. Organizátorům všechny, ostatním jen veřejné | ||||
| 	""" | ||||
| 	user = request.user | ||||
| 	# Využíváme líné vyhodnocování QuerySetů | ||||
| 	qs = Novinky.objects.all() | ||||
| 	if not user.je_org: | ||||
| 		qs = qs.filter(zverejneno=True) | ||||
| 	return qs.order_by('-datum') | ||||
| 
 | ||||
| def aktualni_temata(rocnik): | ||||
| 	""" | ||||
| 	Vrací PolymorphicQuerySet témat v daném ročníku, ke kterým se aktuálně dá něco odevzdat. | ||||
|  | @ -264,12 +253,6 @@ class TitulniStranaView(generic.ListView): | |||
| 
 | ||||
| 		return context | ||||
| 
 | ||||
| class StareNovinkyView(generic.ListView): | ||||
| 	template_name = 'seminar/stare_novinky.html' | ||||
| 
 | ||||
| 	def get_queryset(self): | ||||
| 		return spravne_novinky(self.request) | ||||
| 
 | ||||
| ### Co je M&M | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue