def admin_parent_details_views(request, user_id): """管理员获取父账号用户详情""" client = UserProfile.objects.filter(id=user_id).first() group = client.groups.first() client.group_name = group user_perm_code_list = PermUser.user_perm(client) user_perm_list = Perm.objects.filter(code__in=user_perm_code_list) user_perm, user_perm_type = handle_perm(user_perm_list) all_perm = Perm.objects.filter(content_type__contains='CLIENT') all_perm, all_perm_type = handle_perm(all_perm) client.company = client.company if client.company else '' client.mobile = client.mobile if client.mobile else '' client.active_type = af.IS_ACTIVE if client.is_active else af.IS_NOT_ACTIVE body = { 'username_list': [client.username] } res = APIUrl.post_link('user_query', body) user_query = res.get('user_query', {}) user_info = user_query.get(client.username, {}) secret_id = user_info.get('api_secret_id', '') secret_key = user_info.get('api_secret_key', '') api_create_time = user_info.get('api_create_time', '') if api_create_time: api_create_time = timestamp_to_str(api_create_time) api_open = user_info.get('api_open', 0) api_info = list() if secret_id and secret_key: api_info_dict = { 'secret_id': secret_id, 'secret_key': secret_key, 'create_time': api_create_time, 'status': api_open, 'type': _(af.COMMON) } api_info.append(api_info_dict) client.api_info = api_info res = { 'client': client, 'user_perm': user_perm, 'user_perm_type': user_perm_type, 'all_perm': all_perm, 'all_perm_type': all_perm_type } return render(request, 'user_accounts/admin_parent_details_views.html', res)
def parent_perm_strategy_details_views(request, perm_strategy_id): """父账号策略详情""" perm_strategy = PermStrategy.objects.filter(id=perm_strategy_id).first() parent_perm = {} parent_perm_type = [] if perm_strategy: parent_perm, parent_perm_type = handle_perm(perm_strategy.perm.all()) all_perm = Perm.objects.filter(content_type__contains='CLIENT') all_perm, all_perm_type = handle_perm(all_perm) res = { 'all_perm': all_perm, 'all_perm_type': all_perm_type, 'perm_strategy': perm_strategy, 'parent_perm': parent_perm, 'parent_perm_type': parent_perm_type, 'strategy_type_dict': PermStrategy.strategy_type_dict() } return render(request, 'user/strategy_management_details.html', res)
def admin_group_create_views(request): """管理员角色创建""" all_perm = Perm.objects.all() perm, perm_type = handle_perm(all_perm) res = { 'perm': perm, 'perm_type': perm_type } return render(request, 'admin_accounts/admin_group_create_views.html', res)
def admin_group_details_views(request, group_id): """管理员获取角色用户详情""" group_profile = GroupProfile.objects.filter(id=group_id).first() perm_group = PermGroup.objects.filter(group=group_profile.group).first() group_perm = {} group_perm_type = [] if perm_group and perm_group.perm.all(): group_perm, group_perm_type = handle_perm(perm_group.perm.all()) all_perm = Perm.objects.filter(content_type__contains='ADMIN') all_perm, all_perm_type = handle_perm(all_perm) res = { 'group_perm': group_perm, 'group_perm_type': group_perm_type, 'group_profile': group_profile, 'all_perm': all_perm, 'all_perm_type': all_perm_type } return render(request, 'admin_accounts/admin_group_details_views.html', res)
def parent_create_perm_strategy_views(request): """父账号策略创建页面""" _, perm_strategy_dict_list = get_user_perm_strategy_list(request) perm_user = PermUser.objects.filter(user=request.user).first() user_perm = {} user_perm_type = [] if perm_user and perm_user.perm.all(): user_perm, user_perm_type = handle_perm(perm_user.perm.all()) res = { 'user_perm': user_perm, 'user_perm_type': user_perm_type, 'perm_strategy_list': perm_strategy_dict_list, 'strategy_type_dict': PermStrategy.strategy_type_dict() } return render(request, 'user/parent_create_perm_strategy_views.html', res)