factorized privacy_level field
This commit is contained in:
parent
639cd5da5b
commit
9fdbc7b859
|
@ -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')
|
|
@ -10,15 +10,9 @@ from django.db import models
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext_lazy as _
|
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
|
@python_2_unicode_compatible
|
||||||
class User(AbstractUser):
|
class User(AbstractUser):
|
||||||
|
|
||||||
|
@ -39,8 +33,8 @@ class User(AbstractUser):
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
privacy_level = models.CharField(
|
privacy_level = fields.get_privacy_field()
|
||||||
max_length=30, choices=PRIVACY_LEVEL_CHOICES, default='instance')
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.username
|
return self.username
|
||||||
|
|
Loading…
Reference in New Issue