From 4e018db5a6754a0cbeae1a61b35cb7a54eee32aa Mon Sep 17 00:00:00 2001 From: Alex Seeholzer Date: Fri, 13 Jan 2017 15:14:23 +0100 Subject: [PATCH] =?UTF-8?q?Added=20unique=20related=5Fname=20=E2=80=9Cuser?= =?UTF-8?q?setttings=5Fhelpdesk=E2=80=9D=20for=20the=20one-to-one=20relati?= =?UTF-8?q?on=20to=20User=20in=20UserSettings.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helpdesk/forms.py | 2 +- helpdesk/models.py | 6 ++++-- helpdesk/views/public.py | 2 +- helpdesk/views/staff.py | 10 +++++----- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/helpdesk/forms.py b/helpdesk/forms.py index 013ab270..7ab2024f 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -253,7 +253,7 @@ class AbstractTicketForm(CustomFieldMixin, forms.Form): if ticket.assigned_to and \ ticket.assigned_to != user and \ - ticket.assigned_to.usersettings.settings.get('email_on_ticket_assign', False) and \ + ticket.assigned_to.usersettings_helpdesk.settings.get('email_on_ticket_assign', False) and \ ticket.assigned_to.email and \ ticket.assigned_to.email not in messages_sent_to: send_templated_mail( diff --git a/helpdesk/models.py b/helpdesk/models.py index 4dc28a36..273d4cef 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -1084,10 +1084,12 @@ class UserSettings(models.Model): as notification preferences and other things that should probably be configurable. - We should always refer to user.usersettings.settings['setting_name']. + We should always refer to user.usersettings_helpdesk.settings['setting_name']. """ - user = models.OneToOneField(settings.AUTH_USER_MODEL) + user = models.OneToOneField( + settings.AUTH_USER_MODEL, + related_name="usersettings_helpdesk") settings_pickled = models.TextField( _('Settings Dictionary'), diff --git a/helpdesk/views/public.py b/helpdesk/views/public.py index f15ecb2f..b66900f5 100644 --- a/helpdesk/views/public.py +++ b/helpdesk/views/public.py @@ -27,7 +27,7 @@ def homepage(request): (request.user.is_authenticated() and helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE): try: - if request.user.usersettings.settings.get('login_view_ticketlist', False): + if request.user.usersettings_helpdesk.settings.get('login_view_ticketlist', False): return HttpResponseRedirect(reverse('helpdesk:list')) else: return HttpResponseRedirect(reverse('helpdesk:dashboard')) diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index a482dea3..546aec25 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -578,10 +578,10 @@ def update_ticket(request, ticket_id, public=False): if (not reassigned or (reassigned and - ticket.assigned_to.usersettings.settings.get( + ticket.assigned_to.usersettings_helpdesk.settings.get( 'email_on_ticket_assign', False))) or \ (not reassigned and - ticket.assigned_to.usersettings.settings.get( + ticket.assigned_to.usersettings_helpdesk.settings.get( 'email_on_ticket_change', False)): send_templated_mail( template_staff, @@ -914,7 +914,7 @@ def ticket_list(request): return render(request, 'helpdesk/ticket_list.html', dict( context, tickets=ticket_qs, - default_tickets_per_page=request.user.usersettings.settings.get('tickets_per_page') or 25, + default_tickets_per_page=request.user.usersettings_helpdesk.settings.get('tickets_per_page') or 25, user_choices=User.objects.filter(is_active=True, is_staff=True), queue_choices=user_queues, status_choices=Ticket.STATUS_CHOICES, @@ -965,7 +965,7 @@ def create_ticket(request): return HttpResponseRedirect(reverse('helpdesk:dashboard')) else: initial_data = {} - if request.user.usersettings.settings.get('use_email_as_submitter', False) and request.user.email: + if request.user.usersettings_helpdesk.settings.get('use_email_as_submitter', False) and request.user.email: initial_data['submitter_email'] = request.user.email if 'queue' in request.GET: initial_data['queue'] = request.GET['queue'] @@ -1312,7 +1312,7 @@ delete_saved_query = staff_member_required(delete_saved_query) def user_settings(request): - s = request.user.usersettings + s = request.user.usersettings_helpdesk if request.POST: form = UserSettingsForm(request.POST) if form.is_valid():