Пример #1
0
    async def mutate(self, info, **args):  # pylint: disable=missing-docstring
        err = "workflow_schema -> UpdateAction"
        with ax_model.try_catch(info.context['session'], err) as db_session:
            ax_action = db_session.query(AxAction).filter(
                AxAction.guid == uuid.UUID(args.get('guid'))).first()

            if args.get('name'):
                ax_action.name = args.get('name')
            if args.get('db_name'):
                ax_action.db_name = args.get('db_name')
            if args.get('code') is not None:
                if args.get('code') == '':
                    ax_action.code = None
                else:
                    ax_action.code = args.get('code')
            if args.get('confirm_text'):
                ax_action.confirm_text = args.get('confirm_text')
            if args.get('close_modal') is not None:
                ax_action.close_modal = args.get('close_modal')
            if args.get('icon'):
                ax_action.icon = args.get('icon')
            if args.get('radius') is not None:
                ax_action.radius = args.get('radius')

            return UpdateAction(action=ax_action, ok=True)
    async def mutate(self, info, **args):  # pylint: disable=missing-docstring
        # avatar_tmp = args.get('avatar_tmp')
        guid = args.get('guid')

        err = 'Error in gql mutation - users_schema -> UpdateUser.'
        with ax_model.try_catch(info.context['session'], err) as db_session:
            ax_user = db_session.query(AxUser).filter(
                AxUser.guid == uuid.UUID(guid)).first()

            if args.get('name'):
                ax_user.name = args.get('name')
            if args.get('short_name'):
                ax_user.short_name = args.get('short_name')
            if args.get('info'):
                ax_user.info = args.get('info')
            if args.get('password'):
                ax_user.password = pbkdf2_sha256.hash(args.get('password'))
                ax_user.password_must_change = True

            if args.get('is_blocked') is not None:
                ax_user.is_blocked = args.get('is_blocked')

                number_of_users = db_session.query(AxUser).filter(
                    AxUser.is_group.is_(False)).filter(
                        AxUser.is_blocked.is_(False)).count()
                if number_of_users > ax_auth.user_num:
                    maxi = ax_auth.user_num
                    err = f"Maximum number of users exceeded! Max={maxi}"
                    logger.exception(err)
                    raise Exception(err)

            db_session.flush()
            return UpdateUser(user=ax_user, ok=True)
Пример #3
0
async def create_role(db_session, ax_form, role, form_path):
    """ Create or update AxRole """
    err = "marketplace_schema -> create_role"
    with ax_model.try_catch(db_session, err) as db_session:
        existing_role = db_session.query(AxRole).filter(
            AxRole.guid == ax_misc.guid_or_none(role['guid'])).first()
        new_role = None

        code = None
        role_db_name = re.sub(r'[\W_]+', '', role['name'])
        role_py_path = form_path / f'role_{role_db_name}.py'
        if os.path.exists(role_py_path):
            with open(role_py_path, 'r', encoding="utf-8") as role_file:
                code = role_file.read()

        if existing_role:
            existing_role.name = role['name']
            existing_role.icon = role.get('icon', None)
        else:
            new_role = AxRole()
            new_role.guid = ax_misc.guid_or_none(role['guid'])
            new_role.name = role['name']
            new_role.form_guid = ax_form.guid
            new_role.icon = role.get('icon', None)
            new_role.is_dynamic = role.get('is_dynamic', False)
            new_role.code = code
            db_session.add(new_role)
Пример #4
0
async def create_form(db_session, form):
    """ Create or update AxForm """
    err = "marketplace_schema -> create_form"
    with ax_model.try_catch(db_session, err) as db_session:
        existing_form = db_session.query(AxForm).filter(
            AxForm.guid == ax_misc.guid_or_none(form['guid'])).first()
        new_form = None
        form_is_new = False

        if existing_form:
            existing_form.name = form['name']
            existing_form.tom_label = form['tom_label']
            existing_form.icon = form['icon']
        else:
            form_is_new = True
            new_form = AxForm()
            new_form.guid = ax_misc.guid_or_none(form['guid'])
            new_form.name = form['name']
            new_form.db_name = form['db_name']
            new_form.position = int(form['position'] or 0)
            new_form.parent = ax_misc.guid_or_none(form['parent'])
            new_form.tom_label = form['tom_label']
            new_form.icon = form['icon']
            db_session.add(new_form)

            await ax_dialects.dialect.create_data_table(
                db_session=db_session, db_name=form['db_name'])

            db_session.commit()

        ret_form = existing_form or new_form
        return form_is_new, ret_form
Пример #5
0
    async def resolve_to1_references(
            self, info, field_guid, row_guid, update_time=None):
        """ Used in Ax1to1Children. Selects all 1to1 references to parent row
        """
        del update_time
        err = 'Error in GQL query - resolve_to1_fields.'
        with ax_model.try_catch(info.context['session'], err) as db_session:

            # Check if user have access to field

            ret_guids = []
            parent_field = db_session.query(AxField).filter(
                AxField.guid == uuid.UUID(str(field_guid))
            ).first()

            if parent_field.options and parent_field.options['field']:
                child_form_db_name = parent_field.options['form']

                child_field_guid = parent_field.options['field']
                child_field = db_session.query(AxField).filter(
                    AxField.guid == uuid.UUID(str(child_field_guid))
                ).first()

            result = await ax_dialects.dialect.select_to1_children(
                db_session=db_session,
                child_form_db_name=child_form_db_name,
                child_field_db_name=child_field.db_name,
                parent_row_guid=row_guid)

            if result:
                for row in result:
                    ret_guids.append(RowInfo(guid=row['guid']))

            return ret_guids
    async def mutate(self, info, **args):  # pylint: disable=missing-docstring
        # avatar_tmp = args.get('avatar_tmp')

        err = 'Error in gql mutation - users_schema -> CreateUser.'
        with ax_model.try_catch(info.context['session'], err) as db_session:

            ax_user = db_session.query(AxUser).filter(
                AxUser.email == args.get('email')).first()
            if ax_user:
                return CreateUser(user=None,
                                  ok=False,
                                  msg="users.email-exists")

            new_user = AxUser()
            new_user.email = args.get('email')
            new_user.name = args.get('name')
            new_user.short_name = args.get('short_name')
            new_user.info = args.get('info')
            new_user.password = pbkdf2_sha256.hash(args.get('password'))
            new_user.password_must_change = True
            new_user.is_blocked = args.get('is_blocked')
            db_session.add(new_user)
            db_session.flush()

            return CreateUser(user=new_user, ok=True, msg=None)
Пример #7
0
async def create_state(db_session, ax_form, state):
    """ Create or update AxState """
    err = "marketplace_schema -> create_state"
    with ax_model.try_catch(db_session, err) as db_session:
        existing_state = db_session.query(AxState).filter(
            AxState.guid == ax_misc.guid_or_none(state['guid'])).first()
        new_state = None

        if existing_state:
            existing_state.name = state['name']
            existing_state.x = float(state['x'] or 0)
            existing_state.y = float(state['y'] or 0)
        else:
            new_state = AxState()
            new_state.guid = ax_misc.guid_or_none(state['guid'])
            new_state.name = state['name']
            new_state.form_guid = ax_form.guid
            new_state.is_start = state['is_start']
            new_state.is_deleted = state['is_deleted']
            new_state.is_all = state['is_all']
            new_state.x = float(state['x'] or 0)
            new_state.y = float(state['y'] or 0)
            db_session.add(new_state)

        for role_guid in state['roles']:
            await create_state2role(db_session=db_session,
                                    state_guid=state['guid'],
                                    role_guid=role_guid)
Пример #8
0
    async def resolve_to1_fields(
            self, info, child_form_guid, field_guid, update_time=None):
        """Get all AxMessages for specific thread. """
        del update_time
        err = 'Error in GQL query - resolve_to1_fields.'
        with ax_model.try_catch(info.context['session'], err) as db_session:

            ret_fields = []
            child_form = db_session.query(AxForm).filter(
                AxForm.guid == uuid.UUID(str(child_form_guid))
            ).first()

            current_field = db_session.query(AxField).filter(
                AxField.guid == uuid.UUID(str(field_guid))
            ).first()
            parent_form_db_name = str(current_field.form.db_name)

            for field in child_form.fields:
                if field.is_to1_field:
                    options = field.options
                    if options and options['form'] == parent_form_db_name:
                        db_session.expunge(field)
                        ret_fields.append(field)

            return ret_fields
    async def resolve_page_data(self, info, guid=None, update_time=None):
        """Get specific page"""
        del update_time
        current_user = info.context['user']
        user_is_admin = current_user.get('is_admin',
                                         False) if current_user else False
        err = 'Error in GQL query - resolve_page_data.'
        with ax_model.try_catch(info.context['session'], err,
                                no_commit=True) as db_session:
            user_guid = current_user.get("user_id",
                                         None) if current_user else None
            query = Page.get_query(info)  # SQLAlchemy query
            page = None
            if guid:
                page = query.filter(AxPage.guid == uuid.UUID(guid)).first()
            else:
                page = query.filter(AxPage.parent.is_(None)).first()

            pages_guids = get_allowed_pages_guids(db_session=db_session,
                                                  user_guid=user_guid)

            if page.guid in pages_guids or user_is_admin:
                page.html = apply_markdown(page.code)
                return page
            return None
async def create_default_actions(db_session, ax_form, states, default_create,
                                 default_delete, default_update,
                                 delete_confirm):
    """Creates default AxActions"""
    err = "home_schema -> create_default_actions"
    with ax_model.try_catch(db_session, err) as db_session:
        create = AxAction()
        create.name = default_create
        create.form_guid = ax_form.guid
        create.from_state_guid = states['start']
        create.to_state_guid = states['created']
        db_session.add(create)

        update = AxAction()
        update.name = default_update
        update.form_guid = ax_form.guid
        update.from_state_guid = states['created']
        update.to_state_guid = states['created']
        db_session.add(update)

        delete = AxAction()
        delete.name = default_delete
        delete.form_guid = ax_form.guid
        delete.from_state_guid = states['created']
        delete.to_state_guid = states['deleted']
        delete.confirm_text = delete_confirm
        db_session.add(delete)
        db_session.flush()

        return {"create": create.guid, "delete": delete.guid}
Пример #11
0
    async def mutate(self, info, **args):  # pylint: disable=missing-docstring
        err = "workflow_schema -> CreateState"
        with ax_model.try_catch(info.context['session'], err) as db_session:
            ax_form_guid = uuid.UUID(args.get('form_guid'))

            new_state = AxState()
            new_state.name = args.get('name')
            new_state.form_guid = ax_form_guid
            new_state.x = args.get('x')
            new_state.y = args.get('y')

            db_session.add(new_state)
            db_session.flush()

            # Create default self-action
            update_action = None
            if args.get('update'):
                update_action = AxAction()
                update_action.name = args.get('update')
                update_action.form_guid = ax_form_guid
                update_action.from_state_guid = new_state.guid
                update_action.to_state_guid = new_state.guid
                db_session.add(update_action)

            return CreateState(state=new_state,
                               action=update_action,
                               permissions=[],
                               ok=True)
Пример #12
0
    async def resolver(parent, info):
        err = f"Error in {class_name} -> {ax_field_guid} resolver"
        with ax_model.try_catch(info.context['session'], err) as db_session:

            ret_result = []

            field_value = getattr(parent, to1_field_db_name)
            if field_value:
                guids_list = json.loads(field_value)
                ax_form = db_session.query(AxForm).filter(
                    AxForm.db_name == related_form_db_name
                ).first()

                items = {
                    "items": guids_list
                }

                results = await ax_dialects.dialect.select_all(
                    db_session=db_session,
                    ax_form=ax_form,
                    quicksearch=None,
                    guids=json.dumps(items))

                if results:
                    for row in results:
                        kwargs = {}
                        for key, value in row.items():
                            kwargs[key] = await ax_dialects.dialect.conver_for_graphql(value)
                        if class_name in type_classes:
                            row_class = type_classes[class_name](**kwargs)
                            ret_result.append(row_class)

            return ret_result
async def create_default_grid(db_session, ax_form, name):
    """Creates default AxGrid"""
    err = "home_schema -> create_default_grid"
    with ax_model.try_catch(db_session, err) as db_session:
        ax_grid = AxGrid()
        ax_grid.name = name
        ax_grid.db_name = 'Default'
        ax_grid.form_guid = ax_form.guid
        ax_grid.code = None
        ax_grid.position = 1

        default_options = {
            "enableQuickSearch": False,
            "enableFlatMode": False,
            "enableColumnsResize": True,
            "enableFiltering": True,
            "enableSorting": True,
            "enableOpenForm": True,
            "enableActions": True,
            "rowHeight": 45,
            "pinned": 0
        }

        ax_grid.options_json = json.dumps(default_options)
        ax_grid.is_default_view = True
        db_session.add(ax_grid)
        db_session.flush()
Пример #14
0
    async def mutate(self, info, **args):  # pylint: disable=missing-docstring
        err = "workflow_schema -> DeleteRoleFromState"
        with ax_model.try_catch(info.context['session'], err) as db_session:
            guid = args.get('guid')
            role_guid = args.get('role_guid')
            state_guid = args.get('state_guid')

            role2state = None
            if guid:
                role2state = db_session.query(AxState2Role).filter(
                    AxState2Role.guid == uuid.UUID(guid)).first()
            else:
                role2state = db_session.query(AxState2Role).filter(
                    AxState2Role.role_guid == uuid.UUID(role_guid)).filter(
                        AxState2Role.state_guid == uuid.UUID(
                            state_guid)).first()

            if role2state:
                the_role_guid = role2state.role_guid
                the_state_guid = role2state.state_guid

                db_session.delete(role2state)
                return DeleteRoleFromState(deleted=guid,
                                           role_guid=the_role_guid,
                                           state_guid=the_state_guid,
                                           ok=True)
Пример #15
0
    async def mutate(self, info, **args):  # pylint: disable=missing-docstring
        err = 'grids_schema -> CreateColumn'
        with ax_model.try_catch(info.context['session'], err) as db_session:
            grid_guid = args.get('grid_guid')
            field_guid = args.get('field_guid')
            column_type = args.get('column_type')
            position = args.get('position')
            positions = args.get('positions')

            ax_grid = db_session.query(AxGrid).filter(
                AxGrid.guid == uuid.UUID(grid_guid)).first()

            if not positions:
                positions = []
            if not position:
                position = len(ax_grid.columns)

            ax_column = AxColumn()
            ax_column.grid_guid = ax_grid.guid
            ax_column.field_guid = uuid.UUID(field_guid)
            ax_column.column_type = column_type
            ax_column.position = position
            db_session.add(ax_column)

            for column in ax_grid.columns:
                for pos in positions:
                    if str(column.guid) == pos.guid:
                        column.position = pos.position
                        column.column_type = pos.parent

            db_session.flush()
            return CreateColumn(column=ax_column, ok=True)
Пример #16
0
    async def resolve_thread_messages(
            self, info, thread_guid, update_time=None):
        """Get all AxMessages for specific thread. """
        del update_time
        err = 'Error in GQL query - resolve_thread_messages.'
        with ax_model.try_catch(info.context['session'], err) as db_session:
            current_user = info.context['user']

            if not thread_guid:
                return None

            # get thead
            thread = db_session.query(AxMessageThread).filter(
                AxMessageThread.guid == uuid.UUID(thread_guid)
            ).first()

            if not thread:
                return None

            # check field row permission
            perm = True
            if thread.field_guid and thread.row_guid:
                perm = await ax_auth.check_field_perm(
                    db_session=db_session,
                    current_user=current_user,
                    field_guid=thread.field_guid,
                    row_guid=thread.row_guid)

            if not perm:
                return None

            # get messages
            messages = thread.messages
            return messages
Пример #17
0
    async def resolve_ax_grid(self,
                              info,
                              form_db_name,
                              grid_db_name,
                              update_time=None):
        """Get AxGrid by form db_name and grid db_name"""
        del update_time
        err = 'grids_schema -> resolve_grid'
        with ax_model.try_catch(info.context['session'], err,
                                no_commit=True) as db_session:
            grid = None
            ax_form = db_session.query(AxForm).filter(
                AxForm.db_name == form_db_name).first()

            if ax_form:
                query = Grid.get_query(info=info)
                if grid_db_name and grid_db_name != 'null':
                    grid = query.filter(
                        AxGrid.form_guid == ax_form.guid).filter(
                            AxGrid.db_name == grid_db_name).first()
                else:
                    grid = query.filter(
                        AxGrid.form_guid == ax_form.guid).filter(
                            AxGrid.is_default_view.is_(True)).first()

                if not grid or not grid.code:
                    grid.code_not_none = get_default_grid_code()
                else:
                    grid.code_not_none = grid.code
            return grid
    async def mutate(self, info, **args):  # pylint: disable=missing-docstring
        # avatar_tmp = args.get('avatar_tmp')
        guid = args.get('guid')
        name = args.get('name')
        db_name = args.get('db_name')
        code = args.get('code')
        parent = args.get('parent')

        err = 'Error in gql mutation - pages_schema -> UpdatePage.'
        with ax_model.try_catch(info.context['session'], err) as db_session:

            ax_page = db_session.query(AxPage).filter(
                AxPage.guid == uuid.UUID(guid)).first()

            if name:
                ax_page.name = name

            if db_name:
                already_exist_page = db_session.query(AxPage).filter(
                    AxPage.db_name == db_name).first()
                if already_exist_page:
                    return UpdatePage(page=None,
                                      ok=False,
                                      msg='pages.db-name-exists')
                ax_page.db_name = db_name

            if code:
                ax_page.code = code

            if parent:
                ax_page.parent = uuid.UUID(parent)

            db_session.commit()
            ax_page.html = apply_markdown(ax_page.code)
            return UpdatePage(page=ax_page, ok=True, msg=None)
Пример #19
0
async def create_action(db_session, form_directory, ax_form, action):
    """ Creates new AxAction """
    err = "marketplace_schema -> create_action"
    with ax_model.try_catch(db_session, err) as db_session:
        code = None
        action_id = str(action['guid'])
        if action['db_name']:
            action_id = action['db_name']
        action_py_path = form_directory / f'action_{action_id}.py'

        if os.path.exists(action_py_path):
            with open(action_py_path, 'r', encoding="utf-8") as action_file:
                code = action_file.read()

        new_action = AxAction()
        new_action.guid = ax_misc.guid_or_none(action['guid'])
        new_action.name = action['name']
        new_action.db_name = action['db_name']
        new_action.form_guid = ax_form.guid
        new_action.from_state_guid = ax_misc.guid_or_none(
            action['from_state_guid'])
        new_action.to_state_guid = ax_misc.guid_or_none(
            action['to_state_guid'])
        new_action.code = code
        new_action.confirm_text = action['confirm_text']
        new_action.close_modal = action['close_modal']
        new_action.icon = action['icon']
        new_action.radius = float(action['radius'] or 0)
        db_session.add(new_action)

        for role_guid in action['roles']:
            await create_action2role(db_session=db_session,
                                     action_guid=action['guid'],
                                     role_guid=role_guid)
Пример #20
0
 async def mutate(self, info, **args):  # pylint: disable=missing-docstring
     err = 'Error in gql mutation - grids_schema -> UpdateColumnOptions.'
     with ax_model.try_catch(info.context['session'], err) as db_session:
         ax_column = db_session.query(AxColumn).filter(
             AxColumn.guid == uuid.UUID(args.get('guid'))).first()
         ax_column.options_json = args.get('options')
         db_session.flush()
         return UpdateColumnOptions(ok=True)
Пример #21
0
async def drop_actions(db_session, ax_form):
    """ Deletes all AxActions and AxAction2Role of form """
    err = "marketplace_schema -> drop_actions"
    with ax_model.try_catch(db_session, err) as db_session:
        for action in ax_form.actions:
            db_session.query(AxAction2Role).filter(
                AxAction2Role.action_guid == action.guid).delete()
            db_session.delete(action)
Пример #22
0
 async def mutate(self, info, **args):  # pylint: disable=missing-docstring
     err = "workflow_schema -> DeleteAction"
     with ax_model.try_catch(info.context['session'], err) as db_session:
         guid = args.get('guid')
         ax_action = db_session.query(AxAction).filter(
             AxAction.guid == uuid.UUID(guid)).first()
         db_session.delete(ax_action)
         return DeleteAction(deleted=guid, ok=True)
 async def resolve_all_forms(self, info, update_time):
     """Get all users"""
     del update_time
     err = 'Error in GQL query - resolve_all_forms.'
     with ax_model.try_catch(info.context['session'], err, no_commit=True):
         query = Form.get_query(info)  # SQLAlchemy query
         form_list = query.all()
         return form_list
 async def mutate(self, info, **args):  # pylint: disable=missing-docstring
     err = 'Error in gql mutation - form_schema -> DeleteUser.'
     with ax_model.try_catch(info.context['session'], err) as db_session:
         guid = args.get('guid')
         ax_user = db_session.query(AxUser).filter(
             AxUser.guid == uuid.UUID(guid)).first()
         db_session.delete(ax_user)
         return DeleteUser(deleted=guid, ok=True)
 async def resolve_find_user(self, info, guid, update_time):
     """default find method"""
     del update_time
     err = 'Error in GQL query - find_user.'
     with ax_model.try_catch(info.context['session'], err, no_commit=True):
         query = User.get_query(info)
         ax_user = query.filter(AxUser.guid == guid).first()
         return ax_user
    async def mutate(self, info, **args):  # pylint: disable=missing-docstring
        import backend.schema as ax_schema
        err = "home_schema -> CreateForm"
        with ax_model.try_catch(info.context['session'], err) as db_session:
            name = args.get('name')
            db_name = args.get('db_name')
            default_tab_name = args.get('default_tab_name')
            default_grid_name = args.get('default_grid_name')
            default_start = args.get('default_start')
            default_all = args.get('default_all')
            default_create = args.get('default_create')
            default_state = args.get('default_state')
            default_delete = args.get('default_delete')
            default_deleted = args.get('default_deleted')
            default_update = args.get('default_update')
            delete_confirm = args.get('delete_confirm')

            name_avalible = await is_db_name_avalible(db_name=db_name)
            if name_avalible is False:
                return CreateForm(form=None, avalible=False, ok=True)

            await create_db_table(db_session=db_session, db_name=db_name)

            new_form = await create_ax_form(db_session=db_session,
                                            name=name,
                                            db_name=db_name)

            # Add Admins role to object
            states = await create_default_states(
                db_session=db_session,
                ax_form=new_form,
                default_start=default_start,
                default_state=default_state,
                default_all=default_all,
                default_deleted=default_deleted)

            await create_default_actions(db_session=db_session,
                                         ax_form=new_form,
                                         states=states,
                                         default_create=default_create,
                                         default_delete=default_delete,
                                         default_update=default_update,
                                         delete_confirm=delete_confirm)

            await create_default_grid(db_session=db_session,
                                      ax_form=new_form,
                                      name=default_grid_name)

            await create_default_tab(db_session=db_session,
                                     ax_form=new_form,
                                     name=default_tab_name)

            db_session.commit()
            ax_schema.init_schema(db_session)
            # TODO: check for multiple workers and load balancers.
            # https://community.sanicframework.org/t/removing-routes-necessary-functionality/29

            return CreateForm(form=new_form, avalible=True, ok=True)
Пример #27
0
 async def resolve_action_data(self, info, guid=None, update_time=None):
     """ Gets AxAction by guid. Used in TheActionModal.vue. """
     del update_time
     err = 'action_schema -> resolve_action_data'
     with ax_model.try_catch(
             info.context['session'], err, no_commit=True):
         query = Action.get_query(info=info)
         ax_action = query.filter(AxAction.guid == uuid.UUID(guid)).first()
         return ax_action
Пример #28
0
    async def mutate(self, info, **args):  # pylint: disable=missing-docstring

        err = 'Error in gql mutation - InstallFromRepo.'
        with ax_model.try_catch(info.context['session'], err) as db_session:
            del info
            this.current_modal_guid = args.get('modal_guid')
            repo_name = args.get('repo_name')
            await install_from_repo(db_session=db_session, repo_name=repo_name)
            return InstallFromRepo(msg='InstallFromRepo - OK', ok=True)
    async def resolve_form_data(self,
                                info,
                                db_name=None,
                                row_guid=None,
                                update_time=None):
        """ Get AxForm by db_name and row guid

        Args:
            db_name (str, optional): AxForm db_name. Defaults to None.
            row_guid (str, optional): Guid of table row or AxNum value.
            update_time (str, optional): Used to disable gql caching.

        Returns:
            AxForm: Form with field values, avaluble actions, state, row_guid
        """
        current_user = info.context['user']
        err = 'Error in gql query - form_schema -> resolve_form_data'
        with ax_model.try_catch(info.context['session'], err,
                                no_commit=True) as db_session:
            del update_time  # used to disable gql caching

            query = Form.get_query(info=info)
            ax_form = query.filter(AxForm.db_name == db_name).first()

            if not ax_form:
                return None

            if row_guid is not None:
                ax_form = await set_form_values(db_session=db_session,
                                                ax_form=ax_form,
                                                row_guid=row_guid,
                                                current_user=current_user)

            ax_form = await execute_before_display(db_session=db_session,
                                                   ax_form=ax_form,
                                                   current_user=current_user)

            state_guid = await ax_auth.get_state_guid(
                ax_form=ax_form, state_name=ax_form.current_state_name)

            # Check if form have dynamic role
            dynamic_role_guids = await ax_auth.get_dynamic_roles_guids(
                ax_form=ax_form, current_user=current_user)

            ax_form.avalible_actions = await action_schema.get_actions(
                form=ax_form,
                current_state=ax_form.current_state_name,
                current_user=current_user,
                dynamic_role_guids=dynamic_role_guids)

            ax_form = await ax_auth.set_form_visibility(
                ax_form=ax_form,
                state_guid=state_guid,
                current_user=current_user,
                dynamic_role_guids=dynamic_role_guids)

            return ax_form
Пример #30
0
 async def resolve_ax_role(self, info, guid, update_time=None):
     """Get AxRole with code"""
     del update_time
     err = 'Error in GQL query - resolve_ax_role.'
     with ax_model.try_catch(info.context['session'], err, no_commit=True):
         query = Role.get_query(info)  # SQLAlchemy query
         role_guid = ax_misc.guid_or_none(guid)
         ret_role = query.filter(AxRole.guid == role_guid).first()
         return ret_role