diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2014-04-22 21:19:52 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2014-04-23 20:40:29 +0800 |
commit | 628a57c214b63b81e457a4a369cc370f4254358f (patch) | |
tree | 86c3e2ebbadef58a21d1357ffc7b14d6a2e22ac6 | |
parent | b8c32a2f022890d0ada32b5750b9427607c4c7e1 (diff) | |
download | patchwork-628a57c214b63b81e457a4a369cc370f4254358f.tar patchwork-628a57c214b63b81e457a4a369cc370f4254358f.tar.gz |
Fix django-1.6 incompatibilities
We're seeing a couple of final quirks running the testsuite on django
1.6:
Traceback (most recent call last):
File "patchwork/apps/patchwork/tests/notifications.py", line 182, in testNotificationEscaping
errors = send_notifications()
File "patchwork/apps/patchwork/utils.py", line 227, in send_notifications
delete_notifications()
File "patchwork/apps/patchwork/utils.py", line 197, in delete_notifications
pk__in = notifications).delete()
File "/usr/lib/python2.7/dist-packages/django/db/models/manager.py", line 163, in filter
return self.get_queryset().filter(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 590, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 608, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "/usr/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 1198, in add_q
clause = self._add_q(where_part, used_aliases)
File "/usr/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 1232, in _add_q
current_negated=current_negated)
File "/usr/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 1122, in build_filter
lookup_type, value)
File "/usr/lib/python2.7/dist-packages/django/db/models/fields/related.py", line 1107, in get_lookup_constraint
values = [get_normalized_value(value) for value in raw_value]
File "/usr/lib/python2.7/dist-packages/django/db/models/fields/related.py", line 1084, in get_normalized_value
value_list.append(getattr(value, source.attname))
AttributeError: 'PatchChangeNotification' object has no attribute 'id'
- we're specifying our own pk here, so the PatchChangeNotification has
no id attribute; it looks like the pk__in syntax is expecting IDs.
We also need a default value for BooleanField, as we're getting
integrity errors when creating rows with no explicit send_notifications
set.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r-- | apps/patchwork/models.py | 2 | ||||
-rw-r--r-- | apps/patchwork/utils.py | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/apps/patchwork/models.py b/apps/patchwork/models.py index 9de2a22..a5f60cb 100644 --- a/apps/patchwork/models.py +++ b/apps/patchwork/models.py @@ -55,7 +55,7 @@ class Project(models.Model): web_url = models.CharField(max_length=2000, blank=True) scm_url = models.CharField(max_length=2000, blank=True) webscm_url = models.CharField(max_length=2000, blank=True) - send_notifications = models.BooleanField() + send_notifications = models.BooleanField(default=False) def __unicode__(self): return self.name diff --git a/apps/patchwork/utils.py b/apps/patchwork/utils.py index 9e1702e..7e3346e 100644 --- a/apps/patchwork/utils.py +++ b/apps/patchwork/utils.py @@ -191,8 +191,8 @@ def send_notifications(): projects = set([ n.patch.project.linkname for n in notifications ]) def delete_notifications(): - PatchChangeNotification.objects.filter( - pk__in = notifications).delete() + pks = [ n.pk for n in notifications ] + PatchChangeNotification.objects.filter(pk__in = pks).delete() if EmailOptout.is_optout(recipient.email): delete_notifications() |