Esempio n. 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
Esempio n. 2
0
    def get_prefs(self):

        span = SpanWdg(css='med')
        self.select = FilterSelectWdg('timecard_view', label='View: ')
        self.select.set_option('values','compact|detailed')
        self.select.set_option('default', 'compact')
        span.add(self.select)
        return span
Esempio n. 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)
Esempio n. 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)
Esempio n. 5
0
    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)
Esempio n. 6
0
    def get_display(my):

        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 my.is_refresh:
            widget = Widget()
            my.init_cgi()
        else:
            my.sobject = my.get_current_sobject()
            widget = DivWdg(id="task_elem_%s"% my.sobject.get_id())
            widget.add_class('spt_task_panel')
            try:
                my.set_as_panel(widget)
            except:
                pass
       
        #TODO: remove this
        my.init_setup(widget)
        #my.set_ajax_top(widget)
        
        table = Table(css="minimal")
        table.add_style("width: 100%")

        # get all of the tasks related to this sobject
        search_type = my.sobject.get_search_type()
        search_id = my.sobject.get_id()
        if my.data:
            tasks = my.data.get("%s|%s" % (search_type,search_id) )
        else:
            tasks = Task.get_by_sobject(my.sobject)
            my.data[my.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(my.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
        my.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()
            
            my.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(), my.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 = my.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 my.get_option('supe')=='true':
                my._add_user_assign_wdg(task, info_span, widget) 

            td.add( info_span )

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

            my.calendar_bar.set_sobject(task)
            # set always recalculate since each task is set individually
            my.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 my.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 my.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:
                my.calendar_bar.set_sobject(task)
                # set always recalculate since each task is set individuallly
                my.calendar_bar.set_always_recal(True)

                my.calendar_bar.set_option("width", "40")
                my.calendar_bar.set_option("bid_edit", my.get_option('bid_edit'))
                date_display = my.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(my.sobject)
            
            #dep_status_wdg.preprocess()
            dep_status_wdg.set_data(my.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
Esempio n. 7
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
Esempio n. 8
0
 def init(self):
     self.select = FilterSelectWdg('timecard_view', label='View: ')
     self.select.set_option('values','compact|detailed')
     self.select.set_option('default', 'compact')
     self.info_dict = {}
     self.is_preprocessed = False
Esempio n. 9
0
 def get_prefs(self):
     self.sel = FilterSelectWdg('time_card_mode', label='View: ')
     self.sel.set_option('values', 'week|day')
     return self.sel
Esempio n. 10
0
class TimecardInfoTableElement(BaseTableElementWdg):
    ''' Info about the time card '''

    def get_prefs(self):

        span = SpanWdg(css='med')
        self.select = FilterSelectWdg('timecard_view', label='View: ')
        self.select.set_option('values','compact|detailed')
        self.select.set_option('default', 'compact')
        span.add(self.select)
        return span

    def init(self):
        self.select = FilterSelectWdg('timecard_view', label='View: ')
        self.select.set_option('values','compact|detailed')
        self.select.set_option('default', 'compact')
        self.info_dict = {}
        self.is_preprocessed = False

    def preprocess(self):
        if not self.sobjects:
            return
       
        task_dict = {}
        misc_cards = []
        self.info_dict = {}
        for timecard in self.sobjects:
            if timecard.get_value('search_type') == Task.SEARCH_TYPE:
                task_dict[timecard.get_value('search_id')] = timecard.get_id()
            else:
                misc_cards.append(timecard)

        tasks = Search.get_by_id(Task.SEARCH_TYPE, task_dict.keys())
        if not tasks:
            return 
        for task in tasks:
            
            self.info_dict[ task_dict.get(task.get_id()) ] = task
        
        # store the rest of the timecards which do not have an associated task
        # or have association with some other sobjects (not implemented yet)
        for card in misc_cards:
            self.info_dict[card.get_id()] = card

    def get_display(self):
        if not self.is_preprocessed:
            self.preprocess()
            self.is_preprocessed = True

        card = self.get_current_sobject()
        div  = DivWdg()
        
        sobj = self.info_dict.get(card.get_id())
        if isinstance(sobj, Timecard):
            # add basic timecard info
            if sobj.get_value('search_type'):
                # this is still valid
                div.add("Timecard for [%s] is not implemented yet" %  sobj.get_value('search_type'))     
            else:
                div.add("General")
            return div
        elif isinstance(sobj, Task):
            # add task info
            if self.select.get_value() =='detailed':
                return self.get_detailed(sobj)
            else:
                return self.get_compact(sobj)
        
            
   
    def get_compact(self, sobj):
        table = Table(css='embed')
        col = table.add_col()
        col.add_style("width: 80px")
        table.add_col(css='med')
        table.add_col(css='large')
        table.add_style("width: 200px")
        table.add_row()
        
        src_sobj = sobj.get_parent()
        thumb = ThumbWdg()
        thumb.set_icon_size(40)
        thumb.set_sobject(src_sobj)
        table.add_cell(thumb)
        
        table.add_cell(src_sobj.get_code())
        table.add_data(SpanWdg(HtmlElement.b(sobj.get_process()), css='small'))
        #table.add_row()
        
        expand = ExpandableTextWdg()
        expand.set_max_length(20)
        desc = sobj.get_value("description")
        if not desc:
            desc = '&nbsp;'
        expand.set_value(desc)
        table.add_row_cell(expand)
        return table
        
    def get_detailed(self, sobj):
        table = Table(css='embed')
        table.add_style("width: 200px")
        col = table.add_col()
        col.add_style("width: 80px")
        table.add_col(css='large')
        table.add_col(css='large')

        src_sobj = sobj.get_parent()
        thumb = ThumbWdg()
        thumb.set_icon_size(40)
        thumb.set_sobject(src_sobj)
        table.add_row()
        td = table.add_cell(thumb)
        td.set_attr('rowspan','2')
        self._add_code(table, src_sobj)
        self._add_process(table, sobj)
        self._add_desc(table, sobj)

        return table
    
    def _add_code(self, table, sobj):
        
        table.add_cell(HtmlElement.i("%s Code: " % sobj.get_search_type_obj().get_title()))
        table.add_cell( HtmlElement.b(sobj.get_code()))

    def _add_process(self, table, sobj):
        table.add_row()
        table.add_cell(HtmlElement.i("Process: "))
        table.add_cell( sobj.get_value("process") )

    def _add_desc(self, table, sobj):
        tr = table.add_row()
        #tr.set_attr('colspan', '3') 
        table.add_cell(HtmlElement.i("Desc: "))
        expand = ExpandableTextWdg()
        expand.set_max_length(40)
        desc = sobj.get_value("description")
        if not desc:
            desc = '&nbsp;'
        expand.set_value(desc)
        td = table.add_cell( expand )
        td.set_attr('colspan', '2') 
Esempio n. 11
0
class WeekTableElement(BaseTableElementWdg):

    CAL_NAME = "work_date_selector"
    DAY_TITLE_WIDTH = 15
    WEEK_TITLE_WIDTH = 80
    def preprocess(self):
        self.hours_dict = {}

    def init(self):
        self.weekday = None
        self.mode = 'week'
        self.sel = FilterSelectWdg('time_card_mode', label='View: ')
        self.sel.set_option('values', 'week|day')
        self.prefix = "timecard_filter" 
    
    def get_prefs(self):
        self.sel = FilterSelectWdg('time_card_mode', label='View: ')
        self.sel.set_option('values', 'week|day')
        return self.sel

    def get_title(self):
        from tactic.ui.filter import FilterData
        values = FilterData.get().get_values_by_index(self.prefix, 0)
        selected_year = ''
        date = None
        selected_date_value = values.get(self.CAL_NAME)
 
        work_date_selector = CalendarInputWdg(self.CAL_NAME)
        if selected_date_value:
            selected_date = Date(db_date=selected_date_value)
        else:
            selected_date = Date()
        #self.mode = self.sel.get_value()

        week = int(selected_date.get_week())

        year = int(selected_date.get_year())
        weekday_list = Calendar.get_monthday_time(year, week)

        div = DivWdg() 
        if self.mode == 'day':
            spacer = FloatDivWdg('&nbsp;', width=self.DAY_TITLE_WIDTH)
            div.add(spacer)
            self.weekday = int(selected_date.get_weekday(is_digit=True))
            month = selected_date.get_month(is_digit=False)
            month_div = FloatDivWdg(css='center_content')          
            month_div.add(month)
            div.add_style('width: 15em')
        else:
            month_list = []
            for item in weekday_list:  
                 month, day, time = item
                 if month not in month_list:
                     month_list.append(month)

            month_div = FloatDivWdg(width=self.WEEK_TITLE_WIDTH, css='right_content')
            month_div.add(' / '.join(month_list))
            div.add_style('width: 45em')
       
        div.add(month_div)

        for idx, i in enumerate(TimecardWdg.WEEK_CALENDAR):
            if self.weekday != None and idx != self.weekday:
                continue
            total = FloatDivWdg(width=50, css='center_content')
            span = SpanWdg(weekday_list[idx][1])
            if i in ["sat", "sun"]:
                span.add_style('color', '#995151')
            span.add(HtmlElement.br())

            weekday_span = SpanWdg('%s' %i.capitalize(), css='smaller')
            span.add(weekday_span)
            total.add(span)
            div.add(total)
        
        return div

    def get_display(self):
        mode = self.sel.get_value()
        div = DivWdg()
        if self.mode == 'day':
            spacer = FloatDivWdg('&nbsp;', width=self.DAY_TITLE_WIDTH)
        else:
            spacer = FloatDivWdg('&nbsp;', width=self.WEEK_TITLE_WIDTH)
        div.add(spacer)
        timecard = self.get_current_sobject()
        for idx, i in enumerate(TimecardWdg.WEEK_CALENDAR):
            if self.weekday != None and idx != self.weekday:
                continue
            total = FloatDivWdg(width=50, css='center_content')
            hours = timecard.get_value(i)
            hours_label = hours
            if not hours:
                hours = 0
                hours_label = '-'

            span = SpanWdg(hours_label)
            cur_val = self.hours_dict.get(i)
            if not cur_val:
                cur_val = 0
            self.hours_dict[i] = cur_val + float(hours)

            total.add(span)
            div.add(total)
       
        return div 

    def get_bottom_wdg(self):
        div = DivWdg()
        if self.mode == 'day':
            spacer = FloatDivWdg('Daily Total: ', width=self.DAY_TITLE_WIDTH, css='right_content')
        else:
            spacer = FloatDivWdg('Weekly Total: ', width=self.WEEK_TITLE_WIDTH, css='right_content')
        div.add(spacer)

        weekly_hours = 0
        timecard = self.get_current_sobject()
        for idx, i in enumerate(TimecardWdg.WEEK_CALENDAR):
            if self.weekday != None and idx != self.weekday:
                continue
            total = FloatDivWdg(width=50, css='center_content')
            hours = self.hours_dict.get(i)
            hours_label = hours
            if not hours:
                hours = 0
                hours_label = '-'

            span = SpanWdg(hours_label)

            
            weekly_hours += float(hours)
            if self.weekday == None:
                total.add(span)
                div.add(total)
    
        weekly_total = FloatDivWdg(width=60, css='center_content')
        weekly_total.add(HtmlElement.b(weekly_hours))
        div.add(weekly_total)
        return div
Esempio n. 12
0
 def init(self):
     self.weekday = None
     self.mode = 'week'
     self.sel = FilterSelectWdg('time_card_mode', label='View: ')
     self.sel.set_option('values', 'week|day')
     self.prefix = "timecard_filter" 
Esempio n. 13
0
    def categorize(self, 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 self.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)
Esempio n. 14
0
class HierarchicalFilterWdg(BaseFilterWdg):
    '''A filter that takes the hierarchical schema into account'''

    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)

    def get_parent_type(self):
        return self.parent_type


    def get_display(self):

        widget = Widget()

        if not self.select:
            return widget

        if not self.schema:
            Environment.add_warning("No schema defined")
            widget.add("No schema defined")
            return widget


        if not self.search_type:
            Environment.add_warning("HierarchicalFilterWdg: Cannot find current search_type")
            widget.add("Cannot find current search_type")
            return widget

        span = SpanWdg(css="med")
        parent_type = self.get_parent_type()
        if parent_type:
            parent_type_obj = SearchType.get(parent_type)
            span.add("%s: " % parent_type_obj.get_value("title"))

        # assume that there is a code in the parent
        self.select.add_empty_option("-- Select --")
        self.select.set_option("query", "%s|code|code" % self.parent_type)
        span.add(self.select)

        widget.add(span)

        return widget


    def alter_search(self, search):
        if not self.select:
            return
        if not self.parent_type:
            return
        if not self.schema:
            return

        parent_code = self.select.get_value()
        parent = Search.get_by_code(self.parent_type, parent_code)
        if not parent:
            return
        parent.children_alter_search(search, self.search_type)
Esempio n. 15
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
Esempio n. 16
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"
Esempio n. 17
0
 def get_prefs(my):
     my.sel = FilterSelectWdg('time_card_mode', label='View: ')
     my.sel.set_option('values', 'week|day')
     return my.sel