Browse Source

Merge branch 'matej-seznam-prednasek-inline'

remotes/origin/dev
Matěj Kocián 8 years ago
parent
commit
2691104674
  1. 29
      prednasky/admin.py

29
prednasky/admin.py

@ -2,35 +2,40 @@
from django.contrib import admin from django.contrib import admin
from django.contrib import messages from django.contrib import messages
from reversion.admin import VersionAdmin from reversion.admin import VersionAdmin
from django.utils.safestring import mark_safe
from django.utils.html import escape
from models import Prednaska, Seznam, STAV_NAVRH from models import Prednaska, Seznam, STAV_NAVRH
from seminar.models import Soustredeni from seminar.models import Soustredeni
from django.utils.safestring import mark_safe
class Seznam_PrednaskaInline(admin.TabularInline): class Seznam_PrednaskaInline(admin.TabularInline):
model = Prednaska.seznamy.through model = Prednaska.seznamy.through
extra = 0 extra = 0
def prednaska__nazev(self, instance): def prednaska__nazev(self, obj):
return mark_safe( return mark_safe(
u"<a href='/admin/prednasky/prednaska/{}'>{}</a>".format( u"<a href='/admin/prednasky/prednaska/{}'>{}</a>".format(
instance.prednaska.id, obj.prednaska.id,
instance.prednaska.nazev escape(obj.prednaska.nazev)
) )
) )
def prednaska__popis(self, instance): def prednaska__popis(self, obj):
return instance.prednaska.popis return mark_safe(
u"<div style='width: 200px'>{}</div>".format(
escape(obj.prednaska.popis)
)
)
def prednaska__anotace(self, instance): def prednaska__anotace(self, obj):
return instance.prednaska.anotace return obj.prednaska.anotace
def prednaska__org(self, instance): def prednaska__org(self, obj):
return instance.prednaska.org return obj.prednaska.org
def prednaska__obor(self, instance): def prednaska__obor(self, obj):
return instance.prednaska.obor return obj.prednaska.obor
prednaska__nazev.short_description = u'Přednáška' prednaska__nazev.short_description = u'Přednáška'
prednaska__popis.short_description = u'Popis pro orgy' prednaska__popis.short_description = u'Popis pro orgy'

Loading…
Cancel
Save