gremmie@1: """ gremmie@1: This file contains the automatic admin site definitions for the News models. gremmie@1: """ bgneal@204: import datetime gremmie@1: gremmie@1: from django.contrib import admin bgneal@7: from django.conf import settings bgneal@7: gremmie@1: from news.models import PendingStory gremmie@1: from news.models import Story gremmie@1: from news.models import Category gremmie@1: gremmie@1: class PendingStoryAdmin(admin.ModelAdmin): bgneal@204: list_display = ('title', 'date_submitted', 'submitter') bgneal@204: list_filter = ('date_submitted', ) bgneal@204: search_fields = ('title', 'short_text', 'long_text') bgneal@204: date_hierarchy = 'date_submitted' bgneal@204: actions = ('approve_story', ) gremmie@1: bgneal@204: def approve_story(self, request, qs): bgneal@204: for pending_story in qs: bgneal@204: story = Story( bgneal@204: title=pending_story.title, bgneal@204: submitter=pending_story.submitter, bgneal@204: category=pending_story.category, bgneal@204: short_text=pending_story.short_text, bgneal@204: long_text=pending_story.long_text, bgneal@204: date_submitted=datetime.datetime.now(), bgneal@204: allow_comments=pending_story.allow_comments, bgneal@204: tags=pending_story.tags) bgneal@204: story.save() bgneal@204: pending_story.delete() bgneal@204: bgneal@204: approve_story.short_description = "Approve selected pending stories" bgneal@204: bgneal@204: class Media: bgneal@204: js = settings.GPP_THIRD_PARTY_JS['tiny_mce'] gremmie@1: gremmie@1: gremmie@1: class StoryAdmin(admin.ModelAdmin): bgneal@204: list_display = ('title', 'date_submitted', 'submitter', 'category') bgneal@204: list_filter = ('date_submitted', 'category') bgneal@204: search_fields = ('title', 'short_text', 'long_text') bgneal@204: date_hierarchy = 'date_submitted' gremmie@1: bgneal@204: class Media: bgneal@204: js = settings.GPP_THIRD_PARTY_JS['tiny_mce'] gremmie@1: gremmie@1: gremmie@1: admin.site.register(Category) gremmie@1: admin.site.register(Story, StoryAdmin) gremmie@1: admin.site.register(PendingStory, PendingStoryAdmin)