Mercurial > public > sg101
diff gpp/news/admin.py @ 204:b4305e18d3af
Resolve ticket #74. Add user badges. Some extra credit was done here: also refactored how pending news, links, and downloads are handled.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 01 May 2010 21:53:59 +0000 |
parents | ca66189c7c44 |
children | 65016249bf35 |
line wrap: on
line diff
--- a/gpp/news/admin.py Wed Apr 28 03:00:31 2010 +0000 +++ b/gpp/news/admin.py Sat May 01 21:53:59 2010 +0000 @@ -1,32 +1,52 @@ """ This file contains the automatic admin site definitions for the News models. """ +import datetime from django.contrib import admin from django.conf import settings +from django.core.cache import cache from news.models import PendingStory from news.models import Story from news.models import Category class PendingStoryAdmin(admin.ModelAdmin): - list_display = ('title', 'date_submitted', 'submitter') - list_filter = ('date_submitted', ) - search_fields = ('title', 'short_text', 'long_text') - date_hierarchy = 'date_submitted' + list_display = ('title', 'date_submitted', 'submitter') + list_filter = ('date_submitted', ) + search_fields = ('title', 'short_text', 'long_text') + date_hierarchy = 'date_submitted' + actions = ('approve_story', ) - class Media: - js = settings.GPP_THIRD_PARTY_JS['tiny_mce'] + def approve_story(self, request, qs): + for pending_story in qs: + story = Story( + title=pending_story.title, + submitter=pending_story.submitter, + category=pending_story.category, + short_text=pending_story.short_text, + long_text=pending_story.long_text, + date_submitted=datetime.datetime.now(), + allow_comments=pending_story.allow_comments, + tags=pending_story.tags) + story.save() + pending_story.delete() + cache.delete('home_news') + + approve_story.short_description = "Approve selected pending stories" + + class Media: + js = settings.GPP_THIRD_PARTY_JS['tiny_mce'] class StoryAdmin(admin.ModelAdmin): - list_display = ('title', 'date_published', 'submitter', 'category') - list_filter = ('date_published', 'category') - search_fields = ('title', 'short_text', 'long_text') - date_hierarchy = 'date_published' + list_display = ('title', 'date_submitted', 'submitter', 'category') + list_filter = ('date_submitted', 'category') + search_fields = ('title', 'short_text', 'long_text') + date_hierarchy = 'date_submitted' - class Media: - js = settings.GPP_THIRD_PARTY_JS['tiny_mce'] + class Media: + js = settings.GPP_THIRD_PARTY_JS['tiny_mce'] admin.site.register(Category)