def queue_add(request, response_format='html'): "Queue add" if not request.user.get_profile().is_admin('maker.services'): return user_denied(request, message="You don't have administrator access to the Service Support module") if request.POST: if not 'cancel' in request.POST: queue = TicketQueue() form = QueueForm(request.user.get_profile(), request.POST, instance=queue) if form.is_valid(): queue = form.save() queue.set_user_from_request(request) return HttpResponseRedirect(reverse('services_queue_view', args=[queue.id])) else: return HttpResponseRedirect(reverse('services_settings_view')) else: form = QueueForm(request.user.get_profile()) context = _get_default_context(request) context.update({'form': form}) return render_to_response('services/queue_add', context, context_instance=RequestContext(request), response_format=response_format)
def queue_edit(request, queue_id, response_format='html'): "Queue edit" queue = get_object_or_404(TicketQueue, pk=queue_id) if not request.user.get_profile().has_permission(queue, mode='w'): return user_denied(request, message="You don't have access to this Queue") if request.POST: if not 'cancel' in request.POST: form = QueueForm(request.user.get_profile(), request.POST, instance=queue) if form.is_valid(): queue = form.save() return HttpResponseRedirect(reverse('services_queue_view', args=[queue.id])) else: return HttpResponseRedirect(reverse('services_queue_view', args=[queue.id])) else: form = QueueForm(request.user.get_profile(), instance=queue) context = _get_default_context(request) context.update({'queue': queue, 'form': form}) return render_to_response('services/queue_edit', context, context_instance=RequestContext(request), response_format=response_format)