Merge branch 'matej-drobna-vylepseni'
This commit is contained in:
		
						commit
						2c12aed37e
					
				
					 2 changed files with 51 additions and 18 deletions
				
			
		|  | @ -8,6 +8,8 @@ from solo.admin import SingletonModelAdmin | |||
| from ckeditor.widgets import CKEditorWidget | ||||
| from django.db.models import Count | ||||
| from django.db import models | ||||
| from django.utils.safestring import mark_safe | ||||
| from django.core.urlresolvers import reverse | ||||
| 
 | ||||
| from django.contrib.auth.models import User | ||||
| 
 | ||||
|  | @ -478,11 +480,37 @@ create_modeladmin(ProblemNavrhAdmin, Problem, 'ProblemNavrh', verbose_name=u'Pro | |||
| 
 | ||||
| 
 | ||||
| class ProblemZadanyAdmin(ProblemAdmin): | ||||
|     list_display = ['nazev', 'typ', 'autor', 'opravovatel', 'kod', 'verejne'] | ||||
|     list_display = [ | ||||
|         'nazev', | ||||
|         'typ', | ||||
|         'cislo_zadani_link', | ||||
|         'cislo_reseni_link', | ||||
|         'autor', | ||||
|         'opravovatel', | ||||
|         'kod', | ||||
|         'verejne' | ||||
|     ] | ||||
|     list_filter = [ | ||||
|         'typ', 'zamereni', 'cislo_zadani__cislo', 'cislo_zadani__rocnik' | ||||
|     ] | ||||
| 
 | ||||
|     def cislo_zadani_link(self, obj): | ||||
|         return mark_safe('<a href="{}">{}</a>'.format( | ||||
|             reverse("admin:seminar_cislo_change", args=(obj.cislo_zadani.pk,)), | ||||
|             obj.cislo_zadani | ||||
|         )) | ||||
|     cislo_zadani_link.short_description = u'Číslo zadání' | ||||
| 
 | ||||
|     # TODO pokud se budou odkazy v adminu více používat, možná by se hodilo je | ||||
|     # nějak zjednodušit, např. tímto? | ||||
|     # https://github.com/gitaarik/django-admin-relation-links | ||||
|     def cislo_reseni_link(self, obj): | ||||
|         return mark_safe('<a href="{}">{}</a>'.format( | ||||
|             reverse("admin:seminar_cislo_change", args=(obj.cislo_reseni.pk,)), | ||||
|             obj.cislo_reseni | ||||
|         )) | ||||
|     cislo_reseni_link.short_description = u'Číslo řešení' | ||||
| 
 | ||||
|     def get_inline_instances(self, request, obj=None): | ||||
|         if obj and obj.typ == Problem.TYP_ULOHA: | ||||
|             inlines = [ReseniKProblemuInline, PohadkaKProblemuInline] | ||||
|  |  | |||
|  | @ -13,23 +13,27 @@ | |||
|   {% endif %} | ||||
|   <p><a href='{{ cislo.rocnik.verejne_url }}'>Ročník {{ cislo.rocnik }}</a> | ||||
| 
 | ||||
|   <h2>Zadané problémy</h2> | ||||
|   <ul> | ||||
|   {% for p in v_cisle_zadane %} | ||||
|     <li>{# TODO zprovoznit odkazy i pro účastníky, až bude na co #} | ||||
|       {% if user.is_staff %} | ||||
|         <a href='{{ p.verejne_url }}'>{% endif %}{{ p.kod_v_rocniku }} {{ p.nazev }} {{ p.body_v_zavorce }}{% if user.is_staff %}</a>{% endif %} | ||||
|   {% endfor %} | ||||
|   </ul> | ||||
|   {% if v_cisle_zadane %} | ||||
|     <h2>Zadané problémy</h2> | ||||
|     <ul> | ||||
|     {% for p in v_cisle_zadane %} | ||||
|       <li{% if user.is_staff and not cislo.verejne %} class='mam-org-only'{% endif %}> | ||||
|         {% if user.is_staff or cislo.verejne %} | ||||
|           <a href='{{ p.verejne_url }}'>{% endif %}{{ p.kod_v_rocniku }} {{ p.nazev }} {{ p.body_v_zavorce }}{% if user.is_staff or cislo.verejne %}</a>{% endif %} | ||||
|     {% endfor %} | ||||
|     </ul> | ||||
|   {% endif %} | ||||
| 
 | ||||
|   <h2>Řešené problémy</h2> | ||||
|   <ul> | ||||
|   {% for p in resene_problemy %} | ||||
|     <li>{# TODO zprovoznit odkazy i pro účastníky, až bude na co #} | ||||
|       {% if user.is_staff %} | ||||
|         <a href='{{ p.verejne_url }}'>{% endif %}{{ p.kod_v_rocniku }} {{ p.nazev }} {{ p.body_v_zavorce }}{% if user.is_staff %}</a>{% endif %} | ||||
|   {% endfor %} | ||||
|   </ul> | ||||
|   {% if resene_problemy %} | ||||
|     <h2>Řešené problémy</h2> | ||||
|     <ul> | ||||
|     {% for p in resene_problemy %} | ||||
|       <li{% if user.is_staff and not cislo.verejne %} class='mam-org-only'{% endif %}> | ||||
|         {% if user.is_staff or cislo.verejne %} | ||||
|           <a href='{{ p.verejne_url }}'>{% endif %}{{ p.kod_v_rocniku }} {{ p.nazev }} {{ p.body_v_zavorce }}{% if user.is_staff or cislo.verejne %}</a>{% endif %} | ||||
|     {% endfor %} | ||||
|     </ul> | ||||
|   {% endif %} | ||||
| 
 | ||||
|   {% if user.is_staff %} | ||||
|       <div class="mam-org-only"> | ||||
|  | @ -57,8 +61,9 @@ | |||
|       <tr class='border-b'> | ||||
|         <th class='border-r'># | ||||
|         <th class='border-r'>Jméno | ||||
|         {# problémy by měly být veřejné, když je veřejná výsledkovka #} | ||||
|         {% for p in problemy %} | ||||
|         <th class='border-r'>{# TODO <a href="{{ p.verejne_url }}"> #}{{ p.kod_v_rocniku }}{# </a> #} | ||||
|         <th class='border-r'><a href="{{ p.verejne_url }}">{{ p.kod_v_rocniku }}</a> | ||||
|         {% endfor %} | ||||
|         <th class='border-r'>Za číslo</sup> | ||||
|         <th class='border-r'>Za ročník | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Matěj Kocián
						Matěj Kocián