Example #1
0
def user_list(request):
    lName = request.session.get('name', False)
    if lName:
        master = daozo.getMasterOfAccount(lName)
        userList = []
        if master:
            messages.add_message(request, messages.ERROR, 'Permission denied to view the user list.', 'ERROR')
            return redirect('/my/user/list/')
        else:
            res = daozo.getUserListOfOwner(lName)
            for i in range(len(res)):
                res_tr = daozo.getUser_TenantRole(res[i]['loginName'])
                t_list = []
                r_list = []
                if res_tr:
                    for j in range(len(res_tr)):
                        t_list.append(res_tr[j]['tenant'])
                        r_list.append(res_tr[j]['role'])
                res[i].setdefault('tenants', t_list)
                res[i].setdefault('roles', r_list)
                # u = {
                     # 'loginName':res[i]['loginName'],
                     # 'tenantName':t_list,
                     # 'roleName':r_list,
                     # 'balance':res[i]['balance'],
                     # 'create_at':res[i]['create_at'],
                     # }
                # userList.append(u)
                res[i].setdefault('act_del', '/my/user/delete/?UN=%s' % (res[i]['loginName']))
                res[i].setdefault('act_man', '/my/user/detail/?UN=%s' % (res[i]['loginName']))
                userList.append(res[i])
        return render_to_response('my/user/user_list.html', locals(), RequestContext(request))
    else:
        messages.add_message(request, messages.WARNING, 'Please login first.', 'WARNING')
        return redirect('/login/')
Example #2
0
def user_list(request):
    lName = request.session.get('name', False)
    if lName:
        master = daozo.getMasterOfAccount(lName)
        userList = []
        if master:
            messages.add_message(request, messages.ERROR,
                                 'Permission denied to view the user list.',
                                 'ERROR')
            return redirect('/my/user/list/')
        else:
            res = daozo.getUserListOfOwner(lName)
            for i in range(len(res)):
                res_tr = daozo.getUser_TenantRole(res[i]['loginName'])
                t_list = []
                r_list = []
                if res_tr:
                    for j in range(len(res_tr)):
                        t_list.append(res_tr[j]['tenant'])
                        r_list.append(res_tr[j]['role'])
                res[i].setdefault('tenants', t_list)
                res[i].setdefault('roles', r_list)
                # u = {
                # 'loginName':res[i]['loginName'],
                # 'tenantName':t_list,
                # 'roleName':r_list,
                # 'balance':res[i]['balance'],
                # 'create_at':res[i]['create_at'],
                # }
                # userList.append(u)
                res[i].setdefault(
                    'act_del',
                    '/my/user/delete/?UN=%s' % (res[i]['loginName']))
                res[i].setdefault(
                    'act_man',
                    '/my/user/detail/?UN=%s' % (res[i]['loginName']))
                userList.append(res[i])
        return render_to_response('my/user/user_list.html', locals(),
                                  RequestContext(request))
    else:
        messages.add_message(request, messages.WARNING, 'Please login first.',
                             'WARNING')
        return redirect('/login/')
Example #3
0
def tenant_edit_user(request):
    lName = request.session.get('name', False)
    if lName:
        master = daozo.getMasterOfAccount(lName)
        if master:
            messages.add_message(request, messages.ERROR,
                                 'permission denied, only project owner.')
            return redirect('/my/')
        else:
            tenant = request.GET['t']
            if tenant:
                userList = []
                res = daozo.getUserListOfOwner(lName)
                sys_role_list = daozo.getSysRoleList()
                for i in range(len(res)):
                    res_tr = daozo.getUser_TenantRole(res[i]['loginName'])
                    t_list = []
                    r_list = []
                    res[i].setdefault('current_tenant', False)
                    res[i].setdefault('current_role', False)
                    if res_tr:
                        for j in range(len(res_tr)):
                            if res_tr[j]['tenant'] == tenant:
                                res[i]['current_tenant'] = True
                                res[i]['current_role'] = res_tr[j]['role']
                            else:
                                t_list.append(res_tr[j]['tenant'])
                                r_list.append(res_tr[j]['role'])
                            # res[i].setdefault('desc', res_tr[j]['desc'])
                    res[i].setdefault('tenants', t_list)
                    res[i].setdefault('roles', r_list)
                    userList.append(res[i])
            else:
                messages.add_message(request, messages.ERROR,
                                     'Invalid project.', 'ERROR')
                return redirect('/my/project/list/')
            return render_to_response('my/tenant/tenant_edit_user.html',
                                      locals(), RequestContext(request))
    else:
        messages.add_message(request, messages.WARNING, 'Please login first.',
                             'WARNING')
        return redirect('/login/')
Example #4
0
def tenant_edit_user(request):
    lName = request.session.get('name', False)
    if lName:
        master = daozo.getMasterOfAccount(lName)
        if master:
            messages.add_message(request, messages.ERROR, 'permission denied, only project owner.')
            return redirect('/my/')
        else:
            tenant = request.GET['t']
            if tenant:
                userList = []
                res = daozo.getUserListOfOwner(lName)
                sys_role_list = daozo.getSysRoleList()
                for i in range(len(res)):
                    res_tr = daozo.getUser_TenantRole(res[i]['loginName'])
                    t_list = []
                    r_list = []
                    res[i].setdefault('current_tenant', False)
                    res[i].setdefault('current_role', False)
                    if res_tr:
                        for j in range(len(res_tr)):
                            if res_tr[j]['tenant'] == tenant:
                                res[i]['current_tenant'] = True
                                res[i]['current_role'] = res_tr[j]['role']
                            else:
                                t_list.append(res_tr[j]['tenant'])
                                r_list.append(res_tr[j]['role'])
                            # res[i].setdefault('desc', res_tr[j]['desc'])
                    res[i].setdefault('tenants', t_list)
                    res[i].setdefault('roles', r_list)
                    userList.append(res[i])
            else:
                messages.add_message(request, messages.ERROR, 'Invalid project.', 'ERROR')
                return redirect('/my/project/list/')
            return render_to_response('my/tenant/tenant_edit_user.html', locals(), RequestContext(request))
    else:
        messages.add_message(request, messages.WARNING, 'Please login first.', 'WARNING')
        return redirect('/login/')
Example #5
0
def index(request):
    lName = request.session.get('name', False)
    if lName:
        master = daozo.getMasterOfAccount(lName)
        res = daozo.getAccountInfo(lName)
        id = res[0][0]
        # lName = res[0][1]
        email = res[0][2]
        balance = res[0][3]
        # master = res[0][4]
        customerID = res[0][5]
        lastLogin = res[0][6].strftime('%Y-%m-%d %H:%M:%S')
        createTime = res[0][6].strftime('%Y-%m-%d %H:%M:%S')
        res = daozo.getTenantList(lName)
        if master:
            accType = '子帐号'
        else:
            accType = '主帐号'
            if customerID == None :
                shiming = '未认证'
                shimingHref = True                
            else:
                shiming = '已认证'
                shimingHref = False
        projectList = []
        res = daozo.getTenantList(lName)
        if master:
            for i in range(len(res)):
                tenant = {
                          'name':res[i][0],
                          'role':res[i][1],
                          'desc':res[i][2],
                          'time':res[i][3],
                          }
                projectList.append(tenant)
        else:
            for i in range(len(res)):
                tenant = {
                          'name':res[i][0],
                          'role':res[i][1],
                          'desc':res[i][2],
                          'time':res[i][3],
                          }
                projectList.append(tenant)
        userList = []
        if master:
            userList = []
        else:
            res = daozo.getUserListOfOwner(lName)
            for i in range(len(res)):
                res_tr = daozo.getUser_TenantRole(res[i]['loginName'])
                t_list = []
                r_list = []
                if res_tr:
                    for j in range(len(res_tr)):
                        t_list.append(res_tr[j]['tenant'])
                        r_list.append(res_tr[j]['role'])
                res[i].setdefault('tenants', t_list)
                res[i].setdefault('roles', r_list)
                # u = {
                     # 'loginName':res[i]['loginName'],
                     # 'tenantName':t_list,
                     # 'roleName':r_list,
                     # 'balance':res[i]['balance'],
                     # 'create_at':res[i]['create_at'],
                     # }
                # userList.append(u)
                res[i].setdefault('act_del', '/my/user/delete/?UN=%s' % (res[i]['loginName']))
                res[i].setdefault('act_man', '/my/user/detail/?UN=%s' % (res[i]['loginName']))
                userList.append(res[i])
                
        return render_to_response('my/index.html', locals(), RequestContext(request))
        '''
        master = daozo.getMasterOfAccount(lName)
        userList = []
        res = daozo.getAccountInfo(lName)
        id = res[0][0]
        # lName = res[0][1]
        email = res[0][2]
        balance = res[0][3]
        # master = res[0][4]
        customerID = res[0][5]
        lastLogin = res[0][6].strftime('%Y-%m-%d %H:%M:%S')
        createTime = res[0][6].strftime('%Y-%m-%d %H:%M:%S')
        res = daozo.getTenantList(lName)
        if master:
            accType = '子帐号'
        else:
            accType = '主帐号'
            if customerID == None :
                shiming = '未认证'
                shimingHref = True                
            else:
                shiming = '已认证'
                shimingHref = False    
            # userList = getSubAccount(lName)
        return render_to_response('my/index.html', locals(), RequestContext(request))
        '''
    else:
        messages.add_message(request, messages.WARNING, 'Please login first.', 'WARNING')
        return redirect('/login/')
Example #6
0
def index(request):
    lName = request.session.get('name', False)
    if lName:
        master = daozo.getMasterOfAccount(lName)
        res = daozo.getAccountInfo(lName)
        id = res[0][0]
        # lName = res[0][1]
        email = res[0][2]
        balance = res[0][3]
        # master = res[0][4]
        customerID = res[0][5]
        lastLogin = res[0][6].strftime('%Y-%m-%d %H:%M:%S')
        createTime = res[0][6].strftime('%Y-%m-%d %H:%M:%S')
        res = daozo.getTenantList(lName)
        if master:
            accType = '子帐号'
        else:
            accType = '主帐号'
            if customerID == None:
                shiming = '未认证'
                shimingHref = True
            else:
                shiming = '已认证'
                shimingHref = False
        projectList = []
        res = daozo.getTenantList(lName)
        if master:
            for i in range(len(res)):
                tenant = {
                    'name': res[i][0],
                    'role': res[i][1],
                    'desc': res[i][2],
                    'time': res[i][3],
                }
                projectList.append(tenant)
        else:
            for i in range(len(res)):
                tenant = {
                    'name': res[i][0],
                    'role': res[i][1],
                    'desc': res[i][2],
                    'time': res[i][3],
                }
                projectList.append(tenant)
        userList = []
        if master:
            userList = []
        else:
            res = daozo.getUserListOfOwner(lName)
            for i in range(len(res)):
                res_tr = daozo.getUser_TenantRole(res[i]['loginName'])
                t_list = []
                r_list = []
                if res_tr:
                    for j in range(len(res_tr)):
                        t_list.append(res_tr[j]['tenant'])
                        r_list.append(res_tr[j]['role'])
                res[i].setdefault('tenants', t_list)
                res[i].setdefault('roles', r_list)
                # u = {
                # 'loginName':res[i]['loginName'],
                # 'tenantName':t_list,
                # 'roleName':r_list,
                # 'balance':res[i]['balance'],
                # 'create_at':res[i]['create_at'],
                # }
                # userList.append(u)
                res[i].setdefault(
                    'act_del',
                    '/my/user/delete/?UN=%s' % (res[i]['loginName']))
                res[i].setdefault(
                    'act_man',
                    '/my/user/detail/?UN=%s' % (res[i]['loginName']))
                userList.append(res[i])

        return render_to_response('my/index.html', locals(),
                                  RequestContext(request))
        '''
        master = daozo.getMasterOfAccount(lName)
        userList = []
        res = daozo.getAccountInfo(lName)
        id = res[0][0]
        # lName = res[0][1]
        email = res[0][2]
        balance = res[0][3]
        # master = res[0][4]
        customerID = res[0][5]
        lastLogin = res[0][6].strftime('%Y-%m-%d %H:%M:%S')
        createTime = res[0][6].strftime('%Y-%m-%d %H:%M:%S')
        res = daozo.getTenantList(lName)
        if master:
            accType = '子帐号'
        else:
            accType = '主帐号'
            if customerID == None :
                shiming = '未认证'
                shimingHref = True                
            else:
                shiming = '已认证'
                shimingHref = False    
            # userList = getSubAccount(lName)
        return render_to_response('my/index.html', locals(), RequestContext(request))
        '''
    else:
        messages.add_message(request, messages.WARNING, 'Please login first.',
                             'WARNING')
        return redirect('/login/')