Self hosted FLOSS fitness/workout, nutrition and weight tracker
Don't check for expiring workouts if user has provided no email
Roland Geiderc707f181ac53
diff --git a/wger/manager/management/commands/email-reminders.py b/wger/manager/management/commands/email-reminders.pyindex 5aa6cbd49..61a175786 100644--- a/wger/manager/management/commands/email-reminders.py+++ b/wger/manager/management/commands/email-reminders.py@@ -46,6 +46,11 @@ class Command(BaseCommand):counter = 0for profile in profile_list:+ # Only continue if the user has provided an email address.+ # Checking it here so we check for NULL values and emtpy strings+ if not profile.user.email:+ continue+# Check if we already notified the user and update the profile otherwiseif profile.last_workout_notification and \(datetime.date.today()@@ -91,9 +96,6 @@ class Command(BaseCommand):self.send_email(profile.user,current_workout,profile.workout_duration)- else:- #print '* step not last in schedule'- passif counter and int(options['verbosity']) >= 2:self.stdout.write("Sent {0} email reminders".format(counter))diff --git a/wger/manager/tests/test_email_reminder.py b/wger/manager/tests/test_email_reminder.pyindex e41f8b112..52fa8e894 100644--- a/wger/manager/tests/test_email_reminder.py+++ b/wger/manager/tests/test_email_reminder.py@@ -53,6 +53,23 @@ class EmailReminderTestCase(WorkoutManagerTestCase):call_command('email-reminders')self.assertEqual(len(mail.outbox), 1)+ def test_reminder_skip_if_no_email(self):+ '''+ Tests that no emails are sent if the user has provided no email++ User 2, workout created 2012-11-20+ '''++ user = User.objects.get(pk=2)+ user.email = ''+ user.save()++ Schedule.objects.all().delete()+ Workout.objects.exclude(user=User.objects.get(pk=2)).delete()++ call_command('email-reminders')+ self.assertEqual(len(mail.outbox), 0)+def test_reminder_last_notification(self):'''Test that no emails are sent if the last notification field is more