@treeio_login_required
@handle_response_format
def type_add(request, response_format='html'):
 if (not request.user.profile.is_admin('treeio.infrastructure')):
  return user_denied(request, message="You don't have administrator access to the Infrastructure module", response_format=response_format)
 if request.POST:
  if ('cancel' not in request.POST):
   item_type = ItemType()
   form = ItemTypeForm(request.user.profile, request.POST, instance=item_type)
   if form.is_valid():
    item = form.save(request)
    item_type.set_user_from_request(request)
    return HttpResponseRedirect(reverse('infrastructure_type_view', args=[item.id]))
  else:
   return HttpResponseRedirect(reverse('infrastructure_settings_view'))
 else:
  form = ItemTypeForm(request.user.profile)
 context = _get_default_context(request)
 context.update({'form': form})
 return render_to_response('infrastructure/item_type_add', context, context_instance=RequestContext(request), response_format=response_format)

@ treeio_login_required @ handle_response_format def type_add ( request , response_format = 'html' ) : if ( not request . user . profile . is_admin ( 'treeio.infrastructure' ) ) : return user_denied ( request , message = "You don't have administrator access to the Infrastructure module" , response_format = response_format ) if request . POST : if ( 'cancel' not in request . POST ) : item_type = ItemType ( ) form = ItemTypeForm ( request . user . profile , request . POST , instance = item_type ) if form . is_valid ( ) : item = form . save ( request ) item_type . set_user_from_request ( request ) return HttpResponseRedirect ( reverse ( 'infrastructure_type_view' , args = [ item . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'infrastructure_settings_view' ) ) else : form = ItemTypeForm ( request . user . profile ) context = _get_default_context ( request ) context . update ( { 'form' : form } ) return render_to_response ( 'infrastructure/item_type_add' , context , context_instance = RequestContext ( request ) , response_format = response_format )
contacttype add .