@treeio_login_required
@handle_response_format
def event_add(request, date=None, hour=12, response_format='html'):
 if request.POST:
  if ('cancel' not in request.POST):
   event = Event()
   form = EventForm(request.user.profile, date, hour, request.POST, instance=event)
   if form.is_valid():
    event = form.save()
    event.set_user_from_request(request)
    return HttpResponseRedirect(reverse('events_event_view', args=[event.id]))
  else:
   return HttpResponseRedirect(reverse('events'))
 else:
  form = EventForm(request.user.profile, date, hour)
 return render_to_response('events/event_add', {'form': form}, context_instance=RequestContext(request), response_format=response_format)

@ treeio_login_required @ handle_response_format def event_add ( request , date = None , hour = 12 , response_format = 'html' ) : if request . POST : if ( 'cancel' not in request . POST ) : event = Event ( ) form = EventForm ( request . user . profile , date , hour , request . POST , instance = event ) if form . is_valid ( ) : event = form . save ( ) event . set_user_from_request ( request ) return HttpResponseRedirect ( reverse ( 'events_event_view' , args = [ event . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'events' ) ) else : form = EventForm ( request . user . profile , date , hour ) return render_to_response ( 'events/event_add' , { 'form' : form } , context_instance = RequestContext ( request ) , response_format = response_format )
event add form .