def agent_add(request, response_format='html'): "Agent add" if not request.user.profile.is_admin('anaf.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: new_agent = ServiceAgent() form = AgentForm( request.user.profile, request.POST, instance=new_agent) if form.is_valid(): new_agent = form.save() new_agent.set_user_from_request(request) return HttpResponseRedirect(reverse('services_agent_view', args=[new_agent.id])) else: return HttpResponseRedirect(reverse('services_agent_index')) else: form = AgentForm(request.user.profile) context = _get_default_context(request) context.update({'form': form}) return render_to_response('services/agent_add', context, context_instance=RequestContext(request), response_format=response_format)
def agent_add(request, response_format='html'): "Agent add" if not request.user.profile.is_admin('anaf.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: new_agent = ServiceAgent() form = AgentForm(request.user.profile, request.POST, instance=new_agent) if form.is_valid(): new_agent = form.save() new_agent.set_user_from_request(request) return HttpResponseRedirect( reverse('services_agent_view', args=[new_agent.id])) else: return HttpResponseRedirect(reverse('services_agent_index')) else: form = AgentForm(request.user.profile) context = _get_default_context(request) context.update({'form': form}) return render_to_response('services/agent_add', context, context_instance=RequestContext(request), response_format=response_format)
def agent_edit(request, agent_id, response_format='html'): "Agent edit" view_agent = get_object_or_404(ServiceAgent, pk=agent_id) if not request.user.profile.has_permission(view_agent): return user_denied( request, message="You don't have access to this Service Agent") if request.POST: if 'cancel' not in request.POST: form = AgentForm(request.user.profile, request.POST, instance=view_agent) if form.is_valid(): view_agent = form.save() return HttpResponseRedirect( reverse('services_agent_view', args=[view_agent.id])) else: return HttpResponseRedirect( reverse('services_agent_view', args=[view_agent.id])) else: form = AgentForm(request.user.profile, instance=view_agent) context = _get_default_context(request) context.update({'form': form, 'view_agent': view_agent}) return render_to_response('services/agent_edit', context, context_instance=RequestContext(request), response_format=response_format)
def agent_edit(request, agent_id, response_format='html'): "Agent edit" view_agent = get_object_or_404(ServiceAgent, pk=agent_id) if not request.user.profile.has_permission(view_agent): return user_denied(request, message="You don't have access to this Service Agent") if request.POST: if 'cancel' not in request.POST: form = AgentForm( request.user.profile, request.POST, instance=view_agent) if form.is_valid(): view_agent = form.save() return HttpResponseRedirect(reverse('services_agent_view', args=[view_agent.id])) else: return HttpResponseRedirect(reverse('services_agent_view', args=[view_agent.id])) else: form = AgentForm(request.user.profile, instance=view_agent) context = _get_default_context(request) context.update({'form': form, 'view_agent': view_agent}) return render_to_response('services/agent_edit', context, context_instance=RequestContext(request), response_format=response_format)