

@login_required
def add_suggestion(request):
    if (request.method == 'POST'):
        form = SuggestionForm(request.POST)
        if form.is_valid():
            sug = Suggestion()
            sug.suggested_by = request.user
            sug.text = request.POST.get('text')
            sug.save()
            sug.rating.add(score=1, user=request.user, ip_address=request.META['REMOTE_ADDR'])
            return HttpResponseRedirect('../?sort=suggested_date&dir=desc&filter=mine')
    else:
        form = SuggestionForm()
    suggestions = Suggestion.objects.order_by('rating_score')
    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 add_suggestion/original