@treeio_login_required
@handle_response_format
def item_add_typed(request, type_id, response_format='html'):
 item_type = get_object_or_404(ItemType, pk=type_id)
 if (not request.user.profile.has_permission(item_type, mode='x')):
  return user_denied(request, message=("You don't have access to create " + unicode(item_type)), response_format=response_format)
 if request.POST:
  if ('cancel' not in request.POST):
   form = ItemForm(request.user.profile, item_type, request.POST, files=request.FILES)
   if form.is_valid():
    item = form.save(request)
    return HttpResponseRedirect(reverse('infrastructure_item_view', args=[item.id]))
  else:
   return HttpResponseRedirect(reverse('infrastructure_index'))
 else:
  form = ItemForm(request.user.profile, item_type)
 context = _get_default_context(request)
 context.update({'item_type': item_type, 'form': form})
 return render_to_response('infrastructure/item_add_typed', context, context_instance=RequestContext(request), response_format=response_format)

@ treeio_login_required @ handle_response_format def item_add_typed ( request , type_id , response_format = 'html' ) : item_type = get_object_or_404 ( ItemType , pk = type_id ) if ( not request . user . profile . has_permission ( item_type , mode = 'x' ) ) : return user_denied ( request , message = ( "You don't have access to create " + unicode ( item_type ) ) , response_format = response_format ) if request . POST : if ( 'cancel' not in request . POST ) : form = ItemForm ( request . user . profile , item_type , request . POST , files = request . FILES ) if form . is_valid ( ) : item = form . save ( request ) return HttpResponseRedirect ( reverse ( 'infrastructure_item_view' , args = [ item . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'infrastructure_index' ) ) else : form = ItemForm ( request . user . profile , item_type ) context = _get_default_context ( request ) context . update ( { 'item_type' : item_type , 'form' : form } ) return render_to_response ( 'infrastructure/item_add_typed' , context , context_instance = RequestContext ( request ) , response_format = response_format )
item add with preselected type .