factorized privacy_level field

This commit is contained in:
Eliot Berriot 2018-03-16 23:30:11 +01:00
parent 639cd5da5b
commit 9fdbc7b859
No known key found for this signature in database
GPG Key ID: DD6965E2476E5C27
2 changed files with 17 additions and 9 deletions

View File

@ -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')

View File

@ -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