예제 #1
0
    def get_prefs(my):

        span = SpanWdg(css='med')
        my.select = FilterSelectWdg('timecard_view', label='View: ')
        my.select.set_option('values', 'compact|detailed')
        my.select.set_option('default', 'compact')
        span.add(my.select)
        return span
예제 #2
0
파일: task_wdg.py 프로젝트: mwx1993/TACTIC
    def categorize(my, widget, search_type, search):
        '''categorize parents based on search_type'''
        # FIXME: this should not be here.  This is a general class for all
        # search types, not just prod/asset
        if my.get_option('read_only') != 'true':
            if search_type == "prod/asset":
                lib_select = FilterSelectWdg('parent_lib')
                lib_select.persistence = False
                search2 = Search("prod/asset_library")
                lib_select.set_search_for_options(search2, "code", "title")
                lib_select.add_empty_option("-- Any --")
                widget.add(lib_select)
                # get all of the options for this search type
                parent_lib = lib_select.get_value()
                if parent_lib:
                    search.add_filter('asset_library', parent_lib)
            elif search_type == "prod/shot":
                lib_select = FilterSelectWdg('parent_lib')
                lib_select.persistence = False
                search2 = Search("prod/sequence")
                lib_select.set_search_for_options(search2, "code", "code")
                lib_select.add_empty_option("-- Any --")

                widget.add(lib_select)

                # get all of the options for this search type
                parent_lib = lib_select.get_value()
                if parent_lib:
                    search.add_filter('sequence_code', parent_lib)
            elif search_type == 'prod/texture':
                lib_select = FilterSelectWdg('parent_lib')
                lib_select.persistence = False
                search2 = Search("prod/texture")
                search2.add_column('category')
                search2.add_group_by("category")
                lib_select.set_search_for_options(search2, "category",
                                                  "category")
                lib_select.add_empty_option("-- Any --")
                widget.add(lib_select)

                # get all of the options for this search type
                parent_lib = lib_select.get_value()
                if parent_lib:
                    search.add_filter('category', parent_lib)
예제 #3
0
    def init(self):
        self.schema = Schema.get()
        if not self.schema:
            self.parent_type = None
            self.select = None
            return

        web = WebContainer.get_web()
        self.search_type = web.get_form_value("filter|search_type")
        if not self.search_type:
            search_type = self.options.get("search_type")

        self.parent_type = self.schema.get_parent_type(self.search_type)
        if not self.parent_type:
            self.select = None
        else:
            self.select = FilterSelectWdg("filter|%s" % self.parent_type)
예제 #4
0
    def init(my):
        my.schema = Schema.get()
        if not my.schema:
            my.parent_type = None
            my.select = None
            return

        web = WebContainer.get_web()
        my.search_type = web.get_form_value("filter|search_type")
        if not my.search_type:
            search_type = my.options.get("search_type")

        my.parent_type = my.schema.get_parent_type(my.search_type)
        if not my.parent_type:
            my.select = None
        else:
            my.select = FilterSelectWdg("filter|%s" % my.parent_type)
예제 #5
0
 def init(my):
     my.select = FilterSelectWdg('timecard_view', label='View: ')
     my.select.set_option('values', 'compact|detailed')
     my.select.set_option('default', 'compact')
     my.info_dict = {}
     my.is_preprocessed = False
예제 #6
0
 def get_prefs(my):
     my.sel = FilterSelectWdg('time_card_mode', label='View: ')
     my.sel.set_option('values', 'week|day')
     return my.sel
예제 #7
0
 def init(my):
     my.weekday = None
     my.mode = 'week'
     my.sel = FilterSelectWdg('time_card_mode', label='View: ')
     my.sel.set_option('values', 'week|day')
     my.prefix = "timecard_filter"
예제 #8
0
    def get_display(self):

        web = WebContainer.get_web()
        
        # this needs to be a BaseInputWdg since UserFilterWdg is hideable
        user_filter = FilterSelectWdg("user_filter")
        user_filter = user_filter.get_values()
     
        #login = Environment.get_security().get_login()
        #user = login.get_value("login")

        if self.is_refresh:
            widget = Widget()
            self.init_cgi()
        else:
            self.sobject = self.get_current_sobject()
            widget = DivWdg(id="task_elem_%s"% self.sobject.get_id())
            widget.add_class('spt_task_panel')
            try:
                self.set_as_panel(widget)
            except:
                pass
       
        #TODO: remove this
        self.init_setup(widget)
        #self.set_ajax_top(widget)
        
        table = Table(css="minimal")
        table.add_style("width: 100%")

        # get all of the tasks related to this sobject
        search_type = self.sobject.get_search_type()
        search_id = self.sobject.get_id()
        if self.data:
            tasks = self.data.get("%s|%s" % (search_type,search_id) )
        else:
            tasks = Task.get_by_sobject(self.sobject)
            self.data[self.sobject.get_search_key()] = tasks
        if not tasks:
            tasks = []


        task_statuses_filter = web.get_form_values("task_status")
        show_sub_tasks = False
        if not task_statuses_filter:
            # NOTE: Not sure if this is correct!!
            # have to do this because it is impossible to tell if a checkbox
            # is empty or not there.  This is used for pages that do not have
            # tasks_status checkboxes
            show_all_tasks = True
        else:
            cb = FilterCheckboxWdg('show_all_tasks') 
            show_all_tasks = cb.is_checked(False)

            sub_cb = FilterCheckboxWdg('show_sub_tasks') 
            show_sub_tasks = sub_cb.is_checked(False)
        # trim down the process list
        """
        if not show_sub_tasks:
            process_list = [x for x in process_list if "/" not in x]
        """
        pipeline = Pipeline.get_by_sobject(self.sobject)

        # retrieve the pipeline   
        if not pipeline:
            td = table.add_cell("<br/><i>No pipeline</i>")
            td.add_style("text-align: center")
            return table

        # store completion per process first in a dict
        # reset it first
        self.process_completion_dict = {}
        for task in tasks:
            task_process = task.get_value("process")
            status_attr = task.get_attr('status')
            percent = status_attr.get_percent_completion()
            
            self.store_completion(task_process, percent)

        security = WebContainer.get_security()
        me = Environment.get_user_name()

        

        for task in tasks:
            has_valid_status = True
            task_pipeline = task.get_pipeline()
            task_statuses = task_pipeline.get_process_names()
            task_process = task.get_value("process")

            # Commenting this out.  It is not very meaningful in 2.5 ...
            # we need a better mechanism.  The end result of this code
            # is that "admin" never sees any tasks
            #if security.check_access("public_wdg", "SObjectTaskTableElement|unassigned", "deny", is_match=True):
            #    assignee = task.get_value("assigned")
            #    if assignee != me:
            #        continue


            if not show_all_tasks:
                """
                if process_list and task_process not in process_list:
                    continue
                """
                # skip sub tasks
                if not show_sub_tasks and '/' in task_process:
                    continue

                task_status = task.get_value("status")
                if task_status not in task_statuses:
                    has_valid_status = False

                if has_valid_status  and task_status \
                        and task_status not in task_statuses_filter:
                    continue
                # the first one shouldn't be empty
                if user_filter and user_filter[0] and task.get_value("assigned") not in  user_filter:
                    continue
                
            table.add_row()

            
            #link = "%s/Maya/?text_filter=%s&load_asset_process=%s" % (web.get_site_context_url().to_string(), self.sobject.get_code(), task_process)
            #icon = IconButtonWdg("Open Loader", IconWdg.LOAD, False)
            #table.add_cell( HtmlElement.href(icon, link, target='maya') )

            td = table.add_cell(css='no_wrap')

            description = task.get_value("description")
            expand = ExpandableTextWdg()
            expand.set_max_length(50)
            expand.set_value(description)
            assigned = task.get_value("assigned").strip()

            status_wdg = SimpleStatusWdg()
            status_wdg.set_sobject(task)
            status_wdg.set_name("status")
            # refresh myself on execution of SimpleStatusCmd
            #post_scripts = self.get_refresh_script(show_progress=False)
            post_scripts = '''var panel = bvr.src_el.getParent('.spt_task_panel');
                              var search_top = spt.get_cousin(bvr.src_el, '.spt_view_panel','.spt_search');
                              var search_val = spt.dg_table.get_search_values(search_top);
                              var values = spt.api.Utility.get_input_values(panel);
                              values['json'] = search_val;
                              spt.panel.refresh(panel, values);'''
            status_wdg.set_post_ajax_script(post_scripts)
    
            if assigned:
                user_info = UserExtraInfoWdg(assigned).get_buffer_display()
            else:
                user_info = HtmlElement.i(" unassigned").get_buffer_display()

            info_span = SpanWdg()
            
            info_span.add(TaskExtraInfoWdg(task))
            info_span.add("- ")
            
            info_span.add("&nbsp;[%s]" % user_info)


            if UserAssignWdg.has_access() and self.get_option('supe')=='true':
                self._add_user_assign_wdg(task, info_span, widget) 

            td.add( info_span )

            #--------------

            self.calendar_bar.set_sobject(task)
            # set always recalculate since each task is set individually
            self.calendar_bar.set_always_recal(True)

            #---------------

            td.add_color('color','color')
            td.add(HtmlElement.br())
            if description:
                td.add(expand)
                td.add(HtmlElement.br())
            td.add(status_wdg)

            if self.last_process_finished(pipeline, task_process): 
                dot = IconWdg(icon=IconWdg.DOT_GREEN)
                dot.add_tip("All dependent processs complete")
                dot.add_style('float','left')
                dot.add_style('display','block')
                td.add(dot)
            else:
                dot = IconWdg(icon=IconWdg.DOT_RED)
                dot.add_tip("Dependent process in progress")
                dot.add_style('float','left')
                dot.add_style('display','block')
                td.add(dot)

            
            
            date_display = None
            if self.get_option('simple_date') == 'true':
                start_wdg = DateWdg()
                start_wdg.set_option("pattern", "%b %d")
                start_wdg.set_name('bid_start_date')
                start_wdg.set_sobject(task)
                end_wdg = DateWdg()
                end_wdg.set_name('bid_end_date')
                end_wdg.set_option("pattern", "%b %d")
                end_wdg.set_sobject(task)
                date_display = '%s - %s' %(start_wdg.get_buffer_display(), \
                    end_wdg.get_buffer_display())
            else:
                self.calendar_bar.set_sobject(task)
                # set always recalculate since each task is set individuallly
                self.calendar_bar.set_always_recal(True)

                self.calendar_bar.set_option("width", "40")
                self.calendar_bar.set_option("bid_edit", self.get_option('bid_edit'))
                date_display = self.calendar_bar.get_buffer_display()
            
            #td = table.add_cell(date_display, css='smaller')
            td.add(FloatDivWdg(date_display, float='right', css='smaller')) 
                
            #td.set_style("width: 120; padding-left: 15px")

            # This uses the parallel status widget to display status of
            # dependent tasks
            dependent_processes = pipeline.get_input_contexts(task_process)


            from parallel_status import ParallelStatusWdg
            dep_status_div = DivWdg()
            dep_status_div.add_style("padding-right: 10px")
            dep_status_wdg = ParallelStatusWdg()
            dep_status_wdg.set_process_names(dependent_processes)
            dep_status_wdg.set_label_format("abbr")
            dep_status_wdg.set_sobject(self.sobject)
            
            #dep_status_wdg.preprocess()
            dep_status_wdg.set_data(self.data)
            dep_status_div.add(dep_status_wdg)
            td.add(dep_status_div)
            #td.add_style("border-style: solid")
            #td.add_style("border-bottom: 1px")
            #td.add_style("border-color: #999")
            td.add_style("padding: 3px 0 3px 0")

        
        widget.add(table)
       
        return widget