Commits

Ian Lewis committed fa2e8bc

Added admin actions for items and feeds

  • Participants
  • Parent commits 9e23e35

Comments (0)

Files changed (1)

File lifestream/admin.py

 
     model = Lifestream 
 
-
 admin.site.register(Lifestream, LifestreamAdmin)
 
 class FeedCreationForm(forms.ModelForm):
 class FeedAdmin(admin.ModelAdmin):
     list_display    = ('name', 'lifestream', 'domain', 'fetchable')
     list_filter     = ('domain', 'lifestream')
+    actions         = ['make_fetchable', 'make_unfetchable']
   
     add_form = FeedCreationForm
     model = Feed
   
+    def make_unfetchable(self, request, queryset):
+        queryset.update(fetchable=False)
+    make_unfetchable.short_description = _(u"Mark as unfetchable")
+    
+    def make_fetchable(self, request, queryset):
+        queryset.update(fetchable=True)
+    make_fetchable.short_description = _(u"Mark as fetchable")
+    
     def add_view(self, request):
         if not self.has_change_permission(request):
             raise PermissionDenied
     exclude         = ['clean_content',]
     list_filter     = ('feed',)
     search_fields   = ('title','clean_content')
+    actions         = ['make_published', 'make_unpublished']
     list_per_page   = 20
   
     model = Item
   
+    def make_unpublished(self, request, queryset):
+        queryset.update(published=False)
+    make_unpublished.short_description = _(u"Unpublish items")
+    
+    def make_published(self, request, queryset):
+        queryset.update(published=True)
+    make_published.short_description = _(u"Publish items")
+    
     def save_model(self, request, obj, form, change):
         obj.clean_content = strip_tags(obj.content)
         obj.save()