mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-22 07:52:15 +00:00
FIX: Use a setting for cooldown
This commit is contained in:
@@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/1.7/ref/settings/
|
|||||||
import os
|
import os
|
||||||
import raven
|
import raven
|
||||||
import secrets
|
import secrets
|
||||||
|
import datetime
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||||
|
|
||||||
@@ -44,9 +45,7 @@ if not DEBUG:
|
|||||||
|
|
||||||
INTERNAL_IPS = ['127.0.0.1']
|
INTERNAL_IPS = ['127.0.0.1']
|
||||||
|
|
||||||
ADMINS = (
|
ADMINS = [('Tom Price', 'tomtom5152@gmail.com'), ('IT Manager', 'it@nottinghamtec.co.uk'), ('Arona Jones', 'arona.jones@nottinghamtec.co.uk')]
|
||||||
[('Tom Price', 'tomtom5152@gmail.com'), ('IT Manager', 'it@nottinghamtec.co.uk'), ('Arona Jones', 'arona.jones@nottinghamtec.co.uk')]
|
|
||||||
)
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
ADMINS.append(('Testing Superuser', 'superuser@example.com'))
|
ADMINS.append(('Testing Superuser', 'superuser@example.com'))
|
||||||
|
|
||||||
@@ -184,6 +183,8 @@ if not DEBUG or EMAILER_TEST:
|
|||||||
else:
|
else:
|
||||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||||
|
|
||||||
|
EMAIL_COOLDOWN = datetime.timedelta(minutes=15)
|
||||||
|
|
||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/1.7/topics/i18n/
|
# https://docs.djangoproject.com/en/1.7/topics/i18n/
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ def send_admin_awaiting_approval_email(user, request, **kwargs):
|
|||||||
# Bit more controlled than just emailing all superusers
|
# 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]):
|
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.
|
# 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 = {
|
context = {
|
||||||
'request': request,
|
'request': request,
|
||||||
'link_suffix': '/admin/RIGS/profile/?is_approved__exact=0',
|
'link_suffix': '/admin/RIGS/profile/?is_approved__exact=0',
|
||||||
|
|||||||
Reference in New Issue
Block a user