Пример #1
0
def create_event(request):
	if request.method != 'POST':
		return HttpResponse('must make POST request')
	name = request.POST['name']
	description = request.POST['description']
	start_time = request.POST['start_time']
	location = request.POST['location']
	event = Event(name=name,description=description,start_time=start_time,location=location)
	try:
		event.save()
	except db.Error:
		return _error_response(request,'db error')

	return _success_response(request,{'event':event.id})
Пример #2
0
def event(request):
    form = EventForm()
    event = Event()
    context = {
        'form':form,
        }
    if request.method == 'POST':
        form = EventForm(request.POST)
        if form.is_valid():
            ok_states = ['VA','VIRGINIA']
            state = form.cleaned_data['state']
            state = state.upper().strip()
            if not state in ok_states:
                return HttpResponseRedirect('http://startvirginia.com/onlyva.html')
            event.name = form.cleaned_data['name']
            event.description = form.cleaned_data['description']
            event.when = form.cleaned_data['when']
            event.url = form.cleaned_data['url']
            event.street1 = form.cleaned_data['street1']
            event.street2 = form.cleaned_data['street2']
            event.city = form.cleaned_data['city']
            event.state = state
            event.zipcode = form.cleaned_data['zipcode']
            (latitude, longitude) = location_from_address(
                form.cleaned_data['street1'],
                form.cleaned_data['city'],
                form.cleaned_data['state'],
                form.cleaned_data['zipcode'])
            
            event.latitude = latitude
            event.longitude = longitude
            event.save()
            return HttpResponseRedirect('http://startvirginia.com/thankyou.html')
        
    response = render_to_response('forms/event.html', context,
                                  context_instance=RequestContext(request))
    response['Access-Control-Allow-Origin'] = '*'
    return response