Merge branch 'master' of atrey.karlin.mff.cuni.cz:/akce/MaM/MaMweb/mamweb
This commit is contained in:
		
						commit
						38b42d2d3f
					
				
					 10 changed files with 192 additions and 92 deletions
				
			
		|  | @ -3,6 +3,9 @@ | ||||||
| from galerie.models import Obrazek, Galerie | from galerie.models import Obrazek, Galerie | ||||||
| from django.contrib import admin | from django.contrib import admin | ||||||
| from django.http import HttpResponseRedirect | from django.http import HttpResponseRedirect | ||||||
|  | from django import forms | ||||||
|  | from django.db import models | ||||||
|  | import autocomplete_light | ||||||
| 
 | 
 | ||||||
| # akction | # akction | ||||||
| 
 | 
 | ||||||
|  | @ -27,17 +30,25 @@ def prepnout_fotogalerii_do_org_rezimu(modeladmin, request, queryset): | ||||||
|             'Přepnout do režimu úprav (zneveřejní galerii)' |             'Přepnout do režimu úprav (zneveřejní galerii)' | ||||||
| 
 | 
 | ||||||
| class GalerieInline(admin.TabularInline): | class GalerieInline(admin.TabularInline): | ||||||
|   model = Obrazek |     model = Obrazek | ||||||
|  |     fields = ['obrazek_velky', 'nazev', 'popis', 'obrazek_maly_tag'] | ||||||
|  |     readonly_fields = ['nazev', 'obrazek_maly_tag'] | ||||||
|  |     formfield_overrides = { | ||||||
|  |         models.TextField: {'widget': forms.TextInput}, | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| class ObrazekAdmin(admin.ModelAdmin): | class ObrazekAdmin(admin.ModelAdmin): | ||||||
|   list_display = ('obrazek_velky', 'nazev', 'popis') |     list_display = ('obrazek_velky', 'nazev', 'popis', 'obrazek_maly_tag') | ||||||
|    |    | ||||||
| class GalerieAdmin(admin.ModelAdmin):  | class GalerieAdmin(admin.ModelAdmin): | ||||||
|   model = Galerie |     form = autocomplete_light.modelform_factory(Galerie, autocomplete_fields=['titulni_obrazek'], fields=['titulni_obrazek']) | ||||||
|   fields = ('zobrazit', 'nazev', 'titulni_obrazek', 'popis', 'galerie_up', 'soustredeni', 'poradi') |     model = Galerie | ||||||
|   list_display = ('nazev', 'pk', 'datum_zmeny', 'zobrazit', 'soustredeni') |     fields = ('zobrazit', 'nazev', 'titulni_obrazek', 'popis', 'galerie_up', 'soustredeni', 'poradi') | ||||||
|   inlines = [GalerieInline] |     list_display = ('nazev', 'pk', 'poradi', 'datum_zmeny', 'zobrazit', 'soustredeni') | ||||||
|   actions = [zverejnit_fotogalerii, prepnout_fotogalerii_do_org_rezimu] |     inlines = [GalerieInline] | ||||||
|  |     actions = [zverejnit_fotogalerii, prepnout_fotogalerii_do_org_rezimu] | ||||||
|  |     save_on_top = True | ||||||
|  |     ordering = ['galerie_up__nazev', 'poradi'] | ||||||
| 
 | 
 | ||||||
| admin.site.register(Obrazek, ObrazekAdmin) | admin.site.register(Obrazek, ObrazekAdmin) | ||||||
| admin.site.register(Galerie, GalerieAdmin) | admin.site.register(Galerie, GalerieAdmin) | ||||||
|  |  | ||||||
							
								
								
									
										49
									
								
								galerie/autocomplete_light_registry.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								galerie/autocomplete_light_registry.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,49 @@ | ||||||
|  | # -*- coding: utf-8 -*- | ||||||
|  | 
 | ||||||
|  | from __future__ import unicode_literals | ||||||
|  | 
 | ||||||
|  | import autocomplete_light | ||||||
|  | 
 | ||||||
|  | from models import Obrazek, Galerie | ||||||
|  | from views import cesta_od_korene | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class ObrazekAutocomplete(autocomplete_light.AutocompleteModelBase): | ||||||
|  | 
 | ||||||
|  |     model = Obrazek | ||||||
|  |     search_fields = ['nazev', 'popis'] | ||||||
|  |     split_words = True | ||||||
|  |     limit_choices = 15 | ||||||
|  |     attrs = { | ||||||
|  |         # This will set the input placeholder attribute: | ||||||
|  |         'placeholder': u'Obrázek', | ||||||
|  |         # This will set the yourlabs.Autocomplete.minimumCharacters | ||||||
|  |         # options, the naming conversion is handled by jQuery | ||||||
|  |         'data-autocomplete-minimum-characters': 1, | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     choice_html_format = ''' | ||||||
|  |         <span class="block" data-value="{}"> | ||||||
|  |             <span class="block"> | ||||||
|  |                 {} | ||||||
|  |                 <span class="block">{}</span> | ||||||
|  |             </span> | ||||||
|  |         </span> | ||||||
|  |     ''' | ||||||
|  | 
 | ||||||
|  |     def choice_label(self, obrazek): | ||||||
|  |         cesta = "/".join(g.nazev for g in cesta_od_korene(obrazek.galerie)) | ||||||
|  |         popis = "{}<br>".format(obrazek.popis) if obrazek.popis else "" | ||||||
|  |         return '{}<br>{}{}'.format(obrazek.nazev, popis, cesta) | ||||||
|  | 
 | ||||||
|  |     def choice_html(self, obrazek): | ||||||
|  |         """Vrátí kus html i s obrázkem, které se pak ukazuje v nabídce""" | ||||||
|  |         return self.choice_html_format.format(self.choice_value(obrazek), | ||||||
|  |             obrazek.obrazek_maly_tag(), self.choice_label(obrazek)) | ||||||
|  | 
 | ||||||
|  |     widget_attrs={ | ||||||
|  |         'data-widget-maximum-values': 15, | ||||||
|  |         'class': 'modern-style', | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | autocomplete_light.register(ObrazekAutocomplete) | ||||||
|  | @ -56,6 +56,12 @@ class Obrazek(models.Model): | ||||||
|     verbose_name = 'Obrázek' |     verbose_name = 'Obrázek' | ||||||
|     verbose_name_plural = 'Obrázky' |     verbose_name_plural = 'Obrázky' | ||||||
|     ordering = ['nazev'] |     ordering = ['nazev'] | ||||||
|  | 
 | ||||||
|  |   def obrazek_maly_tag(self): | ||||||
|  |     return u'<img src="{}">'.format(self.obrazek_maly.url) | ||||||
|  |   obrazek_maly_tag.short_description = "Náhled" | ||||||
|  |   obrazek_maly_tag.allow_tags = True | ||||||
|  | 
 | ||||||
|    |    | ||||||
| 
 | 
 | ||||||
| class Galerie(models.Model): | class Galerie(models.Model): | ||||||
|  |  | ||||||
|  | @ -6,6 +6,10 @@ Galerie {{galerie.nazev}} | ||||||
| 
 | 
 | ||||||
| {% block content %} | {% block content %} | ||||||
| 
 | 
 | ||||||
|  |   {% if galerie.zobrazit > 0 %} | ||||||
|  |     <div class="mam-org-only"> | ||||||
|  |   {% endif %} | ||||||
|  | 
 | ||||||
|   <h2> |   <h2> | ||||||
|     {% for g in cesta %} |     {% for g in cesta %} | ||||||
|       {% if not forloop.last %} |       {% if not forloop.last %} | ||||||
|  | @ -19,7 +23,7 @@ Galerie {{galerie.nazev}} | ||||||
|   {% if not obrazky %} |   {% if not obrazky %} | ||||||
|    <div class="galerie_hlavicka"> |    <div class="galerie_hlavicka"> | ||||||
|     {% if galerie.titulni_obrazek %} |     {% if galerie.titulni_obrazek %} | ||||||
|       <img src="{{ galerie.titulni_obrazek.obrazek_stredni.url }}" style="border: 1px solid black;"> |       <img src="{{ galerie.titulni_obrazek.obrazek_stredni.url }}" class="titulni_obrazek"> | ||||||
|     {% endif %} |     {% endif %} | ||||||
|    </div> |    </div> | ||||||
|   {% endif %} |   {% endif %} | ||||||
|  | @ -45,8 +49,8 @@ Galerie {{galerie.nazev}} | ||||||
|             {% if galerie.titulni_obrazek %} |             {% if galerie.titulni_obrazek %} | ||||||
|             {% with galerie.titulni_obrazek.obrazek_maly as obrazek %} |             {% with galerie.titulni_obrazek.obrazek_maly as obrazek %} | ||||||
|             <img src="{{ obrazek.url }}" |             <img src="{{ obrazek.url }}" | ||||||
|                 width="{{ obrazek.width }}" |                 width="{% widthratio obrazek.width 167 obrazek.width %}" | ||||||
|                 height="{{ obrazek.height }}" /> |                 height="{% widthratio obrazek.width 167 obrazek.height %}" /> | ||||||
|             {% endwith %} |             {% endwith %} | ||||||
|             {% endif %} |             {% endif %} | ||||||
|             <div> |             <div> | ||||||
|  | @ -103,4 +107,9 @@ Galerie {{galerie.nazev}} | ||||||
|       </div> |       </div> | ||||||
|     {% endif %} |     {% endif %} | ||||||
|   {% endif %} |   {% endif %} | ||||||
|  | 
 | ||||||
|  |   {% if galerie.zobrazit > 0 %} | ||||||
|  |     </div> {# mam-org-only #} | ||||||
|  |   {% endif %} | ||||||
|  | 
 | ||||||
| {% endblock content %} | {% endblock content %} | ||||||
|  |  | ||||||
|  | @ -18,6 +18,15 @@ body { | ||||||
|   border: orange 2px dashed; |   border: orange 2px dashed; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | .mam-org-only .mam-org-only { | ||||||
|  |     border: 0px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | li.mam-org-only { | ||||||
|  |     padding: 3px 0px; | ||||||
|  |     margin: -2px 0px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| table .border-r { | table .border-r { | ||||||
|   border-right: solid 1px; |   border-right: solid 1px; | ||||||
| } | } | ||||||
|  | @ -446,7 +455,8 @@ div.zadani_azad_termin { | ||||||
| /* galerie */ | /* galerie */ | ||||||
| 
 | 
 | ||||||
| /* velká fotka */ | /* velká fotka */ | ||||||
| .galerie .obrazek { | /* zmenšování spolu s oknem prohlížeče */ | ||||||
|  | .galerie .obrazek, .titulni_obrazek { | ||||||
|     max-width: 100%; |     max-width: 100%; | ||||||
|     height: auto; |     height: auto; | ||||||
|     width: auto\9; /* ie8 */ |     width: auto\9; /* ie8 */ | ||||||
|  | @ -482,7 +492,6 @@ div.zadani_azad_termin { | ||||||
| .galerie { | .galerie { | ||||||
|   position: relative; |   position: relative; | ||||||
|   text-align: center; |   text-align: center; | ||||||
|   /*width: 100%;*/ |  | ||||||
|   margin: 20px auto 0 auto; |   margin: 20px auto 0 auto; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -503,6 +512,11 @@ div.zadani_azad_termin { | ||||||
|   text-align: center; |   text-align: center; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | /* titulní obrázek hlavní galerie soustředění */ | ||||||
|  | .titulni_obrazek { | ||||||
|  |     border: 1px solid black; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| .galerie_nahledy{ | .galerie_nahledy{ | ||||||
|   /*margin: 1em 0;*/ |   /*margin: 1em 0;*/ | ||||||
|   margin: 0 auto 30px auto; |   margin: 0 auto 30px auto; | ||||||
|  |  | ||||||
|  | @ -334,7 +334,7 @@ create_modeladmin(ProblemNavrhAdmin, Problem, 'ProblemNavrh', verbose_name=u'Pro | ||||||
| 
 | 
 | ||||||
| class ProblemZadanyAdmin(ProblemAdmin): | class ProblemZadanyAdmin(ProblemAdmin): | ||||||
|     list_display = ['nazev', 'typ', 'autor', 'opravovatel', 'kod', 'cislo_zadani', 'pocet_reseni', 'verejne'] |     list_display = ['nazev', 'typ', 'autor', 'opravovatel', 'kod', 'cislo_zadani', 'pocet_reseni', 'verejne'] | ||||||
|     list_filter = ['typ', 'cislo_zadani__cislo', 'cislo_zadani__rocnik'] |     list_filter = ['typ', 'zamereni', 'cislo_zadani__cislo', 'cislo_zadani__rocnik'] | ||||||
|     inlines = [ReseniKProblemuInline] |     inlines = [ReseniKProblemuInline] | ||||||
| 
 | 
 | ||||||
|     def get_queryset(self, request): |     def get_queryset(self, request): | ||||||
|  |  | ||||||
|  | @ -27,6 +27,16 @@ | ||||||
|   {% endfor %} |   {% endfor %} | ||||||
|   </ul> |   </ul> | ||||||
| 
 | 
 | ||||||
|  |   {% if user.is_staff %} | ||||||
|  |   	<div class="mam-org-only"> | ||||||
|  | 	<h3> Orgovské odkazy </h3> | ||||||
|  | 	<ul> | ||||||
|  | 		<li><a href="obalky.pdf">Obálky (PDF)</a></li> | ||||||
|  | 		<li><a href="tituly.tex">Tituly (TeX)</a></li> | ||||||
|  | 	</ul> | ||||||
|  | 	</div> | ||||||
|  |   {% endif %} | ||||||
|  | 
 | ||||||
|   {% if cislo.verejna_vysledkovka %} |   {% if cislo.verejna_vysledkovka %} | ||||||
|   <h3>Výsledkovka</h3> |   <h3>Výsledkovka</h3> | ||||||
|   {% else %} |   {% else %} | ||||||
|  |  | ||||||
|  | @ -21,47 +21,44 @@ | ||||||
|   {# Projdi vsechna soustredeni #} |   {# Projdi vsechna soustredeni #} | ||||||
|   {% for soustredeni in object_list %} |   {% for soustredeni in object_list %} | ||||||
|     {# Kdyz je verejne -> zobraz #} |     {# Kdyz je verejne -> zobraz #} | ||||||
|     {% if soustredeni.verejne_db or user.is_authenticated %} |     {% if soustredeni.verejne_db or user.is_staff %} | ||||||
|       {% if not soustredeni.verejne_db and user.is_authenticated %} |       {% if not soustredeni.verejne_db and user.is_staff %} | ||||||
|         Groups of user: {{user.groups.all}} <br> |         <div class="mam-org-only"> | ||||||
|         <!-- TODO pri prihlasovani ucastniku dodelat prava |         <!--Groups of user: {{user.groups.all}} <br>--> | ||||||
|         jen na group org ve view --> |  | ||||||
|         Toto soustředění není veřejné, vidíte ho jen proto, |  | ||||||
|         že jste přihlášení. <br> |  | ||||||
|       {% endif %} |       {% endif %} | ||||||
|       {# misto soustredeni TODO upravit#} |       {# misto soustredeni TODO upravit#} | ||||||
|         <h2> |       <h2> | ||||||
| 	  {{soustredeni.get_typ_display}}  | 	    {{soustredeni.get_typ_display}} | ||||||
| 	  {{soustredeni.misto}} | 	    {{soustredeni.misto}} | ||||||
|         </h2> |       </h2> | ||||||
| 	<ul> |       <ul> | ||||||
| 	<li> |  | ||||||
| 		{{soustredeni.datum_zacatku}} – {{soustredeni.datum_konce}} |  | ||||||
| 	</li> |  | ||||||
|   {# Zobrazeni odkazu na galerie #} |  | ||||||
|   {% if soustredeni.galerie_set.all %} |  | ||||||
|     {% for galerie in soustredeni.galerie_set.all %} |  | ||||||
|       {% if galerie.zobrazit == 0 or user.is_staff %} |  | ||||||
|         <li> |         <li> | ||||||
|           <a href="../{{soustredeni.pk}}/fotogalerie/{{galerie.pk}}">Fotogalerie</a> |           {{soustredeni.datum_zacatku}} – {{soustredeni.datum_konce}} | ||||||
|           {# TODO kdyz je titulni obrazek, tak asi i titulni obrazek #} |  | ||||||
|         </li> |         </li> | ||||||
|       {% endif %} |         {# Zobrazeni odkazu na galerie #} | ||||||
|     {% endfor %} |         {% if soustredeni.galerie_set.all %} | ||||||
|   {% endif %} |           {% for galerie in soustredeni.galerie_set.all %} | ||||||
| 	</ul> |             {% if galerie.zobrazit == 0 or user.is_staff %} | ||||||
|   {% if user.is_staff %} |               <li {% if galerie.zobrazit > 0 and user.is_staff %}class="mam-org-only"{% endif %}> | ||||||
|     <div class="mam-org-only"> |                 <a href="../{{soustredeni.pk}}/fotogalerie/{{galerie.pk}}">Fotogalerie</a> | ||||||
|       <a href="../{{soustredeni.pk}}/fotogalerie/0/new/">Vytvořit novou fotogalerii</a><br> |                 {# TODO kdyz je titulni obrazek, tak asi i titulni obrazek #} | ||||||
|       <a href="../{{soustredeni.pk}}/obalky.pdf">Vygenerovat obálky pro účastníky</a> |               </li> | ||||||
|     </div> |             {% endif %} | ||||||
|   {% endif %} |           {% endfor %} | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|         {# popis soustredeni #} |  | ||||||
|         {% if soustredeni.text %} |  | ||||||
|           {% autoescape off %}{{soustredeni.text}}{% endautoescape %} |  | ||||||
|         {% endif %} |         {% endif %} | ||||||
|  |       </ul> | ||||||
|  |       {% if user.is_staff %} | ||||||
|  |         <div class="mam-org-only"> | ||||||
|  |           <a href="../{{soustredeni.pk}}/fotogalerie/0/new/">Vytvořit novou fotogalerii</a><br> | ||||||
|  |           <a href="../{{soustredeni.pk}}/obalky.pdf">Vygenerovat obálky pro účastníky</a> | ||||||
|  |         </div> | ||||||
|  |       {% endif %} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |       {# popis soustredeni #} | ||||||
|  |       {% if soustredeni.text %} | ||||||
|  |         {% autoescape off %}{{soustredeni.text}}{% endautoescape %} | ||||||
|  |       {% endif %} | ||||||
|       {% if user.is_authenticated %} |       {% if user.is_authenticated %} | ||||||
|         {# Účastníci #} |         {# Účastníci #} | ||||||
|         <h3>Soustředění se zúčastnili tito účastníci:</h3> |         <h3>Soustředění se zúčastnili tito účastníci:</h3> | ||||||
|  | @ -73,9 +70,12 @@ | ||||||
|         {% endfor %} |         {% endfor %} | ||||||
|         </ul> |         </ul> | ||||||
|       {% endif %} |       {% endif %} | ||||||
|  |       {% if not soustredeni.verejne_db and user.is_staff %} | ||||||
|  |         </div> {# class="mam-org-only" #} | ||||||
|  |       {% endif %} | ||||||
|     {% endif %} |     {% endif %} | ||||||
|   {% empty %} |     {% empty %} | ||||||
|     Žádná soustředění zatím neproběhla! |       Žádná soustředění zatím neproběhla! | ||||||
|   {% endfor %} |   {% endfor %} | ||||||
| 
 | 
 | ||||||
| {% endblock %} | {% endblock %} | ||||||
|  |  | ||||||
|  | @ -22,23 +22,9 @@ M&M je korespondeční seminář. Několikrát do roka zdarma vydáváme ča | ||||||
|   <div class="odpocet"> |   <div class="odpocet"> | ||||||
|     <p><b>Do konce <a href="https://mam.mff.cuni.cz/zadani/aktualni/">odeslání řešení</a> zbývá:<br> |     <p><b>Do konce <a href="https://mam.mff.cuni.cz/zadani/aktualni/">odeslání řešení</a> zbývá:<br> | ||||||
|       <big>{{ted|timesince:dead}}</big></b></p> |       <big>{{ted|timesince:dead}}</big></b></p> | ||||||
| 
 |  | ||||||
|       |  | ||||||
|     <!--  |  | ||||||
|     {{cas_do_konce_dni}} dní |  | ||||||
|     {% if cas_do_konce_dni < 5 %} |  | ||||||
|       {{cas_do_konce_hodin}} hodin |  | ||||||
|       {% if cas_do_konce_hodin < 5 %} |  | ||||||
|         {{cas_do_konce_minut}} minut |  | ||||||
|         {% if cas_do_konce_minut < 5 %} |  | ||||||
|           {{cas_do_konce_sekund}} |  | ||||||
|         {% endif %} |  | ||||||
|       {% endif %} |  | ||||||
|     {% endif %} |  | ||||||
|     --> |  | ||||||
| 
 |  | ||||||
|   </div> |   </div> | ||||||
|   {% endif %} |   {% endif %} | ||||||
|  | 
 | ||||||
|   {# Novinky #} |   {# Novinky #} | ||||||
|   <h2>Novinky</h2> |   <h2>Novinky</h2> | ||||||
|   {% include 'seminar/novinky.html' %} |   {% include 'seminar/novinky.html' %} | ||||||
|  |  | ||||||
|  | @ -7,6 +7,7 @@ from django.core.urlresolvers import reverse | ||||||
| from django.views import generic | from django.views import generic | ||||||
| from django.utils.translation import ugettext as _ | from django.utils.translation import ugettext as _ | ||||||
| from django.http import Http404 | from django.http import Http404 | ||||||
|  | from django.db.models import Q | ||||||
| 
 | 
 | ||||||
| from .models import Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Organizator, Resitel, Novinky, Soustredeni_Ucastnici | from .models import Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Organizator, Resitel, Novinky, Soustredeni_Ucastnici | ||||||
| from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva | from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva | ||||||
|  | @ -72,16 +73,16 @@ class TitulniStranaView(generic.ListView): | ||||||
|         context = super(TitulniStranaView, self).get_context_data(**kwargs) |         context = super(TitulniStranaView, self).get_context_data(**kwargs) | ||||||
|         nastaveni = get_object_or_404(Nastaveni) |         nastaveni = get_object_or_404(Nastaveni) | ||||||
|         cas_deadline = nastaveni.aktualni_cislo.datum_deadline |         cas_deadline = nastaveni.aktualni_cislo.datum_deadline | ||||||
|         try: |         # Pokud neni zverejnene cislo nezverejnuj odpocet | ||||||
|           rozdil_casu =  datetime.combine(cas_deadline, datetime.max.time()) \ |         if nastaveni.aktualni_cislo.verejne(): | ||||||
|                   - datetime.now() |           # pokus se zjistit termin odeslani a pokud neni zadany, | ||||||
|           context['cas_do_konce_dni']    = rozdil_casu.days |           # nezverejnuj odpocet | ||||||
|           context['cas_do_konce_hodin']  = rozdil_casu.seconds / 3600 |           try: | ||||||
|           context['cas_do_konce_minut'] = (rozdil_casu.seconds / 60) % 60 |             context['dead'] = datetime.combine(cas_deadline, datetime.max.time()) | ||||||
|           context['cas_do_konce_sekund'] = rozdil_casu.seconds % 60 |             context['ted'] = datetime.now() | ||||||
|           context['dead'] = datetime.combine(cas_deadline, datetime.max.time()) |           except: | ||||||
|           context['ted'] = datetime.now() |               context['dead'] = None | ||||||
|         except: |         else: | ||||||
|             context['dead'] = None |             context['dead'] = None | ||||||
|         return context |         return context | ||||||
| 
 | 
 | ||||||
|  | @ -344,28 +345,42 @@ class RocnikVysledkovkaView(RocnikView): | ||||||
| 
 | 
 | ||||||
| ### Generovani obalek | ### Generovani obalek | ||||||
| class CisloObalkyStruct: | class CisloObalkyStruct: | ||||||
|     resitele = None |  | ||||||
|     rocnik = None |     rocnik = None | ||||||
|     problemy = None |     cisla = None | ||||||
| 
 | 
 | ||||||
| def cisloObalkyView(request,rocnik,cislo): | 
 | ||||||
|  | # Vraci QuerySet aktualnich resitelu = nekdy neco poslali, ale jeste neodmaturovali | ||||||
|  | def aktualniResitele(rocnik): | ||||||
|  |     letos = Rocnik.objects.filter(rocnik = rocnik).first() | ||||||
|  |     return Resitel.objects.filter(rok_maturity__gt = letos.prvni_rok) | ||||||
|  | #   # ALERT: pokud nekdo nema vypleny rok maturity, tak neni aktualni, protoze Karel Tesar a jini | ||||||
|  | #    return Resitel.objects.filter(Q(rok_maturity__gt = letos.prvni_rok)|Q(rok_maturity = None)) | ||||||
|  |      | ||||||
|  | # Vraci QuerySet aktivnich resitelu =  | ||||||
|  | # jeste neodmaturovali &&  | ||||||
|  | # (pokud je aktualni cislo mensi nez 3, pak (letos || loni) neco poslali | ||||||
|  | # jinak letos neco poslali) | ||||||
|  | def aktivniResitele(rocnik,cislo): | ||||||
|     letos = CisloObalkyStruct() |     letos = CisloObalkyStruct() | ||||||
|     loni = CisloObalkyStruct() |     loni = CisloObalkyStruct() | ||||||
| 
 | 
 | ||||||
|     letos.rocnik = Rocnik.objects.filter(rocnik = rocnik)[0] |     aktualni_resitele = aktualniResitele(rocnik) | ||||||
|     loni.rocnik = Rocnik.objects.filter(rocnik = int(rocnik)-1)[0] |      | ||||||
|     letos.problemy = Problem.objects.filter(cislo_zadani = Cislo.objects.filter(rocnik=letos.rocnik,cislo__lte = cislo)) |     letos.rocnik = Rocnik.objects.filter(rocnik = rocnik).first() | ||||||
|     loni.problemy = Problem.objects.filter(cislo_zadani = Cislo.objects.filter(rocnik=loni.rocnik)) |     loni.rocnik = Rocnik.objects.filter(rocnik = int(rocnik)-1).first() | ||||||
|     letos.resitele = Resitel.objects.filter(reseni = Reseni.objects.filter(problem=letos.problemy)).distinct() |     letos.cisla = Cislo.objects.filter(rocnik=letos.rocnik,cislo__lte = cislo) | ||||||
|     loni.resitele = Resitel.objects.filter(reseni = Reseni.objects.filter(problem=loni.problemy)).distinct() |     loni.cisla = Cislo.objects.filter(rocnik=loni.rocnik)  | ||||||
| 
 |  | ||||||
|     loni.resitele = loni.resitele.filter(rok_maturity__gt =  letos.rocnik.prvni_rok) |  | ||||||
| 
 |  | ||||||
|     if int(cislo) > 3: |     if int(cislo) > 3: | ||||||
|         resitele = letos.resitele |         problemy = Problem.objects.filter(cislo_zadani = letos.cisla) | ||||||
|     else: |     else: | ||||||
|         resitele = list(letos.resitele) + list(loni.resitele) |         problemy = Problem.objects.filter(Q(cislo_zadani = letos.cisla)|Q(cislo_zadani=loni.cisla)) | ||||||
|     return obalkyView(request,resitele) |     resitele = aktualni_resitele.filter(reseni = Reseni.objects.filter(problem=problemy)).distinct() | ||||||
|  | 
 | ||||||
|  |     return resitele | ||||||
|  |      | ||||||
|  | 
 | ||||||
|  | def cisloObalkyView(request,rocnik,cislo): | ||||||
|  |     return obalkyView(request,aktivniResitele(rocnik,cislo)) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def obalkyView(request,resitele): | def obalkyView(request,resitele): | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Aneta
						Aneta