From 669c53b5ce8921af0fb9226066d76d8d4d00d9a8 Mon Sep 17 00:00:00 2001 From: Chris Van Date: Mon, 27 Feb 2012 15:21:50 -0800 Subject: [PATCH] revert read_dev_agreement back to a bool --- apps/users/models.py | 2 +- lib/misc/admin_log.py | 3 ++- migrations/325-dev-agreement-datetime.sql | 9 +++++---- migrations/328-bool-dev-agreement.sql | 3 +++ mkt/submit/tests/test_views.py | 22 +++++++++++++--------- 5 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 migrations/328-bool-dev-agreement.sql diff --git a/apps/users/models.py b/apps/users/models.py index b1f9f38c24..08eb91124a 100644 --- a/apps/users/models.py +++ b/apps/users/models.py @@ -114,7 +114,7 @@ class UserProfile(amo.models.OnChangeMixin, amo.models.ModelBase): resetcode_expires = models.DateTimeField(default=datetime.now, null=True, blank=True) sandboxshown = models.BooleanField(default=False) - read_dev_agreement = models.DateTimeField(null=True, blank=True) + read_dev_agreement = models.BooleanField(default=False) last_login_ip = models.CharField(default='', max_length=45, editable=False) last_login_attempt = models.DateTimeField(null=True, editable=False) diff --git a/lib/misc/admin_log.py b/lib/misc/admin_log.py index 20bc1e211c..1ffa68ff76 100644 --- a/lib/misc/admin_log.py +++ b/lib/misc/admin_log.py @@ -18,7 +18,8 @@ NO_EMAIL_PATTERNS = { # re.compile(r'''OperationalError: (1205, 'Lock wait timeout ''' # '''exceeded; try restarting transaction')'''), 'ValidationError': - re.compile(r'Enter a valid date/time'), + re.compile(re.escape('Enter a valid date/time in YYYY-MM-DD ' + 'HH:MM[:ss[.uuuuuu]] format.')), } import logging diff --git a/migrations/325-dev-agreement-datetime.sql b/migrations/325-dev-agreement-datetime.sql index d3a964ac49..5f4c6fe904 100644 --- a/migrations/325-dev-agreement-datetime.sql +++ b/migrations/325-dev-agreement-datetime.sql @@ -1,4 +1,5 @@ -ALTER TABLE `users` CHANGE COLUMN - `read_dev_agreement` `read_dev_agreement` DATETIME; -UPDATE `users` SET `read_dev_agreement` = NULL - WHERE `read_dev_agreement` = '0000-00-00 00:00:00'; +-- -dev was choking on this +-- ALTER TABLE `users` CHANGE COLUMN +-- `read_dev_agreement` `read_dev_agreement` DATETIME; +-- UPDATE `users` SET `read_dev_agreement` = NULL +-- WHERE `read_dev_agreement` = '0000-00-00 00:00:00'; diff --git a/migrations/328-bool-dev-agreement.sql b/migrations/328-bool-dev-agreement.sql new file mode 100644 index 0000000000..91da7d7bb0 --- /dev/null +++ b/migrations/328-bool-dev-agreement.sql @@ -0,0 +1,3 @@ +-- Make this a bool until I figure out why -dev choked on this. +ALTER TABLE `users` CHANGE COLUMN + `read_dev_agreement` `read_dev_agreement` BOOL; diff --git a/mkt/submit/tests/test_views.py b/mkt/submit/tests/test_views.py index f3a39874a4..2f8f9fc5ec 100644 --- a/mkt/submit/tests/test_views.py +++ b/mkt/submit/tests/test_views.py @@ -95,18 +95,20 @@ class TestTerms(TestSubmit): def test_agree(self): r = self.client.post(self.url, {'read_dev_agreement': True}) self.assertRedirects(r, reverse('submit.app.manifest')) - dt = self.get_user().read_dev_agreement - assert close_to_now(dt), ( - 'Expected date of agreement read to be close to now. Was %s' % dt) + #dt = self.get_user().read_dev_agreement + #assert close_to_now(dt), ( + # 'Expected date of agreement read to be close to now. Was %s' % dt) + eq_(self.get_user().read_dev_agreement, True) eq_(UserNotification.objects.count(), 0) def test_agree_and_sign_me_up(self): r = self.client.post(self.url, {'read_dev_agreement': True, 'newsletter': True}) self.assertRedirects(r, reverse('submit.app.manifest')) - dt = self.get_user().read_dev_agreement - assert close_to_now(dt), ( - 'Expected date of agreement read to be close to now. Was %s' % dt) + #dt = self.get_user().read_dev_agreement + #assert close_to_now(dt), ( + # 'Expected date of agreement read to be close to now. Was %s' % dt) + eq_(self.get_user().read_dev_agreement, True) eq_(UserNotification.objects.count(), 1) notes = UserNotification.objects.filter(user=self.user, enabled=True, notification_id=app_surveys.id) @@ -115,7 +117,7 @@ class TestTerms(TestSubmit): def test_disagree(self): r = self.client.post(self.url) eq_(r.status_code, 200) - eq_(self.user.read_dev_agreement, None) + eq_(self.user.read_dev_agreement, False) eq_(UserNotification.objects.count(), 0) @@ -127,7 +129,8 @@ class TestManifest(TestSubmit): self.url = reverse('submit.app.manifest') def _step(self): - self.user.update(read_dev_agreement=datetime.datetime.now()) + #self.user.update(read_dev_agreement=datetime.datetime.now()) + self.user.update(read_dev_agreement=True) def test_anonymous(self): self._test_anonymous() @@ -310,7 +313,8 @@ class TestDetails(TestSubmit): return json.loads(rp.content)['upload_hash'] def _step(self): - self.user.update(read_dev_agreement=datetime.datetime.now()) + #self.user.update(read_dev_agreement=datetime.datetime.now()) + self.user.update(read_dev_agreement=True) self.cl = AppSubmissionChecklist.objects.create(addon=self.webapp, terms=True, manifest=True)