Source

django-happening / happening / news / admin.py

Full commit
Rich Leland 762d120 
Rich Leland 7a63a19 
Rich Leland de37381 
Rich Leland 762d120 
Rich Leland 7a63a19 











Rich Leland de37381 




Rich Leland 762d120 
Rich Leland 7a63a19 

Rich Leland 762d120 
Rich Leland de37381 
Rich Leland 762d120 


Rich Leland de37381 
Rich Leland 762d120 
from django.contrib import admin
from django import forms
from happening.news.models import Category, NewsItem

try:
    from tinymce.widgets import TinyMCE
except:
    TinyMCE = None

if TinyMCE:
    class NewsItemForm(forms.ModelForm):
        long_text = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))
        
        class Meta:
            model = NewsItem


class CategoryAdmin(admin.ModelAdmin):
    prepopulated_fields = { 'slug': ('name',) }


class NewsItemAdmin(admin.ModelAdmin):
    if TinyMCE:
        form = NewsItemForm
    list_display = ('title', 'pub_date', 'visible')
    list_filter = ('visible', 'category')
    search_fields = ('title',)
    prepopulated_fields = { 'slug': ('title',) }

admin.site.register(Category, CategoryAdmin)
admin.site.register(NewsItem, NewsItemAdmin)