Exemplo n.º 1
0
    def get_process(my):
        '''Get from the ProcessFilterWdg in SObjectLoadWdg,
            otherwise get from FilterData'''

        process = ''

        # Ususally there is no pipeline defined for prod/shot_instance
        # so get from prod/shot
        search_type = my.search_type
        if search_type == 'prod/shot_instance':
            search_type = 'prod/shot'

        state = Container.get("global_state")
        if state:
            process = state.get('process')
        else:

            # get it from FilterData
            data = FilterData.get()
            values = data.get_values_by_prefix('view_action_option')
            if values:
                process = values[0].get('load_%s_process' % search_type)

        if not process:
            from pyasm.prod.web import ProcessFilterWdg
            process_filter = ProcessFilterWdg(None, search_type)
            process = process_filter.get_value()
        return process
Exemplo n.º 2
0
    def get_process(my):
        '''Get from the ProcessFilterWdg in SObjectLoadWdg,
            otherwise get from FilterData'''

        process = ''

        # Ususally there is no pipeline defined for prod/shot_instance
        # so get from prod/shot
        search_type = my.search_type
        if search_type =='prod/shot_instance':
            search_type = 'prod/shot'

        state = Container.get("global_state")
        if state:
            process = state.get('process')
        else:
            
            # get it from FilterData
            data = FilterData.get()
            values = data.get_values_by_prefix('view_action_option')
            if values:
                process = values[0].get('load_%s_process' %search_type)

        if not process:
            from pyasm.prod.web import ProcessFilterWdg
            process_filter = ProcessFilterWdg(None, search_type)
            process = process_filter.get_value()
        return process
Exemplo n.º 3
0
    def get_display(self):

        widget = DivWdg()
        self.set_as_panel(
            widget,
            class_name='spt_view_panel spt_panel spt_app_asset_inst_panel')

        parent_search_type = self.search_type

        if self.show_search:
            # Have to limit this search to just its parent.. cuz if the target is prod/shot_instance
            # and its parent search is ShotFilterWdg, it's hard to isolate what shot has been selected
            search_bvr = {
                'type':
                'click_up',
                'cbjs_action':
                'spt.dg_table.search_cbk(evt, bvr)',
                'override_class_name':
                'tactic.ui.cgapp.AppAssetInstancePanelWdg',
                'override_target':
                "bvr.src_el.getParent('.spt_app_asset_inst_panel')"
            }

            search_wdg = SearchWdg(search_type=parent_search_type, view='search_shot_loader', parent_key='', filter=''\
            , display='block', custom_filter_view='', state=None, run_search_bvr=search_bvr)
            widget.add(HtmlElement.spacer_div(1, 10))
            widget.add(search_wdg)

            # if there is result, it could only be one shot
            search = search_wdg.get_search()
            shots = search.get_sobjects()

            if not self.shot and len(shots) == 1:
                self.shot = shots[0]

        # create the asset table
        table_id = "main_body_asset_instance_table"

        if not self.shot:
            return widget
        # get any parent shots
        parent_code = self.shot.get_value("parent_code")
        shot_code = self.shot.get_code()

        # add the search make sure set elements are not shown
        search = Search(self.instance_search_type)
        if parent_code != "":
            search.add_filters(self.shot.get_foreign_key(),
                               [shot_code, parent_code])
        else:
            search.add_filter(self.shot.get_foreign_key(), shot_code)

        search.add_where("\"type\" in ('set_item', 'asset')")
        search.add_order_by('asset_code')

        instances = search.get_sobjects()

        # if parent shot and current shot has the same instance, hide the
        # parent's one

        top_instances = []
        for instance in instances:
            if instance.get_value('type') != 'set_item':
                top_instances.append(instance)

        #instances = ShotInstance.filter_instances(instances, shot_code)
        top_instances = ShotInstance.filter_instances(top_instances, shot_code)
        # TODO: just add asset name to the ShotInstance table
        # get the original asset names

        aux_data = ShotInstance.get_aux_data(top_instances,
                                             self.asset_search_type)

        values = FilterData.get().get_values_by_index('view_action_option', 0)
        state = {}

        if not self.show_search:
            if values:
                state['process'] = values.get('load_%s_process' %
                                              parent_search_type)
            else:
                process_filter = ProcessFilterWdg(None, parent_search_type)
                state['process'] = process_filter.get_value()

        Container.put("global_state", state)

        from tactic.ui.cgapp import CGAppLoaderWdg
        cg_wdg = CGAppLoaderWdg(view='load',
                                search_type=self.instance_search_type)
        widget.add(cg_wdg)

        if not top_instances:
            widget.add('No Asset Instances in Shot.')
        else:
            asset_table = TableLayoutWdg(table_id = table_id, search_type=self.instance_search_type,\
                view="load", inline_search=False, aux_info = aux_data, mode='simple')

            #asset_table = ViewPanelWdg( search_type=search_type,  inline_search=False, \
            #        show_general_search=False, view='load', state=state, mode='simple')

            asset_table.set_sobjects(top_instances)
            widget.add(asset_table)

            shot_inst_names = [inst.get_code() for inst in instances]

            self.add_unassigned_instances(widget, shot_inst_names)
        return widget
Exemplo n.º 4
0
    def get_display(my):
        
        widget = DivWdg()
        my.set_as_panel(widget, class_name='spt_view_panel spt_panel spt_app_asset_inst_panel')
        
        parent_search_type= my.search_type
        
        if my.show_search:
            # Have to limit this search to just its parent.. cuz if the target is prod/shot_instance
            # and its parent search is ShotFilterWdg, it's hard to isolate what shot has been selected
            search_bvr = {
                'type':         'click_up',
                'cbjs_action':  'spt.dg_table.search_cbk(evt, bvr)',
                'override_class_name': 'tactic.ui.cgapp.AppAssetInstancePanelWdg',
                'override_target': "bvr.src_el.getParent('.spt_app_asset_inst_panel')"
            }

            search_wdg = SearchWdg(search_type=parent_search_type, view='search_shot_loader', parent_key='', filter=''\
            , display='block', custom_filter_view='', state=None, run_search_bvr=search_bvr)
            widget.add( HtmlElement.spacer_div(1,10) )
            widget.add(search_wdg)


            # if there is result, it could only be one shot
            search = search_wdg.get_search()
            shots = search.get_sobjects()
            
            if not my.shot and len(shots) == 1:
                my.shot= shots[0]

        # create the asset table
        table_id = "main_body_asset_instance_table" 
              
        if not my.shot:
            return widget
        # get any parent shots
        parent_code = my.shot.get_value("parent_code")
        shot_code = my.shot.get_code()

        # add the search make sure set elements are not shown
        search = Search(my.instance_search_type)
        if parent_code != "":
            search.add_filters(my.shot.get_foreign_key(), [shot_code,parent_code] )
        else:
            search.add_filter(my.shot.get_foreign_key(), shot_code )

        search.add_where("\"type\" in ('set_item', 'asset')")
        search.add_order_by('asset_code')
        
        instances = search.get_sobjects()

        # if parent shot and current shot has the same instance, hide the 
        # parent's one
        
        top_instances = []
        for instance in instances:
            if instance.get_value('type') != 'set_item':
                top_instances.append(instance)

        #instances = ShotInstance.filter_instances(instances, shot_code)
        top_instances = ShotInstance.filter_instances(top_instances, shot_code)
        # TODO: just add asset name to the ShotInstance table
        # get the original asset names

        aux_data = ShotInstance.get_aux_data(top_instances, my.asset_search_type)

        values = FilterData.get().get_values_by_index('view_action_option', 0)
        state = {}
        
        if not my.show_search:
            if values:
                state['process'] = values.get('load_%s_process'% parent_search_type)
            else:
                process_filter = ProcessFilterWdg(None, parent_search_type)
                state['process'] = process_filter.get_value()

        Container.put("global_state", state)
        
        from tactic.ui.cgapp import CGAppLoaderWdg
        cg_wdg = CGAppLoaderWdg(view='load', search_type=my.instance_search_type)
        widget.add(cg_wdg)

        if not top_instances:
            widget.add('No Asset Instances in Shot.')
        else:
            asset_table = TableLayoutWdg(table_id = table_id, search_type=my.instance_search_type,\
                view="load", inline_search=False, aux_info = aux_data, mode='simple')

            #asset_table = ViewPanelWdg( search_type=search_type,  inline_search=False, \
            #        show_general_search=False, view='load', state=state, mode='simple') 

            asset_table.set_sobjects(top_instances)
            widget.add(asset_table)

            shot_inst_names = [inst.get_code() for inst in instances]
            
            my.add_unassigned_instances(widget, shot_inst_names)
        return widget