Beispiel #1
0
def gather(request):
    if request.method == 'POST': # If the form has been submitted...
        form = GatherForm(request.POST) # A form bound to the POST data
        
        if form.is_valid(): # All validation rules pass
            gather_data = dict()
            
            for key in form.cleaned_data:
                if form.cleaned_data[key]:
                    gather_data[key] = form.cleaned_data[key]
            
            formatted = get_fromForm(gather_data)
            print formatted
            print "time to fill"
            filler = makeObjects_fromText(formatted, 'FORM')
            print filler
            print form.cleaned_data['headline']
            slug = slugify(form.cleaned_data['headline'])
            print slug
            new_storygroup = StoryGroup.objects.filter(slugline=slug)
            print new_storygroup
            
            return HttpResponse( json.dumps({'new': str(new_storygroup)}), mimetype="application/json" )
        else:
            form = str(GatherForm(request.POST))
            #soup = BeautifulSoup(form)
            return HttpResponse( json.dumps(form), mimetype="application/json" )
    else:
        form = GatherForm() # An unbound form
    return render_to_response( 'news/gather.html', {'form': form}, context_instance=RequestContext(request) )
Beispiel #2
0
def special(request):
    
    #SLTRIB.COM always comes up with wired chars and crap
    output = get_google() #call function from util.py   
    filler = makeObjects_fromText(output, 'GOOGLE')
    
    return HttpResponse(filler)