Commits

Gustavo Picon committed 6c8b5a4

feedjack is now newforms-admin compliant

  • Participants
  • Parent commits 89c0c71

Comments (0)

Files changed (3)

File feedjack/admin.py

+# -*- coding: utf-8 -*-
+
+"""
+feedjack
+Gustavo Picón
+admin.py
+"""
+
+from django.contrib import admin
+from django.utils.translation import ugettext_lazy as _ 
+from feedjack import models
+
+
+class LinkAdmin(admin.ModelAdmin):
+    pass
+
+
+
+class SiteAdmin(admin.ModelAdmin):
+    list_display = ('url', 'name')
+    filter_vertical = ('links',)
+
+
+
+class FeedAdmin(admin.ModelAdmin):
+    list_display = ('name', 'feed_url', 'title', 'last_modified', \
+      'is_active')
+    fieldsets = (
+      (None,
+        {'fields':('feed_url', 'name', 'shortname', 'is_active')}),
+      (_('Fields updated automatically by Feedjack'),
+        {'classes':('collapse',),
+         'fields':('title', 'tagline', 'link', 'etag', 'last_modified',
+                   'last_checked'),
+        })
+    )
+    search_fields = ['feed_url', 'name', 'title']
+
+
+
+class PostAdmin(admin.ModelAdmin):
+    list_display = ('title', 'link', 'author', 'date_modified')
+    search_fields = ['link', 'title']
+    date_hierarchy = 'date_modified'
+    filter_vertical = ('tags',)
+
+
+
+class SubscriberAdmin(admin.ModelAdmin):
+    list_display = ('name', 'site', 'feed')
+    list_filter = ('site',)
+
+
+admin.site.register(models.Link, LinkAdmin)
+admin.site.register(models.Site, SiteAdmin)
+admin.site.register(models.Feed, FeedAdmin)
+admin.site.register(models.Post, PostAdmin)
+admin.site.register(models.Subscriber, SubscriberAdmin)
+
+#~

File feedjack/models.py

         return u'%s (%s)' % (self.name, self.link)
 
 
+
 class Site(models.Model):
     name = models.CharField(_('name'), max_length=100)
     url = models.CharField(_('url'),
 
     default_site = models.BooleanField(_('default site'), default=False)
     posts_per_page = models.IntegerField(_('posts per page'), default=20)
-    order_posts_by = models.IntegerField(_('order posts by'), default=1, \
-      choices=SITE_ORDERBY_CHOICES)
+    order_posts_by = models.IntegerField(_('order posts by'), default=1,
+        choices=SITE_ORDERBY_CHOICES)
     tagcloud_levels = models.IntegerField(_('tagcloud level'), default=5)
     show_tagcloud = models.BooleanField(_('show tagcloud'), default=True)
     
     use_internal_cache = models.BooleanField(_('use internal cache'), default=True)
-    cache_duration = models.IntegerField(_('cache duration'), default=60*60*24, \
-      help_text=_('Duration in seconds of the cached pages and data.') )
+    cache_duration = models.IntegerField(_('cache duration'), default=60*60*24,
+        help_text=_('Duration in seconds of the cached pages and data.') )
 
-    links = models.ManyToManyField(Link, verbose_name=_('links'), filter_interface=models.VERTICAL, \
+    links = models.ManyToManyField(Link, verbose_name=_('links'),
       null=True, blank=True)
-    template = models.CharField(_('template'), max_length=100, null=True, blank=True, \
-      help_text=_('This template must be a directory in your feedjack ' \
+    template = models.CharField(_('template'), max_length=100, null=True,
+      blank=True, 
+      help_text=_('This template must be a directory in your feedjack '
         'templates directory. Leave blank to use the default template.') )
 
-    class Admin:
-        list_display = ('url', 'name')
-
     class Meta:
         verbose_name = _('site')
         verbose_name_plural = _('sites')
 
 
 
+
 class Feed(models.Model):
     feed_url = models.URLField(_('feed url'), unique=True)
 
     name = models.CharField(_('name'), max_length=100)
     shortname = models.CharField(_('shortname'), max_length=50)
-    is_active = models.BooleanField(_('is active'), default=True, \
-      help_text=_('If disabled, this feed will not be further updated.') )
+    is_active = models.BooleanField(_('is active'), default=True,
+        help_text=_('If disabled, this feed will not be further updated.') )
 
     title = models.CharField(_('title'), max_length=200, blank=True)
     tagline = models.TextField(_('tagline'), blank=True)
     last_modified = models.DateTimeField(_('last modified'), null=True, blank=True)
     last_checked = models.DateTimeField(_('last checked'), null=True, blank=True)
 
-    class Admin:
-        list_display = ('name', 'feed_url', 'title', 'last_modified', \
-          'is_active')
-        fields = (
-          (None, {'fields':('feed_url', 'name', 'shortname', 'is_active')}),
-          (_('Fields updated automatically by Feedjack'), {
-            'classes':'collapse',
-            'fields':('title', 'tagline', 'link', 'etag', 'last_modified', \
-              'last_checked')})
-        )
-        search_fields = ['feed_url', 'name', 'title']
-
     class Meta:
         verbose_name = _('feed')
         verbose_name_plural = _('feeds')
     def save(self):
         super(Feed, self).save()
 
+
+
 class Tag(models.Model):
     name = models.CharField(_('name'), max_length=50, unique=True)
 
     author = models.CharField(_('author'), max_length=50, blank=True)
     author_email = models.EmailField(_('author email'), blank=True)
     comments = models.URLField(_('comments'), blank=True)
-    tags = models.ManyToManyField(Tag, verbose_name=_('tags'), filter_interface=models.VERTICAL)
+    tags = models.ManyToManyField(Tag, verbose_name=_('tags'))
     date_created = models.DateField(_('date created'), auto_now_add=True)
 
-    class Admin:
-        list_display = ('title', 'link', 'author', 'date_modified')
-        search_fields = ['link', 'title']
-        date_hierarchy = 'date_modified'
-
     class Meta:
         verbose_name = _('post')
         verbose_name_plural = _('posts')
         return self.link
 
 
+
 class Subscriber(models.Model):
     site = models.ForeignKey(Site, verbose_name=_('site') )
     feed = models.ForeignKey(Feed, verbose_name=_('feed') )
 
-    name = models.CharField(_('name'), max_length=100, null=True, blank=True, \
-      help_text=_('Keep blank to use the Feed\'s original name.') )
-    shortname = models.CharField(_('shortname'), max_length=50, null=True, blank=True, \
+    name = models.CharField(_('name'), max_length=100, null=True, blank=True,
+        help_text=_('Keep blank to use the Feed\'s original name.') )
+    shortname = models.CharField(_('shortname'), max_length=50, null=True,
+      blank=True,
       help_text=_('Keep blank to use the Feed\'s original shortname.') )
-    is_active = models.BooleanField(_('is active'), default=True, \
-      help_text=_('If disabled, this subscriber will not appear in the site or '\
+    is_active = models.BooleanField(_('is active'), default=True,
+        help_text=_('If disabled, this subscriber will not appear in the site or '
         'in the site\'s feed.') )
 
-    class Admin:
-        list_display = ('name', 'site', 'feed')
-        list_filter = ('site',)
-
     class Meta:
         verbose_name = _('subscriber')
         verbose_name_plural = _('subscribers')

File feedjack/urls.py

     (r'^foaf/$', views.foaf),
     (r'^$', views.mainview),
 )
+
+#~