def status_add(request, response_format='html'): "TicketStatus 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: status = TicketStatus() form = TicketStatusForm( request.user.profile, request.POST, instance=status) if form.is_valid(): status = form.save() status.set_user_from_request(request) return HttpResponseRedirect(reverse('services_status_view', args=[status.id])) else: return HttpResponseRedirect(reverse('services_settings_view')) else: form = TicketStatusForm(request.user.profile) context = _get_default_context(request) context.update({'form': form}) return render_to_response('services/status_add', context, context_instance=RequestContext(request), response_format=response_format)
def status_edit(request, status_id, response_format='html'): "TicketStatus edit" status = get_object_or_404(TicketStatus, pk=status_id) if not request.user.profile.has_permission(status, mode='w') \ and not request.user.profile.is_admin('anaf'): return user_denied(request, "You don't have access to this Ticket Status", response_format) if request.POST: if 'cancel' not in request.POST: form = TicketStatusForm( request.user.profile, request.POST, instance=status) if form.is_valid(): status = form.save() return HttpResponseRedirect(reverse('services_status_view', args=[status.id])) else: return HttpResponseRedirect(reverse('services_status_view', args=[status.id])) else: form = TicketStatusForm(request.user.profile, instance=status) context = _get_default_context(request) context.update({'form': form, 'status': status}) return render_to_response('services/status_edit', context, context_instance=RequestContext(request), response_format=response_format)
def ticket_status_create(request, slug): project = Project.objects.get(slug=slug) form = TicketStatusForm(request.POST, project=project) if(form.is_valid()): ticket_status = form.save() return HttpResponse(json.dumps({'error': False, 'color': ticket_status.color, 'name': ticket_status.name, 'proj_id': ticket_status.id, 'slug': ticket_status.slug}), content_type="application/json") else: return HttpResponse(json.dumps({'error': True, 'errors': form.errors}), content_type="application/json")
def check_ticket(request): ticket_status_form = TicketStatusForm(request.POST or None) if request.POST and ticket_status_form.is_valid(): ref_no = request.POST.get('ticket_ref_no') try: ticket = Ticket.objects.get(ref_no=ref_no) except: return submit_ticket(request) return redirect('/helpdesk/view/' + str(ticket.uuid) + '/') else: return submit_ticket(request)
def ticket_status(request,slug): template_name = 'Attributes_Status.html' if(request.method=='POST'): form = TicketStatusForm(request.POST,project=slug) if(form.is_valid()): tslug = slugify(request.POST['name']) project = TicketStatus.objects.create(name=request.POST['name'],slug=tslug,color=request.POST['color'],project=Project.objects.get(slug=slug)); return HttpResponse(json.dumps({'error':False,'color':request.POST['color'],'name':request.POST['name'],'proj_id':project.id}),content_type="application/json") else: return HttpResponse(json.dumps({'error':True,'errors':form.errors}),content_type="application/json"); priority_list=TicketStatus.objects.filter(project=Project.objects.get(slug=slug)) return render(request,template_name,{'slug':slug,'priority_list':priority_list})
def submit_ticket(request): if request.user.is_authenticated(): ticket_form = TicketAuthenticatedUserForm(request.POST or None) else: ticket_form = TicketAnonymousUserForm(request.POST or None) message_form = MessageForm(request.POST or None) ticket_status_form = TicketStatusForm(request.POST or None) context = { "ticket_form": ticket_form, "message_form": message_form, "ticket_status_form": ticket_status_form } if request.POST: if ticket_form.is_valid() and message_form.is_valid(): ticket = ticket_form.save(commit=False) if request.user.is_authenticated(): ticket.submitter_email = request.user.email ticket.submitter = request.user ticket.save() message = message_form.save(commit=False) message.ticket = ticket message.sender_type = 'U' if request.user.is_authenticated(): message.sender = request.user message.save() return HttpResponse("Ticket Reference Number is: " + ticket.ref_no) else: return render(request, 'helpdesk/submit_ticket.html', context) else: return render(request, 'helpdesk/submit_ticket.html', context)
def status_add(request, response_format='html'): "TicketStatus 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: status = TicketStatus() form = TicketStatusForm(request.user.profile, request.POST, instance=status) if form.is_valid(): status = form.save() status.set_user_from_request(request) return HttpResponseRedirect( reverse('services_status_view', args=[status.id])) else: return HttpResponseRedirect(reverse('services_settings_view')) else: form = TicketStatusForm(request.user.profile) context = _get_default_context(request) context.update({'form': form}) return render_to_response('services/status_add', context, context_instance=RequestContext(request), response_format=response_format)
def status_edit(request, status_id, response_format='html'): "TicketStatus edit" status = get_object_or_404(TicketStatus, pk=status_id) if not request.user.profile.has_permission(status, mode='w') \ and not request.user.profile.is_admin('anaf'): return user_denied(request, "You don't have access to this Ticket Status", response_format) if request.POST: if 'cancel' not in request.POST: form = TicketStatusForm(request.user.profile, request.POST, instance=status) if form.is_valid(): status = form.save() return HttpResponseRedirect( reverse('services_status_view', args=[status.id])) else: return HttpResponseRedirect( reverse('services_status_view', args=[status.id])) else: form = TicketStatusForm(request.user.profile, instance=status) context = _get_default_context(request) context.update({'form': form, 'status': status}) return render_to_response('services/status_edit', context, context_instance=RequestContext(request), response_format=response_format)