Skip to content

Commit

Permalink
Use the global setting and default to false
Browse files Browse the repository at this point in the history
  • Loading branch information
ab-smith committed Jan 27, 2025
1 parent c98f0ac commit 704e444
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion backend/core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.conf import settings
import logging
import random
from global_settings.models import GlobalSettings

import logging.config
import structlog
Expand All @@ -15,7 +16,7 @@
logger = structlog.getLogger(__name__)


# @db_periodic_task(crontab(minute='*/1')) for testing
# @db_periodic_task(crontab(minute='*/1'))# for testing
@db_periodic_task(crontab(hour="6"))
def check_controls_with_expired_eta():
expired_controls = (
Expand All @@ -37,6 +38,16 @@ def check_controls_with_expired_eta():

@task()
def send_notification_email(owner_email, controls):
# TODO this will probably will move to a common section later on.
notifications_enable_mailing = GlobalSettings.objects.get(name="general").value.get(
"notifications_enable_mailing", False
)
if not notifications_enable_mailing:
logger.warning(
"Email notification is disabled. You can enable it under Extra/Settings. Skipping for now."
)
return

# Check required email settings
required_settings = ["EMAIL_HOST", "EMAIL_PORT", "DEFAULT_FROM_EMAIL"]
missing_settings = [
Expand Down

0 comments on commit 704e444

Please sign in to comment.