Self hosted FLOSS fitness/workout, nutrition and weight tracker
a check for user trustworthiness that gives them add image permissions if true and a check for whether a user has full admin or exercise editor permissions in user preferences
emuthd634d1991573
diff --git a/wger/core/models.py b/wger/core/models.pyindex f45c6d3d4..bb1ee063b 100644--- a/wger/core/models.py+++ b/wger/core/models.py@@ -19,7 +19,10 @@ import datetimeimport decimal# Django-from django.contrib.auth.models import User+from django.contrib.auth.models import (+ Permission,+ User+)from django.core.exceptions import ValidationErrorfrom django.core.validators import (MaxValueValidator,@@ -218,6 +221,32 @@ by the US Department of Agriculture. It is extremely complete, with aroundDefault duration of workout pauses in the gym view"""+ @property+ def is_trustworthy(self):+ """+ Trustworthy if they've had an account for more than three weeks. More trustworthiness+ criteria could be added in future.+ """+ days_since_joined = datetime.date.today() - self.user.date_joined.date()++ if days_since_joined.days > 21:+ # perms will be updated only once, after they hit three week mark+ image_perm = Permission.objects.get(codename='add_exerciseimage')+ self.user.user_permissions.add(image_perm)++ return days_since_joined.days > 21++ @property+ def has_exercise_permission(self):+ """+ Returns true if user has all the exercise permissions and not just one.+ """+ if self.user.groups.filter(name='admin').exists() or \+ self.user.groups.filter(name='exercises_editor').exists():+ return True+ else:+ return False+## User statistics#