def handle_noargs(self, **options): # Date range of the last 7 days end_date = datetime.datetime.combine(datetime.date.today(), datetime.time()) start_date = end_date - datetime.timedelta(days=7) for user in get_subscribed_users(): data = reports.completed_workouts(start_date, end_date, user) email_user(user, 'Workout Report', 'reports/completed_workouts.html', data) #raise CommandError("I'm an error that something went wrong")
def send_perm_request(user): # Grab existing hash, or generate one email_perms = UserEmailPermissions.objects.filter(user=user) if len(email_perms) > 0: email_perm = email_perms[0] else: email_perm = UserEmailPermissions(user=user) email_perm.save() subscribe_hash = email_perm.subscribe_hash subscribe_url = "%semail/confirm/%s/" % (settings.CONFIRM_EMAIL_PERM_BASE_URL, subscribe_hash) email_user(user, "Permission Request", 'email_sender/emails/perm_request.html', {"subscribe_url":subscribe_url}) return render_to_response('email_sender/perm_sent.html')