Beispiel #1
0
    def get_display(self):
        web = WebContainer.get_web()

        widget = Widget()

        if not self.search_type:
            self.search_type = self.options.get("search_type")
        assert self.search_type

        sobject_filter = self.sobject_filter

        web_state = WebState.get()
        web_state.add_state("ref_search_type", self.search_type)

        div = FilterboxWdg()
        widget.add(div)

        # add the sobject filter
        if self.sobject_filter:
            div.add(self.sobject_filter)

        # add a milestone filter
        milestone_filter = FilterSelectWdg("milestone_filter",
                                           label="Milestone: ")
        milestones = Search("sthpw/milestone").get_sobjects()
        milestone_filter.set_sobjects_for_options(milestones, "code", "code")
        milestone_filter.add_empty_option(label='-- Any Milestones --')
        milestone_filter.set_submit_onchange(False)
        milestone = milestone_filter.get_value()

        div.add_advanced_filter(milestone_filter)

        # add a process filter
        process_filter = ProcessFilterSelectWdg(name=self.process_filter_name,
                                                label='Process: ')
        process_filter.set_search_type(self.search_type)
        process_filter.set_submit_onchange(False)

        div.add_advanced_filter(process_filter)

        user_filter = None
        user = Environment.get_user_name()
        # it has a special colunn 'assigned'
        if not UserFilterWdg.has_restriction():
            user_filter = UserFilterWdg()
            user_filter.set_search_column('assigned')
            user = user_filter.get_value()
            div.add_advanced_filter(user_filter)

        # add a task properties search
        search_columns = ['status', 'description']
        task_search_filter = SearchFilterWdg(name='task_prop_search', \
                columns=search_columns, label='Task Search: ')
        div.add_advanced_filter(task_search_filter)

        # add a retired filter
        retired_filter = RetiredFilterWdg()
        div.add_advanced_filter(retired_filter)

        # set a limit to only see set amount of sobjects at a time
        search_limit = SearchLimitWdg()
        search_limit.set_limit(50)
        search_limit.set_style(SearchLimitWdg.LESS_DETAIL)
        div.add_bottom(search_limit)

        div.add_advanced_filter(HtmlElement.br(2))
        start_date_wdg = CalendarInputWdg("start_date_filter",
                                          label="From: ",
                                          css='med')
        start_date_wdg.set_persist_on_submit()
        div.add_advanced_filter(start_date_wdg)

        start_date = start_date_wdg.get_value()

        # these dates are actually used for search filtering
        processed_start_date = None
        processed_end_date = None
        if start_date:
            date = Date(db_date=start_date)
            # this guarantees a valid date( today ) is invalid input is detected
            processed_start_date = date.get_db_date()
            if start_date != processed_start_date:
                start_date_wdg.set_value(self.INVALID)
        # add hints
        hint = HintWdg("The 'From' and 'To' dates apply to bid dates.")
        #span.add(hint)

        end_date_wdg = CalendarInputWdg("end_date_filter",
                                        label="To: ",
                                        css='med')
        end_date_wdg.set_persist_on_submit()
        div.add_advanced_filter(end_date_wdg)
        div.add_advanced_filter(hint)

        end_date = end_date_wdg.get_value()
        if end_date:
            date = Date(db_date=end_date)
            processed_end_date = date.get_db_date()
            if end_date != processed_end_date:
                end_date_wdg.set_value(self.INVALID)

        # show sub task checkbox
        sub_task_cb = FilterCheckboxWdg('show_sub_tasks',
                                        label='show sub tasks',
                                        css='med')
        div.add_advanced_filter(sub_task_cb)

        div.add_advanced_filter(HtmlElement.br(2))
        task_filter = TaskStatusFilterWdg()
        div.add_advanced_filter(task_filter)

        shot_filter = None
        if self.search_type == 'prod/shot':
            shot_filter = SObjectStatusFilterWdg()
            div.add_advanced_filter(shot_filter)

        # add refresh icon
        '''
        refresh = IconRefreshWdg(long=False)
        calendar_div.add(refresh)
        calendar_div.add(SpanWdg(' ', css='small'))
        '''

        # get all of the assets
        search = Search(self.search_type)

        if sobject_filter:
            sobject_filter.alter_search(search)

        if shot_filter:
            shot_statuses = shot_filter.get_statuses()
            shot_statuses_selected = shot_filter.get_values()
            if shot_statuses != shot_statuses_selected:
                search.add_filters("status", shot_filter.get_values())

        assets = search.get_sobjects()

        if not assets:
            # drawing the empty table prevents the loss of some prefs data
            table = TableWdg("sthpw/task", self.task_view)
            #widget.add(HtmlElement.h3("No assets found"))
            widget.add(table)
            return widget

        # this assumes looking at one project only
        project_search_type = assets[0].get_search_type()

        ids = SObject.get_values(assets, 'id')

        # get all of the tasks
        search = Search("sthpw/task")
        if processed_start_date and start_date_wdg.get_value(
                True) != self.INVALID:
            search.add_where("(bid_start_date >= '%s' or actual_start_date >='%s')" \
                % (processed_start_date, processed_start_date))
        if processed_end_date and end_date_wdg.get_value(True) != self.INVALID:
            search.add_where("(bid_end_date <= '%s' or actual_end_date <='%s')" \
                % (processed_end_date, processed_end_date))

        # filter out sub pipeline tasks
        if not sub_task_cb.is_checked():
            search.add_regex_filter('process', '/', op='NEQ')

        search.add_filter("search_type", project_search_type)
        search.add_filters("search_id", ids)

        # order by the search ids of the asset as the were defined in the
        # previous search
        search.add_enum_order_by("search_id", ids)

        if user != "":
            search.add_filter("assigned", user)
        if milestone != "":
            search.add_filter("milestone_code", milestone)

        process_filter.alter_search(search)

        task_search_filter.alter_search(search)

        if not self.show_all_task_approvals:
            #task_filter = TaskStatusFilterWdg(task_pipeline="task")
            #widget.add(task_filter)
            task_statuses = task_filter.get_processes()
            task_statuses_selected = task_filter.get_values()

            # one way to show tasks with obsolete statuses when the user
            # check all the task status checkboxes
            if task_statuses != task_statuses_selected:
                search.add_filters("status", task_filter.get_values())

        # filter for retired ...
        # NOTE: this must be above the search limit filter
        # because it uses a get count which commits the retired flag
        if retired_filter.get_value() == 'true':
            search.set_show_retired(True)

        # alter_search() will run set_search() implicitly
        search_limit.alter_search(search)

        # define the table
        table = TableWdg("sthpw/task", self.task_view)

        # get all of the tasks
        tasks = search.get_sobjects()
        sorted_tasks = self.process_tasks(tasks, search)

        widget.add(HtmlElement.br())

        table.set_sobjects(sorted_tasks)

        # make some adjustments to the calendar widget
        calendar_wdg = table.get_widget("schedule")
        for name, value in self.calendar_options.items():
            calendar_wdg.set_option(name, value)

        widget.add(table)

        return widget
Beispiel #2
0
    def get_filter_wdg(self, search, search_type, search_id, div_id):
        
        ajax = AjaxLoader()
        ajax.set_option("search_type", search_type)
        ajax.set_option("search_id", search_id)
        bin_name = "bin_%s_%s" % (search_type, search_id)
        artist_name = "artist_%s_%s" % (search_type, search_id)
        status_name = "status_%s_%s" % (search_type, search_id)
        retired_name = "%s_%s_show_retired" % (search_type, search_id)
        ajax.add_element_name(bin_name )
        ajax.add_element_name(artist_name )
        ajax.add_element_name(status_name )
        ajax.add_element_name(retired_name )
        # add a shot id
        #ajax.add_element_name("shot_id")
        ajax.set_display_id(div_id)

        cls = self.__class__
        class_path = '%s.%s' %(cls.__module__, cls.__name__)
        ajax.set_load_class( class_path )
        refresh_script = ajax.get_refresh_script(show_progress=False)


       
       # select.set_persist_on_submit()

     
        filter_wdg = DivWdg()
        filter_wdg.add_style("margin-bottom: 5px")
        filter_wdg.add_style("text-align: right")
        from asset_filter_wdg import UserFilterWdg
        bin_filter = BinFilterSelectWdg(bin_name, label='Bin: ')
        bin_filter.add_empty_option('-- Any Bin --')
        #bin_filter.get_navigator().set_submit_onchange(False)
        bin_filter.set_event('onchange', refresh_script)
        bin_filter.set_persist_on_submit()
        bin_id = bin_filter.get_value()
        if not bin_id or bin_id == SelectWdg.NONE_MODE:
           #search.add_filter('id','-1')
           search.add_where("\"id\" in (select \"submission_id\" from "\
            " submission_in_bin"\
            " where \"bin_id\" in (select \"id\" from bin where \"type\" = 'dailies') )" )
        elif bin_id:
           search.add_where("\"id\" in (select \"submission_id\" from "\
            " submission_in_bin"\
            " where \"bin_id\" = %s)" %bin_id)
        
        filter_wdg.add(bin_filter)
        hint = HintWdg("To see any bins, you need to create them (Type 'dailies') in the Bins tab.")
        filter_wdg.add(hint)

        
        user_filter = UserFilterWdg(artist_name, label='Artist: ')
        user_filter.get_navigator().set_submit_onchange(False)
        user_filter.get_navigator().set_persist_on_submit()
        user_filter.get_navigator().add_event('onchange', refresh_script)

        user_filter.set_search_column('artist')
        filter_wdg.add(user_filter)

        config_base = 'table' 
       

        user_filter.alter_search(search)

        status_filter = SelectWdg(status_name, label='Status: ')
        status_filter.add_empty_option("-- Any Status--")
        status_filter.set_option('setting', 'dailies_submission_status')
        status_filter.add_event('onchange', refresh_script)
        status_filter.set_persist_on_submit()
        
        filter_wdg.add(status_filter)

        status_value = status_filter.get_value()
        if status_value:
            search.add_filter('status', status_value)

        prefix = "%s_%s" % (search_type, search_id)
        retired_filter = RetiredFilterWdg(prefix=prefix, refresh=False)
        retired_filter.add_event('onclick', refresh_script)
        filter_wdg.add(retired_filter)


        retired_value = WebContainer.get_web().get_form_value(retired_name)
        if retired_value == 'true':
            search.set_show_retired(True)
        button = IconButtonWdg("Refresh", IconWdg.REFRESH, long=False)
        button.add_event("onclick", refresh_script)
        filter_wdg.add(button)


        
        return filter_wdg
Beispiel #3
0
    def get_display(self):
        web = WebContainer.get_web()
        
        widget = Widget() 

        if not self.search_type:
            self.search_type = self.options.get("search_type")
        assert self.search_type


        sobject_filter = self.sobject_filter

        web_state = WebState.get()
        web_state.add_state("ref_search_type", self.search_type)

        div = FilterboxWdg()
        widget.add(div)


        # add the sobject filter
        if self.sobject_filter:
            div.add(self.sobject_filter)
      
        # add a milestone filter
        milestone_filter = FilterSelectWdg("milestone_filter", label="Milestone: ")
        milestones = Search("sthpw/milestone").get_sobjects()
        milestone_filter.set_sobjects_for_options(milestones, "code", "code")
        milestone_filter.add_empty_option(label='-- Any Milestones --')
        milestone_filter.set_submit_onchange(False)
        milestone = milestone_filter.get_value()
        
    
        div.add_advanced_filter(milestone_filter)

        # add a process filter
        process_filter = ProcessFilterSelectWdg(name=self.process_filter_name, label='Process: ')
        process_filter.set_search_type(self.search_type)
        process_filter.set_submit_onchange(False)
        
        div.add_advanced_filter(process_filter)


        user_filter = None
        user = Environment.get_user_name()
        # it has a special colunn 'assigned'
        if not UserFilterWdg.has_restriction():
            user_filter = UserFilterWdg() 
            user_filter.set_search_column('assigned')
            user = user_filter.get_value()
            div.add_advanced_filter(user_filter)

        
        # add a task properties search
        search_columns = ['status', 'description']
        task_search_filter = SearchFilterWdg(name='task_prop_search', \
                columns=search_columns, label='Task Search: ')
        div.add_advanced_filter(task_search_filter)

        # add a retired filter
        retired_filter = RetiredFilterWdg()
        div.add_advanced_filter(retired_filter)

        # set a limit to only see set amount of sobjects at a time
        search_limit = SearchLimitWdg()
        search_limit.set_limit(50)
        search_limit.set_style(SearchLimitWdg.LESS_DETAIL)
        div.add_bottom(search_limit)
        
        div.add_advanced_filter(HtmlElement.br(2))
        start_date_wdg = CalendarInputWdg("start_date_filter", label="From: ", css='med')
        start_date_wdg.set_persist_on_submit()
        div.add_advanced_filter(start_date_wdg)

        start_date = start_date_wdg.get_value()

        # these dates are actually used for search filtering
        processed_start_date = None
        processed_end_date = None
        if start_date:
            date = Date(db_date=start_date)
            # this guarantees a valid date( today ) is invalid input is detected
            processed_start_date = date.get_db_date()
            if start_date != processed_start_date:
                start_date_wdg.set_value(self.INVALID)
        # add hints
        hint = HintWdg("The 'From' and 'To' dates apply to bid dates.")
        #span.add(hint)
        
        end_date_wdg = CalendarInputWdg("end_date_filter", label="To: ", css='med')
        end_date_wdg.set_persist_on_submit()
        div.add_advanced_filter(end_date_wdg)
        div.add_advanced_filter(hint)

        end_date = end_date_wdg.get_value()
        if end_date:
            date = Date(db_date=end_date)
            processed_end_date = date.get_db_date()
            if end_date != processed_end_date:
                end_date_wdg.set_value(self.INVALID)
      
        # show sub task checkbox
        sub_task_cb = FilterCheckboxWdg('show_sub_tasks', label='show sub tasks', css='med')
        div.add_advanced_filter(sub_task_cb)

        div.add_advanced_filter(HtmlElement.br(2))
        task_filter = TaskStatusFilterWdg()
        div.add_advanced_filter(task_filter)
       
        shot_filter = None
        if self.search_type == 'prod/shot': 
            shot_filter = SObjectStatusFilterWdg()
            div.add_advanced_filter(shot_filter)

        # add refresh icon
        '''
        refresh = IconRefreshWdg(long=False)
        calendar_div.add(refresh)
        calendar_div.add(SpanWdg('&nbsp;', css='small'))
        '''
        

        

        # get all of the assets
        search = Search(self.search_type)
        
        if sobject_filter:
            sobject_filter.alter_search(search)

        if shot_filter:
            shot_statuses = shot_filter.get_statuses()
            shot_statuses_selected = shot_filter.get_values()
            if shot_statuses != shot_statuses_selected:
                search.add_filters("status", shot_filter.get_values() )

        assets = search.get_sobjects()
        
        if not assets:
            # drawing the empty table prevents the loss of some prefs data
            table = TableWdg("sthpw/task", self.task_view)
            #widget.add(HtmlElement.h3("No assets found"))
            widget.add(table)
            return widget

        # this assumes looking at one project only
        project_search_type = assets[0].get_search_type()
        
        ids = SObject.get_values(assets, 'id')

        # get all of the tasks
        search = Search("sthpw/task")
        if processed_start_date and start_date_wdg.get_value(True) != self.INVALID:
            search.add_where("(bid_start_date >= '%s' or actual_start_date >='%s')" \
                % (processed_start_date, processed_start_date))
        if processed_end_date and end_date_wdg.get_value(True) != self.INVALID:
            search.add_where("(bid_end_date <= '%s' or actual_end_date <='%s')" \
                % (processed_end_date, processed_end_date))

        # filter out sub pipeline tasks
        if not sub_task_cb.is_checked():
            search.add_regex_filter('process', '/', op='NEQ')

        search.add_filter("search_type", project_search_type)
        search.add_filters("search_id", ids )

        # order by the search ids of the asset as the were defined in the
        # previous search
        search.add_enum_order_by("search_id", ids)


        if user != "":
            search.add_filter("assigned", user)
        if milestone != "":
            search.add_filter("milestone_code", milestone)
        
        process_filter.alter_search(search)
        
        task_search_filter.alter_search(search)
       
        if not self.show_all_task_approvals:
            #task_filter = TaskStatusFilterWdg(task_pipeline="task")
            #widget.add(task_filter)
            task_statuses = task_filter.get_processes()
            task_statuses_selected = task_filter.get_values()
           
            # one way to show tasks with obsolete statuses when the user
            # check all the task status checkboxes
            if task_statuses != task_statuses_selected:
                search.add_filters("status", task_filter.get_values() )

            


        # filter for retired ...
        # NOTE: this must be above the search limit filter
        # because it uses a get count which commits the retired flag
        if retired_filter.get_value() == 'true':
            search.set_show_retired(True)

        
        # alter_search() will run set_search() implicitly
        search_limit.alter_search(search)

        # define the table
        table = TableWdg("sthpw/task", self.task_view)

        # get all of the tasks
        tasks = search.get_sobjects()
        sorted_tasks = self.process_tasks(tasks, search)

        widget.add( HtmlElement.br() )

        table.set_sobjects(sorted_tasks)

        # make some adjustments to the calendar widget
        calendar_wdg = table.get_widget("schedule")
        for name,value in self.calendar_options.items():
            calendar_wdg.set_option(name, value)

        widget.add(table)

        return widget
Beispiel #4
0
    def get_filter_wdg(my, search, search_type, search_id, div_id):

        ajax = AjaxLoader()
        ajax.set_option("search_type", search_type)
        ajax.set_option("search_id", search_id)
        bin_name = "bin_%s_%s" % (search_type, search_id)
        artist_name = "artist_%s_%s" % (search_type, search_id)
        status_name = "status_%s_%s" % (search_type, search_id)
        retired_name = "%s_%s_show_retired" % (search_type, search_id)
        ajax.add_element_name(bin_name)
        ajax.add_element_name(artist_name)
        ajax.add_element_name(status_name)
        ajax.add_element_name(retired_name)
        # add a shot id
        #ajax.add_element_name("shot_id")
        ajax.set_display_id(div_id)

        cls = my.__class__
        class_path = '%s.%s' % (cls.__module__, cls.__name__)
        ajax.set_load_class(class_path)
        refresh_script = ajax.get_refresh_script(show_progress=False)

        # select.set_persist_on_submit()

        filter_wdg = DivWdg()
        filter_wdg.add_style("margin-bottom: 5px")
        filter_wdg.add_style("text-align: right")
        from asset_filter_wdg import UserFilterWdg
        bin_filter = BinFilterSelectWdg(bin_name, label='Bin: ')
        bin_filter.add_empty_option('-- Any Bin --')
        #bin_filter.get_navigator().set_submit_onchange(False)
        bin_filter.set_event('onchange', refresh_script)
        bin_filter.set_persist_on_submit()
        bin_id = bin_filter.get_value()
        if not bin_id or bin_id == SelectWdg.NONE_MODE:
            #search.add_filter('id','-1')
            search.add_where("\"id\" in (select \"submission_id\" from "\
             " submission_in_bin"\
             " where \"bin_id\" in (select \"id\" from bin where \"type\" = 'dailies') )" )
        elif bin_id:
            search.add_where("\"id\" in (select \"submission_id\" from "\
             " submission_in_bin"\
             " where \"bin_id\" = %s)" %bin_id)

        filter_wdg.add(bin_filter)
        hint = HintWdg(
            "To see any bins, you need to create them (Type 'dailies') in the Bins tab."
        )
        filter_wdg.add(hint)

        user_filter = UserFilterWdg(artist_name, label='Artist: ')
        user_filter.get_navigator().set_submit_onchange(False)
        user_filter.get_navigator().set_persist_on_submit()
        user_filter.get_navigator().add_event('onchange', refresh_script)

        user_filter.set_search_column('artist')
        filter_wdg.add(user_filter)

        config_base = 'table'

        user_filter.alter_search(search)

        status_filter = SelectWdg(status_name, label='Status: ')
        status_filter.add_empty_option("-- Any Status--")
        status_filter.set_option('setting', 'dailies_submission_status')
        status_filter.add_event('onchange', refresh_script)
        status_filter.set_persist_on_submit()

        filter_wdg.add(status_filter)

        status_value = status_filter.get_value()
        if status_value:
            search.add_filter('status', status_value)

        prefix = "%s_%s" % (search_type, search_id)
        retired_filter = RetiredFilterWdg(prefix=prefix, refresh=False)
        retired_filter.add_event('onclick', refresh_script)
        filter_wdg.add(retired_filter)

        retired_value = WebContainer.get_web().get_form_value(retired_name)
        if retired_value == 'true':
            search.set_show_retired(True)
        button = IconButtonWdg("Refresh", IconWdg.REFRESH, long=False)
        button.add_event("onclick", refresh_script)
        filter_wdg.add(button)

        return filter_wdg