Self hosted FLOSS fitness/workout, nutrition and weight tracker
Add MINIMUM_AGE_TO_TRUST variable
Mohammad Rafigh1cf814ef5037
diff --git a/extras/docker/development/settings.py b/extras/docker/development/settings.pyindex f900c4733..e25b70a19 100644--- a/extras/docker/development/settings.py+++ b/extras/docker/development/settings.py@@ -94,6 +94,7 @@ DEFAULT_FROM_EMAIL = WGER_SETTINGS['EMAIL_FROM']WGER_SETTINGS["ALLOW_REGISTRATION"] = env.bool("ALLOW_REGISTRATION", True)WGER_SETTINGS["ALLOW_GUEST_USERS"] = env.bool("ALLOW_GUEST_USERS", True)WGER_SETTINGS["ALLOW_UPLOAD_VIDEOS"] = env.bool("ALLOW_UPLOAD_VIDEOS", True)+WGER_SETTINGS["MINIMUM_AGE_TO_TRUST"] = env.int("MINIMUM_AGE_TO_TRUST", 21) # in daysWGER_SETTINGS["EXERCISE_CACHE_TTL"] = env.int("EXERCISE_CACHE_TTL", 3600)diff --git a/wger/core/models/profile.py b/wger/core/models/profile.pyindex 1671b59a0..81b1577d9 100644--- a/wger/core/models/profile.py+++ b/wger/core/models/profile.py@@ -19,6 +19,7 @@ import datetimeimport decimal# Django+from django.conf import settingsfrom django.contrib.auth.models import Userfrom django.core.exceptions import ValidationErrorfrom django.core.validators import (@@ -201,7 +202,7 @@ by the US Department of Agriculture. It is extremely complete, with aroundreturn Falsedays_since_joined = datetime.date.today() - self.user.date_joined.date()- minimum_account_age = 21+ minimum_account_age = settings.WGER_SETTINGS['MINIMUM_AGE_TO_TRUST']:return days_since_joined.days > minimum_account_age and self.email_verifieddiff --git a/wger/core/tests/test_registration.py b/wger/core/tests/test_registration.pyindex 0d89a8043..0d63c9b3e 100644--- a/wger/core/tests/test_registration.py+++ b/wger/core/tests/test_registration.py@@ -46,6 +46,7 @@ class RegistrationTestCase(WgerTestCase):'ALLOW_REGISTRATION': True,'ALLOW_GUEST_USERS': True,'TWITTER': False,+ 'MINIMUM_AGE_TO_TRUST': 21,}):response = self.client.get(reverse('core:user:registration'))@@ -57,6 +58,7 @@ class RegistrationTestCase(WgerTestCase):'ALLOW_REGISTRATION': True,'ALLOW_GUEST_USERS': True,'TWITTER': False,+ 'MINIMUM_AGE_TO_TRUST': 21,}):response = self.client.get(reverse('core:user:registration'))@@ -116,6 +118,7 @@ class RegistrationTestCase(WgerTestCase):'USE_RECAPTCHA': False,'ALLOW_GUEST_USERS': True,'ALLOW_REGISTRATION': False,+ 'MINIMUM_AGE_TO_TRUST': 21,}):diff --git a/wger/core/tests/test_temporary_users.py b/wger/core/tests/test_temporary_users.pyindex 20d902375..fa571ded9 100644--- a/wger/core/tests/test_temporary_users.py+++ b/wger/core/tests/test_temporary_users.py@@ -64,6 +64,7 @@ class DemoUserTestCase(WgerTestCase):'ALLOW_REGISTRATION': True,'ALLOW_GUEST_USERS': False,'TWITTER': False,+ 'MINIMUM_AGE_TO_TRUST': 21,}):self.assertEqual(self.count_temp_users(), 1)diff --git a/wger/settings_global.py b/wger/settings_global.pyindex da5835a70..0555b4f2c 100644--- a/wger/settings_global.py+++ b/wger/settings_global.py@@ -483,6 +483,7 @@ WGER_SETTINGS = {'ALLOW_GUEST_USERS': True,'ALLOW_REGISTRATION': True,'ALLOW_UPLOAD_VIDEOS': False,+ 'MINIMUM_AGE_TO_TRUST': 21,'EMAIL_FROM': 'wger Workout Manager <[email protected]>','EXERCISE_CACHE_TTL': 3600,'TWITTER': False,