jumpserver/apps/perms/forms.py

31 lines
903 B
Python
Raw Normal View History

2016-09-10 13:08:10 +00:00
# ~*~ coding: utf-8 ~*~
from __future__ import absolute_import, unicode_literals
from django import forms
from django.utils.translation import ugettext_lazy as _
2018-02-01 09:14:15 +00:00
from .models import NodePermission
2016-09-10 13:08:10 +00:00
2016-09-11 14:45:24 +00:00
class AssetPermissionForm(forms.ModelForm):
2016-09-10 13:08:10 +00:00
class Meta:
2018-02-01 09:14:15 +00:00
model = NodePermission
2016-09-10 13:08:10 +00:00
fields = [
2018-02-01 09:14:15 +00:00
'node', 'user_group', 'system_user', 'is_active',
2018-02-02 10:52:09 +00:00
'date_expired', 'comment',
2016-09-10 13:08:10 +00:00
]
2016-09-11 08:59:19 +00:00
widgets = {
2018-02-01 09:14:15 +00:00
'node': forms.Select(
2018-02-02 10:52:09 +00:00
attrs={'style': 'display:none'}
2018-02-01 09:14:15 +00:00
),
'user_group': forms.Select(
attrs={'class': 'select2', 'data-placeholder': _("User group")}
),
'system_user': forms.Select(
attrs={'class': 'select2', 'data-placeholder': _('System user')}
),
2016-09-11 14:45:24 +00:00
}
2017-12-21 03:31:13 +00:00
2018-02-01 09:14:15 +00:00
def clean_system_user(self):
return self.cleaned_data['system_user']