Browse Source

Remove Profile.reports_allowed (obsolete)

It is obsoleted by Profile.reports
pull/540/head
Pēteris Caune 3 years ago
parent
commit
61a8a8de26
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
6 changed files with 17 additions and 12 deletions
  1. +17
    -0
      hc/accounts/migrations/0039_remove_profile_reports_allowed.py
  2. +0
    -1
      hc/accounts/models.py
  3. +0
    -6
      hc/accounts/tests/test_notifications.py
  4. +0
    -1
      hc/accounts/tests/test_unsubscribe_reports.py
  5. +0
    -2
      hc/accounts/views.py
  6. +0
    -2
      hc/api/tests/test_sendreports.py

+ 17
- 0
hc/accounts/migrations/0039_remove_profile_reports_allowed.py 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',
),
]

+ 0
- 1
hc/accounts/models.py View File

@ -52,7 +52,6 @@ class ProfileManager(models.Manager):
class Profile(models.Model): class Profile(models.Model):
user = models.OneToOneField(User, models.CASCADE, blank=True, null=True) user = models.OneToOneField(User, models.CASCADE, blank=True, null=True)
next_report_date = models.DateTimeField(null=True, blank=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) reports = models.CharField(max_length=10, default="monthly", choices=REPORT_CHOICES)
nag_period = models.DurationField(default=NO_NAG, choices=NAG_PERIODS) nag_period = models.DurationField(default=NO_NAG, choices=NAG_PERIODS)
next_nag_date = models.DateTimeField(null=True, blank=True) next_nag_date = models.DateTimeField(null=True, blank=True)


+ 0
- 6
hc/accounts/tests/test_notifications.py View File

@ -15,7 +15,6 @@ class NotificationsTestCase(BaseTestCase):
def test_it_saves_reports_monthly(self): def test_it_saves_reports_monthly(self):
self.profile.reports = "off" self.profile.reports = "off"
self.profile.reports_allowed = False
self.profile.save() self.profile.save()
self.client.login(username="[email protected]", password="password") self.client.login(username="[email protected]", password="password")
@ -24,13 +23,11 @@ class NotificationsTestCase(BaseTestCase):
self.assertEqual(r.status_code, 200) self.assertEqual(r.status_code, 200)
self.profile.refresh_from_db() self.profile.refresh_from_db()
self.assertTrue(self.profile.reports_allowed)
self.assertEqual(self.profile.reports, "monthly") self.assertEqual(self.profile.reports, "monthly")
self.assertEqual(self.profile.next_report_date.day, 1) self.assertEqual(self.profile.next_report_date.day, 1)
def test_it_saves_reports_weekly(self): def test_it_saves_reports_weekly(self):
self.profile.reports = "off" self.profile.reports = "off"
self.profile.reports_allowed = False
self.profile.save() self.profile.save()
self.client.login(username="[email protected]", password="password") self.client.login(username="[email protected]", password="password")
@ -39,12 +36,10 @@ class NotificationsTestCase(BaseTestCase):
self.assertEqual(r.status_code, 200) self.assertEqual(r.status_code, 200)
self.profile.refresh_from_db() self.profile.refresh_from_db()
self.assertTrue(self.profile.reports_allowed)
self.assertEqual(self.profile.reports, "weekly") self.assertEqual(self.profile.reports, "weekly")
self.assertEqual(self.profile.next_report_date.weekday(), 0) self.assertEqual(self.profile.next_report_date.weekday(), 0)
def test_it_saves_reports_off(self): def test_it_saves_reports_off(self):
self.profile.reports_allowed = True
self.profile.reports = "monthly" self.profile.reports = "monthly"
self.profile.next_report_date = now() self.profile.next_report_date = now()
self.profile.save() self.profile.save()
@ -55,7 +50,6 @@ class NotificationsTestCase(BaseTestCase):
self.assertEqual(r.status_code, 200) self.assertEqual(r.status_code, 200)
self.profile.refresh_from_db() self.profile.refresh_from_db()
self.assertFalse(self.profile.reports_allowed)
self.assertEqual(self.profile.reports, "off") self.assertEqual(self.profile.reports, "off")
self.assertIsNone(self.profile.next_report_date) self.assertIsNone(self.profile.next_report_date)


+ 0
- 1
hc/accounts/tests/test_unsubscribe_reports.py View File

@ -21,7 +21,6 @@ class UnsubscribeReportsTestCase(BaseTestCase):
self.assertContains(r, "Unsubscribed") self.assertContains(r, "Unsubscribed")
self.profile.refresh_from_db() self.profile.refresh_from_db()
self.assertFalse(self.profile.reports_allowed)
self.assertEqual(self.profile.reports, "off") self.assertEqual(self.profile.reports, "off")
self.assertIsNone(self.profile.next_report_date) self.assertIsNone(self.profile.next_report_date)


+ 0
- 2
hc/accounts/views.py View File

@ -454,7 +454,6 @@ def notifications(request):
profile.tz = form.cleaned_data["tz"] profile.tz = form.cleaned_data["tz"]
profile.reports = form.cleaned_data["reports"] profile.reports = form.cleaned_data["reports"]
profile.next_report_date = profile.choose_next_report_date() profile.next_report_date = profile.choose_next_report_date()
profile.reports_allowed = profile.reports != "off"
if profile.nag_period != form.cleaned_data["nag_period"]: if profile.nag_period != form.cleaned_data["nag_period"]:
# Set the new nag period # Set the new nag period
@ -545,7 +544,6 @@ def unsubscribe_reports(request, signed_username):
user = User.objects.get(username=username) user = User.objects.get(username=username)
profile = Profile.objects.for_user(user) profile = Profile.objects.for_user(user)
profile.reports = "off" profile.reports = "off"
profile.reports_allowed = False
profile.next_report_date = None profile.next_report_date = None
profile.nag_period = td() profile.nag_period = td()
profile.next_nag_date = None profile.next_nag_date = None


+ 0
- 2
hc/api/tests/test_sendreports.py View File

@ -21,11 +21,9 @@ class SendReportsTestCase(BaseTestCase):
# Disable bob's and charlie's monthly reports so they don't interfere # Disable bob's and charlie's monthly reports so they don't interfere
self.bobs_profile.reports = "off" self.bobs_profile.reports = "off"
self.bobs_profile.reports_allowed = False
self.bobs_profile.save() self.bobs_profile.save()
self.charlies_profile.reports = "off" self.charlies_profile.reports = "off"
self.charlies_profile.reports_allowed = False
self.charlies_profile.save() self.charlies_profile.save()
# And it needs at least one check that has been pinged. # And it needs at least one check that has been pinged.


Loading…
Cancel
Save