-
+
-
- {% include '_pagination.html' %}
-
@@ -115,38 +86,38 @@
{% trans 'Quick create permission for user' %}
@@ -159,25 +130,69 @@
{% endblock %}
{% block custom_foot_js %}
{% endblock %}
\ No newline at end of file
diff --git a/apps/users/templates/users/user_detail.html b/apps/users/templates/users/user_detail.html
index c1cdbc5f5..d4e328465 100644
--- a/apps/users/templates/users/user_detail.html
+++ b/apps/users/templates/users/user_detail.html
@@ -313,7 +313,6 @@ $(document).ready(function() {
var user_groups = $('.bdg_user_group').map(function() {
return $(this).data('gid');
}).get();
- console.log(user_groups);
updateUserGroups(user_groups)
}).on('click', '#btn_reset_password', function() {
function doReset() {
diff --git a/apps/users/templates/users/user_list.html b/apps/users/templates/users/user_list.html
index 087d27db0..cf2c0d2b7 100644
--- a/apps/users/templates/users/user_list.html
+++ b/apps/users/templates/users/user_list.html
@@ -53,7 +53,7 @@ $(document).ready(function(){
$(td).html(detail_btn.replace('99991937', rowData.id));
}},
{targets: 4, createdCell: function (td, cellData) {
- var innerHtml = cellData.length > 8 ? cellData.substring(0, 8) + '...': cellData;
+ var innerHtml = cellData.length > 20 ? cellData.substring(0, 20) + '...': cellData;
$(td).html('' + innerHtml + '');
}},
{targets: 6, createdCell: function (td, cellData) {
diff --git a/apps/users/urls.py b/apps/users/urls.py
index 6fd732d8c..dd39c87e9 100644
--- a/apps/users/urls.py
+++ b/apps/users/urls.py
@@ -19,13 +19,13 @@ urlpatterns = [
url(r'^user/(?P[0-9]+)$', views.UserDetailView.as_view(), name='user-detail'),
url(r'^user/(?P[0-9]+)/asset-permission$', views.UserAssetPermissionView.as_view(),
name='user-asset-permission'),
- url(r'^user/(?P[0-9]+)/asset-permission/create$', views.UserAssetPermissionCreateView.as_view(),
- name='user-asset-permission-create'),
+ # url(r'^user/(?P[0-9]+)/asset-permission/create$', views.UserAssetPermissionCreateView.as_view(),
+ # name='user-asset-permission-create'),
url(r'^user/(?P[0-9]+)/granted-asset', views.UserGrantedAssetView.as_view(), name='user-granted-asset'),
url(r'^user/(?P[0-9]+)/login-history', views.UserDetailView.as_view(), name='user-login-history'),
url(r'^first-login/$', views.UserFirstLoginView.as_view(), name='user-first-login'),
url(r'^import/$', views.BulkImportUserView.as_view(), name='user-import'),
- url(r'^user/(?P[0-9]+)/assets-perm$', views.UserDetailView.as_view(), name='user-detail'),
+ # url(r'^user/(?P[0-9]+)/assets-perm$', views.UserDetailView.as_view(), name='user-detail'),
url(r'^user/create$', views.UserCreateView.as_view(), name='user-create'),
url(r'^user/(?P[0-9]+)/update$', views.UserUpdateView.as_view(), name='user-update'),
diff --git a/apps/users/utils.py b/apps/users/utils.py
index 7ce37a463..9797b5fe4 100644
--- a/apps/users/utils.py
+++ b/apps/users/utils.py
@@ -120,60 +120,60 @@ def send_reset_ssh_key_mail(user):
send_mail_async.delay(subject, message, recipient_list, html_message=message)
-def validate_ssh_pk(text):
- """
- Expects a SSH private key as string.
- Returns a boolean and a error message.
- If the text is parsed as private key successfully,
- (True,'') is returned. Otherwise,
- (False, ) is returned.
-
- from https://github.com/githubnemo/SSH-private-key-validator/blob/master/validate.py
-
- """
-
- if not text:
- return False, 'No text given'
-
- startPattern = re.compile("^-----BEGIN [A-Z]+ PRIVATE KEY-----")
- optionPattern = re.compile("^.+: .+")
- contentPattern = re.compile("^([a-zA-Z0-9+/]{64}|[a-zA-Z0-9+/]{1,64}[=]{0,2})$")
- endPattern = re.compile("^-----END [A-Z]+ PRIVATE KEY-----")
-
- def contentState(text):
- for i in range(0, len(text)):
- line = text[i]
-
- if endPattern.match(line):
- if i == len(text) - 1 or len(text[i + 1]) == 0:
- return True, ''
- else:
- return False, 'At end but content coming'
-
- elif not contentPattern.match(line):
- return False, 'Wrong string in content section'
-
- return False, 'No content or missing end line'
-
- def optionState(text):
- for i in range(0, len(text)):
- line = text[i]
-
- if line[-1:] == '\\':
- return optionState(text[i + 2:])
-
- if not optionPattern.match(line):
- return contentState(text[i + 1:])
-
- return False, 'Expected option, found nothing'
-
- def startState(text):
- if len(text) == 0 or not startPattern.match(text[0]):
- return False, 'Header is wrong'
- return optionState(text[1:])
-
- return startState([n.strip() for n in text.splitlines()])
+# def validate_ssh_pk(text):
+# """
+# Expects a SSH private key as string.
+# Returns a boolean and a error message.
+# If the text is parsed as private key successfully,
+# (True,'') is returned. Otherwise,
+# (False, ) is returned.
+#
+# from https://github.com/githubnemo/SSH-private-key-validator/blob/master/validate.py
+#
+# """
+#
+# if not text:
+# return False, 'No text given'
+#
+# startPattern = re.compile("^-----BEGIN [A-Z]+ PRIVATE KEY-----")
+# optionPattern = re.compile("^.+: .+")
+# contentPattern = re.compile("^([a-zA-Z0-9+/]{64}|[a-zA-Z0-9+/]{1,64}[=]{0,2})$")
+# endPattern = re.compile("^-----END [A-Z]+ PRIVATE KEY-----")
+#
+# def contentState(text):
+# for i in range(0, len(text)):
+# line = text[i]
+#
+# if endPattern.match(line):
+# if i == len(text) - 1 or len(text[i + 1]) == 0:
+# return True, ''
+# else:
+# return False, 'At end but content coming'
+#
+# elif not contentPattern.match(line):
+# return False, 'Wrong string in content section'
+#
+# return False, 'No content or missing end line'
+#
+# def optionState(text):
+# for i in range(0, len(text)):
+# line = text[i]
+#
+# if line[-1:] == '\\':
+# return optionState(text[i + 2:])
+#
+# if not optionPattern.match(line):
+# return contentState(text[i + 1:])
+#
+# return False, 'Expected option, found nothing'
+ # def startState(text):
+ # if len(text) == 0 or not startPattern.match(text[0]):
+ # return False, 'Header is wrong'
+ # return optionState(text[1:])
+ #
+ # return startState([n.strip() for n in text.splitlines()])
+#
def check_user_valid(**kwargs):
password = kwargs.pop('password', None)
diff --git a/apps/users/views.py b/apps/users/views.py
index 006df3328..5a07efbbc 100644
--- a/apps/users/views.py
+++ b/apps/users/views.py
@@ -21,14 +21,14 @@ from django.views.generic.list import ListView
from django.views.generic.edit import CreateView, DeleteView, UpdateView, FormView, SingleObjectMixin, \
FormMixin
from django.views.generic.detail import DetailView
-
from formtools.wizard.views import SessionWizardView
from common.mixins import JSONResponseMixin
from common.utils import get_object_or_none, get_logger
+from perms.models import AssetPermission
from .models import User, UserGroup
from .utils import AdminUserRequiredMixin, user_add_success_next, send_reset_password_mail
-from .hands import AssetPermission, get_user_granted_asset_groups, get_user_granted_assets
+# from .hands import AssetPermission, get_user_granted_asset_groups, get_user_granted_assets
from . import forms
@@ -341,32 +341,33 @@ class UserFirstLoginView(LoginRequiredMixin, SessionWizardView):
return form
-class UserAssetPermissionView(AdminUserRequiredMixin, FormMixin, SingleObjectMixin, ListView):
- paginate_by = settings.CONFIG.DISPLAY_PER_PAGE
+class UserAssetPermissionView(AdminUserRequiredMixin, DetailView):
+ model = User
template_name = 'users/user_asset_permission.html'
- context_object_name = 'user_object'
- form_class = forms.UserPrivateAssetPermissionForm
+ context_object_name = 'user'
- def get(self, request, *args, **kwargs):
- self.object = self.get_object(queryset=User.objects.all())
- return super(UserAssetPermissionView, self).get(request, *args, **kwargs)
+ # form_class = forms.UserPrivateAssetPermissionForm
- def get_asset_permission_inherit_from_user_group(self):
- asset_permissions = set()
- user_groups = self.object.groups.all()
+ # def get(self, request, *args, **kwargs):
+ # self.object = self.get_object(queryset=User.objects.all())
+ # return super(UserAssetPermissionView, self).get(request, *args, **kwargs)
- for user_group in user_groups:
- for asset_permission in user_group.asset_permissions.all():
- setattr(asset_permission, 'is_inherit_from_user_groups', True)
- setattr(asset_permission, 'inherit_from_user_groups',
- getattr(asset_permission, b'inherit_from_user_groups', set()).add(user_group))
- asset_permissions.add(asset_permission)
- return asset_permissions
-
- def get_queryset(self):
- asset_permissions = set(self.object.asset_permissions.all()) \
- | self.get_asset_permission_inherit_from_user_group()
- return list(asset_permissions)
+ # def get_asset_permission_inherit_from_user_group(self):
+ # asset_permissions = set()
+ # user_groups = self.object.groups.all()
+ #
+ # for user_group in user_groups:
+ # for asset_permission in user_group.asset_permissions.all():
+ # setattr(asset_permission, 'is_inherit_from_user_groups', True)
+ # setattr(asset_permission, 'inherit_from_user_groups',
+ # getattr(asset_permission, b'inherit_from_user_groups', set()).add(user_group))
+ # asset_permissions.add(asset_permission)
+ # return asset_permissions
+ #
+ # def get_queryset(self):
+ # asset_permissions = set(self.object.asset_permissions.all()) \
+ # | self.get_asset_permission_inherit_from_user_group()
+ # return list(asset_permissions)
def get_context_data(self, **kwargs):
context = {
@@ -414,18 +415,19 @@ class UserGrantedAssetView(AdminUserRequiredMixin, SingleObjectMixin, ListView):
def get_queryset(self):
# Convert format from {'asset': ['system_users'], ..} to
# [('asset', ['system_users']), ('asset', ['system_users']))
- assets_granted = [(asset, system_users) for asset, system_users in
- get_user_granted_assets(self.object).items()]
+ # assets_granted = [(asset, system_users) for asset, system_users in
+ # get_user_granted_assets(self.object).items()]
- return assets_granted
+ # return assets_granted
+ return []
def get_context_data(self, **kwargs):
- asset_groups = [(asset_group, system_users) for asset_group, system_users in
- get_user_granted_asset_groups(self.object).items()]
+ # asset_groups = [(asset_group, system_users) for asset_group, system_users in
+ # get_user_granted_asset_groups(self.object).items()]
context = {
'app': 'User',
'action': 'User granted asset',
- 'asset_groups': asset_groups,
+ # 'asset_groups': asset_groups,
}
kwargs.update(context)
return super(UserGrantedAssetView, self).get_context_data(**kwargs)