示例#1
0
def list_dept(wfc):
    dept_dict = af.list_dept()
    obj_json = {"name": dept_dict.get('name')}
    response_obj = {"status": obj_json}
    return jsonify(response_obj)
def main():
    if len(sys.argv) == 1:
        # display help message when no args are passed.
        parser.print_help()
        sys.exit(1)

    if sys.argv[1] == 'initdb':
        print("performing db table creation as per the last schema"
              " change in migration dir : {}".format(migration_path))
        os.environ["FLASK_APP"] = flask_app
        subprocess.run([
            "flask",
            "db",
            "upgrade",
            "-d",
            migration_path,
        ])

    #print(sys.argv[3])


#     options.name = options.name

    if sys.argv[1] == 'add':

        if options.entity == 'org':
            af.register_org(options.name)

        if options.entity == 'ou':
            af.register_ou(options.name)

        if options.entity == 'dept':
            af.register_dept(options.name)

        if options.entity == 'role':
            af.register_role(options.name)

    if sys.argv[1] == 'addwfc':
        af.register_work_func_context(options.name, options.wfcorg,
                                      options.wfcou, options.wfcdept)

    if sys.argv[1] == 'adduser':
        password = options.password
        username = options.name
        emailid = options.emailid
        rolenames = options.rolenames
        if rolenames:
            role_list = []
            if not ',' in rolenames:
                role_list.append(rolenames)
            else:
                role_list = rolenames.split(',')
            af.register_user(
                username,
                email=emailid,
                pwd=password,
                wfc_name=options.wfc,
                roles=role_list,
            )
        else:
            af.register_user(username,
                             email=emailid,
                             pwd=password,
                             wfc_name=options.wfc)
        #af.delete_user(options.name, options.email, options.password, options.roles)

    if sys.argv[1] == 'list':

        if options.entity == 'org':
            if options.name == 'all':
                af.list_org()
            else:
                af.list_org(options.name)

        if options.entity == 'ou':
            if options.name == 'all':
                af.list_ou()
            else:
                af.list_ou(options.name)

        if options.entity == 'dept':
            if options.name == 'all':
                af.list_dept()
            else:
                af.list_dept(options.name)

        if options.entity == 'wfc':
            if options.name == 'all':
                af.list_wfc()
            else:
                af.list_wfc(options.name)

        if options.entity == 'role':
            if options.name == 'all':
                af.list_role()
            else:
                af.list_role(options.name)

        if options.entity == 'user':
            if options.name == 'all':
                af.list_users()
            else:
                af.list_users(options.name)

    if sys.argv[1] == 'delete':

        if options.entity == 'org':
            af.delete_org(options.name)

        if options.entity == 'ou':
            af.delete_ou(options.name)

        if options.entity == 'dept':
            af.delete_dept(options.name)

        if options.entity == 'wfc':
            af.delete_wfc(options.name)

        if options.entity == 'role':
            af.delete_role(options.name)

        if options.entity == 'user':
            af.delete_user(options.name)

    if sys.argv[1] == 'addservice':
        cf.add_service(options.name,
                       pwd=options.password,
                       urlint=options.urlint,
                       urlext=options.urlext,
                       urladmin=options.urladmin)

    if sys.argv[1] == 'listservice':
        if options.name == 'all':
            cf.list_services()
        else:
            cf.list_services(options.name)

    if sys.argv[1] == 'deletservice':
        cf.delete_service(options.name)
示例#3
0
 def test_list_dept_non_existing(self):
     af.list_dept('dept_non_existing')
示例#4
0
 def test_list_dept(self):
     self.create_dept_for_test()
     af.list_dept()
示例#5
0
 def test_list_dept_single_item(self):
     self.create_dept_for_test()
     af.list_dept('dept1')