def get_servicedesk_tickets(request): groups = utils.stringify_groups(request.user) status = request.GET.get('status') priority = request.GET.get('priority') type = request.GET.get('type') search = request.GET.get('search') count = request.GET.get('count') or BY_DEFAULT_RECORDS_PER_PAGE page_details = {} feedback_obects = get_feedbacks(request.user, status, priority, type, search) paginator = Paginator(feedback_obects, count) page = request.GET.get('page', 1) feedbacks = paginator.page(page) page_details['total_objects'] = paginator.count page_details['from'] = feedbacks.start_index() page_details['to'] = feedbacks.end_index() training_material = models.Service.objects.filter(service_type__name=Services.SERVICE_DESK) if len(training_material)>0: training_material = training_material[0].training_material_url else: training_material = None return render(request, 'service-desk/tickets.html', {"feedbacks" : feedbacks, "status": utils.get_list_from_set(FEEDBACK_STATUS), "types": utils.get_list_from_set(FEEDBACK_TYPE), "priorities": utils.get_list_from_set(PRIORITY), "pagination_links": PAGINATION_LINKS, "page_details": page_details, "record_showing_counts": RECORDS_PER_PAGE, "training_material" : training_material, "groups":groups[0], "filter_params": {'status': status, 'priority': priority, 'type': type, 'count': str(count), 'search': search}} )
def service_desk(request): status = request.GET.get('status') priority = request.GET.get('priority') type = request.GET.get('type') search = request.GET.get('search') count = request.GET.get('count') or BY_DEFAULT_RECORDS_PER_PAGE page_details = {} feedback_obects = get_feedbacks(request.user, status, priority, type, search) paginator = Paginator(feedback_obects, count) page = request.GET.get('page', 1) feedbacks = paginator.page(page) page_details['total_objects'] = paginator.count page_details['from'] = feedbacks.start_index() page_details['to'] = feedbacks.end_index() groups = utils.stringify_groups(request.user) training_material = models.Service.objects.filter(service_type__name=Services.SERVICE_DESK) if len(training_material)>0: training_material = training_material[0].training_material_url else: training_material = None if request.method == 'GET': template = 'service-desk/feedback_details.html' data = None if request.user.groups.filter(name=Roles.DEALERS).exists(): data = models.ServiceAdvisor.objects.active_under_dealer(request.user) else: data = models.ServiceAdvisor.objects.active_under_asc(request.user) dealer_asc_details = models.UserProfile.objects.get(user__username=request.user) return render(request, template, {"feedbacks" : feedbacks, 'active_menu': 'support', "data": data, 'groups': groups, "status": utils.get_list_from_set(FEEDBACK_STATUS), "pagination_links": PAGINATION_LINKS, "page_details": page_details, "record_showing_counts": RECORDS_PER_PAGE, "types": utils.get_list_from_set(FEEDBACK_TYPE), "priorities": utils.get_list_from_set(PRIORITY), "training_material" : training_material, "dealer_asc" : dealer_asc_details, "filter_params": {'status': status, 'priority': priority, 'type': type, 'count': str(count), 'search': search}} ) elif request.method == 'POST': try: data = save_help_desk_data(request) return HttpResponse(content=json.dumps(data), content_type='application/json') except Exception as ex: LOG.error('Exception while saving data : {0}'.format(ex)) return HttpResponseBadRequest() else: return HttpResponseBadRequest()