Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding approval_status to Feed objects (with accompanying admin).

  • Loading branch information...
commit 1ea624b97337f4eb75645750d200a779ed53a222 1 parent e358782
@justinabrahms justinabrahms authored
View
8 django_website/aggregator/admin.py
@@ -3,16 +3,16 @@
from django.contrib import admin
from .models import Feed, FeedItem, FeedType
-admin.site.register(Feed,
- list_display = ["title", "feed_type", "public_url"],
- list_filter = ["feed_type", "is_defunct"],
+admin.site.register(Feed,
+ list_display = ["title", "feed_type", "public_url", "approval_status"],
+ list_filter = ["feed_type", "is_defunct", "approval_status"],
ordering = ["title"],
search_fields = ["title", "public_url"],
raw_id_fields = ['owner'],
list_per_page = 500,
)
-admin.site.register(FeedItem,
+admin.site.register(FeedItem,
list_display = ['title', 'feed', 'date_modified'],
list_filter = ['feed'],
search_fields = ['feed__title', 'feed__public_url', 'title'],
View
88 django_website/aggregator/migrations/0004_add_approval_status_field.py
@@ -0,0 +1,88 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Adding field 'Feed.approval_status'
+ db.add_column('aggregator_feed', 'approval_status', self.gf('django.db.models.fields.CharField')(default='P', max_length=1), keep_default=False)
+
+
+ def backwards(self, orm):
+
+ # Deleting field 'Feed.approval_status'
+ db.delete_column('aggregator_feed', 'approval_status')
+
+
+ models = {
+ 'aggregator.feed': {
+ 'Meta': {'object_name': 'Feed'},
+ 'approval_status': ('django.db.models.fields.CharField', [], {'default': "'P'", 'max_length': '1'}),
+ 'feed_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['aggregator.FeedType']"}),
+ 'feed_url': ('django.db.models.fields.URLField', [], {'unique': 'True', 'max_length': '500'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_defunct': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'owned_feeds'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'public_url': ('django.db.models.fields.URLField', [], {'max_length': '500'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '500'})
+ },
+ 'aggregator.feeditem': {
+ 'Meta': {'ordering': "('-date_modified',)", 'object_name': 'FeedItem'},
+ 'date_modified': ('django.db.models.fields.DateTimeField', [], {}),
+ 'feed': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['aggregator.Feed']"}),
+ 'guid': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '500', 'db_index': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'link': ('django.db.models.fields.URLField', [], {'max_length': '500'}),
+ 'summary': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '500'})
+ },
+ 'aggregator.feedtype': {
+ 'Meta': {'object_name': 'FeedType'},
+ 'can_self_add': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '250'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '250', 'db_index': 'True'})
+ },
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ }
+ }
+
+ complete_apps = ['aggregator']
View
15 django_website/aggregator/models.py
@@ -5,6 +5,7 @@
from django.conf import settings
from django_push.subscriber import signals as push_signals
from django_push.subscriber.models import Subscription
+from django.conf import settings
log = logging.getLogger(__name__)
@@ -19,11 +20,19 @@ def __unicode__(self):
def items(self):
return FeedItem.objects.filter(feed__feed_type=self)
+STATUS_CHOICES = (
+ ('P', 'Pending'),
+ ('D', 'Denied'),
+ ('A', 'Approved')
+)
+
+
class Feed(models.Model):
title = models.CharField(max_length=500)
feed_url = models.URLField(unique=True, max_length=500)
public_url = models.URLField(max_length=500)
is_defunct = models.BooleanField()
+ approval_status = models.CharField(max_length=1, choices=STATUS_CHOICES, default=STATUS_CHOICES[0][0])
feed_type = models.ForeignKey(FeedType)
owner = models.ForeignKey(User, blank=True, null=True, related_name='owned_feeds')
@@ -32,11 +41,13 @@ def __unicode__(self):
def save(self, **kwargs):
super(Feed, self).save(**kwargs)
- Subscription.objects.subscribe(self.feed_url, settings.PUSH_HUB)
+ if settings.PRODUCTION and self.approval_status == STATUS_CHOICES[2][0]:
+ Subscription.objects.subscribe(self.feed_url, settings.PUSH_HUB)
def delete(self, **kwargs):
super(Feed, self).delete(**kwargs)
- Subscription.objects.unsubscribe(self.feed_url, settings.PUSH_HUB)
+ if settings.PRODUCTION: # @@@ need to validate what pubsub stuff is actually doing here.
+ Subscription.objects.unsubscribe(self.feed_url, settings.PUSH_HUB)
class FeedItemManager(models.Manager):
def create_or_update_by_guid(self, guid, **kwargs):
Please sign in to comment.
Something went wrong with that request. Please try again.