Пример #1
0
    def get_display(my):
        widget = DivWdg()

        my.set_as_panel(widget, class_name='spt_view_panel spt_panel')
 
        # create a table widget and set the sobjects to it
        table_id = "main_body_table" 
        filter = my.kwargs.get('filter')
        table = TableLayoutWdg(table_id=table_id, search_type="sthpw/timecard", \
                view="table", inline_search=True, filter=filter, search_view='search' ) 

       
        search_type = "sthpw/timecard"
        from tactic.ui.app import SearchWdg
        
        search_wdg = SearchWdg(search_type=search_type, view='search', filter=filter)
        
        widget.add(search_wdg)
        search = search_wdg.get_search()

        # FIX to current project timecard for now
        search.add_filter('project_code', Project.get_project_code())
        #search.add_project_filter()

        table.alter_search(search)
        print "SEA ", search.get_statement()
        sobjects = search.get_sobjects()
        print "SOB ", sobjects
        table.set_sobjects(sobjects, search)
        widget.add(table)
        #widget.add(SpecialDayWdg())
        return widget
Пример #2
0
    def get_display(my):

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

        # create a table widget and set the sobjects to it
        table_id = "main_body_table" 
        table = TableLayoutWdg(table_id=table_id, search_type="sthpw/notification_log", \
                view="table", inline_search=True, search_view='search') 

        search_type = "sthpw/notification_log"
        
        from tactic.ui.app import SearchWdg
        
        search_wdg = SearchWdg(search_type=search_type, view='search')

        
        widget.add(search_wdg)
        search = search_wdg.get_search()
        table.alter_search(search)
        sobjects = search.get_sobjects()
        table.set_sobjects(sobjects, search)
        widget.add(table)

        return widget
Пример #3
0
    def get_display(my):

        # just refresh the whole thing 
        widget = DivWdg()
        
        outer_widget = DivWdg(css='spt_view_panel')
        search_div = DivWdg()
        search_bvr = {
            'type':         'click_up',
            'cbjs_action':  'spt.dg_table.search_cbk(evt, bvr)',
            'override_class_name': 'tactic.ui.cgapp.AppShotPanelWdg',
            'override_target': 'bvr.src_el.getParent(".spt_app_shot_panel")',
            'extra_args': {'instance_search_type': my.instance_search_type,
                        'asset_search_type': my.asset_search_type}
            #'panel_id':     'main_body_search'
            
        }

        # WARNING: this is made just for main search box and  won't be compatible with the simple search wdg
        search_wdg = SearchWdg(search_type=my.search_type, custom_search_view='search_shot_loader', parent_key='', filter=''\
            , display='block', custom_filter_view='', state=None, run_search_bvr=search_bvr)

        #from tactic.ui.app.simple_search_wdg import SimpleSearchWdg
        #search_wdg = SimpleSearchWdg(search_type=my.search_type, search_view=my.simple_search_view, state=None, run_search_bvr=search_bvr)
        search_div.add( HtmlElement.spacer_div(1,10) )
        search_div.add(search_wdg)

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

        # avoid getting a shot when no shot is selected
        if not my.shot_code and len(shots) == 1:
            my.shot_code = shots[0].get_code()
        
        outer_widget.add(search_div)

        my.set_as_panel(outer_widget, class_name='spt_panel spt_view_panel spt_app_shot_panel')
        #show_shot_panel = False
        #if show_shot_panel:
        panel = ViewPanelWdg( search_type=my.search_type, \
                 inline_search=True, show_search='false', show_refresh='false', view=my.view, \
                run_search_bvr=search_bvr, simple_search_view=my.simple_search_view)
        panel.set_sobjects(shots)

        widget.add(panel)
         
        show_instances_in_shot = ProdSetting.get_value_by_key("show_instances_in_shot_panel")
        if show_instances_in_shot != "false":

            widget.add(HtmlElement.h3("Asset Instances in Shot [%s]" %my.shot_code))
            widget.add(HtmlElement.br(2))
            asset_inst_panel = AppAssetInstancePanelWdg(search_type=my.search_type, instance_search_type=my.instance_search_type, asset_search_type=my.asset_search_type, shot_code=my.shot_code, show_search='false')
            widget.add(asset_inst_panel)
        outer_widget.add(widget)
        return outer_widget
Пример #4
0
    def preprocess(my):
        if my.sobjects:
            try:
                search = Search(Task)
                search_ids = [x.get_id() for x in my.sobjects]
                search.add_filters("search_id", search_ids)
                search_type = my.sobjects[0].get_search_type()
                search.add_filter("search_type", search_type)

                # go thru children of main search
                search = my.alter_task_search(search, prefix='children')
                # go thru Local Search
                search = my.alter_task_search(
                    search,
                    prefix='main_body',
                    prefix_namespace=my.__class__.__name__)

                sobj = my.sobjects[0]
                pipeline = Pipeline.get_by_sobject(sobj)
                if pipeline:
                    process_names = pipeline.get_process_names(True)
                    search.add_enum_order_by("process", process_names)
                else:
                    search.add_order_by("process")

                search.add_order_by("id")
                tasks = search.get_sobjects()
                # create a data structure
                for task in tasks:
                    search_type = task.get_value("search_type")
                    search_id = task.get_value("search_id")
                    search_key = "%s|%s" % (search_type, search_id)

                    sobject_tasks = my.data.get(search_key)
                    if not sobject_tasks:
                        sobject_tasks = []
                        my.data[search_key] = sobject_tasks
                    sobject_tasks.append(task)
            except:
                from tactic.ui.app import SearchWdg
                parent_search_type = get_search_type()
                SearchWdg.clear_search_data(parent_search_type)
                raise
Пример #5
0
    def preprocess(my):
        if my.sobjects:
            try:
                search = Search(Task) 
                search_ids = [x.get_id() for x in my.sobjects]
                search.add_filters("search_id", search_ids)
                search_type = my.sobjects[0].get_search_type()
                search.add_filter("search_type", search_type)
                
                # go thru children of main search
                search = my.alter_task_search(search, prefix='children')
                # go thru Local Search
                search = my.alter_task_search(search, prefix='main_body', prefix_namespace=my.__class__.__name__)

                sobj = my.sobjects[0]
                pipeline = Pipeline.get_by_sobject(sobj) 
                if pipeline:
                    process_names = pipeline.get_process_names(True)
                    search.add_enum_order_by("process", process_names)
                else:
                    search.add_order_by("process")

                search.add_order_by("id")
                tasks = search.get_sobjects()
                # create a data structure
                for task in tasks:
                    search_type = task.get_value("search_type")
                    search_id = task.get_value("search_id")
                    search_key = "%s|%s" % (search_type, search_id)

                    sobject_tasks = my.data.get(search_key)
                    if not sobject_tasks:
                        sobject_tasks = []
                        my.data[search_key] = sobject_tasks
                    sobject_tasks.append(task)
            except:
                from tactic.ui.app import SearchWdg
                parent_search_type = get_search_type()
                SearchWdg.clear_search_data(parent_search_type)
                raise
Пример #6
0
    def get_search_wdg(my):
        if not my.publish_search_type:
            my.publish_search_type = ''
        search_type = "sthpw/snapshot"
        from tactic.ui.app import SearchWdg

        # provide a view, so it will not automatically get the last saved search instead
        # we need to differentiate between client and dailies search
        state = {'publish_search_type': my.publish_search_type,
                'snapshot_filter_enabled': my.snapshot_filter_enabled}
        search_wdg = SearchWdg(search_type=search_type, view='search', state=state)
    
        
        return search_wdg
Пример #7
0
    def get_search_wdg(self):
        search_type = "prod/submission"
        type = self.kwargs.get('type')
        if not type:
            type = 'dailies'
        from tactic.ui.app import SearchWdg
        filter_xml = '''
        <config>
        <filter>
              <element name='Main Filter'>
                <display class='tactic.ui.filter.SubmissionFilterWdg'>
                  <prefix>%(type)s</prefix>
                  <type>%(type)s</type>
                  <search_type>%(search_type)s</search_type>
                </display>
              </element>

              <element name='Quick Search'>
                <display class='tactic.ui.filter.SObjectSearchFilterWdg'>
                  <search_type>%(search_type)s</search_type>
                  <prefix>simple</prefix>
                </display>
              </element>

              <element name='General'>
                <display class='tactic.ui.filter.GeneralFilterWdg'>
                  <prefix>main_body</prefix>
                  <search_type>%(search_type)s</search_type>
                  <mode>sobject</mode>
                </display>
              </element>
        </filter>
        </config>''' % {
            'search_type': search_type,
            'type': type
        }

        # provide a view, so it will not automatically get the last saved search instead
        # we need to differentiate between client and dailies search
        search_wdg = SearchWdg(search_type=search_type,
                               view=type,
                               filter=filter_xml)

        return search_wdg
Пример #8
0
 def init(self):
     # clear the widget settings of last_search:sthpw/sobject_list
     SearchWdg.clear_search_data('sthpw/sobject_list')
Пример #9
0
 def init(my):
     # clear the widget settings of last_search:sthpw/sobject_list
     SearchWdg.clear_search_data('sthpw/sobject_list')
Пример #10
0
    def get_display(self):

        # just refresh the whole thing
        widget = DivWdg()

        outer_widget = DivWdg(css='spt_view_panel')
        search_div = DivWdg()
        search_bvr = {
            'type': 'click_up',
            'cbjs_action': 'spt.dg_table.search_cbk(evt, bvr)',
            'override_class_name': 'tactic.ui.cgapp.AppShotPanelWdg',
            'override_target': 'bvr.src_el.getParent(".spt_app_shot_panel")',
            'extra_args': {
                'instance_search_type': self.instance_search_type,
                'asset_search_type': self.asset_search_type
            }
            #'panel_id':     'main_body_search'
        }

        # WARNING: this is made just for main search box and  won't be compatible with the simple search wdg
        search_wdg = SearchWdg(search_type=self.search_type, custom_search_view='search_shot_loader', parent_key='', filter=''\
            , display='block', custom_filter_view='', state=None, run_search_bvr=search_bvr)

        #from tactic.ui.app.simple_search_wdg import SimpleSearchWdg
        #search_wdg = SimpleSearchWdg(search_type=self.search_type, search_view=self.simple_search_view, state=None, run_search_bvr=search_bvr)
        search_div.add(HtmlElement.spacer_div(1, 10))
        search_div.add(search_wdg)

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

        # avoid getting a shot when no shot is selected
        if not self.shot_code and len(shots) == 1:
            self.shot_code = shots[0].get_code()

        outer_widget.add(search_div)

        self.set_as_panel(
            outer_widget,
            class_name='spt_panel spt_view_panel spt_app_shot_panel')
        #show_shot_panel = False
        #if show_shot_panel:
        panel = ViewPanelWdg( search_type=self.search_type, \
                 inline_search=True, show_search='false', show_refresh='false', view=self.view, \
                run_search_bvr=search_bvr, simple_search_view=self.simple_search_view)
        panel.set_sobjects(shots)

        widget.add(panel)

        show_instances_in_shot = ProdSetting.get_value_by_key(
            "show_instances_in_shot_panel")
        if show_instances_in_shot != "false":

            widget.add(
                HtmlElement.h3("Asset Instances in Shot [%s]" %
                               self.shot_code))
            widget.add(HtmlElement.br(2))
            asset_inst_panel = AppAssetInstancePanelWdg(
                search_type=self.search_type,
                instance_search_type=self.instance_search_type,
                asset_search_type=self.asset_search_type,
                shot_code=self.shot_code,
                show_search='false')
            widget.add(asset_inst_panel)
        outer_widget.add(widget)
        return outer_widget
Пример #11
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
Пример #12
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