def type_add(request, response_format='html'): "ItemType add" if not request.user.get_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 not 'cancel' in request.POST: item_type = ItemType() form = ItemTypeForm( request.user.get_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.get_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)
def type_add(request, response_format='html'): "ItemType add" if not request.user.get_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 not 'cancel' in request.POST: item_type = ItemType() form = ItemTypeForm(request.user.get_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.get_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)