diff --git a/seminar/admin.py b/seminar/admin.py
index 9ce11a93..cdb9f3fc 100644
--- a/seminar/admin.py
+++ b/seminar/admin.py
@@ -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('{}'.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('{}'.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]