Repository: kartoza/prj.app

Issue:
Crash on listing current sponsors
When opening the sponsors view (with some sponsors and sponsor periods created) we get a crash.

http://changelog.inasafe.org/en/qgis/sponsor/list/

Sentry info:

http://sentry.kartoza.com/kartoza/projecta-live/group/5848/

Relevant code.

```
    def current_sponsor(self):
        today = datetime.datetime.now().replace(tzinfo=utc)
        end = self.end_date.replace(tzinfo=utc)  # <-- offending line
        if end < today:
            return False
        else:
            return True
```



Discussion:
```
piroot@uwsgi:/home/web/django_project# pip freeze
Django==1.8.8
Markdown==2.3.1
Pillow==3.1.0
South==1.0.2
Unidecode==0.04.19
awesome-slugify==1.4
beautifulsoup4==4.3.2
django-braces==1.8.1
django-crispy-forms==1.4.0
django-disqus==0.5
django-embed-video==1.0.0
django-grappelli==2.7.3
django-hashedfilenamestorage==1.0
django-indexer==0.3.0
django-model-utils==1.4.0
django-paging==0.2.5
django-pipeline==1.3.11
django-pure-pagination==0.3.0
django-reversion==1.9.3
django-rosetta==0.7.0
django-sentry==1.13.5
django-templatetag-sugar==1.0
django-widget-tweaks==1.3
docutils==0.12
easy-thumbnails==2.3
eventlet==0.18.1
funcsigs==0.4
futures==3.0.4
greenlet==0.4.9
lockfile==0.12.2
mock==1.3.0
pbr==1.8.1
psycopg2==2.6.1
pypandoc==0.6.0
python-daemon==2.1.0
pytz==2015.7
raven==5.8.1
regex==2016.01.10
requests==1.2.3
six==1.10.0
uWSGI==2.0.12
virtualenv==1.11.6
wsgiref==0.1.2
```

See also #215 


Resolving patch:
diff --git a/django_project/changes/models/sponsorship_period.py b/django_project/changes/models/sponsorship_period.py
--- a/django_project/changes/models/sponsorship_period.py
+++ b/django_project/changes/models/sponsorship_period.py
@@ -1,15 +1,19 @@
-__author__ = 'rischan'
+# coding=utf-8
 
 import string
 import random
+import datetime
 from django.utils import timezone
 from django.core.urlresolvers import reverse
 from django.utils.text import slugify
+# noinspection PyPackageRequirements
 from core.settings.contrib import STOP_WORDS
 from django.db import models
 from django.utils.translation import ugettext_lazy as _
 from django.contrib.auth.models import User
 
+__author__ = 'rischan'
+
 
 class ApprovedSponsorshipPeriodManager(models.Manager):
     """Custom sponsor manager that shows only approved records."""
@@ -57,14 +61,16 @@ class SponsorshipPeriod(models.Model):
     objects = models.Manager()
     approved_objects = ApprovedSponsorshipPeriodManager()
     unapproved_objects = UnapprovedSponsorshipPeriodManager()
+    # noinspection PyUnresolvedReferences
     sponsor = models.ForeignKey(
-            'Sponsor',
-            help_text='Input the sponsor name',
+        'Sponsor',
+        help_text='Input the sponsor name',
     )
+    # noinspection PyUnresolvedReferences
     sponsorshiplevel = models.ForeignKey(
-            'SponsorshipLevel',
-            help_text='This level take from Sponsorship Level, '
-            'you can add it by using Sponsorship Level menu',
+        'SponsorshipLevel',
+        help_text='This level take from Sponsorship Level, '
+        'you can add it by using Sponsorship Level menu',
     )
     # noinspection PyClassicStyleClass
 
@@ -86,11 +92,13 @@ def save(self, *args, **kwargs):
             self.slug = slugify(new_list)[:50]
         super(SponsorshipPeriod, self).save(*args, **kwargs)
 
-    def slug_generator(self, size=6, chars=string.ascii_lowercase):
+    @staticmethod
+    def slug_generator(size=6, chars=string.ascii_lowercase):
         return ''.join(random.choice(chars) for _ in range(size))
 
     def __unicode__(self):
         return u'%s - %s : %s' % (
+            self.sponsor.name,
             self.start_date,
             self.end_date
         )
@@ -102,7 +110,7 @@ def get_absolute_url(self):
         })
 
     def current_sponsor(self):
-        today = timezone.now()
+        today = datetime.datetime.now().date()
         end = self.end_date
         if end < today:
             return False


Test patch: