1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# -*- coding: utf-8
from django.utils.translation import ugettext_lazy as _
from django.contrib import admin
from pybb.models import Category, Forum, Topic, Post, Read
class CategoryAdmin(admin.ModelAdmin):
list_display = ['name', 'position', 'forum_count']
list_per_page = 20
ordering = ['position']
search_fields = ['name']
class ForumAdmin(admin.ModelAdmin):
list_display = ['name', 'category', 'position', 'topic_count']
list_per_page = 20
ordering = ['-category']
search_fields = ['name', 'category__name']
fieldsets = (
(None, {
'fields': ('category', 'name', 'updated')
}
),
(_('Additional options'), {
'classes': ('collapse',),
'fields': ('position', 'description', 'moderators')
}
),
)
class TopicAdmin(admin.ModelAdmin):
list_display = ['name', 'forum', 'created', 'head']
list_per_page = 20
ordering = ['-created']
date_hierarchy = 'created'
search_fields = ['name']
fieldsets = (
(None, {
'fields': ('forum', 'name', 'user', ('created', 'updated'))
}
),
(_('Additional options'), {
'classes': ('collapse',),
'fields': (('views',), ('sticky', 'closed'), 'subscribers')
}
),
)
class PostAdmin(admin.ModelAdmin):
list_display = ['topic', 'user', 'created', 'updated', 'summary']
list_per_page = 20
ordering = ['-created']
date_hierarchy = 'created'
search_fields = ['body']
fieldsets = (
(None, {
'fields': ('topic', 'user', 'markup')
}
),
(_('Additional options'), {
'classes': ('collapse',),
'fields' : (('created', 'updated'), 'user_ip')
}
),
(_('Message'), {
'fields': ('body', 'body_html', 'body_text')
}
),
)
class ReadAdmin(admin.ModelAdmin):
list_display = ['user', 'topic', 'time']
list_per_page = 20
ordering = ['-time']
date_hierarchy = 'time'
search_fields = ['user__username', 'topic__name']
admin.site.register(Category, CategoryAdmin)
admin.site.register(Forum, ForumAdmin)
admin.site.register(Topic, TopicAdmin)
admin.site.register(Post, PostAdmin)
admin.site.register(Read, ReadAdmin)
|