template + structure django CMS
[ifgu.git] / project / article / admin.py
1 # coding: utf8
2 from project.article.models import *
3 from django.db import models
4 from django.contrib import admin
5
6
7 class ActualiteAdmin(admin.ModelAdmin):
8 prepopulated_fields = {'slug': ['titre']}
9 fieldsets = [
10 ('Article', {'fields': ['status', 'date_pub', 'titre', 'slug', 'image', 'texte'], 'classes': ['wide']}),
11 ]
12
13 def show_image2(self, obj):
14 if obj.image:
15 return "<img src='../../../media/%s' style='height:40px;'>" % obj.image
16 else:
17 return "<img src='../../../static/img/logoActu.png' style='height:40px;'>"
18 show_image2.allow_tags = True #permet de sortir du html#
19 show_image2.short_description = 'Image'
20
21 list_display = ('status', 'show_image2', 'titre', 'date_pub')
22 list_display_links = ('status', 'titre')
23 search_fields = ['titre']
24
25 class PublicationAdmin(admin.ModelAdmin):
26 prepopulated_fields = {'slug': ['titre']}
27 fieldsets = [
28 ('Article', {'fields': ['status', 'date_pub', 'titre', 'slug', 'image', 'texte'], 'classes': ['wide']}),
29 ]
30
31 def show_image2(self, obj):
32 if obj.image:
33 return "<img src='../../../media/%s' style='height:40px;'>" % obj.image
34 else:
35 return "<img src='../../../static/img/logoActu.png' style='height:40px;'>"
36 show_image2.allow_tags = True #permet de sortir du html#
37 show_image2.short_description = 'Image'
38
39 list_display = ('status', 'show_image2', 'titre', 'date_pub')
40 list_display_links = ('status', 'titre')
41 search_fields = ['titre']
42
43
44 admin.site.register(Actualite, ActualiteAdmin)
45 admin.site.register(Publication, PublicationAdmin)