Example #1
0
def add_feed(request):
    if request.method == 'POST':
        form = FeedForm(data=request.POST)
        if form.is_valid():
            event = form.save()
            return HttpResponse('OK')
            #return HttpResponseRedirect("%s" % post.get_nice_url())
    else:
        form = FeedForm()
    return HttpResponse('0')
Example #2
0
File: views.py Project: dnet/f33dme
def add_feed(request):
    if request.method == "POST":
        form = FeedForm(data=request.POST)
        if form.is_valid() and not Feed.objects.filter(url=form.cleaned_data["url"]).all():
            event = form.save()
            return HttpResponse("OK")
            # return HttpResponseRedirect("%s" % post.get_nice_url())
    else:
        form = FeedForm()
    return HttpResponse("0")
Example #3
0
def feed(request):
    '''This view will hold the feed'''

     #  Creating FeedForm object
    feedForm = FeedForm()

    #  Creating title for the new feed page.
    title = 'New Feed'

    #  The below if statement deals with POST data sent to the FeedForm form.
    if request.POST:
        feedForm = FeedForm(request.POST)

        #  Checking the validity of the form
        if feedForm.is_valid():
            #  Saving the submitted data to the approriate tables via the save method.
            feedForm.save()

            #  Success message string that is sent to the template below to confirm that the write to the database was successful.
            success_message = 'SUCCESS'

            #  Creating first context this is a total success of form.
            context = {
                'title': title,
                'feedForm':feedForm,
                'success_message': success_message
            }

            #  This return is issued if no post data was made
            return render(request,'feeds/feed.html',context)

    #  Default context. This is an empty forum.
    context = {
        'title': title,
        'feedForm':feedForm
    }

    #This return is issued if no post data was made
    return render(request,'feeds/feed.html',context)