FIX: Use a setting for cooldown

This commit is contained in:
2020-01-26 15:35:04 +00:00
parent 3157741860
commit 18f771d508
2 changed files with 5 additions and 4 deletions

View File

@@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/1.7/ref/settings/
import os
import raven
import secrets
import datetime
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
@@ -44,9 +45,7 @@ if not DEBUG:
INTERNAL_IPS = ['127.0.0.1']
ADMINS = (
[('Tom Price', 'tomtom5152@gmail.com'), ('IT Manager', 'it@nottinghamtec.co.uk'), ('Arona Jones', 'arona.jones@nottinghamtec.co.uk')]
)
ADMINS = [('Tom Price', 'tomtom5152@gmail.com'), ('IT Manager', 'it@nottinghamtec.co.uk'), ('Arona Jones', 'arona.jones@nottinghamtec.co.uk')]
if DEBUG:
ADMINS.append(('Testing Superuser', 'superuser@example.com'))
@@ -184,6 +183,8 @@ if not DEBUG or EMAILER_TEST:
else:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_COOLDOWN = datetime.timedelta(minutes=15)
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/

View File

@@ -111,7 +111,7 @@ def send_admin_awaiting_approval_email(user, request, **kwargs):
# Bit more controlled than just emailing all superusers
for admin in models.Profile.objects.filter(email__in=[y for x in settings.ADMINS for y in x]):
# Check we've ever emailed them before and if so, if cooldown has passed.
if admin.last_emailed is None or admin.last_emailed + datetime.timedelta(minutes=15) <= timezone.now():
if admin.last_emailed is None or admin.last_emailed + settings.EMAIL_COOLDOWN <= timezone.now():
context = {
'request': request,
'link_suffix': '/admin/RIGS/profile/?is_approved__exact=0',