Example #1
0
def cancel_admin(request):
    '''
    取消管理员
    '''
    user_id = request.REQUEST.get('user_id')

    return PermissionBase().cancel_admin(user_id)
Example #2
0
    def format_user_full_info(self, user_id):
        '''
        格式化完整用户信息
        '''
        format_user = self.get_user_by_id(user_id)

        # 统计信息
        format_user.user_count = UserCountBase().get_user_count_info(user_id)

        # 是否管理员
        from www.admin.interface import PermissionBase
        if PermissionBase().get_user_permissions(user_id):
            format_user.is_admin = True
        else:
            format_user.is_admin = False

        # 活跃时间
        la = LastActive.objects.filter(user_id=user_id)
        if la:
            la = la[0]
            format_user.last_active = la.last_active_time
            format_user.last_active_ip = la.ip
        else:
            format_user.last_active = format_user.create_time
            format_user.last_active_ip = format_user.ip

        # 注册来源
        if format_user.source > 0:
            format_user.source_display = ExternalToken.objects.filter(user_id=user_id)[0].get_source_display()
        else:
            format_user.source_display = u"直接注册"

        return format_user
Example #3
0
def save_user_permission(request):
    '''
    保存用户权限
    '''
    user_id = request.REQUEST.get('user_id')
    permissions = request.REQUEST.getlist('permissions')

    return PermissionBase().save_user_permission(user_id, permissions, request.user.id)
Example #4
0
def get_user_permissions(request):
    '''
    获取用户对应权限
    '''
    user_id = request.REQUEST.get('user_id')
    data = PermissionBase().get_user_permissions(user_id)
    user = UserBase().get_user_by_id(user_id)
    return HttpResponse(json.dumps({'permissions': data, 'user': {'user_id': user.id, 'user_nick': user.nick}}), mimetype='application/json')
Example #5
0
def get_all_administrators(request):
    '''
    获取所有管理员
    '''
    num = 0
    data = []

    for x in PermissionBase().get_all_administrators():
        num += 1
        data.append({
            'num': num,
            'user_id': x.id,
            'user_nick': x.nick,
            'user_avatar': x.get_avatar_25()
        })

    return HttpResponse(json.dumps(data), mimetype='application/json')
Example #6
0
    def format_user_full_info(self, user_id):
        '''
        格式化完整用户信息
        '''
        format_user = self.get_user_by_id(user_id, state=[0, 1, 2])

        # 判断是否已经是推荐用户了
        if RecommendUser.objects.filter(user_id=user_id).count() > 0:
            format_user.is_recommend = True
        else:
            format_user.is_recommend = False

        # 统计信息
        format_user.user_count = UserCountBase().get_user_count_info(user_id)

        # 是否管理员
        from www.admin.interface import PermissionBase
        if PermissionBase().get_user_permissions(user_id):
            format_user.is_admin = True
        else:
            format_user.is_admin = False

        # 客户经理
        from www.kaihu.interface import CustomerManagerBase
        if CustomerManagerBase().get_customer_manager_by_user_id(user_id):
            format_user.is_customer_manager = True
        else:
            format_user.is_customer_manager = False

        # 活跃时间
        la = LastActive.objects.filter(user_id=user_id)
        if la:
            la = la[0]
            format_user.last_active = la.last_active_time
            format_user.last_active_ip = la.ip
        else:
            format_user.last_active = format_user.create_time
            format_user.last_active_ip = format_user.ip

        return format_user
Example #7
0
def permission(request, template_name='admin/permission.html'):
    permissions = PermissionBase().get_all_permissions()
    return render_to_response(template_name, locals(), context_instance=RequestContext(request))
Example #8
0
 def can_query_stock_chart(self):
     from www.admin.interface import PermissionBase
     return True if 'query_stock_chart' in PermissionBase(
     ).get_user_permissions(self.id) else False