From 9ae358e6f894bedb5b36f1e964df76858f2b70f4 Mon Sep 17 00:00:00 2001 From: Ross Poulton Date: Wed, 8 Aug 2012 14:31:51 +1000 Subject: [PATCH] Allow tests to run if Sites module isn't properly configured. --- helpdesk/lib.py | 6 +++++- helpdesk/models.py | 10 ++++++++-- helpdesk/views/staff.py | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/helpdesk/lib.py b/helpdesk/lib.py index 6587d8a1..f3e0b50f 100644 --- a/helpdesk/lib.py +++ b/helpdesk/lib.py @@ -241,9 +241,13 @@ def text_is_spam(text, request): from helpdesk.akismet import Akismet except: return False + try: + site = Site.objects.get_current() + except: + site = Site(domain='configure-django-sites.com') ak = Akismet( - blog_url='http://%s/' % Site.objects.get(pk=settings.SITE_ID).domain, + blog_url='http://%s/' % site.domain, agent='django-helpdesk', ) diff --git a/helpdesk/models.py b/helpdesk/models.py index 6ad543f7..a9bdef11 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -395,7 +395,10 @@ class Ticket(models.Model): """ from django.contrib.sites.models import Site from django.core.urlresolvers import reverse - site = Site.objects.get_current() + try: + site = Site.objects.get_current() + except: + site = Site(domain='configure-django-sites.com') return u"http://%s%s?ticket=%s&email=%s" % ( site.domain, reverse('helpdesk_public_view'), @@ -411,7 +414,10 @@ class Ticket(models.Model): """ from django.contrib.sites.models import Site from django.core.urlresolvers import reverse - site = Site.objects.get_current() + try: + site = Site.objects.get_current() + except: + site = Site(domain='configure-django-sites.com') return u"http://%s%s" % ( site.domain, reverse('helpdesk_view', diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 0b0d2a6e..47210bff 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -350,7 +350,7 @@ def update_ticket(request, ticket_id, public=False): title == ticket.title, priority == int(ticket.priority), due_date == ticket.due_date, - (not owner and not ticket.assigned_to) or (owner and User.objects.get(id=owner) == ticket.assigned_to), + (owner == -1) or (not owner and not ticket.assigned_to) or (owner and User.objects.get(id=owner) == ticket.assigned_to), (HAS_TAG_SUPPORT and tags == ticket.tags) or not HAS_TAG_SUPPORT, ]) if no_changes: