@handle_response_format
@treeio_login_required
def service_add(request, response_format='html'):
 if (not request.user.profile.is_admin('treeio.services')):
  return user_denied(request, message="You don't have administrator access to the Service Support module")
 if request.POST:
  if ('cancel' not in request.POST):
   service = Service()
   form = ServiceForm(request.user.profile, request.POST, instance=service)
   if form.is_valid():
    service = form.save()
    service.set_user_from_request(request)
    return HttpResponseRedirect(reverse('services_service_view', args=[service.id]))
  else:
   return HttpResponseRedirect(reverse('services'))
 else:
  form = ServiceForm(request.user.profile)
 context = _get_default_context(request)
 context.update({'form': form})
 return render_to_response('services/service_add', context, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def service_add ( request , response_format = 'html' ) : if ( not request . user . profile . is_admin ( 'treeio.services' ) ) : return user_denied ( request , message = "You don't have administrator access to the Service Support module" ) if request . POST : if ( 'cancel' not in request . POST ) : service = Service ( ) form = ServiceForm ( request . user . profile , request . POST , instance = service ) if form . is_valid ( ) : service = form . save ( ) service . set_user_from_request ( request ) return HttpResponseRedirect ( reverse ( 'services_service_view' , args = [ service . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'services' ) ) else : form = ServiceForm ( request . user . profile ) context = _get_default_context ( request ) context . update ( { 'form' : form } ) return render_to_response ( 'services/service_add' , context , context_instance = RequestContext ( request ) , response_format = response_format )
service add .