Zobrazení Znalostí (stejně jako Přednášek) u daného seznamu
This commit is contained in:
		
							parent
							
								
									2767e82f11
								
							
						
					
					
						commit
						9460c484f7
					
				
					 1 changed files with 31 additions and 1 deletions
				
			
		|  | @ -58,10 +58,40 @@ class Seznam_PrednaskaInline(admin.TabularInline): | |||
| 	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): | ||||
| 	""" Admin pro :py:class:`Seznam <prednasky.models.Seznam>` """ | ||||
| 	list_display = ['soustredeni', 'stav'] | ||||
| 	inlines = [Seznam_PrednaskaInline] | ||||
| 	inlines = [Seznam_PrednaskaInline, Seznam_ZnalostInline] | ||||
| 
 | ||||
| admin.site.register(Seznam, SeznamAdmin) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue