コード例 #1
0
ファイル: views.py プロジェクト: igzebedze/bdash
def manage_categories(request):
	# find all feedjack posts assigned to sites with names of categories
	for c in Category.objects.all():
		for p in Post.objects.filter(infographic__isnull=True,feed__subscriber__site__name=c.title):
			image = imagify(p.content)
			i = Infographic(title=p.title, source=p, category=c, url=p.link, text=p.content, imageurl=image)
			i.save()
	return render_to_response('edit.html', {
    	'latest': Post.objects.filter(infographic__isnull=True)[0:1], 
    	'links': Link.objects.all(), 
		'categories': Category.objects.all(),
    }, context_instance=RequestContext(request))
コード例 #2
0
ファイル: views.py プロジェクト: igzebedze/bdash
def classify(request):
    p = get_object_or_404(Post, guid=request.POST['guid'])
    try:
        selected_choice = Category.objects.get(title=request.POST['category'])
    except (KeyError, Category.DoesNotExist):
        # Redisplay the poll voting form.
        return render_to_response('edit.html', {
            'error_message': "You didn't select a choice.",
            'latest': Post.objects.filter(infographic__title__isnull=True)[0:2],
            'categories': Category.objects.all(),
        }, context_instance=RequestContext(request))
    else:
    	image = imagify(p.content)
        i = Infographic(title=p.title, source=p, category=selected_choice, url=p.link, text=p.content, imageurl=image)
        i.save()
        return HttpResponseRedirect(reverse('feeds.views.manage_categories'))