Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MINIMUM_AGE_TO_TRUST variable #1188

Merged
merged 4 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Developers
* Kade - https://github.com/kp5431/
* Tom Bowyer - https://github.com/ImTheTom
* Rohan Karan - https://github.com/RohanKaran
* Mohammad Rafigh - https://github.com/mohammadrafigh

Translators
-----------
Expand Down
1 change: 1 addition & 0 deletions extras/docker/development/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
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["MIN_ACCOUNT_AGE_TO_TRUST"] = env.int("MIN_ACCOUNT_AGE_TO_TRUST", 21) # in days
WGER_SETTINGS["EXERCISE_CACHE_TTL"] = env.int("EXERCISE_CACHE_TTL", 3600)


Expand Down
3 changes: 2 additions & 1 deletion wger/core/models/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import decimal

# Django
from django.conf import settings
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.core.validators import (
Expand Down Expand Up @@ -201,7 +202,7 @@ def is_trustworthy(self) -> bool:
return False

days_since_joined = datetime.date.today() - self.user.date_joined.date()
minimum_account_age = 21
minimum_account_age = settings.WGER_SETTINGS['MIN_ACCOUNT_AGE_TO_TRUST']

return days_since_joined.days > minimum_account_age and self.email_verified

Expand Down
3 changes: 3 additions & 0 deletions wger/core/tests/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def test_registration_captcha(self):
'ALLOW_REGISTRATION': True,
'ALLOW_GUEST_USERS': True,
'TWITTER': False,
'MIN_ACCOUNT_AGE_TO_TRUST': 21,
}
):
response = self.client.get(reverse('core:user:registration'))
Expand All @@ -57,6 +58,7 @@ def test_registration_captcha(self):
'ALLOW_REGISTRATION': True,
'ALLOW_GUEST_USERS': True,
'TWITTER': False,
'MIN_ACCOUNT_AGE_TO_TRUST': 21,
}
):
response = self.client.get(reverse('core:user:registration'))
Expand Down Expand Up @@ -116,6 +118,7 @@ def test_registration_deactivated(self):
'USE_RECAPTCHA': False,
'ALLOW_GUEST_USERS': True,
'ALLOW_REGISTRATION': False,
'MIN_ACCOUNT_AGE_TO_TRUST': 21,
}
):

Expand Down
1 change: 1 addition & 0 deletions wger/core/tests/test_temporary_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def test_demo_data_no_guest_account(self):
'ALLOW_REGISTRATION': True,
'ALLOW_GUEST_USERS': False,
'TWITTER': False,
'MIN_ACCOUNT_AGE_TO_TRUST': 21,
}
):
self.assertEqual(self.count_temp_users(), 1)
Expand Down
1 change: 1 addition & 0 deletions wger/settings_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@
'ALLOW_GUEST_USERS': True,
'ALLOW_REGISTRATION': True,
'ALLOW_UPLOAD_VIDEOS': False,
'MIN_ACCOUNT_AGE_TO_TRUST': 21,
'EMAIL_FROM': 'wger Workout Manager <wger@example.com>',
'EXERCISE_CACHE_TTL': 3600,
'TWITTER': False,
Expand Down