def __init__ (self, id, order, display_name, table_name = None, criteria = {}):
     self.id = id
     self.order = order
     self.display_name = (display_name or table_name)
     self.table_name = table_name
     self.table_dict = {} # results indexed by row id and table|field name
     self.criteria = criteria
     self.rac = g_helper.get_role_access_control()
     # fields will be decided with id or table_name
     self.fc = FieldCollection(id, table_name)
    def __init__ (self, table_query_id = None, table_name = None, criteria = {}, role_filter = True):
        self.table_name = table_name
        self.table_query_id = table_query_id
        self.date_fields = {}
        self.rac = g_helper.get_role_access_control()
        self.fields_by_id = {} # for setting fk_field
        self.criteria = criteria
        self.role_filter = role_filter # used to ignore role for FK search

        # get all the fields
        self.fields = self._populate_fields()
Exemple #3
0
    def __init__ (self, field, table_object, field_role, data_type, order, table_query_field = None, calculation = None):
        self.Field = field
        self.TableObject = table_object
        self.FieldRole = field_role
        self.DataType = data_type

        # FK data will be set when set_fk_field is called
        self.FK_Field = None
        self.FK_TableObject = None
        self.FK_FieldRole = None

        self.DYN_TableObject = None
        self.DYN_Field_Definition = None

        # None if table_query by table_name rather than id
        self.TableQueryField = table_query_field
        self.TableQueryCalculation = calculation

        if calculation:
            # there are cases where we want to display calculated and
            # uncalculated values of a field so calculated fields need
            # a name unique from the uncalculated field
            self.name = 'calc|' + self.TableQueryField.name
        else:
            # unique name, table|field
            self.name = self.TableObject.name + '|' + self.Field.display_name
        # if table query set any group_bys
        self.group_by = None
        self.group_func = None
        if self.TableQueryField:
            self.group_by = self.TableQueryField.group_by
            self.group_func = self.TableQueryField.group_func
        self.display_name = self.get_field_display_name() # name from role or tq
        self.rac = g_helper.get_role_access_control()
        self.calculation_fields = self._get_calculation_fields(calculation)
        self.type = self._get_type()
        self.is_foreign_key = (self.Field.foreign_key_table_object_id is not None)
        self.is_dynamic_field = (self.Field.dynamic_field_definition_field_id is not None)
        self.is_title_field = (self.TableObject.id == self.Field.table_object_id and self.Field.display_name == 'name')
        self.order = self.get_field_order()

        # base visibility on original field, do not change if fk field
        self.visible = self.set_visiblity()

        # can be set by set_default()
        self.default = None
    def __init__(self, table_name, instance_name = None, depth = 2):
        self.role_access_control = g_helper.get_role_access_control()
        self.organization_access_control = g_helper.get_org_access_control()

        self.table_name = table_name
        self.tables = OrderedDict()
        self.fields = {}
        self.instances = {}
        self.instance_names = {}
        self.get_tables(depth)

        self.instance_counter = 0

        if self.tables[table_name]['table_meta_data'] is None:
            abort(403)

        self.instance_id = None
        self.instance_name = None
        if instance_name is not None:
            self.get_data(instance_name)
    def __init__ (self, work_item_group_name, workflow_name, show_step = None):
        self.name = work_item_group_name  # can be new
        self.rac = g_helper.get_role_access_control()
        self.oac = g_helper.get_org_access_control()
        self.workflow = Workflow(workflow_name)

        # sql alchemy results will populate these capitalized vars
        self.WorkItemGroup = None
        self.work_items = {}
        self.parent_work_item = None
        self.get_work_item_group()

        # which step is the wig currently on
        self.step = self.get_step()
        self.step_num = self.step.Step.order

        # which step is requested for show
        if show_step and show_step != self.step_num:
            self.show_step_num = int(show_step)
            self.step = self.get_step(show_step)
        else:
            self.show_step_num = self.step_num

        # set the url for current step
        self.endpoint = self.step.Module.name + '.' + self.step.Route.url_path
        self.dynamic_params = self.set_dynamic_params()
        self.url = self.workflow.get_step_url(self.show_step_num, self.name)

        # default set on init, actions can change this
        self.next_step = self.show_step_num + 1

        # not all steps are necessary depending on items
        self.active_steps = self.get_active_steps(self.workflow.steps)
        self.buttons = []
        self.saved_rows = {}

        # do before step actions, if current step
        if self.show_step_num == self.step_num:
            self.do_step_actions(timing.BEFORE)
def change_role(facility_name):
    role_id = request.json['role_id']
    rac = g_helper.get_role_access_control()
    success = rac.change_role(role_id)
    return json.dumps({'success': success})
 def __init__ (self, table_name = None, criteria = {}):
     self.table_name = table_name
     self.criteria = criteria
     self.rac = g_helper.get_role_access_control()
     self.queries = self._get_queries()