diff --git a/api/funkwhale_api/common/fields.py b/api/funkwhale_api/common/fields.py new file mode 100644 index 0000000000000000000000000000000000000000..ab8f6e773543aa076750190a60e3d3ab46602fef --- /dev/null +++ b/api/funkwhale_api/common/fields.py @@ -0,0 +1,14 @@ +from django.db import models + + +PRIVACY_LEVEL_CHOICES = [ + ('me', 'Only me'), + ('followers', 'Me and my followers'), + ('instance', 'Everyone on my instance, and my followers'), + ('everyone', 'Everyone, including people on other instances'), +] + + +def get_privacy_field(): + return models.CharField( + max_length=30, choices=PRIVACY_LEVEL_CHOICES, default='instance') diff --git a/api/funkwhale_api/users/models.py b/api/funkwhale_api/users/models.py index a5478656b178c94037ca232834cc15d36c6b1f9d..9516c108f896275837be3161fe80e07dda6273e7 100644 --- a/api/funkwhale_api/users/models.py +++ b/api/funkwhale_api/users/models.py @@ -10,15 +10,9 @@ from django.db import models from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ +from funkwhale_api.common import fields -PRIVACY_LEVEL_CHOICES = [ - ('me', 'Only me'), - ('followers', 'Me and my followers'), - ('instance', 'Everyone on my instance, and my followers'), - ('everyone', 'Everyone, including people on other instances'), -] - @python_2_unicode_compatible class User(AbstractUser): @@ -39,8 +33,8 @@ class User(AbstractUser): }, } - privacy_level = models.CharField( - max_length=30, choices=PRIVACY_LEVEL_CHOICES, default='instance') + privacy_level = fields.get_privacy_field() + def __str__(self): return self.username