Compare commits

...

3 commits

3 changed files with 33 additions and 1 deletions

View file

@ -36,6 +36,7 @@ extensions = [
'sphinx.ext.intersphinx', 'sphinx.ext.intersphinx',
'sphinx.ext.autosectionlabel', 'sphinx.ext.autosectionlabel',
'myst_parser', 'myst_parser',
'sphinxcontrib_django',
] ]
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.

View file

@ -58,10 +58,40 @@ class Seznam_PrednaskaInline(admin.TabularInline):
def has_add_permission(self, req, obj): return False def has_add_permission(self, req, obj): return False
class Seznam_ZnalostInline(admin.TabularInline):
"""
Pomůcka pro :py:class:`prednasky.admin.SeznamAdmin` zobrazující hezky :py:class:`Znalosti <prednasky.models.Znalost>`
v adminu :py:class:`Seznamu <prednasky.models.Seznam>`.
"""
model = Znalost.seznamy.through
extra = 0
def znalost__nazev(self, obj):
return mark_safe(
f"<a href='/admin/prednasky/znalost/{obj.znalost.id}'>{obj.znalost.nazev}</a>"
)
def znalost__text(self, obj):
return mark_safe(
f"<div style='width: 200px'>{escape(obj.znalost.text)}</div>"
)
znalost__nazev.short_description = u'Přednáška'
znalost__text.short_description = u'Popis pro orgy'
readonly_fields = [
'znalost__nazev',
'znalost__text',
]
exclude = ['znalost']
def has_add_permission(self, req, obj): return False
class SeznamAdmin(VersionAdmin): class SeznamAdmin(VersionAdmin):
""" Admin pro :py:class:`Seznam <prednasky.models.Seznam>` """ """ Admin pro :py:class:`Seznam <prednasky.models.Seznam>` """
list_display = ['soustredeni', 'stav'] list_display = ['soustredeni', 'stav']
inlines = [Seznam_PrednaskaInline] inlines = [Seznam_PrednaskaInline, Seznam_ZnalostInline]
admin.site.register(Seznam, SeznamAdmin) admin.site.register(Seznam, SeznamAdmin)

View file

@ -49,4 +49,5 @@ lorem
sphinx sphinx
sphinx_rtd_theme sphinx_rtd_theme
sphinxcontrib-django
myst_parser myst_parser