Skip to content

Commit

Permalink
Merge pull request #1188 from mohammadrafigh/master
Browse files Browse the repository at this point in the history
Add MINIMUM_AGE_TO_TRUST variable
  • Loading branch information
rolandgeider committed Nov 21, 2022
2 parents e42f8b6 + 60dd5eb commit a1a270a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 1 deletion.
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

0 comments on commit a1a270a

Please sign in to comment.