remove AccessUserForm
This commit is contained in:
parent
f13fb0a899
commit
281f01b8a0
1 changed files with 27 additions and 30 deletions
|
@ -1,19 +1,11 @@
|
|||
from django.forms import ModelForm, MultipleChoiceField
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from c3nav.access.models import AccessToken, AccessUser
|
||||
from c3nav.access.models import AccessToken
|
||||
from c3nav.mapdata.models import AreaLocation
|
||||
|
||||
|
||||
class AccessUserForm(ModelForm):
|
||||
class Meta:
|
||||
model = AccessUser
|
||||
fields = ['user_url', 'description']
|
||||
|
||||
|
||||
class AccessTokenForm(ModelForm):
|
||||
def __init__(self, *args, request, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
def get_permissions_field(request):
|
||||
locations = AreaLocation.objects.filter(routing_inclusion='needs_permission')
|
||||
|
||||
has_operator = True
|
||||
|
@ -37,8 +29,13 @@ class AccessTokenForm(ModelForm):
|
|||
OPTIONS.append((':full', _('Full Permissions')))
|
||||
|
||||
OPTIONS += [(location.name, location.title) for location in locations]
|
||||
print(OPTIONS)
|
||||
self.fields['permissions'] = MultipleChoiceField(choices=OPTIONS, required=True)
|
||||
return MultipleChoiceField(choices=OPTIONS, required=True)
|
||||
|
||||
|
||||
class AccessTokenForm(ModelForm):
|
||||
def __init__(self, *args, request, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['permissions'] = get_permissions_field(request)
|
||||
|
||||
class Meta:
|
||||
model = AccessToken
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue