aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2011-04-27 20:37:30 -0400
committerbnewbold <bnewbold@robocracy.org>2011-04-27 20:37:30 -0400
commit481459f41a30c6708c4b18e8200a4d5bcf9cd1e6 (patch)
tree41965aea40d73268bc45571d490b8612ddc39206
parentc0394f2461854b2735aa5ff7b5435b5bc1978498 (diff)
downloadpiccast-481459f41a30c6708c4b18e8200a4d5bcf9cd1e6.zip
piccast-481459f41a30c6708c4b18e8200a4d5bcf9cd1e6.tar.gz
enable is_valid for PicSets, fix sets_by_feed sort
-rw-r--r--piccast/feeds/management/commands/scrape_feeds.py5
-rw-r--r--piccast/feeds/models.py1
-rw-r--r--piccast/feeds/views.py6
3 files changed, 7 insertions, 5 deletions
diff --git a/piccast/feeds/management/commands/scrape_feeds.py b/piccast/feeds/management/commands/scrape_feeds.py
index 2371f97..957c596 100644
--- a/piccast/feeds/management/commands/scrape_feeds.py
+++ b/piccast/feeds/management/commands/scrape_feeds.py
@@ -10,7 +10,7 @@ from feeds.models import *
# see Command definition at the end
# this mechanism isn't robust yet b/c any small sets get parsed repeatedly
-MIN_SET_SIZE = 1 # Need to find at least this many images for each set
+MIN_SET_SIZE = 3 # Need to find at least this many images for each set
###############################################################################
def scrape_pics_from_html(pset, html):
@@ -94,7 +94,8 @@ def scrape_pics_acidcow(pset):
if(len(pics) < MIN_SET_SIZE):
print "Didn't find enough pictures to save this set (found " + \
str(len(pics)) + ", MIN_SET_SIZE=" + str(MIN_SET_SIZE) + ")"
- pset.delete()
+ pset.is_valid = False
+ pset.save()
return
# TODO: oh boy, serial, this is a horrible way to do it!
diff --git a/piccast/feeds/models.py b/piccast/feeds/models.py
index 716bd78..2b04b7a 100644
--- a/piccast/feeds/models.py
+++ b/piccast/feeds/models.py
@@ -97,6 +97,7 @@ class PicSet(models.Model):
feed = models.ForeignKey('feeds.PicFeed', null=True,blank=False)
category = models.ForeignKey('feeds.Category', null=True,blank=True)
is_nsfw = models.BooleanField(default=False, blank=False);
+ is_valid = models.BooleanField(default=True);
def __unicode__(self):
return self.title
diff --git a/piccast/feeds/views.py b/piccast/feeds/views.py
index 84d2d8d..1c26d12 100644
--- a/piccast/feeds/views.py
+++ b/piccast/feeds/views.py
@@ -21,13 +21,13 @@ def newest_feeds(request):
def sets_by_feed(request, req_feed):
# TODO: validate req_feed
- sets = PicSet.objects.filter(feed=req_feed).order_by('-created')
+ sets = PicSet.objects.filter(feed=req_feed, is_valid=True).order_by('-created')
return HttpResponse(json.dumps({'list': [s.serializable() for s in sets]}, indent=2), mimetype="application/json")
def sets_by_feedslug(request, req_feedslug):
# TODO: validate req_feedslug
- feed = PicFeed.objects.filter(shortname=req_feedslug).order_by('-created')
- sets = PicSet.objects.filter(feed=feed)
+ feed = PicFeed.objects.filter(shortname=req_feedslug)
+ sets = PicSet.objects.filter(feed=feed, is_valid=True).order_by('-created')
return HttpResponse(json.dumps({'list': [s.serializable() for s in sets]}, indent=2), mimetype="application/json")
def pics_by_set(request, req_picset):