Repository: wger-project/wger

Issue:
Remove or edit minimum account age for trustworthy
## Use case

There is a hardcoded [21 days minimum account age limit ](https://github.com/wger-project/wger/blob/da3a478c2caf5e8204d1f3322f08c8cbdc94be18/wger/core/models/profile.py#L204) That I think there should be a way to modify it using configs. Actually it doesn't make sense to prevent users from contributing in exercises in a private instance where all users are trusted.

## Proposal

There should be some config to modify it dynamically.


Discussion:

Resolving patch:
diff --git a/extras/docker/development/settings.py b/extras/docker/development/settings.py
--- a/extras/docker/development/settings.py
+++ b/extras/docker/development/settings.py
@@ -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)
 
 
diff --git a/wger/core/models/profile.py b/wger/core/models/profile.py
--- a/wger/core/models/profile.py
+++ b/wger/core/models/profile.py
@@ -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 (
@@ -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
 
diff --git a/wger/settings_global.py b/wger/settings_global.py
--- a/wger/settings_global.py
+++ b/wger/settings_global.py
@@ -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,


Test patch:
diff --git a/wger/core/tests/test_registration.py b/wger/core/tests/test_registration.py
--- a/wger/core/tests/test_registration.py
+++ b/wger/core/tests/test_registration.py
@@ -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'))
@@ -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'))
@@ -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,
             }
         ):
 
diff --git a/wger/core/tests/test_temporary_users.py b/wger/core/tests/test_temporary_users.py
--- a/wger/core/tests/test_temporary_users.py
+++ b/wger/core/tests/test_temporary_users.py
@@ -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)