From 6405da36e422f45af2347ecd13b591ebc575f285 Mon Sep 17 00:00:00 2001 From: digitalpbk Date: Sun, 7 Oct 2012 14:14:32 +0530 Subject: [PATCH 1/3] create_ticket POST should accept all users based on HELPDESK_STAFF_ONLY_TICKET_OWNERS setting, the POST part should accept all users or staff users --- helpdesk/views/staff.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 47210bff..b2f5df07 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -885,10 +885,15 @@ def edit_ticket(request, ticket_id): edit_ticket = staff_member_required(edit_ticket) def create_ticket(request): + if helpdesk_settings.HELPDESK_STAFF_ONLY_TICKET_OWNERS: + assignable_users = User.objects.filter(is_active=True, is_staff=True).order_by('username') + else: + assignable_users = User.objects.filter(is_active=True).order_by('username') + if request.method == 'POST': form = TicketForm(request.POST, request.FILES) form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.all()] - form.fields['assigned_to'].choices = [('', '--------')] + [[u.id, u.username] for u in User.objects.filter(is_active=True,is_staff=True).order_by('username')] + form.fields['assigned_to'].choices = [('', '--------')] + [[u.id, u.username] for u in assignable_users] if form.is_valid(): ticket = form.save(user=request.user) return HttpResponseRedirect(ticket.get_absolute_url()) @@ -901,11 +906,7 @@ def create_ticket(request): form = TicketForm(initial=initial_data) form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.all()] - if helpdesk_settings.HELPDESK_STAFF_ONLY_TICKET_OWNERS: - users = User.objects.filter(is_active=True, is_staff=True).order_by('username') - else: - users = User.objects.filter(is_active=True).order_by('username') - form.fields['assigned_to'].choices = [('', '--------')] + [[u.id, u.username] for u in users] + form.fields['assigned_to'].choices = [('', '--------')] + [[u.id, u.username] for u in assignable_users] if helpdesk_settings.HELPDESK_CREATE_TICKET_HIDE_ASSIGNED_TO: form.fields['assigned_to'].widget = forms.HiddenInput() From 7716eb69a91b4312331cdcfefb3ee26343bdd93a Mon Sep 17 00:00:00 2001 From: digitalpbk Date: Sun, 7 Oct 2012 14:16:57 +0530 Subject: [PATCH 2/3] assigned_to.usersettings.settings is a dictionary t.assigned_to.usersettings.settings is a dictionary, so getattr does not work --- helpdesk/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpdesk/forms.py b/helpdesk/forms.py index 9951a6fd..f3c33dc7 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -320,7 +320,7 @@ class TicketForm(forms.Form): ) messages_sent_to.append(t.submitter_email) - if t.assigned_to and t.assigned_to != user and getattr(t.assigned_to.usersettings.settings, 'email_on_ticket_assign', False) and t.assigned_to.email and t.assigned_to.email not in messages_sent_to: + if t.assigned_to and t.assigned_to != user and t.assigned_to.usersettings.settings.get('email_on_ticket_assign', False) and t.assigned_to.email and t.assigned_to.email not in messages_sent_to: send_templated_mail( 'assigned_owner', context, From 88fa35cf2907ee0c7ee246dcfbacc86c6fa32b65 Mon Sep 17 00:00:00 2001 From: digitalpbk Date: Sun, 7 Oct 2012 14:20:26 +0530 Subject: [PATCH 3/3] import settings from helpdesk instead of django --- helpdesk/management/commands/get_email.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helpdesk/management/commands/get_email.py b/helpdesk/management/commands/get_email.py index d0e9691d..38d840e2 100644 --- a/helpdesk/management/commands/get_email.py +++ b/helpdesk/management/commands/get_email.py @@ -25,7 +25,7 @@ from django.core.files.base import ContentFile from django.core.management.base import BaseCommand from django.db.models import Q from django.utils.translation import ugettext as _ -from django.conf import settings +from helpdesk import settings from helpdesk.lib import send_templated_mail, safe_template_context from helpdesk.models import Queue, Ticket, FollowUp, Attachment, IgnoreEmail @@ -266,7 +266,7 @@ def ticket_from_message(message, queue, quiet): f.save() if not quiet: - print (" [%s-%s] %s%s" % (t.queue.slug, t.id, t.title, update)).encode('ascii', 'replace') + print (" [%s-%s] %s" % (t.queue.slug, t.id, t.title,)).encode('ascii', 'replace') for file in files: if file['content']: