def homepage(request): if not request.user.is_authenticated( ) and helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT: return HttpResponseRedirect(reverse('helpdesk:login')) if request.user.is_staff or \ (request.user.is_authenticated() and helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE): try: if request.user.usersettings_helpdesk.settings.get( 'login_view_ticketlist', False): return HttpResponseRedirect(reverse('helpdesk:list')) else: return HttpResponseRedirect(reverse('helpdesk:dashboard')) except UserSettings.DoesNotExist: return HttpResponseRedirect(reverse('helpdesk:dashboard')) if request.method == 'POST': form = PublicTicketForm(request.POST, request.FILES) form.fields['queue'].choices = [('', '--------')] + [ (q.id, q.title) for q in Queue.objects.filter(allow_public_submission=True) ] if form.is_valid(): if text_is_spam(form.cleaned_data['body'], request): # This submission is spam. Let's not save it. return render(request, template_name='helpdesk/public_spam.html') else: ticket = form.save() return HttpResponseRedirect( '%s?ticket=%s&email=%s' % (reverse('helpdesk:public_view'), ticket.ticket_for_url, urlquote(ticket.submitter_email))) else: try: queue = Queue.objects.get(slug=request.GET.get('queue', None)) except Queue.DoesNotExist: queue = None initial_data = {} if queue: initial_data['queue'] = queue.id if request.user.is_authenticated() and request.user.email: initial_data['submitter_email'] = request.user.email form = PublicTicketForm(initial=initial_data) form.fields['queue'].choices = [('', '--------')] + [ (q.id, q.title) for q in Queue.objects.filter(allow_public_submission=True) ] knowledgebase_categories = KBCategory.objects.all() return render( request, 'helpdesk/public_homepage.html', { 'form': form, 'helpdesk_settings': helpdesk_settings, 'kb_categories': knowledgebase_categories })
def homepage(request): if not request.user.is_authenticated() and helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT: return HttpResponseRedirect(reverse('login')) if (request.user.is_staff or (request.user.is_authenticated() and helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE)): try: if getattr(request.user.usersettings.settings, 'login_view_ticketlist', False): return HttpResponseRedirect(reverse('helpdesk_list')) else: return HttpResponseRedirect(reverse('helpdesk_dashboard')) except UserSettings.DoesNotExist: return HttpResponseRedirect(reverse('helpdesk_dashboard')) if request.method == 'POST': form = PublicTicketForm(request.POST, request.FILES) form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] if form.is_valid(): if text_is_spam(form.cleaned_data['body'], request): # This submission is spam. Let's not save it. return render_to_response('helpdesk/public_spam.html', RequestContext(request, {})) else: ticket = form.save() return HttpResponseRedirect('%s?ticket=%s&email=%s'% ( reverse('helpdesk_public_view'), ticket.ticket_for_url, ticket.submitter_email) ) else: try: queue = Queue.objects.get(slug=request.GET.get('queue', None)) except Queue.DoesNotExist: queue = None initial_data = {} if queue: initial_data['queue'] = queue.id if request.user.is_authenticated() and request.user.email: initial_data['submitter_email'] = request.user.email form = PublicTicketForm(initial=initial_data) form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] knowledgebase_categories = KBCategory.objects.all() # all tickets, reported by current user all_tickets_reported_by_current_user = '' email_current_user = request.user.email if email_current_user: all_tickets_reported_by_current_user = Ticket.objects.select_related('queue').filter( submitter_email=email_current_user, ).order_by('status', '-modified') return render_to_response('helpdesk/public_homepage.html', RequestContext(request, { 'form': form, 'helpdesk_settings': helpdesk_settings, 'all_tickets_reported_by_current_user': all_tickets_reported_by_current_user, 'kb_categories': knowledgebase_categories }))
def homepage(request): if not request.user.is_authenticated(): return HttpResponseRedirect(reverse('login')) if (request.user.is_staff or (request.user.is_authenticated())): try: if getattr(request.user.usersettings.settings, 'login_view_ticketlist', False): return HttpResponseRedirect(reverse('helpdesk_list')) else: return HttpResponseRedirect(reverse('helpdesk_dashboard')) except UserSettings.DoesNotExist: return HttpResponseRedirect(reverse('helpdesk_dashboard')) if request.method == 'POST': form = PublicTicketForm(request.POST, request.FILES) form.fields['queue'].choices = [ ('', '--------') ] + [[q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] if form.is_valid(): if text_is_spam(form.cleaned_data['body'], request): # This submission is spam. Let's not save it. return render_to_response('helpdesk/public_spam.html', RequestContext(request, {})) else: ticket = form.save() return HttpResponseRedirect( '%s?ticket=%s&email=%s' % (reverse('helpdesk_public_view'), ticket.ticket_for_url, ticket.submitter_email)) else: try: queue = Queue.objects.get(slug=request.GET.get('queue', None)) except Queue.DoesNotExist: queue = None initial_data = {} if queue: initial_data['queue'] = queue.id if request.user.is_authenticated() and request.user.email: initial_data['submitter_email'] = request.user.email form = PublicTicketForm(initial=initial_data) form.fields['queue'].choices = [ ('', '--------') ] + [[q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] knowledgebase_categories = KBCategory.objects.all() return render_to_response( 'helpdesk/public_homepage.html', RequestContext(request, { 'form': form, 'kb_categories': knowledgebase_categories }))
def homepage(request): if not request.user.is_authenticated() and helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT: if hasattr(settings, 'LOGIN_URL') and settings.LOGIN_URL: return HttpResponseRedirect(settings.LOGIN_URL+'?next='+request.path) return HttpResponseRedirect(reverse('login')+'?next='+request.path) if (request.user.is_staff or ( request.user.is_authenticated() and helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE)): try: if getattr(request.user.usersettings.settings, 'login_view_ticketlist', False): return HttpResponseRedirect(reverse('helpdesk_list')) return HttpResponseRedirect(reverse('helpdesk_dashboard')) except UserSettings.DoesNotExist: return HttpResponseRedirect(reverse('helpdesk_dashboard')) if request.method == 'POST': form = PublicTicketForm(request.POST, request.FILES) form.fields['queue'].choices = [('', '--------')] + [ [q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] if form.is_valid(): if text_is_spam(form.cleaned_data['body'], request): # This submission is spam. Let's not save it. return render(request, 'helpdesk/public_spam.html', {}) ticket = form.save() return HttpResponseRedirect('%s?ticket=%s&email=%s'% ( reverse('helpdesk_public_view'), ticket.ticket_for_url, ticket.submitter_email)) else: try: queue = Queue.objects.get(slug=request.GET.get('queue', None)) except Queue.DoesNotExist: queue = None initial_data = {} if queue: initial_data['queue'] = queue.id if request.user.is_authenticated() and request.user.email: initial_data['submitter_email'] = request.user.email form = PublicTicketForm(initial=initial_data) form.fields['queue'].choices = [('', '--------')] + [ [q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] knowledgebase_categories = KBCategory.objects.all() public_queues = Queue.objects.filter(allow_public_submission=True) show_submit_form = public_queues.count() and helpdesk_settings.HELPDESK_SUBMIT_A_TICKET_PUBLIC return render(request, 'helpdesk/public_homepage.html', dict( form=form, helpdesk_settings=helpdesk_settings, kb_categories=knowledgebase_categories, show_submit_form=show_submit_form ))
def homepage(request): if not request.user.is_authenticated() and helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT: return HttpResponseRedirect(reverse('helpdesk:login')) if request.user.is_staff or \ (request.user.is_authenticated() and helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE): try: if request.user.usersettings.settings.get('login_view_ticketlist', False): return HttpResponseRedirect(reverse('helpdesk:list')) else: return HttpResponseRedirect(reverse('helpdesk:dashboard')) except UserSettings.DoesNotExist: return HttpResponseRedirect(reverse('helpdesk:dashboard')) if request.method == 'POST': form = PublicTicketForm(request.POST, request.FILES) form.fields['queue'].choices = [('', '--------')] + [ (q.id, q.title) for q in Queue.objects.filter(allow_public_submission=True)] if form.is_valid(): if text_is_spam(form.cleaned_data['body'], request): # This submission is spam. Let's not save it. return render(request, template_name='helpdesk/public_spam.html') else: ticket = form.save() return HttpResponseRedirect('%s?ticket=%s&email=%s' % ( reverse('helpdesk:public_view'), ticket.ticket_for_url, ticket.submitter_email) ) else: try: queue = Queue.objects.get(slug=request.GET.get('queue', None)) except Queue.DoesNotExist: queue = None initial_data = {} if queue: initial_data['queue'] = queue.id if request.user.is_authenticated() and request.user.email: initial_data['submitter_email'] = request.user.email form = PublicTicketForm(initial=initial_data) form.fields['queue'].choices = [('', '--------')] + [ (q.id, q.title) for q in Queue.objects.filter(allow_public_submission=True)] knowledgebase_categories = KBCategory.objects.all() return render(request, 'helpdesk/public_homepage.html', { 'form': form, 'helpdesk_settings': helpdesk_settings, 'kb_categories': knowledgebase_categories })
def homepage(request): if not request.user.is_authenticated() and helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT: if hasattr(settings, 'LOGIN_URL') and settings.LOGIN_URL: return HttpResponseRedirect(settings.LOGIN_URL+'?next='+request.path) return HttpResponseRedirect(reverse('login')+'?next='+request.path) if (request.user.is_staff or (request.user.is_authenticated() and helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE)): try: if getattr(request.user.usersettings.settings, 'login_view_ticketlist', False): return HttpResponseRedirect(reverse('helpdesk_list')) return HttpResponseRedirect(reverse('helpdesk_dashboard')) except UserSettings.DoesNotExist: return HttpResponseRedirect(reverse('helpdesk_dashboard')) if request.method == 'POST': form = PublicTicketForm(request.POST, request.FILES) form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] if form.is_valid(): if text_is_spam(form.cleaned_data['body'], request): # This submission is spam. Let's not save it. return render(request, 'helpdesk/public_spam.html', {}) ticket = form.save() return HttpResponseRedirect('%s?ticket=%s&email=%s'% ( reverse('helpdesk_public_view'), ticket.ticket_for_url, ticket.submitter_email)) else: try: queue = Queue.objects.get(slug=request.GET.get('queue', None)) except Queue.DoesNotExist: queue = None initial_data = {} if queue: initial_data['queue'] = queue.id if request.user.is_authenticated() and request.user.email: initial_data['submitter_email'] = request.user.email form = PublicTicketForm(initial=initial_data) form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] knowledgebase_categories = KBCategory.objects.all() public_queues = Queue.objects.filter(allow_public_submission=True) show_submit_form = public_queues.count() and helpdesk_settings.HELPDESK_SUBMIT_A_TICKET_PUBLIC return render(request, 'helpdesk/public_homepage.html', dict( form=form, helpdesk_settings=helpdesk_settings, kb_categories=knowledgebase_categories, show_submit_form=show_submit_form, ))
def homepage(request): if not request.user.is_authenticated(): return HttpResponseRedirect(reverse('login')) if (request.user.is_staff or (request.user.is_authenticated())): try: if getattr(request.user.usersettings.settings, 'login_view_ticketlist', False): return HttpResponseRedirect(reverse('helpdesk_list')) else: return HttpResponseRedirect(reverse('helpdesk_dashboard')) except UserSettings.DoesNotExist: return HttpResponseRedirect(reverse('helpdesk_dashboard')) if request.method == 'POST': form = PublicTicketForm(request.POST, request.FILES) form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] if form.is_valid(): if text_is_spam(form.cleaned_data['body'], request): # This submission is spam. Let's not save it. return render_to_response('helpdesk/public_spam.html', RequestContext(request, {})) else: ticket = form.save() return HttpResponseRedirect('%s?ticket=%s&email=%s'% ( reverse('helpdesk_public_view'), ticket.ticket_for_url, ticket.submitter_email) ) else: try: queue = Queue.objects.get(slug=request.GET.get('queue', None)) except Queue.DoesNotExist: queue = None initial_data = {} if queue: initial_data['queue'] = queue.id if request.user.is_authenticated() and request.user.email: initial_data['submitter_email'] = request.user.email form = PublicTicketForm(initial=initial_data) form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] knowledgebase_categories = KBCategory.objects.all() return render_to_response('helpdesk/public_homepage.html', RequestContext(request, { 'form': form, 'kb_categories': knowledgebase_categories }))
def form_valid(self, form): request = self.request if text_is_spam(form.cleaned_data['body'], request): # This submission is spam. Let's not save it. return render(request, template_name='helpdesk/public_spam.html') else: ticket = form.save() try: return HttpResponseRedirect( '%s?ticket=%s&email=%s&key=%s' % (reverse('helpdesk:public_view'), ticket.ticket_for_url, urlquote(ticket.submitter_email), ticket.secret_key)) except ValueError: # if someone enters a non-int string for the ticket return HttpResponseRedirect(reverse('helpdesk:home'))
def popup_ticket(request): if request.method == 'POST': form = ShortTicketForm(request.POST, request.FILES) #form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] if form.is_valid(): if text_is_spam(form.cleaned_data['body'], request): # This submission is spam. Let's not save it. return render_to_response('helpdesk/public_spam.html', RequestContext(request, {})) else: ticket = form.save() return HttpResponse('<script type="text/javascript">window.close(); window.parent.location.href = "/";</script>') else: form = ShortTicketForm() html = render(request,"helpdesk/popup_ticket_form.html",{'form':form}) return HttpResponse(html)
def homepage(request): if not request.user.is_authenticated() and helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT: return HttpResponseRedirect(reverse('login')) if (request.user.is_staff or (request.user.is_authenticated() and helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE)): return HttpResponseRedirect(reverse('haystack_search')) if request.method == 'POST': form = PublicTicketForm(request.POST, request.FILES) form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] if form.is_valid(): if text_is_spam(form.cleaned_data['body'], request): # This submission is spam. Let's not save it. return render_to_response('helpdesk/public_spam.html', RequestContext(request, {})) else: ticket = form.save() return HttpResponseRedirect('%s?ticket=%s&email=%s'% ( reverse('helpdesk_public_view'), ticket.ticket_for_url, ticket.submitter_email) ) else: try: queue = Queue.objects.get(slug=request.GET.get('queue', None)) except Queue.DoesNotExist: queue = None initial_data = {} if queue: initial_data['queue'] = queue.id if request.user.is_authenticated() and request.user.email: initial_data['submitter_email'] = request.user.email form = PublicTicketForm(initial=initial_data) form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] return render_to_response('helpdesk/public_homepage.html', RequestContext(request, { 'form': form, 'helpdesk_settings': helpdesk_settings, }))
def homepage(request): if request.user.is_staff: if getattr(request.user.usersettings.settings, "login_view_ticketlist", False): return HttpResponseRedirect(reverse("helpdesk_list")) else: return HttpResponseRedirect(reverse("helpdesk_dashboard")) if request.method == "POST": form = PublicTicketForm(request.POST, request.FILES) form.fields["queue"].choices = [("", "--------")] + [ [q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True) ] if form.is_valid(): if text_is_spam(form.cleaned_data["body"], request): # This submission is spam. Let's not save it. return render_to_response("helpdesk/public_spam.html", RequestContext(request, {})) else: ticket = form.save() return HttpResponseRedirect( "%s?ticket=%s&email=%s" % (reverse("helpdesk_public_view"), ticket.ticket_for_url, ticket.submitter_email) ) else: try: queue = Queue.objects.get(slug=request.GET.get("queue", None)) except Queue.DoesNotExist: queue = None initial_data = {} if queue: initial_data["queue"] = queue.id if request.user.is_authenticated() and request.user.email: initial_data["submitter_email"] = request.user.email form = PublicTicketForm(initial=initial_data) form.fields["queue"].choices = [("", "--------")] + [ [q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True) ] return render_to_response("helpdesk/public_homepage.html", RequestContext(request, {"form": form}))
def homepage(request): if request.user.is_staff or \ (request.user.is_authenticated and helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE): try: if request.user.usersettings_helpdesk.settings.get( 'login_view_ticketlist', False): return HttpResponseRedirect(reverse('helpdesk:list')) else: return HttpResponseRedirect(reverse('helpdesk:dashboard')) except UserSettings.DoesNotExist: return HttpResponseRedirect(reverse('helpdesk:dashboard')) if request.method == 'POST': form = PublicTicketForm(request.POST, request.FILES) form.fields['queue'].choices = [('', '--------')] + [ (q.id, q.title) for q in Queue.objects.filter(allow_public_submission=True) ] if form.is_valid(): if text_is_spam(form.cleaned_data['body'], request): # This submission is spam. Let's not save it. return render(request, template_name='helpdesk/public_spam.html') else: ticket = form.save() try: return HttpResponseRedirect( '%s?ticket=%s&email=%s' % (reverse('helpdesk:public_view'), ticket.ticket_for_url, urlquote( ticket.submitter_email))) except ValueError: # if someone enters a non-int string for the ticket return HttpResponseRedirect(reverse('helpdesk:home')) else: try: queue = Queue.objects.get(slug=request.GET.get('queue', None)) except Queue.DoesNotExist: queue = None initial_data = {} # add pre-defined data for public ticket if hasattr(settings, 'HELPDESK_PUBLIC_TICKET_QUEUE'): slug = settings.HELPDESK_PUBLIC_TICKET_QUEUE queue = Queue.objects.get(slug=slug) if hasattr(settings, 'HELPDESK_PUBLIC_TICKET_PRIORITY'): initial_data['priority'] = settings.HELPDESK_PUBLIC_TICKET_PRIORITY if hasattr(settings, 'HELPDESK_PUBLIC_TICKET_DUE_DATE'): initial_data['due_date'] = settings.HELPDESK_PUBLIC_TICKET_DUE_DATE if queue: initial_data['queue'] = queue.id if request.user.is_authenticated and request.user.email: initial_data['submitter_email'] = request.user.email form = PublicTicketForm(initial=initial_data) form.fields['queue'].choices = [('', '--------')] + [ (q.id, q.title) for q in Queue.objects.filter(allow_public_submission=True) ] knowledgebase_categories = KBCategory.objects.all() return render( request, 'helpdesk/public_homepage.html', { 'form': form, 'helpdesk_settings': helpdesk_settings, 'kb_categories': knowledgebase_categories })
def form_valid(self, form): if text_is_spam(form.cleaned_data['body'], self.request): # This submission is spam. Let's not save it. self.template_name = 'helpdesk/public_spam.html' return self.render_to_response({}) return super(CreateTicket, self).form_valid(form)
def homepage(request): if request.user.is_staff or \ (request.user.is_authenticated and helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE): try: if request.user.usersettings_helpdesk.settings.get('login_view_ticketlist', False): return HttpResponseRedirect(reverse('helpdesk:list')) else: return HttpResponseRedirect(reverse('helpdesk:dashboard')) except UserSettings.DoesNotExist: return HttpResponseRedirect(reverse('helpdesk:dashboard')) if request.method == 'POST': form = PublicTicketForm(request.POST, request.FILES) form.fields['queue'].choices = [('', '--------')] + [ (q.id, q.title) for q in Queue.objects.filter(allow_public_submission=True)] if form.is_valid(): if text_is_spam(form.cleaned_data['body'], request): # This submission is spam. Let's not save it. return render(request, template_name='helpdesk/public_spam.html') else: ticket = form.save() try: return HttpResponseRedirect('%s?ticket=%s&email=%s' % ( reverse('helpdesk:public_view'), ticket.ticket_for_url, urlquote(ticket.submitter_email)) ) except ValueError: # if someone enters a non-int string for the ticket return HttpResponseRedirect(reverse('helpdesk:home')) # form = AuthenticationForm(request.POST, request.FILES) # if form.is_valid(): # ''' Begin reCAPTCHA validation ''' # # recaptcha_response = request.POST.get('g-recaptcha-response') # # url = 'https://www.google.com/recaptcha/api/siteverify' # # values = { # # 'secret': "6LeBWpkUAAAAAMKlYr6-k3JAQZFNP3LvBbTDPnRs", # # 'response': recaptcha_response # # } # # data = urllib.urlencode(values) # # req = urllib2.Request(url, data) # # response = urllib2.urlopen(req) # # result = json.load(response) # # ''' End reCAPTCHA validation ''' # # # # if result['success']: # # form.save() # # messages.success(request, 'New comment added with success!') # # else: # # messages.error(request, 'Invalid reCAPTCHA. Please try again.') # # # # return redirect('login') else: try: queue = Queue.objects.get(slug=request.GET.get('queue', None)) except Queue.DoesNotExist: queue = None initial_data = {} # add pre-defined data for public ticket if hasattr(settings, 'HELPDESK_PUBLIC_TICKET_QUEUE'): # get the requested queue; return an error if queue not found try: queue = Queue.objects.get(slug=settings.HELPDESK_PUBLIC_TICKET_QUEUE) except Queue.DoesNotExist: return HttpResponse(status=500) if hasattr(settings, 'HELPDESK_PUBLIC_TICKET_PRIORITY'): initial_data['priority'] = settings.HELPDESK_PUBLIC_TICKET_PRIORITY if hasattr(settings, 'HELPDESK_PUBLIC_TICKET_DUE_DATE'): initial_data['due_date'] = settings.HELPDESK_PUBLIC_TICKET_DUE_DATE if queue: initial_data['queue'] = queue.id if request.user.is_authenticated and request.user.email: initial_data['submitter_email'] = request.user.email form = PublicTicketForm(initial=initial_data) form.fields['queue'].choices = [('', '--------')] + [ (q.id, q.title) for q in Queue.objects.filter(allow_public_submission=True)] knowledgebase_categories = KBCategory.objects.all() return render(request, 'helpdesk/public_homepage.html', { 'form': form, 'helpdesk_settings': helpdesk_settings, 'kb_categories': knowledgebase_categories })
def homepage(request): tickets = {} followupsTickets = {} if not request.user.is_authenticated() and helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT: return HttpResponseRedirect(reverse('login')) if (request.user.is_staff or (request.user.is_authenticated() and helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE)): try: if getattr(request.user.usersettings.settings, 'login_view_ticketlist', False): return HttpResponseRedirect(reverse('helpdesk_list')) else: return HttpResponseRedirect(reverse('helpdesk_dashboard')) except UserSettings.DoesNotExist: return HttpResponseRedirect(reverse('helpdesk_dashboard')) if request.method == 'POST': form = PublicTicketForm(request.POST, request.FILES) form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] if form.is_valid(): if text_is_spam(form.cleaned_data['body'], request): # This submission is spam. Let's not save it. return render_to_response('helpdesk/public_spam.html', RequestContext(request, {})) else: ticket = form.save() return HttpResponseRedirect('%s?ticket=%s&email=%s'% ( reverse('helpdesk_public_view'), ticket.ticket_for_url, ticket.submitter_email) ) else: try: queue = Queue.objects.get(slug=request.GET.get('queue', None)) except Queue.DoesNotExist: queue = None initial_data = {} if queue: initial_data['queue'] = queue.id if request.user.is_authenticated() and request.user.email: initial_data['submitter_email'] = request.user.email # Display users tickets if configured if helpdesk_settings.HELPDESK_USERS_TICKETS_PUBLIC : try: print("display tickets") tickets = Ticket.objects.all().filter(submitter_email = request.user.email) if tickets.count() > 0: #load Last FllowUp Inset for tk in tickets: follow = FollowUp.objects.all().filter(ticket=tk).order_by('-date')[:1] follow = follow.get() followupsTickets[follow.ticket.id] = "[you]" if follow.user is None else "Support Tech" except Ticket.DoesNotExist: print("don't tickets") ticket = None form = PublicTicketForm(initial=initial_data) form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] knowledgebase_categories = KBCategory.objects.all() return render_to_response('helpdesk/public_homepage.html', RequestContext(request, { 'form': form, 'helpdesk_settings': helpdesk_settings, 'kb_categories': knowledgebase_categories, 'tickets': tickets, 'assigned_tickets_followups':followupsTickets, }))