

def list_all(request):
    suggestions = Suggestion.objects.order_by('-rating_score')
    if ('nqs' in request.GET):
        qs = request.GET['nqs'].replace('+', ' ')
        suggestions = suggestions.filter(text__icontains=qs)
    if ('filter' in request.GET):
        try:
            f = request.GET['filter']
            if (f == 'mine'):
                user = User.objects.get(username=request.user)
                for s in suggestions:
                    voted = s.rating.get_rating_for_user(user=user, ip_address=request.META['REMOTE_ADDR'])
                    if (not voted):
                        suggestions = suggestions.exclude(pk=s.id)
            if (f == 'done'):
                suggestions = suggestions.exclude(completed=False)
        except:
            pass
    form = SuggestionForm()
    return render_to_response('suggestions/list.html', {
        'suggestions': suggestions,
        'form': form,
    }, context_instance=RequestContext(request))

dataset/ETHPy150Open azavea/Open-Data-Catalog/OpenDataCatalog/suggestions/views.py list_all/original