Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Move EMAIL_FROM to settings file

Roland Geidercd59bea4abfb
diff --git a/wger/exercises/models.py b/wger/exercises/models.py
index 187a89716..f4ed03d31 100644
--- a/wger/exercises/models.py
+++ b/wger/exercises/models.py
@@ -31,11 +31,11 @@ from django.core.urlresolvers import reverse
from django.core import mail
from django.core.cache import cache
from django.core.validators import MinLengthValidator
+from django.conf import settings
from wger.core.models import Language
from wger.utils.managers import SubmissionManager
from wger.utils.models import AbstractLicenseModel, AbstractSubmissionModel
-from wger.utils.constants import EMAIL_FROM
from wger.utils.cache import (
delete_template_fragment_cache,
reset_workout_canonical_form,
@@ -315,7 +315,7 @@ class Exercise(AbstractSubmissionModel, AbstractLicenseModel, models.Model):
message = render_to_string('exercise/email_new.html', context)
mail.send_mail(subject,
message,
- EMAIL_FROM,
+ settings.EMAIL_FROM,
[user.email],
fail_silently=True)
diff --git a/wger/gym/management/commands/inactive-members.py b/wger/gym/management/commands/inactive-members.py
index fecca69f3..008243c0f 100644
--- a/wger/gym/management/commands/inactive-members.py
+++ b/wger/gym/management/commands/inactive-members.py
@@ -21,8 +21,8 @@ from django.utils import translation
from django.utils.translation import ugettext as _
from django.core.management.base import BaseCommand
from django.template.loader import render_to_string
+from django.conf import settings
-from wger.utils.constants import EMAIL_FROM
from wger.gym.helpers import is_any_gym_admin
from wger.gym.helpers import get_user_last_activity
from wger.gym.models import Gym
@@ -101,6 +101,6 @@ class Command(BaseCommand):
message = render_to_string('gym/email_inactive_members.html', context)
mail.send_mail(subject,
message,
- EMAIL_FROM,
+ settings.EMAIL_FROM,
[trainer.email],
fail_silently=True)
diff --git a/wger/manager/management/commands/email-reminders.py b/wger/manager/management/commands/email-reminders.py
index 06b7c383c..134a1243e 100644
--- a/wger/manager/management/commands/email-reminders.py
+++ b/wger/manager/management/commands/email-reminders.py
@@ -21,11 +21,11 @@ from django.core.management.base import BaseCommand
from django.core import mail
from django.utils.translation import ugettext_lazy as _
from django.utils import translation
+from django.conf import settings
from django.contrib.sites.models import Site
from wger.core.models import UserProfile
from wger.manager.models import Schedule
-from wger.utils.constants import EMAIL_FROM
class Command(BaseCommand):
@@ -122,6 +122,6 @@ class Command(BaseCommand):
message = loader.render_to_string('workout/email_reminder.tpl', context)
mail.send_mail(subject,
message,
- EMAIL_FROM,
+ settings.EMAIL_FROM,
[user.email],
fail_silently=True)
diff --git a/wger/nutrition/models.py b/wger/nutrition/models.py
index c306024bc..c5436f401 100644
--- a/wger/nutrition/models.py
+++ b/wger/nutrition/models.py
@@ -30,9 +30,10 @@ from django.contrib.auth.models import User
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django.utils import translation
+from django.conf import settings
from wger.core.models import Language
-from wger.utils.constants import EMAIL_FROM, TWOPLACES
+from wger.utils.constants import TWOPLACES
from wger.utils.cache import cache_mapper
from wger.utils.fields import Html5TimeField
from wger.utils.models import AbstractLicenseModel
@@ -429,7 +430,7 @@ class Ingredient(AbstractLicenseModel, models.Model):
message = render_to_string('ingredient/email_new.html', context)
mail.send_mail(subject,
message,
- EMAIL_FROM,
+ settings.EMAIL_FROM,
[self.user.email],
fail_silently=True)
diff --git a/wger/settings.tpl b/wger/settings.tpl
index a68fc87e1..e85ee5bf1 100644
--- a/wger/settings.tpl
+++ b/wger/settings.tpl
@@ -55,4 +55,7 @@ ALLOWED_HOSTS = '*'
# Configure a real backend in production
if DEBUG:
- EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
\ No newline at end of file
+ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
+
+# Sender address used for sent emails
+EMAIL_FROM = 'wger Workout Manager <[email protected]>'
\ No newline at end of file
diff --git a/wger/utils/constants.py b/wger/utils/constants.py
index caf3cf5b3..d62f01726 100644
--- a/wger/utils/constants.py
+++ b/wger/utils/constants.py
@@ -59,7 +59,3 @@ HTML_STYLES_WHITELIST = ('text-decoration',)
PAGINATION_OBJECTS_PER_PAGE = 25
PAGINATION_MAX_TOTAL_PAGES = 10
PAGINATION_PAGES_AROUND_CURRENT = 5
-
-
-# Email
-EMAIL_FROM = 'wger Workout Manager <[email protected]>'
diff --git a/wger/weight/management/commands/email-weight-reminder.py b/wger/weight/management/commands/email-weight-reminder.py
index ff83e5007..9cb64596d 100644
--- a/wger/weight/management/commands/email-weight-reminder.py
+++ b/wger/weight/management/commands/email-weight-reminder.py
@@ -21,11 +21,11 @@ from django.core.management.base import BaseCommand
from django.core import mail
from django.utils.translation import ugettext_lazy as _
from django.utils import translation
+from django.conf import settings
from django.contrib.sites.models import Site
from wger.core.models import UserProfile
from wger.weight.models import WeightEntry
-from wger.utils.constants import EMAIL_FROM
class Command(BaseCommand):
@@ -79,6 +79,6 @@ class Command(BaseCommand):
message = loader.render_to_string('workout/email_weight_reminder.tpl', context)
mail.send_mail(subject,
message,
- EMAIL_FROM,
+ settings.EMAIL_FROM,
[user.email],
fail_silently=True)