Exemple #1
0
    def execute(self):

        column = self.get_option("column")
        if not column:
            column = self.name

        # get the value
        # NOTE: not sure why this was "column".  The value will come
        # through with the name of the element.  The "column" options
        # tells the action which column to set the value to
        #value = self.get_value(column)
        value = self.get_value(self.name)


        # check if there is an expression on the update
        expr = self.get_option("expression")

        # check for parent action to save search_type and search_id or parent_code etc separately
        # this is usually already taken care of in EditCmd
        parent_key_action = self.get_option('parent_key') == 'true'

        if expr:
            vars = {
                'VALUE': value
            }
            Search.eval(expr, self.sobject, vars=vars)
       
        
        else:     

            search_type = self.sobject.get_search_type()
            col_type = SearchType.get_tactic_type(search_type, column)


            value = self.convert_value(col_type, value)

            if value == None:
                pass 
            elif parent_key_action:
                self.sobject.add_relationship(value)
            else:
                self.sobject.set_value(column, value )

            if self.commit_flag == True:
                self.sobject.commit()
Exemple #2
0
    def execute(my):

        column = my.get_option("column")
        if not column:
            column = my.name

        # get the value
        # NOTE: not sure why this was "column".  The value will come
        # through with the name of the element.  The "column" options
        # tells the action which column to set the value to
        #value = my.get_value(column)
        value = my.get_value(my.name)


        # check if there is an expression on the update
        expr = my.get_option("expression")

        # check for parent action to save search_type and search_id or parent_code etc separately
        # this is usually already taken care of in EditCmd
        parent_key_action = my.get_option('parent_key') == 'true'

        if expr:
            vars = {
                'VALUE': value
            }
            Search.eval(expr, my.sobject, vars=vars)
       
        
        else:     

            search_type = my.sobject.get_search_type()
            col_type = SearchType.get_tactic_type(search_type, column)


            value = my.convert_value(col_type, value)
            
            if parent_key_action:
                my.sobject.add_relationship(value)
            else:
                my.sobject.set_value(column, value )

            if my.commit_flag == True:
                my.sobject.commit()
Exemple #3
0
    def is_new_group(self, prev_sobj, sobj):
        '''check if this task belong to a new parent ''' 
        if not prev_sobj:
            return True

        # let the widget determine if it is new
        is_new = self.widget.is_new_group(prev_sobj, sobj)
        if is_new != None:
            return is_new


        # if it is None, use the default
        prev_value = prev_sobj.get_value(self.column)
        sobj_value = sobj.get_value(self.column, no_exception=True)


        # Now check for timestamp values and if found group by each calendar day (as default behavior),
        # otherwise you get one grouping for each row if the time part of the timestamp is not the same ...
        #
        st = sobj.get_search_type()
        value_type = SearchType.get_tactic_type(st, self.column)
        
        if value_type == 'timestamp':
            from dateutil import parser

            prev_date = parser.parse(prev_value)  # returns a datetime object
            sobj_date = parser.parse(sobj_value)  # returns a datetime object

            prev_value = "%s-%s-%s" % (prev_date.year, str(prev_date.month).zfill(2), str(prev_date.day).zfill(2))
            sobj_value = "%s-%s-%s" % (sobj_date.year, str(sobj_date.month).zfill(2), str(sobj_date.day).zfill(2))


        # compare search key here 
        if prev_value == sobj_value:
            return False
        else:
            return True
Exemple #4
0
    def is_new_group(self, prev_sobj, sobj):
        '''check if this task belong to a new parent '''
        if not prev_sobj:
            return True

        # let the widget determine if it is new
        is_new = self.widget.is_new_group(prev_sobj, sobj)
        if is_new != None:
            return is_new

        # if it is None, use the default
        prev_value = prev_sobj.get_value(self.column)
        sobj_value = sobj.get_value(self.column, no_exception=True)

        # Now check for timestamp values and if found group by each calendar day (as default behavior),
        # otherwise you get one grouping for each row if the time part of the timestamp is not the same ...
        #
        st = sobj.get_search_type()
        value_type = SearchType.get_tactic_type(st, self.column)

        if value_type == 'timestamp':
            from dateutil import parser

            prev_date = parser.parse(prev_value)  # returns a datetime object
            sobj_date = parser.parse(sobj_value)  # returns a datetime object

            prev_value = "%s-%s-%s" % (prev_date.year, str(
                prev_date.month).zfill(2), str(prev_date.day).zfill(2))
            sobj_value = "%s-%s-%s" % (sobj_date.year, str(
                sobj_date.month).zfill(2), str(sobj_date.day).zfill(2))

        # compare search key here
        if prev_value == sobj_value:
            return False
        else:
            return True