snipt/snipt/snipts/admin.py

29 lines
888 B
Python
Raw Normal View History

from django.contrib import admin
2011-06-05 08:55:27 -07:00
from snipts.models import Comment, Snipt
class CommentInline(admin.TabularInline):
2011-06-05 09:51:56 -07:00
readonly_fields = ('user', 'snipt',)
2011-06-05 08:55:27 -07:00
model = Comment
extra = 0
allow_add = False
class SniptAdmin(admin.ModelAdmin):
2011-10-19 20:50:23 -07:00
# TODO: Make user readonly
#readonly_fields = ('user',)
2011-06-05 09:51:56 -07:00
list_display = ('title', 'slug', 'user', 'lexer', 'public', 'created', 'modified',)
2011-10-19 20:50:23 -07:00
search_fields = ('title', 'user__username', 'lexer', 'id',)
ordering = ('created',)
prepopulated_fields = {'slug': ('title',)}
2011-06-05 08:55:27 -07:00
inlines = [CommentInline]
admin.site.register(Snipt, SniptAdmin)
2011-06-05 08:55:27 -07:00
class CommentAdmin(admin.ModelAdmin):
2011-10-19 20:50:23 -07:00
readonly_fields = ('user', 'snipt',)
2011-06-05 08:55:27 -07:00
list_display = ('comment', 'user', 'snipt', 'created', 'modified',)
search_fields = ('comment', 'user__username',)
ordering = ('created',)
admin.site.register(Comment, CommentAdmin)