Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updating the UI to be aware of status.

  • Loading branch information...
commit 604e6ff1bc9ae5d7b2ce1b5819220b8a093d8438 1 parent 46cf97a
@justinabrahms justinabrahms authored
View
2  django_website/aggregator/forms.py
@@ -14,4 +14,4 @@ class FeedModelForm(forms.ModelForm):
class Meta:
model = Feed
- exclude = ('is_defunct', 'feed_type', 'owner')
+ exclude = ('is_defunct', 'feed_type', 'owner', 'approval_status')
View
4 django_website/aggregator/models.py
@@ -20,10 +20,12 @@ def __unicode__(self):
def items(self):
return FeedItem.objects.filter(feed__feed_type=self)
+APPROVED_FEED='A'
+
STATUS_CHOICES = (
('P', 'Pending'),
('D', 'Denied'),
- ('A', 'Approved')
+ (APPROVED_FEED, 'Approved')
)
View
12 django_website/aggregator/views.py
@@ -7,7 +7,7 @@
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.views.generic.list_detail import object_list
-from .models import FeedItem, Feed, FeedType
+from .models import FeedItem, Feed, FeedType, APPROVED_FEED
from .forms import FeedModelForm
from ..shortcuts import render
@@ -23,8 +23,8 @@ def feed_list(request, feed_type_slug):
Shows the latest feeds for the given type.
"""
feed_type = get_object_or_404(FeedType, slug=feed_type_slug)
- return object_list(request,
- queryset = FeedItem.objects.filter(feed__feed_type=feed_type),
+ return object_list(request,
+ queryset = FeedItem.objects.filter(feed__feed_type=feed_type, feed__approval_status=APPROVED_FEED),
paginate_by = 25,
extra_context = {'feed_type': feed_type},
)
@@ -54,7 +54,7 @@ def add_feed(request, feed_type_slug):
ft = get_object_or_404(FeedType, slug=feed_type_slug, can_self_add=True)
if not ft.can_self_add and not request.user.is_superuser:
return render(request, 'aggregator/denied.html')
-
+
instance = Feed(feed_type=ft, owner=request.user)
f = FeedModelForm(request.POST or None, instance=instance)
if f.is_valid():
@@ -76,7 +76,7 @@ def edit_feed(request, feed_id):
if f.is_valid():
f.save()
return redirect('community-my-feeds')
-
+
ctx = {'form': f, 'feed': feed, 'adding': False}
return render(request, 'aggregator/edit-feed.html', ctx)
@@ -91,4 +91,4 @@ def delete_feed(request, feed_id):
if request.method == 'POST':
feed.delete()
return redirect('community-my-feeds')
- return render(request, 'aggregator/delete-confirm.html', {'feed': feed})
+ return render(request, 'aggregator/delete-confirm.html', {'feed': feed})
Please sign in to comment.
Something went wrong with that request. Please try again.