Remove Profile.reports_allowed (obsolete)

It is obsoleted by Profile.reports
This commit is contained in:
Pēteris Caune 2021-06-29 14:38:06 +03:00
parent b70e2c9a25
commit 61a8a8de26
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
6 changed files with 17 additions and 12 deletions

View File

@ -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',
),
]

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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.