From 61a8a8de26cc2471025b1ca9505dab920ff047d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Tue, 29 Jun 2021 14:38:06 +0300 Subject: [PATCH] Remove Profile.reports_allowed (obsolete) It is obsoleted by Profile.reports --- .../0039_remove_profile_reports_allowed.py | 17 +++++++++++++++++ hc/accounts/models.py | 1 - hc/accounts/tests/test_notifications.py | 6 ------ hc/accounts/tests/test_unsubscribe_reports.py | 1 - hc/accounts/views.py | 2 -- hc/api/tests/test_sendreports.py | 2 -- 6 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 hc/accounts/migrations/0039_remove_profile_reports_allowed.py diff --git a/hc/accounts/migrations/0039_remove_profile_reports_allowed.py b/hc/accounts/migrations/0039_remove_profile_reports_allowed.py new file mode 100644 index 00000000..7165c480 --- /dev/null +++ b/hc/accounts/migrations/0039_remove_profile_reports_allowed.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.4 on 2021-06-29 11:35 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0038_profile_theme'), + ] + + operations = [ + migrations.RemoveField( + model_name='profile', + name='reports_allowed', + ), + ] diff --git a/hc/accounts/models.py b/hc/accounts/models.py index 81b80fd6..67afa351 100644 --- a/hc/accounts/models.py +++ b/hc/accounts/models.py @@ -52,7 +52,6 @@ class ProfileManager(models.Manager): class Profile(models.Model): user = models.OneToOneField(User, models.CASCADE, blank=True, null=True) next_report_date = models.DateTimeField(null=True, blank=True) - reports_allowed = models.BooleanField(default=True) reports = models.CharField(max_length=10, default="monthly", choices=REPORT_CHOICES) nag_period = models.DurationField(default=NO_NAG, choices=NAG_PERIODS) next_nag_date = models.DateTimeField(null=True, blank=True) diff --git a/hc/accounts/tests/test_notifications.py b/hc/accounts/tests/test_notifications.py index 1d2fa137..dbbad042 100644 --- a/hc/accounts/tests/test_notifications.py +++ b/hc/accounts/tests/test_notifications.py @@ -15,7 +15,6 @@ class NotificationsTestCase(BaseTestCase): def test_it_saves_reports_monthly(self): self.profile.reports = "off" - self.profile.reports_allowed = False self.profile.save() self.client.login(username="alice@example.org", password="password") @@ -24,13 +23,11 @@ class NotificationsTestCase(BaseTestCase): self.assertEqual(r.status_code, 200) self.profile.refresh_from_db() - self.assertTrue(self.profile.reports_allowed) self.assertEqual(self.profile.reports, "monthly") self.assertEqual(self.profile.next_report_date.day, 1) def test_it_saves_reports_weekly(self): self.profile.reports = "off" - self.profile.reports_allowed = False self.profile.save() self.client.login(username="alice@example.org", password="password") @@ -39,12 +36,10 @@ class NotificationsTestCase(BaseTestCase): self.assertEqual(r.status_code, 200) self.profile.refresh_from_db() - self.assertTrue(self.profile.reports_allowed) self.assertEqual(self.profile.reports, "weekly") self.assertEqual(self.profile.next_report_date.weekday(), 0) def test_it_saves_reports_off(self): - self.profile.reports_allowed = True self.profile.reports = "monthly" self.profile.next_report_date = now() self.profile.save() @@ -55,7 +50,6 @@ class NotificationsTestCase(BaseTestCase): self.assertEqual(r.status_code, 200) self.profile.refresh_from_db() - self.assertFalse(self.profile.reports_allowed) self.assertEqual(self.profile.reports, "off") self.assertIsNone(self.profile.next_report_date) diff --git a/hc/accounts/tests/test_unsubscribe_reports.py b/hc/accounts/tests/test_unsubscribe_reports.py index 4e976109..c2bdd566 100644 --- a/hc/accounts/tests/test_unsubscribe_reports.py +++ b/hc/accounts/tests/test_unsubscribe_reports.py @@ -21,7 +21,6 @@ class UnsubscribeReportsTestCase(BaseTestCase): self.assertContains(r, "Unsubscribed") self.profile.refresh_from_db() - self.assertFalse(self.profile.reports_allowed) self.assertEqual(self.profile.reports, "off") self.assertIsNone(self.profile.next_report_date) diff --git a/hc/accounts/views.py b/hc/accounts/views.py index 8d5f2dc5..92625088 100644 --- a/hc/accounts/views.py +++ b/hc/accounts/views.py @@ -454,7 +454,6 @@ def notifications(request): profile.tz = form.cleaned_data["tz"] profile.reports = form.cleaned_data["reports"] profile.next_report_date = profile.choose_next_report_date() - profile.reports_allowed = profile.reports != "off" if profile.nag_period != form.cleaned_data["nag_period"]: # Set the new nag period @@ -545,7 +544,6 @@ def unsubscribe_reports(request, signed_username): user = User.objects.get(username=username) profile = Profile.objects.for_user(user) profile.reports = "off" - profile.reports_allowed = False profile.next_report_date = None profile.nag_period = td() profile.next_nag_date = None diff --git a/hc/api/tests/test_sendreports.py b/hc/api/tests/test_sendreports.py index d675ee97..c203ba49 100644 --- a/hc/api/tests/test_sendreports.py +++ b/hc/api/tests/test_sendreports.py @@ -21,11 +21,9 @@ class SendReportsTestCase(BaseTestCase): # Disable bob's and charlie's monthly reports so they don't interfere self.bobs_profile.reports = "off" - self.bobs_profile.reports_allowed = False self.bobs_profile.save() self.charlies_profile.reports = "off" - self.charlies_profile.reports_allowed = False self.charlies_profile.save() # And it needs at least one check that has been pinged.