def edit_ticket(request, ticket_id): ticket = get_object_or_404(Ticket, id=ticket_id) if request.method == "POST": form = EditTicketForm(request.POST, instance=ticket) if form.is_valid(): ticket = form.save() return HttpResponseRedirect(ticket.get_absolute_url()) else: form = EditTicketForm(instance=ticket) return render_to_response( "helpdesk/edit_ticket.html", RequestContext(request, {"form": form, "tags_enabled": HAS_TAG_SUPPORT}) )
def edit_ticket(request, ticket_id): ticket = get_object_or_404(Ticket, id=ticket_id) if request.method == 'POST': form = EditTicketForm(request.POST, instance=ticket) if form.is_valid(): ticket = form.save() return HttpResponseRedirect(ticket.get_absolute_url()) else: form = EditTicketForm(instance=ticket) return render_to_response('helpdesk/create_ticket.html', RequestContext(request, { 'form': form, 'tags_enabled': HAS_TAG_SUPPORT, }))
def edit_ticket(request, ticket_id): ticket = get_object_or_404(Ticket, id=ticket_id) if request.method == 'POST': form = EditTicketForm(request.POST, instance=ticket) if form.is_valid(): ticket = form.save() return HttpResponseRedirect(ticket.get_absolute_url()) else: form = EditTicketForm(instance=ticket) return render_to_response('helpdesk/edit_ticket.html', RequestContext(request, { 'form': form, 'tags_enabled': HAS_TAG_SUPPORT, }))
def edit_ticket(request, ticket_id): ticket = get_object_or_404(Ticket, id=ticket_id) if request.method == 'POST': form = EditTicketForm(request.POST, instance=ticket) if form.is_valid(): ticket = form.save() return HttpResponseRedirect(ticket.get_absolute_url()) else: form = EditTicketForm(instance=ticket) form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.all()] return render_to_response('helpdesk/edit_ticket.html', RequestContext(request, { 'form': form, 'tags_enabled': HAS_TAG_SUPPORT, }))
def create_ticket(request): if request.method == 'POST': id = request.POST.get('id') if id: ticket = get_object_or_404(Ticket, id=id) form = EditTicketForm(request.POST, request.FILES, instance=ticket) else: form = TicketForm(request.POST, request.FILES) if form.is_valid(): if id: ticket = form.save() else: ticket = form.save(user=request.user) return HttpResponseRedirect(ticket.get_absolute_url()) else: initial_data = {} id = request.GET.get('id') account_id = request.GET.get('account_id') if account_id: initial_data['account'] = Account.objects.get(id=account_id) if request.user.usersettings.settings.get('use_email_as_submitter', False) and request.user.account.email: initial_data['submitter_email'] = request.user.account.email if id: ticket = get_object_or_404(Ticket, id=id) form = EditTicketForm(instance=ticket) else: form = TicketForm(initial=initial_data) form.fields['assigned_to'].initial = request.user.account form.fields['owner'].initial = request.user return render_to_response('helpdesk/create_ticket.html', RequestContext(request, { 'form': form, 'tags_enabled': HAS_TAG_SUPPORT, }))
def create_ticket(request): if request.method == 'POST': id = request.POST.get('id') if id: ticket = get_object_or_404(Ticket, id=id) form = EditTicketForm(request.POST, request.FILES, instance=ticket) else: form = TicketForm(request.POST, request.FILES) if form.is_valid(): if id: ticket = form.save() else: ticket = form.save(user=request.user) return HttpResponseRedirect(ticket.get_absolute_url()) else: initial_data = {} id = request.GET.get('id') account_id = request.GET.get('account_id') if account_id: initial_data['account'] = Account.objects.get(id=account_id) if request.user.usersettings.settings.get( 'use_email_as_submitter', False) and request.user.account.email: initial_data['submitter_email'] = request.user.account.email if id: ticket = get_object_or_404(Ticket, id=id) form = EditTicketForm(instance=ticket) else: form = TicketForm(initial=initial_data) form.fields['assigned_to'].initial = request.user.account form.fields['owner'].initial = request.user return render_to_response( 'helpdesk/create_ticket.html', RequestContext(request, { 'form': form, 'tags_enabled': HAS_TAG_SUPPORT, }))