jumpserver/apps/perms/forms.py

37 lines
1.6 KiB
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 _
2016-09-11 14:45:24 +00:00
# from .hands import User, UserGroup, Asset, AssetGroup, SystemUser
from .models import AssetPermission
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:
2016-09-11 14:45:24 +00:00
model = AssetPermission
2016-09-10 13:08:10 +00:00
fields = [
2016-09-11 14:45:24 +00:00
'name', 'users', 'user_groups', 'assets', 'asset_groups',
2016-09-16 01:55:26 +00:00
'system_users', 'is_active', 'date_expired', 'comment',
2016-09-10 13:08:10 +00:00
]
2016-09-11 08:59:19 +00:00
widgets = {
2016-09-11 14:45:24 +00:00
'users': forms.SelectMultiple(attrs={'class': 'select2',
'data-placeholder': _('Select users')}),
'user_groups': forms.SelectMultiple(attrs={'class': 'select2',
'data-placeholder': _('Select user groups')}),
2016-09-11 08:59:19 +00:00
'assets': forms.SelectMultiple(attrs={'class': 'select2',
'data-placeholder': _('Select assets')}),
'asset_groups': forms.SelectMultiple(attrs={'class': 'select2',
'data-placeholder': _('Select asset groups')}),
'system_users': forms.SelectMultiple(attrs={'class': 'select2',
'data-placeholder': _('Select system users')}),
2016-09-11 14:45:24 +00:00
}
help_texts = {
'name': '* required',
'user_groups': '* User or user group at least one required',
'asset_groups': '* Asset or Asset group at least one required',
'system_users': '* required',
2016-09-11 08:59:19 +00:00
}