예제 #1
0
 def init(self):
     search = Search(Bin)
     
     search.add_column('type')
     search.add_group_by('type')
     self.set_search_for_options(search, 'type','type')
     self.add_empty_option('-- Any --')
예제 #2
0
    def preprocess(self):

        sobjects = self.sobjects
        if not sobjects:
            return

        # find all of the instances in a shot
        sobject = sobjects[0]
        foreign_key = sobject.get_foreign_key()

        search_type = WebState.get().get_state("planner_search_type")
        search = Search(search_type)

        search.add_column(foreign_key)

        if len(sobjects) == 1:
            search.add_filter(foreign_key, sobject.get_code())
        else:
            search_codes = [x.get_code() for x in sobjects]
            search.add_filters(foreign_key, search_codes)

        search_type = sobject.get_search_type()
        search.add_order_by(foreign_key)
        children = search.get_sobjects()

        # convert to a dictionary
        for child in children:
            code = child.get_value(foreign_key)
            number = self.numbers.get(code)
            if not number:
                number = 0

            number += 1
            self.numbers[code] = number
예제 #3
0
 def init(my):
     search = Search(Bin)
     
     search.add_column('label')
     search.add_group_by('label')
     my.set_search_for_options(search, 'label','label')
     my.add_empty_option('-- Any --')
예제 #4
0
    def init(my):
        search = Search(Bin)

        search.add_column('type')
        search.add_group_by('type')
        my.set_search_for_options(search, 'type', 'type')
        my.add_empty_option('-- Any --')
예제 #5
0
    def init(self):
        search = Search(Bin)

        search.add_column('label')
        search.add_group_by('label')
        self.set_search_for_options(search, 'label', 'label')
        self.add_empty_option('-- Any --')
예제 #6
0
    def preprocess(self):

        sobjects = self.sobjects
        if not sobjects:
            return

        # find all of the instances in a shot
        sobject = sobjects[0]
        foreign_key = sobject.get_foreign_key()

        search_type = WebState.get().get_state("planner_search_type")
        search = Search( search_type )

        search.add_column(foreign_key)

        if len(sobjects) == 1:
            search.add_filter(foreign_key, sobject.get_code())
        else:
            search_codes = [x.get_code() for x in sobjects]
            search.add_filters(foreign_key, search_codes)

        search_type = sobject.get_search_type()
        search.add_order_by(foreign_key)
        children = search.get_sobjects()

        # convert to a dictionary
        for child in children:
            code = child.get_value(foreign_key)
            number = self.numbers.get(code)
            if not number:
                number = 0
           
            number += 1
            self.numbers[code] = number
예제 #7
0
    def execute(my):

        server = Config.get_value("install", "server")

        search_types = ['sthpw/note', 'sthpw/task']
        prefixes = ["NOTE", "TASK"]

        for j, search_type in enumerate(search_types):

            search = Search(search_type)
            search.add_column("id")
            search.add_column("code")
            sobjects = search.get_sobjects()
            num = len(sobjects)
            print "Found [%s] of %s" % (num, search_type)

            for i, sobject in enumerate(sobjects):
                code = sobject.get_code()
                if code.startswith(server):
                    continue

                if not code:
                    #sobject.delete()
                    continue

                if not code.startswith(prefixes[j]):
                    continue

                print "(%s of %s) %s" % (i, num, code)

                new_code = "%s%s" % (server, code)

                sobject.set_value("code", new_code)
                sobject.commit()
예제 #8
0
    def get_tasks(my, sobjects=[]):

        # get all of the relevant tasks to the user
        task_search = Search("sthpw/task")
        task_search.add_column("search_id", distinct=True)

        if sobjects:
            task_search.add_filter("search_type",
                                   sobjects[0].get_search_type())
            sobject_ids = SObject.get_values(sobjects, "id", unique=True)
            task_search.add_filters("search_id", sobject_ids)

        # only look at this project
        search_type = SearchType.get(my.search_type).get_full_key()
        task_search.add_filter("search_type", search_type)

        my.process_filter.alter_search(task_search)
        if isinstance(my.user_filter, UserFilterWdg):
            my.user_filter.alter_search(task_search)
        else:
            user = Environment.get_user_name()
            task_search.add_filter('assigned', user)

        status_filters = my.task_status_filter.get_values()

        if not status_filters:
            return []

        task_search.add_filters("status", status_filters)

        tasks = task_search.get_sobjects()

        return tasks
예제 #9
0
파일: header_wdg.py 프로젝트: 0-T-0/TACTIC
    def get_display(my):
        widget = Widget()
        span = SpanWdg('[ projects ]', css='hand')
        span.add_style('color','white')
        span.add_event('onclick',"spt.show_block('%s')" %my.WDG_ID)
        widget.add(span)
        
        # add the popup
        div = DivWdg(id=my.WDG_ID, css='popup_wdg')
        widget.add(div)
        div.add_style('width', '80px')
        div.add_style('display', 'none')
        title_div = DivWdg()
        div.add(title_div)
        title = FloatDivWdg(' ', width='60px')
        title.add_style('margin-right','2px')
        title_div.add_style('padding-bottom', '4px')
        title_div.add(title)
        title_div.add(CloseWdg(my.get_off_script(), is_absolute=False))


        div.add(HtmlElement.br())
        
        search = Search(Project)
        search.add_where("\"code\" not in ('sthpw','admin')")
        search.add_column('code')
        projects = search.get_sobjects()
        values = SObject.get_values(projects, 'code')

        web = WebContainer.get_web()
        root = web.get_site_root()
        
        
        security = Environment.get_security()
        for value in values:
            if not security.check_access("project", value, "view"):
                continue
            script = "location.href='/%s/%s'"%(root, value)
            sub_div = DivWdg(HtmlElement.b(value), css='selection_item') 
            sub_div.add_event('onclick', script)
            div.add(sub_div)
        
        div.add(HtmlElement.hr())
        if security.check_access("project", 'default', "view"):
            script = "location.href='/%s'" % root
            sub_div = DivWdg('home', css='selection_item') 
            sub_div.add_event('onclick', script)
            div.add(sub_div)

        if security.check_access("project", "admin", "view"):
            script = "location.href='/%s/admin/'" %root
            sub_div = DivWdg('admin', css='selection_item') 
            sub_div.add_event('onclick', script)
            div.add(sub_div)

       

        return widget
예제 #10
0
    def alter_search(my, search):

        # get all of the relevant tasks to the user
        task_search = Search("sthpw/task")
        task_search.add_column("search_id")

        # only look at this project
        project = Project.get_project_name()
        task_search.add_filter("search_type", search.get_search_type())

        # figure out who the user is
        security = Environment.get_security()
        login = security.get_login()
        user = login.get_value("login")



        print "is_artist: ", my.is_artist()
        print "is_supervisor: ", my.is_supervisor()


        # do some filtering
        web = WebContainer.get_web()
        show_assigned_only = my.checkbox.get_value()
        show_process = web.get_form_values("process")
        if not show_process or show_process[0] == '':
            show_process = []

        show_task_status = web.get_form_values("task_status")
        if not show_task_status or show_task_status[0] == '':
            show_task_status = []


        if show_assigned_only == "on":
            task_search.add_filter("assigned", user)

        if show_process:
            where = "process in (%s)" % ", ".join( ["'%s'" % x for x in show_process] )
            task_search.add_where(where)

        if show_task_status:
            where = "status in (%s)" % ", ".join( ["'%s'" % x for x in show_task_status] )
            task_search.add_where(where)
        else:
            task_search.add_where("NULL")




        # record the tasks
        my.tasks = task_search.get_sobjects()

        # get all of the sobject ids
        sobject_ids = ["'%s'" % x.get_value("search_id") for x in my.tasks]

        # get all of the sobjects related to this task
        if sobject_ids:
            search.add_where( "id in (%s)" % ", ".join(sobject_ids) )
예제 #11
0
    def alter_search(self, search):

        # get all of the relevant tasks to the user
        task_search = Search("sthpw/task")
        task_search.add_column("search_id")

        # only look at this project
        project = Project.get_project_name()
        task_search.add_filter("search_type", search.get_search_type())

        # figure out who the user is
        security = Environment.get_security()
        login = security.get_login()
        user = login.get_value("login")



        print "is_artist: ", self.is_artist()
        print "is_supervisor: ", self.is_supervisor()


        # do some filtering
        web = WebContainer.get_web()
        show_assigned_only = self.checkbox.get_value()
        show_process = web.get_form_values("process")
        if not show_process or show_process[0] == '':
            show_process = []

        show_task_status = web.get_form_values("task_status")
        if not show_task_status or show_task_status[0] == '':
            show_task_status = []


        if show_assigned_only == "on":
            task_search.add_filter("assigned", user)

        if show_process:
            where = "process in (%s)" % ", ".join( ["'%s'" % x for x in show_process] )
            task_search.add_where(where)

        if show_task_status:
            where = "status in (%s)" % ", ".join( ["'%s'" % x for x in show_task_status] )
            task_search.add_where(where)
        else:
            task_search.add_where("NULL")




        # record the tasks
        self.tasks = task_search.get_sobjects()

        # get all of the sobject ids
        sobject_ids = ["'%s'" % x.get_value("search_id") for x in self.tasks]

        # get all of the sobjects related to this task
        if sobject_ids:
            search.add_where( "id in (%s)" % ", ".join(sobject_ids) )
예제 #12
0
    def get_display(self):
        widget = Widget()
        span = SpanWdg('[ projects ]', css='hand')
        span.add_style('color', 'white')
        span.add_event('onclick', "spt.show_block('%s')" % self.WDG_ID)
        widget.add(span)

        # add the popup
        div = DivWdg(id=self.WDG_ID, css='popup_wdg')
        widget.add(div)
        div.add_style('width', '80px')
        div.add_style('display', 'none')
        title_div = DivWdg()
        div.add(title_div)
        title = FloatDivWdg(' ', width='60px')
        title.add_style('margin-right', '2px')
        title_div.add_style('padding-bottom', '4px')
        title_div.add(title)
        title_div.add(CloseWdg(self.get_off_script(), is_absolute=False))

        div.add(HtmlElement.br())

        search = Search(Project)
        search.add_where("\"code\" not in ('sthpw','admin')")
        search.add_column('code')
        projects = search.get_sobjects()
        values = SObject.get_values(projects, 'code')

        web = WebContainer.get_web()
        root = web.get_site_root()

        security = Environment.get_security()
        for value in values:
            if not security.check_access("project", value, "view"):
                continue
            script = "location.href='/%s/%s'" % (root, value)
            sub_div = DivWdg(HtmlElement.b(value), css='selection_item')
            sub_div.add_event('onclick', script)
            div.add(sub_div)

        div.add(HtmlElement.hr())
        if security.check_access("project", 'default', "view"):
            script = "location.href='/%s'" % root
            sub_div = DivWdg('home', css='selection_item')
            sub_div.add_event('onclick', script)
            div.add(sub_div)

        if security.check_access("project", "admin", "view"):
            script = "location.href='/%s/admin/'" % root
            sub_div = DivWdg('admin', css='selection_item')
            sub_div.add_event('onclick', script)
            div.add(sub_div)

        return widget
예제 #13
0
    def execute(my):
        project = Project.get()

        search = Search("sthpw/transaction_log")
        search.add_filter("namespace", project.get_code())
        search.add_column("code")

        transactions = search.get_sobjects()
        codes = SObject.get_values(transactions, "code")
        codes = set(codes)

        # dump out the transactions for this project
        f = open("/tmp/transactions_codes", 'wb')
        f.write(str(codes))
        f.close()
예제 #14
0
    def execute(my):
        project = Project.get()

        search = Search("sthpw/transaction_log")
        search.add_filter("namespace", project.get_code() )
        search.add_column("code")

        transactions = search.get_sobjects()
        codes = SObject.get_values(transactions, "code")
        codes = set(codes)

        # dump out the transactions for this project
        f = open("/tmp/transactions_codes", 'wb')
        f.write(str(codes))
        f.close()
예제 #15
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)
예제 #16
0
파일: task_wdg.py 프로젝트: 0-T-0/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)
예제 #17
0
    def _get_bins(self):
        
        search = Search(Bin)

        # get all the types in the Bin table
        type_search = Search(Bin)
        type_search.add_column('type')
        type_search.add_group_by('type')
        types = SObject.get_values(type_search.get_sobjects(), 'type')

        select = SelectWdg('display_limit')
        select.set_option('persist', 'true')
        display_limit = select.get_value()
        if display_limit:
            self.display_limit = display_limit

        # by default, get 10 for each type
        joined_statements = []
        for type in types:
            # TODO: fix this sql to run through search
            select = Search('prod/bin')
            select.add_filter("type", type)
            select.set_show_retired(False)
            select.add_order_by("code")
            select.add_limit(self.display_limit)
            statement = select.get_statement()
            joined_statements.append(statement)

            #joined_statements.append("select * from \"bin\" where \"type\" ='%s' and (\"s_status\" != 'retired' or \"s_status\" is NULL)" \
            #    " order by \"code\" desc limit %s" % (type, self.display_limit))

        if len(joined_statements) > 1:
            joined_statements = ["(%s)"%x for x in joined_statements]
            statement = ' union all '.join(joined_statements)
        elif len(joined_statements) == 1:
            statement = joined_statements[0]
        else:
            # no bins created yet
            return []
        #print "statement: ", statement
    
        return Bin.get_by_statement(statement)
예제 #18
0
    def _get_bins(my):

        search = Search(Bin)

        # get all the types in the Bin table
        type_search = Search(Bin)
        type_search.add_column('type')
        type_search.add_group_by('type')
        types = SObject.get_values(type_search.get_sobjects(), 'type')

        select = SelectWdg('display_limit')
        select.set_option('persist', 'true')
        display_limit = select.get_value()
        if display_limit:
            my.display_limit = display_limit

        # by default, get 10 for each type
        joined_statements = []
        for type in types:
            # TODO: fix this sql to run through search
            select = Search('prod/bin')
            select.add_filter("type", type)
            select.set_show_retired(False)
            select.add_order_by("code")
            select.add_limit(my.display_limit)
            statement = select.get_statement()
            joined_statements.append(statement)

            #joined_statements.append("select * from \"bin\" where \"type\" ='%s' and (\"s_status\" != 'retired' or \"s_status\" is NULL)" \
            #    " order by \"code\" desc limit %s" % (type, my.display_limit))

        if len(joined_statements) > 1:
            joined_statements = ["(%s)" % x for x in joined_statements]
            statement = ' union all '.join(joined_statements)
        elif len(joined_statements) == 1:
            statement = joined_statements[0]
        else:
            # no bins created yet
            return []
        #print "statement: ", statement

        return Bin.get_by_statement(statement)
예제 #19
0
    def _map_display_label(my):

        my.display_label = ''

        target_table = my.get_option("target_table")
        target_column = my.get_option("target_column")

        source_column = my.get_option("source_column")
        display_column = my.get_option("display_column")

        my.sobject = my.get_current_sobject()
        my.mapping_value = my.sobject.get_data().get(source_column)

        # do search here
        search = Search(target_table)
        search.add_filter(target_column, my.mapping_value)
        search.add_column(display_column)

        items = search.get_sobjects()
        if items:
            my.display_label = items[0].get_data().get(display_column)
예제 #20
0
    def _map_display_label(my):

        my.display_label = ''

        target_table = my.get_option("target_table")
        target_column = my.get_option("target_column")

        source_column = my.get_option("source_column")
        display_column = my.get_option("display_column")

        my.sobject = my.get_current_sobject()
        my.mapping_value = my.sobject.get_data().get( source_column )

        # do search here
        search = Search( target_table )
        search.add_filter( target_column, my.mapping_value)
        search.add_column( display_column )

        items = search.get_sobjects()
        if items:
            my.display_label = items[0].get_data().get( display_column )
예제 #21
0
    def get_tasks(my, sobjects=[]):


        # get all of the relevant tasks to the user
        task_search = Search("sthpw/task")
        task_search.add_column("search_id", distinct=True)


        if sobjects:
            task_search.add_filter("search_type", sobjects[0].get_search_type() )
            sobject_ids = SObject.get_values(sobjects, "id", unique=True)
            task_search.add_filters("search_id", sobject_ids)


        # only look at this project
        search_type = SearchType.get(my.search_type).get_full_key()
        task_search.add_filter("search_type", search_type)


        my.process_filter.alter_search(task_search)
        if isinstance(my.user_filter, UserFilterWdg):
            my.user_filter.alter_search(task_search)
        else:
            user = Environment.get_user_name()
            task_search.add_filter('assigned', user)
        
        status_filters = my.task_status_filter.get_values()
        
        if not status_filters:
            return []

        task_search.add_filters("status", status_filters)

        tasks = task_search.get_sobjects()
        
        return tasks
예제 #22
0
    def execute(self):

        server = Config.get_value("install", "server")

        search_types = ['sthpw/note', 'sthpw/task']
        prefixes = ["NOTE", "TASK"]
        

        for j, search_type in enumerate(search_types):

            search = Search(search_type)
            search.add_column("id")
            search.add_column("code")
            sobjects = search.get_sobjects()
            num = len(sobjects)
            print "Found [%s] of %s" % (num, search_type)


            for i, sobject in enumerate(sobjects):
                code = sobject.get_code()
                if code.startswith(server):
                    continue

                if not code:
                    #sobject.delete()
                    continue

                if not code.startswith(prefixes[j]):
                    continue

                print "(%s of %s) %s" % (i, num, code)

                new_code = "%s%s" % (server,code)

                sobject.set_value("code", new_code)
                sobject.commit()
예제 #23
0
    def get_transaction_info(my):

        remote_server = my.get_remote_server()

        
        search_keys = my.kwargs.get("search_keys")

        project_code = my.kwargs.get("project_code")
        if not project_code:
            project_code = Project.get_project_code()

        print "search_keys: ", search_keys

        if search_keys:
            search_keys_str = "|".join(search_keys)
            # need to get the code from the search_keys
            codes = []
            for search_key in search_keys:
                # HACK
                parts = search_key.split("code=")
                code = parts[1]
                codes.append(code)
            codes_str = "|".join(codes)

            filters = [
                ['code','in',codes_str]
            ]
            remote_codes = remote_server.query("sthpw/transaction_log", filters=filters, columns=['code'], order_bys=['timestamp'])

        elif my.start_expr:

            start_date = my.get_date(my.start_expr)

            # FIXME: this only works with Postgres
            filters = [
	        ['timestamp', '>', str(start_date)],
            ]

            if project_code:
                filters.append( ['namespace', project_code] )

            remote_codes = remote_server.query("sthpw/transaction_log", filters=filters, columns=['code'], order_bys=['timestamp'])
        else:
            raise TacticException("No start date expression given")


        print "# remote codes: ", len(remote_codes)



        # get all of the local transactions with the same filters
        search = Search("sthpw/transaction_log")
        search.add_column("code")
        search.add_filter("namespace", project_code)
        search.add_op_filters(filters)
        search.add_order_by("timestamp")
        print "search: ", search.get_statement()
        local_codes = search.get_sobjects()
        print "local codes: ", local_codes

        lset = set()
        for lt in local_codes:
            lcode = lt.get_value("code")
            if not lcode:
                continue
            lset.add(lcode)
            

        rset = set()
        for rt in remote_codes:
            rcode = rt.get("code")
            if not rcode:
                continue
            rset.add(rcode)
            

        info = {}
        remote_diff = rset.difference(lset)
        local_diff = lset.difference(rset)

        # go get the missing remote transactions
        filters = [['code', 'in', "|".join(remote_diff)]]
        remote_transactions = remote_server.query("sthpw/transaction_log", filters=filters, order_bys=['timestamp'])
        for i, transaction in enumerate(remote_transactions):
            sobject = SearchType.create("sthpw/transaction_log")
            sobject.data = transaction
            remote_transactions[i] = sobject
        info['remote_transactions'] = remote_transactions
 

        search = Search("sthpw/transaction_log")
        search.add_filters("code", local_diff)
        search.add_order_by("timestamp")
        local_transactions = search.get_sobjects()
        info['local_transactions'] = local_transactions

        local_paths = []
        for transaction in local_transactions:
            paths = my.get_file_paths(transaction)
            if not paths:
                continue
            local_paths.extend(paths)
        info['local_paths'] = local_paths


        remote_paths = [] 
        for transaction in remote_transactions:
            paths = my.get_file_paths(transaction)
            if not paths:
                continue
            remote_paths.extend(paths)
        info['remote_paths'] = remote_paths


        return info
예제 #24
0
    def get_display(my):

        menus = []

        widget = DivWdg(id='ProjectSelectWdg', css='spt_panel')
        widget.set_attr('spt_class_name', 'tactic.ui.app.ProjectSelectWdg') 
        if not WebContainer.get_web().is_IE():
            widget.add_style("float: right")

        from tactic.ui.widget import SingleButtonWdg
        button = SingleButtonWdg(title='Open Project', icon=IconWdg.PROJECT, show_arrow=True)
        widget.add(button)


        #from tactic.ui.activator import ButtonForDropdownMenuWdg
        #menu_data = []
        #menu_id = "project_select_menu"

        allowed = Project.get_user_projects()
        allowed_codes = [x.get_code() for x in allowed]

        search = Search("sthpw/project")
        search.add_filters("code", allowed_codes)
        # ignore some builtin projects
        search.add_where("\"code\" not in ('admin','sthpw','unittest')")
        search.add_op("begin")
        #search.add_filter("is_template", 'true', quoted=False, op='!=')
        search.add_filter("is_template", True, op='!=')
        search.add_filter("is_template", 'NULL', quoted=False, op='is')
        search.add_op("or")
        projects = search.get_sobjects()


        from tactic.ui.container import  Menu, MenuItem
        menu = Menu(width=240)
        menus.append(menu)
        menu.set_allow_icons(False)

        security = Environment.get_security()
        if security.check_access("builtin", "view_site_admin", "allow", default="deny") or security.check_access("builtin", "create_projects", "allow", default="deny"):
            menu_item = MenuItem(type='title', label='Project Action')
            menu.add(menu_item)

            menu_item = MenuItem(type='action', label='Create New Project')
            menu.add(menu_item)
            menu_item.add_behavior( {
            'cbjs_action': '''
            //spt.popup.open('create_project_wizard');
            //Effects.fade_in($('create_project_wizard'), 200);
            var env = spt.Environment.get();
            var project = env.get_project();
            if (project == 'admin') {
                spt.tab.set_main_body_top();
                var class_name = 'tactic.ui.app.ProjectCreateWdg';
                spt.tab.add_new("create_project", "Create Project", class_name);
            }
            else {
                document.location = "/tactic/admin/link/create_project";
            }
            '''
            } )


            search = Search("config/url")
            search.add_filter("url", "/index")
            url = search.get_sobject()
            if url:
                menu_item = MenuItem(type='action', label='Open Index')
                menu.add(menu_item)
                menu_item.add_behavior( {
                'cbjs_action': '''
                var env = spt.Environment.get();
                var project = env.get_project();
                //document.location = "/tactic/" + project + "/";
                window.open('/tactic/'+project+'/');
                '''
                } )




        menu_item = MenuItem(type='title', label='Open Project')
        menu.add(menu_item)


        def add_project_menu(menu, project):
            project_code = project.get_code()
            menu_item = MenuItem(type='action', label=project.get_value("title"))

            web = WebContainer.get_web()
            browser = web.get_browser()

            if browser != 'Qt':

                menu_item.add_behavior( {
                'type': 'click_up',
                'project_code': project_code,
                'cbjs_action': '''
                window.open('/tactic/%s/');
                ''' % project_code
                } )

            else:
                menu_item.add_behavior( {
                'project_code': project_code,
                'cbjs_action': '''
                spt.app_busy.show("Jumping to Project ["+bvr.project_code+"]", "");
                document.location = '/tactic/%s/';
                ''' % project_code
                } )

            menu.add(menu_item)


        search = Search("sthpw/project")
        search.add_column("category", distinct=True)
        categories = [x.get_value("category") for x in search.get_sobjects() ]
        for category in categories:
            if category == '':
                continue

            # FIXME: a little inefficient, but should be ok for now
            category_projects = []
            for project in projects:
                if project.get_value("category") != category:
                    continue

                project_code = project.get_code()
                if not security.check_access("project", project_code, "view"):
                    continue
                
                category_projects.append(project)

            if category_projects:
                suffix = Common.get_filesystem_name(category)
                label = "%s (%s)" % (category, len(category_projects))
                menu_item = MenuItem(type='submenu', label=label)
                menu_item.set_submenu_tag_suffix(suffix)
                menu.add(menu_item)

                submenu = Menu(width=200, menu_tag_suffix=suffix)
                menus.append(submenu)
                for project in category_projects:
                    add_project_menu(submenu, project)


        from pyasm.security import get_security_version
        security_version = get_security_version()

        for project in projects:
            if project.get_value("category") != "":
                continue

            project_code = project.get_code()
            if security_version >= 2:
                key = { "code": project_code }
                key2 = { "code": "*" }
                keys = [key, key2]
                default = "deny"
                if not security.check_access("project", keys, "allow", default=default):
                    continue
            else:
                if not security.check_access("project", project_code, "view", default="allow"):
                    continue

            add_project_menu(menu, project)



        if not projects:
            menu_item = MenuItem(type='action', label="- No Projects Created -")
            menu_item.add_behavior( {
            'cbjs_action': '''
            '''
            } )
            menu.add(menu_item)




        if security.check_access("builtin", "view_site_admin", "allow") or security.check_access("builtin", "view_template_projects", "allow"):
            search = Search("sthpw/project")
            #search.add_filter("is_template", 'true', quoted=False)
            search.add_filter("is_template", True)
            projects = search.get_sobjects()

            if projects:
                menu_item = MenuItem(type='title', label="Template Projects")
                menu.add(menu_item)

           

            for project in projects:
                project_code = project.get_code()
                if security_version >= 2:
                    key = { "code": project_code }
                    key2 = { "code": "*" }
                    keys = [key, key2]
                    default = "deny"
                    if not security.check_access("project", keys, "allow", default=default):
                        continue
                else:
                    if not security.check_access("project", project_code, "view", default="allow"):
                        continue

                menu_item = MenuItem(type='action', label=project.get_value("title"))
                menu_item.add_behavior( {
                'project_code': project_code,
                'cbjs_action': '''
                spt.app_busy.show("Jumping to Project ["+bvr.project_code+"]", "");
                document.location = '/projects/%s/'
                ''' % project_code
                } )
                menu.add(menu_item)


        if security.check_access("builtin", "view_site_admin", "allow", default="deny") or security.check_access("builtin", "create_projects", "allow", default="deny"):
            menu_item = MenuItem(type='title', label="Admin")
            menu.add(menu_item)
            project = Project.get_by_code("admin")
            add_project_menu(menu, project)





        from tactic.ui.container import SmartMenu
        smenu_set = SmartMenu.add_smart_menu_set( button, { 'BUTTON_MENU': menus } )
        SmartMenu.assign_as_local_activator( button, "BUTTON_MENU", True )


        return widget
예제 #25
0
 def init(my):
     search = Search(CommandSObj)
     search.add_column('notification_code')
     search.add_group_by('notification_code')
     my.set_search_for_options(search, 'notification_code','notification_code')
예제 #26
0
 def init(my):
     search = Search(CommandSObj)
     search.add_column('notification_code')
     search.add_group_by('notification_code')
     my.set_search_for_options(search, 'notification_code',
                               'notification_code')
예제 #27
0
    def get_display(self):

        top = self.top
        top.add_class("spt_panel_layout_top")
        self.set_as_panel(top)

        inner = DivWdg()
        top.add(inner)

        self.view = self.kwargs.get("view")

        # Define some views that are pages.  Pages are views that are self
        # contained and do not require arguments.  They are often created
        # by users
        search = Search("config/widget_config")
        search.add_column("view")
        search.add_filter("category", "CustomLayoutWdg")
        search.add_filter("view", "pages.%", op="like")
        sobjects = search.get_sobjects()
        self.pages = SObject.get_values(sobjects, "view")

        config = None
        is_test = False
        if self.view:
            search = Search("config/widget_config")
            search.add_filter("category", "PanelLayoutWdg")
            search.add_filter("view", self.view)
            config = search.get_sobject()

        elif is_test:
            config_xml = '''
            <config>
            <elements>
              <element name="a">
                <display class="tactic.ui.panel.CustomLayoutWdg">
                  <view>pages.test1</view>
                </display>
              </element>

              <element name="b">
                <display class="tactic.ui.panel.StaticTableLayoutWdg">
                    <search_type>sthpw/login_group</search_type>
                    <element_names>login_group</element_names>
                    <show_shelf>false</show_shelf>
                </display>
              </element>

              <element name="c">
                <display class="tactic.ui.panel.CustomLayoutWdg">
                  <view>test.search</view>
                </display>
              </element>

     
              <element name="d">
                <display class="tactic.ui.panel.StaticTableLayoutWdg">
                    <search_type>sthpw/login_group</search_type>
                    <element_names>login_group</element_names>
                    <show_shelf>false</show_shelf>
                </display>
              </element>
            </elements>
            </config>
            '''

            config = WidgetConfig.get(view="elements", xml=config_xml)

        if not config:
            config_xml = '''
            <config>
            <elements>
            </elements>
            </config>
            '''

            config = WidgetConfig.get(view="elements", xml=config_xml)

        grid = self.kwargs.get("grid")
        if not grid:
            grid = config.get_view_attribute("grid")

        if grid:
            if isinstance(grid, basestring):
                grid = [int(x) for x in grid.split("x")]

        else:
            grid = (3, 1)

        is_owner = True

        table = DivWdg()
        inner.add(table)
        table.add_style("margin: 20px")
        table.add_style("box-sizing: border-box")

        if is_owner:
            menu = self.get_action_menu()
            #SmartMenu.add_smart_menu_set( top, { 'BUTTON_MENU': menu } )

        element_names = config.get_element_names()

        index = 0
        for y in range(grid[1]):
            row = DivWdg()
            table.add(row)
            row.add_class("row")
            row.add_style("box-sizing: border-box")

            num_cols = grid[0]
            size = 12 / num_cols

            for x in range(grid[0]):
                col = DivWdg()
                row.add(col)
                col.add_class("col-sm-%s" % size)
                col.add_style("box-sizing: border-box")
                col.add_style("overflow: auto")

                col.add_class("spt_panel_top")

                if is_owner:
                    header = DivWdg()
                    col.add(header)

                    menu_wdg = DivWdg()
                    header.add(menu_wdg)
                    menu_wdg.add_style("float: right")
                    menu_wdg.add("<i class='fa fa-bars'> </i>")
                    menu_wdg.add_class("hand")

                    SmartMenu.add_smart_menu_set(menu_wdg,
                                                 {'BUTTON_MENU': menu})
                    SmartMenu.assign_as_local_activator(
                        menu_wdg, "BUTTON_MENU", True)

                element = None
                title = None
                if index < len(element_names):
                    element_name = element_names[index]
                    #element_name = "%s,%s" % (x,y)

                    element = config.get_display_widget(element_name)
                    title = config.get_element_title(element_name)
                    if not title:
                        title = Common.get_display_title(element_name)

                if not element:
                    element = DivWdg()
                    element.add("No content")
                    element.add_style("height: 100%")
                    element.add_style("width: 100%")
                    element.add_style("text-align: center")
                    element.add_border()
                else:
                    try:
                        element = element.get_buffer_display()
                    except:

                        element = DivWdg()
                        element.add("No content")
                        element.add_style("height: 100%")
                        element.add_style("width: 100%")
                        element.add_style("text-align: center")
                        element.add_border()

                if is_owner:
                    if title:
                        header.add(title)
                    else:
                        header.add("Panel: %s,%s" % (x, y))
                    col.add("<hr/>")

                content = DivWdg()
                col.add(content)
                content.add_class("spt_panel_content")
                content.add_style("min-height: 200px;")

                content.add(element)

                index += 1

        if self.kwargs.get("is_refresh"):
            return inner
        else:
            return top
예제 #28
0
    def get_display(my):
        top = my.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("width", "400px")
        top.add_class('spt_delete_stype_top')
        top.add_border()

        project_code = Project.get_project_code()
        # Note search types should only really be deleted if they were just
        # created

        search_type = my.kwargs.get("search_type")
        if not search_type:
            node_name = my.kwargs.get("node_name")
            if node_name:
                #project_code = Project.get_project_code()
                search_type = "%s/%s" % (project_code, node_name)

        assert search_type
        built_in_stypes = [
            'task', 'note', 'work_hour', 'login', 'login_group', 'schema',
            'project', 'login_in_group', 'snapshot', 'file', 'trigger',
            'spt_trigger', 'widget_config', 'custom_script', 'notification',
            'notification_log', 'file_access', 'cache', 'exception_log',
            'milestone', 'pipeline', 'pref_list', 'pref_setting',
            'project_type', 'repo', 'remote_repo', 'search_sobject',
            'sobject_list', 'ticket', 'db_resource', 'wdg_settings',
            'status_log', 'debug_log', 'transaction_log', 'sobject_log'
        ]

        for tbl in built_in_stypes:
            if search_type == 'sthpw/%s' % tbl:
                top.add("sType [%s] is internal and cannot be deleted!" %
                        search_type)
                top.add_style("font-size: 14px")
                top.add_style('padding: 20px')
                return top

        search_type_obj = SearchType.get(search_type)
        if not search_type:
            top.add("sType [%s] does not exist!" % search_type)
            top.add_style("font-size: 14px")
            top.add_style('padding: 20px')
            return top
        table = search_type_obj.get_table()

        db_val = search_type_obj.get_value('database')
        if db_val == '{project}':
            label = ''
        elif db_val == 'sthpw':
            label = 'built-in'
        else:
            label = 'project-specific'

        # warn if more than 1 sType point to the same table in the same project
        expr = "@GET(sthpw/search_type['table_name', '%s']['database', 'in',  '{project}|%s']['namespace','%s'].search_type)" % (
            table, project_code, project_code)
        rtn = Search.eval(expr)

        warning_msg = ''
        if len(rtn) > 1:
            warning_msg = 'Warning: There is more than 1 sType [%s] pointing to the same table [%s]. Deleting will affect both sTypes.' % (
                ', '.join(rtn), table)

        title_wdg = DivWdg()

        top.add(title_wdg)
        title_wdg.add(IconWdg(icon=IconWdg.WARNING))
        title_wdg.add("Delete %s sType: %s" % (label, search_type))
        title_wdg.add_gradient("background", "background", -10, -10)
        title_wdg.add_style("padding: 5px")
        title_wdg.add_style("font-weight: bold")
        title_wdg.add_style("font-size: 14px")

        content = DivWdg()
        top.add(content)
        content.add_style("padding: 10px")

        if warning_msg:
            content.add(DivWdg(warning_msg, css='warning'))
            content.add("<br/>")
        content.add("This sType uses the table \"%s\" to store items.<br/>" %
                    table)

        content.add("<br/>")

        search = Search(search_type)
        count = search.get_count()
        content.add("Number of items in the table: %s<br/>" % count)

        content.add("<br/>")

        search.add_column("id")
        sobjects = search.get_sobjects()

        if sobjects:
            items_search_type = sobjects[0].get_search_type()

            search_ids = [x.get_id() for x in sobjects]

            notes_search = Search("sthpw/note")
            notes_search.add_filters("search_id", search_ids)
            notes_search.add_filter("search_type", items_search_type)
            note_count = notes_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/note')
            content.add(cb)
            content.add(
                SpanWdg("Number of related notes: %s" % note_count,
                        css='small'))
            content.add(HtmlElement.br())

            tasks_search = Search("sthpw/task")
            tasks_search.add_filters("search_id", search_ids)
            tasks_search.add_filter("search_type", items_search_type)
            task_count = tasks_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/task')
            content.add(cb)
            content.add(
                SpanWdg("Number of related tasks: %s" % task_count,
                        css='small'))
            content.add(HtmlElement.br())

            snapshots_search = Search("sthpw/snapshot")
            snapshots_search.add_filters("search_id", search_ids)
            snapshots_search.add_filter("search_type", items_search_type)
            snapshot_count = snapshots_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/snapshot')
            content.add(cb)
            content.add(
                SpanWdg("Number of related snapshots: %s" % snapshot_count,
                        css='small'))
            content.add(HtmlElement.br())

        pipelines_search = Search("sthpw/pipeline")
        pipelines_search.add_filter("search_type", search_type)
        pipeline_count = pipelines_search.get_count()
        cb = CheckboxWdg('related_types')
        cb.set_attr('value', 'sthpw/pipeline')
        content.add(cb)
        content.add(
            SpanWdg("Number of related pipelines: %s" % pipeline_count,
                    css='small'))
        content.add(HtmlElement.br(2))

        content.add(
            "<b>WARNING: Deleting the sType will delete all of these items.</b> "
        )
        content.add("<br/>" * 2)
        content.add("Do you wish to continue deleting?")
        content.add("<br/>" * 2)

        button_div = DivWdg()
        button_div.add_styles('width: 300px; height: 50px')
        button = ActionButtonWdg(title="Delete")
        button_div.add(button)
        content.add(button_div)
        button.add_style("float: left")

        button.add_behavior({
            'type':
            'click_up',
            'search_type':
            search_type,
            'cbjs_action':
            '''
        spt.app_busy.show("Deleting sType");
        var class_name = "tactic.ui.tools.DeleteSearchTypeCmd";
        var ui_top = bvr.src_el.getParent(".spt_delete_stype_top");
        var values = spt.api.Utility.get_input_values(ui_top);
        var kwargs = {
            'search_type': bvr.search_type,
             'values': values
        };
        var server = TacticServerStub.get();
        try {
            server.start({'title': 'Delete sType', 'description': 'Delete sType [' + bvr.search_type + ']'});
            server.execute_cmd(class_name, kwargs);
            var top = bvr.src_el.getParent(".spt_popup");
            spt.pipeline.remove_node(top.stype_node);

            // force a schema save
            spt.named_events.fire_event('schema|save', bvr)
            top.destroy();
            
            server.finish();
        
        }
        catch(e) {
            spt.alert(spt.exception.handler(e));
        }

        spt.app_busy.hide();

        spt.notify.show_message("Successfully deleted sType ["+bvr.search_type+"]");
       
        '''
        })

        button = ActionButtonWdg(title="Cancel")
        button.add_style("float: left")
        button_div.add(button)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_popup");
        top.destroy();
        '''
        })

        return top
예제 #29
0
    def get_display(my):

        my.search_type = my.kwargs.get("search_type")
        if not my.search_type:
            my.search_type = 'sthpw/task'

        my.column = my.kwargs.get("column")
        if not my.column:
            my.column = 'status'


        my.project_code = my.kwargs.get("project_code")
        if not my.project_code:
            my.project_code = Project.get_project_code()

        my.bar_width = my.kwargs.get("bar_width")
        if not my.bar_width:
            my.bar_width = 200


        values = my.kwargs.get("values")
        if values:
            values = values.split("|")

        else:
            pipeline_code = my.kwargs.get("pipeline_code")
            if pipeline_code:
                pipeline = Pipeline.get_by_code(pipeline_code)
                values = pipeline.get_process_names()
            else:    
                search = Search(my.search_type)
                search.add_filter("project_code", my.project_code)
                search.add_column(my.column, distinct=True)
                xx = search.get_sobjects()
                values = [x.get_value(my.column) for x in xx]


        search = Search(my.search_type)
        search.add_filter("project_code", my.project_code)
        search.add_filters(my.column, values)
        total = search.get_count()




        colors = ['#900', '#090', '#009', '#990', '#099', '#909', '#900', '#090', '#009', '#990']
        while len(values) > len(colors):
            colors.extend(colors)

        top = DivWdg()
        top.add_color("background", "background")

        date = "@FORMAT(@STRING($TODAY),'Dec 31, 1999')"
        date = Search.eval(date, single=True)
        title = "Tasks Status Chart"

        title_wdg = DivWdg()
        top.add(title_wdg)
        title_wdg.add(title)
        title_wdg.add(" [%s]" % date)
        title_wdg.add_style("font-size: 14")
        title_wdg.add_color("background", "background3")
        title_wdg.add_color("color", "color3")
        title_wdg.add_style("padding: 10px")
        title_wdg.add_style("font-weight: bold")
        title_wdg.add_style("text-align: center")


        inner = DivWdg()
        top.add(inner)
        inner.center()
        inner.add_style("width: 500px")
        inner.add_style("padding: 30px")


        for i,status in enumerate(values):

            if not status:
                continue

            count = my.get_count(status)
            div = my.get_div(status, count, total, colors[i])
            inner.add( div.get_buffer_display() )
            inner.add( "<br clear='all'/>")

        inner.add("<hr/>")

        div = my.get_div("Total", total, total, "gray")
        inner.add( div.get_buffer_display() )
        inner.add("<br clear='all'/>")


        return top
예제 #30
0
    def get_display(my):
        ''' this does not run do_search'''
        search_type = my.options.get("search_type")
        if search_type:
            my.search_type = search_type

        view = my.options.get("view")
        if view:
            my.view = view

        search_type = my.search_type
        pipeline_name = my.pipeline_name
        sobject_filter = my.sobject_filter

        assert search_type != None

        search = Search(search_type)

        widget = Widget()

        div = FilterboxWdg()
        widget.add(div)


        my.process_filter = ProcessFilterSelectWdg(label="Process: ", \
            search_type=search_type, css='med', name=my.process_filter_name)
        my.process_filter.set_submit_onchange(False)

        # get all of the sobjects related to this task
        taskless_filter = FilterCheckboxWdg('show_taskless_assets', \
            label='Show Taskless Assets', css='small')
        taskless_filter.set_submit_onchange(False)

        # add in the asset filter
        if sobject_filter:
            sobject_filter.alter_search(search)
            div.add(sobject_filter)

        # append the process filter and user filter
        div.add_advanced_filter(my.process_filter)

        # add a hint
        hint = HintWdg('You can select a single process or the &lt;&lt; heading &gt;&gt; '\
             'which will select the group of processes it contains.')

        div.add_advanced_filter(hint)

        if UserFilterWdg.has_restriction():
            user = Environment.get_user_name()
            my.user_filter = HiddenWdg('user_filter', user)
            my.user_filter.set_persistence()
        else:
            # it has a special colunn 'assigned'
            my.user_filter = UserFilterWdg(['user_filter', 'Assigned: '])
            my.user_filter.set_search_column('assigned')
        div.add_advanced_filter(my.user_filter)

        # add the show assets with no task option
        div.add_advanced_filter(taskless_filter)

        # add the task filter
        my.task_status_filter = TaskStatusFilterWdg()
        div.add_advanced_filter(my.task_status_filter)

        div.add_advanced_filter(HtmlElement.br())
        if search_type == 'prod/shot':
            shot_filter = SObjectStatusFilterWdg()
            div.add_advanced_filter(shot_filter)
            shot_statuses = shot_filter.get_statuses()
            if shot_statuses:
                search.add_filters("status", shot_filter.get_values())

        # add search limit
        search_limit = SearchLimitWdg()
        search_limit.set_limit(my.search_limit)
        div.add_bottom(search_limit)

        # only show shots that match the task filter
        if not taskless_filter.is_checked(False):
            # filter out the tasks
            search.add_column("id")
            tmp_sobjects = search.get_sobjects()
            sobjects = []
            if tmp_sobjects:

                # get all of the sobject ids corresponding to these tasks
                tasks = my.get_tasks(tmp_sobjects)
                sobject_ids = SObject.get_values(tasks,
                                                 "search_id",
                                                 unique=True)

                search = Search(search_type)
                search.add_filters("id", sobject_ids)
                search_limit.alter_search(search)
                sobjects = search.get_sobjects()

        else:
            search_limit.alter_search(search)
            tmp_sobjects = search.get_sobjects()
            sobjects = tmp_sobjects

        table = TableWdg(search_type, my.view)
        widget.add(HtmlElement.br())
        table.set_sobjects(sobjects)

        widget.add(table)
        return widget
예제 #31
0
    def get_display(my):

        collection = my.kwargs.get("collection")
        path = my.kwargs.get("path")

        search_type = collection.get_base_search_type()
        parts = search_type.split("/")
        collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])

        search = Search(collection_type)
        search.add_filter("parent_code", collection.get_value("code"))
        search.add_column("search_code")
        items = search.get_sobjects()
        codes = [x.get_value("search_code") for x in items]

        count = search.get_count()

        # find the children that are actually collections
        search = Search(search_type)
        search.add_filter("_is_collection", True)
        search.add_filters("code", codes)
        has_child_collections = search.get_count() > 0

        top = my.top
        collection_top = top
        collection_top.add_class("spt_collection_div_top")
        collection_div = DivWdg()

        name = collection.get_value("name")
        # Adding Collection title (without the number count) as an attribute
        collection_top.set_attr("collection_name", name)

        collection_top.add(collection_div)
        collection_top.add_class("tactic_hover")
        collection_top.add_class("hand")

        collection_div.add_class("spt_collection_item")
        collection_div.add_attr("spt_collection_key",
                                collection.get_search_key())
        collection_div.add_attr("spt_collection_code", collection.get_code())
        collection_div.add_attr("spt_collection_path", path)

        # This is for Drag and Drop from a tile widget
        collection_div.add_class("spt_tile_top")
        collection_div.add_attr("spt_search_key", collection.get_search_key())
        collection_div.add_attr("spt_search_code", collection.get_code())
        collection_div.add_attr("spt_name", name)

        collection_div.add_style("height: 20px")
        collection_div.add_style("padding-top: 10px")

        if has_child_collections:
            icon_div = DivWdg()
            icon = IconWdg(name="View Collection", icon="BS_CHEVRON_DOWN")
            icon_div.add(icon)
            icon.add_style("float: right")
            icon.add_style("margin-top: -20px")
            collection_top.add(icon_div)
            icon_div.add_class("spt_collection_open")
            icon_div.add_attr("spt_collection_key",
                              collection.get_search_key())
            icon_div.add_attr("spt_collection_path", path)

        from tactic.ui.panel import ThumbWdg2
        thumb_wdg = ThumbWdg2()
        thumb_wdg.set_sobject(collection)
        collection_div.add(thumb_wdg)
        thumb_wdg.add_style("width: 45px")
        thumb_wdg.add_style("float: left")
        thumb_wdg.add_style("margin-top: -10px")

        if count:
            count_div = DivWdg()
            collection_div.add(count_div)
            #count_div.add_style("margin-top: -10px")
            #count_div.add_style("margin-left: -10px")

            count_div.add_style("width: 15px")
            count_div.add_style("height: 15px")
            count_div.add_style("font-size: 0.8em")
            count_div.add_style("border-radius: 10px")
            count_div.add_style("background: #DDD")
            count_div.add_style("position: absolute")
            count_div.add_style("text-align: center")
            count_div.add_style("margin-left: 23px")
            count_div.add_style("margin-top: -8px")
            count_div.add_style("box-shadow: 0px 0px 3px rgba(0,0,0,0.5)")

            expression = "@COUNT(%s['parent_code','%s'])" % (
                collection_type, collection.get_code())
            count_div.add(count)
            count_div.add_update({
                #'expr_key': collection.get_search_key(),
                'expression': expression,
                'interval': 2
            })

        name = collection.get_value("name")
        collection_div.add(name)

        return top
예제 #32
0
파일: panel_wdg.py 프로젝트: mincau/TACTIC
    def get_display(self):

        top = self.top
        top.add_style("margin: 10px")


        search = Search("config/widget_config")
        search.add_column("view")
        search.add_filter("category", "CustomLayoutWdg")
        search.add_filter("view", "pages.%", op="like")
        sobjects = search.get_sobjects()
        self.pages = SObject.get_values(sobjects, "view")


        top.add("<div style='font-size: 16px'>Select page to load</div>")
        top.add("<hr/>")



        pages_div = DivWdg()
        top.add(pages_div)
        pages_div.add_style("margin: 20px")


        pages_div.add_relay_behavior( {
            'type': 'click',
            'bvr_match_class': "spt_user_page_item",
            'cbjs_action': '''
            var popup = bvr.src_el.getParent(".spt_popup");
            var activator = popup.activator;

            var page = bvr.src_el.getAttribute("spt_page");

            var top = activator.getParent(".spt_panel_top");
            var content = top.getElement(".spt_panel_content");

            var class_name = 'tactic.ui.panel.CustomLayoutWdg';
            var kwargs = {
                view: page,
            }
            spt.panel.load(content, class_name, kwargs);

            spt.popup.close(popup);


            '''
        } )

        if self.pages:
            last_parts = self.pages[0].split(".")[:-1]


        self.pages.sort()

        last_parts = []
        for count, page in enumerate(self.pages):

            page = page.replace(".", "/")

            page_div = DivWdg()
            pages_div.add(page_div)
            page_div.add_class("spt_user_page_item")
            page_div.add_style("padding: 3px")
            page_div.add_class("tactic_hover")
            page_div.add_attr("spt_page", page)
            page_div.add_class("hand")
            page_div.add_style("min-width: 400px")


            new_parts = []
            parts = page.split("/")
            parts = parts[1:]
            index = 0
            for part in parts:
                if index < len(last_parts):
                    last_part = last_parts[index]
                    if part == last_part:
                        part = "<i style='opacity: 0.0'>%s</i>" % part

                index += 1
                new_parts.append(part)
            last_parts = parts

            #parts = ["<b>%s</b>" % x for x in parts]
            display_path = "&nbsp;&nbsp;<i style='opacity: 1.0'>/</i>&nbsp;&nbsp;".join(new_parts)

            page_div.add("<div style='margin-right: 10px;display: inline-block; width: 20px; text-align: right'>%s: </div>" % count)
            page_div.add(display_path)


        return top
예제 #33
0
파일: panel_wdg.py 프로젝트: mincau/TACTIC
    def get_display(self):

        top = self.top
        top.add_class("spt_panel_layout_top")
        self.set_as_panel(top)

        inner = DivWdg()
        top.add(inner)


        self.view = self.kwargs.get("view")


        # Define some views that are pages.  Pages are views that are self
        # contained and do not require arguments.  They are often created
        # by users
        search = Search("config/widget_config")
        search.add_column("view")
        search.add_filter("category", "CustomLayoutWdg")
        search.add_filter("view", "pages.%", op="like")
        sobjects = search.get_sobjects()
        self.pages = SObject.get_values(sobjects, "view")

        config = None
        is_test = False
        if self.view:
            search = Search("config/widget_config")
            search.add_filter("category", "PanelLayoutWdg")
            search.add_filter("view", self.view)
            config = search.get_sobject()

        elif is_test:
            config_xml = '''
            <config>
            <elements>
              <element name="a">
                <display class="tactic.ui.panel.CustomLayoutWdg">
                  <view>pages.test1</view>
                </display>
              </element>

              <element name="b">
                <display class="tactic.ui.panel.StaticTableLayoutWdg">
                    <search_type>sthpw/login_group</search_type>
                    <element_names>login_group</element_names>
                    <show_shelf>false</show_shelf>
                </display>
              </element>

              <element name="c">
                <display class="tactic.ui.panel.CustomLayoutWdg">
                  <view>test.search</view>
                </display>
              </element>

     
              <element name="d">
                <display class="tactic.ui.panel.StaticTableLayoutWdg">
                    <search_type>sthpw/login_group</search_type>
                    <element_names>login_group</element_names>
                    <show_shelf>false</show_shelf>
                </display>
              </element>
            </elements>
            </config>
            '''

            config = WidgetConfig.get(view="elements", xml=config_xml)


        if not config:
            config_xml = '''
            <config>
            <elements>
            </elements>
            </config>
            '''

            config = WidgetConfig.get(view="elements", xml=config_xml)


        grid = self.kwargs.get("grid")
        if not grid:
            grid = config.get_view_attribute("grid")

        if grid:
            if isinstance(grid, basestring):
                grid = [int(x) for x in grid.split("x")]

        else:
            grid = (3,1)


        is_owner = True


        table = DivWdg() 
        inner.add(table)
        table.add_style("margin: 20px")
        table.add_style("box-sizing: border-box")


        if is_owner:
            menu = self.get_action_menu()
            #SmartMenu.add_smart_menu_set( top, { 'BUTTON_MENU': menu } )

        element_names = config.get_element_names()

        index = 0
        for y in range(grid[1]):
            row = DivWdg()
            table.add(row)
            row.add_class("row")
            row.add_style("box-sizing: border-box")

            num_cols = grid[0]
            size = 12 / num_cols

            for x in range(grid[0]):
                col = DivWdg()
                row.add(col)
                col.add_class("col-sm-%s" % size)
                col.add_style("box-sizing: border-box")
                col.add_style("overflow: auto")

                col.add_class("spt_panel_top")



                if is_owner:
                    header = DivWdg()
                    col.add(header)

                    menu_wdg = DivWdg()
                    header.add(menu_wdg)
                    menu_wdg.add_style("float: right")
                    menu_wdg.add("<i class='fa fa-bars'> </i>")
                    menu_wdg.add_class("hand")

                    SmartMenu.add_smart_menu_set( menu_wdg, { 'BUTTON_MENU': menu } )
                    SmartMenu.assign_as_local_activator( menu_wdg, "BUTTON_MENU", True )


                element = None
                title = None
                if index < len(element_names):
                    element_name = element_names[index]
                    #element_name = "%s,%s" % (x,y)

                    element = config.get_display_widget(element_name)
                    title = config.get_element_title(element_name)
                    if not title:
                        title = Common.get_display_title(element_name)

                if not element:
                    element = DivWdg()
                    element.add("No content")
                    element.add_style("height: 100%")
                    element.add_style("width: 100%")
                    element.add_style("text-align: center")
                    element.add_border()
                else:
                    try:
                        element = element.get_buffer_display()
                    except:

                        element = DivWdg()
                        element.add("No content")
                        element.add_style("height: 100%")
                        element.add_style("width: 100%")
                        element.add_style("text-align: center")
                        element.add_border()



                if is_owner:
                    if title:
                        header.add(title)
                    else:
                        header.add("Panel: %s,%s" % (x, y))
                    col.add("<hr/>")

                content = DivWdg()
                col.add(content)
                content.add_class("spt_panel_content")
                content.add_style("min-height: 200px;")


                content.add(element)


                index += 1

        if self.kwargs.get("is_refresh"):
            return inner
        else:
            return top
예제 #34
0
    def get_display(my):

        collection = my.kwargs.get("collection")
        path = my.kwargs.get("path")

        search_type = collection.get_base_search_type()
        parts = search_type.split("/")
        collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])

        search = Search(collection_type)
        search.add_filter("parent_code", collection.get_value("code"))
        search.add_column("search_code")
        items = search.get_sobjects()
        codes = [x.get_value("search_code") for x in items]

        count = search.get_count()


        # find the children that are actually collections
        search = Search(search_type)
        search.add_filter("_is_collection", True)
        search.add_filters("code", codes)
        has_child_collections = search.get_count() > 0


        top = my.top
        collection_top = top
        collection_top.add_class("spt_collection_div_top")
        collection_div = DivWdg()
        
        name = collection.get_value("name")
        # Adding Collection title (without the number count) as an attribute
        collection_top.set_attr("collection_name", name)

        collection_top.add(collection_div)
        collection_top.add_class("tactic_hover")
        collection_top.add_class("hand")

        collection_div.add_class("spt_collection_item")
        collection_div.add_attr("spt_collection_key", collection.get_search_key())
        collection_div.add_attr("spt_collection_code", collection.get_code())
        collection_div.add_attr("spt_collection_path", path)

        # This is for Drag and Drop from a tile widget
        collection_div.add_class("spt_tile_top")
        collection_div.add_attr("spt_search_key", collection.get_search_key())
        collection_div.add_attr("spt_search_code", collection.get_code())

        collection_div.add_style("height: 20px")
        collection_div.add_style("padding-top: 10px")

        
        if has_child_collections:
            icon_div = DivWdg()
            icon = IconWdg(name="View Collection", icon="BS_CHEVRON_DOWN")
            icon_div.add(icon)
            icon.add_style("float: right")
            icon.add_style("margin-top: -20px")
            collection_top.add(icon_div)
            icon_div.add_class("spt_collection_open")
            icon_div.add_attr("spt_collection_key", collection.get_search_key())
            icon_div.add_attr("spt_collection_path", path)

        from tactic.ui.panel import ThumbWdg2
        thumb_wdg = ThumbWdg2()
        thumb_wdg.set_sobject(collection)
        collection_div.add(thumb_wdg)
        thumb_wdg.add_style("width: 45px")
        thumb_wdg.add_style("float: left")
        thumb_wdg.add_style("margin-top: -10px")

        if count:
            count_div = DivWdg()
            collection_div.add(count_div)
            #count_div.add_style("margin-top: -10px")
            #count_div.add_style("margin-left: -10px")

            count_div.add_style("width: 15px")
            count_div.add_style("height: 15px")
            count_div.add_style("font-size: 0.8em")
            count_div.add_style("border-radius: 10px")
            count_div.add_style("background: #DDD")
            count_div.add_style("position: absolute")
            count_div.add_style("text-align: center")
            count_div.add_style("margin-left: 23px")
            count_div.add_style("margin-top: -8px")
            count_div.add_style("box-shadow: 0px 0px 3px rgba(0,0,0,0.5)")

            count_div.add(count)
            #count_div.add_update( {
            #    'parent_key': collection.get_search_key(),
            #    'expression': "@COUNT(%s)" % collection_type,
            #} )


        name = collection.get_value("name")
        collection_div.add(name)



        return top
예제 #35
0
    def get_display(my):

        my.search_type = my.kwargs.get("search_type")
        if not my.search_type:
            my.search_type = 'sthpw/task'

        my.column = my.kwargs.get("column")
        if not my.column:
            my.column = 'status'

        my.project_code = my.kwargs.get("project_code")
        if not my.project_code:
            my.project_code = Project.get_project_code()

        my.bar_width = my.kwargs.get("bar_width")
        if not my.bar_width:
            my.bar_width = 200

        values = my.kwargs.get("values")
        if values:
            values = values.split("|")

        else:
            pipeline_code = my.kwargs.get("pipeline_code")
            if pipeline_code:
                pipeline = Pipeline.get_by_code(pipeline_code)
                values = pipeline.get_process_names()
            else:
                search = Search(my.search_type)
                search.add_filter("project_code", my.project_code)
                search.add_column(my.column, distinct=True)
                xx = search.get_sobjects()
                values = [x.get_value(my.column) for x in xx]

        search = Search(my.search_type)
        search.add_filter("project_code", my.project_code)
        search.add_filters(my.column, values)
        total = search.get_count()

        colors = [
            '#900', '#090', '#009', '#990', '#099', '#909', '#900', '#090',
            '#009', '#990'
        ]
        while len(values) > len(colors):
            colors.extend(colors)

        top = DivWdg()
        top.add_color("background", "background")

        date = "@FORMAT(@STRING($TODAY),'Dec 31, 1999')"
        date = Search.eval(date, single=True)
        title = "Tasks Status Chart"

        title_wdg = DivWdg()
        top.add(title_wdg)
        title_wdg.add(title)
        title_wdg.add(" [%s]" % date)
        title_wdg.add_style("font-size: 14")
        title_wdg.add_color("background", "background3")
        title_wdg.add_color("color", "color3")
        title_wdg.add_style("padding: 10px")
        title_wdg.add_style("font-weight: bold")
        title_wdg.add_style("text-align: center")

        inner = DivWdg()
        top.add(inner)
        inner.center()
        inner.add_style("width: 500px")
        inner.add_style("padding: 30px")

        for i, status in enumerate(values):

            if not status:
                continue

            count = my.get_count(status)
            div = my.get_div(status, count, total, colors[i])
            inner.add(div.get_buffer_display())
            inner.add("<br clear='all'/>")

        inner.add("<hr/>")

        div = my.get_div("Total", total, total, "gray")
        inner.add(div.get_buffer_display())
        inner.add("<br clear='all'/>")

        return top
예제 #36
0
    def get_data(self):
        """
        <element name='work_location' title='Originating Site'>
          <display class='tactic.ui.table.ExpressionElementWdg'>
            <expression>@GET(MMS/work_location.location)</expression>
            <alt_expression>@GET(MMS/work_location.id)</alt_expression>
            <order_by>work_location.location</order_by>
          </display>
        </element>
        """


        data = {}

        sobjects = self.sobjects
        if not sobjects:
            return data

        #template = "MMS/subtask.MMS/job.MMS/request.MMS/security_classification"
        template = self.get_option("template")
        keys = template.split(".")

        # get the sobjects (main search)
        search_type_obj = sobjects[0].get_search_type_obj()
        join_table = search_type_obj.get_table()
        search_type = search_type_obj.get_value("search_type")

        if keys[0] != search_type:
            keys.insert(0, search_type)

        search_ids = []
        for sobject in sobjects:
            search_id = sobject.get_id()
            search_ids.append(search_id)


        keys.reverse()

        # create main search
        search = Search(keys[0])
        table = search.get_table()

        # add the columns
        search.add_column("*", table=table)
        # add the id column from the joined table
        search.add_column("id", table=join_table, as_column='%s_id' % join_table)

        current_key = None
        for i in range(1, len(keys)):
            key = keys[i]
            namespace, table = key.split("/")
            search.add_join(key, current_key)

            current_key = key

        search.add_filters("id", search_ids, table=table)
        search.set_show_retired(True)

        results = search.get_sobjects()

        # make into a dictionary based on search id
        for result in results:
            id = result.get_value("%s_id" % join_table)
            data[id] = result
            print id, result.get_data()

        print "results: ", len(results)
        return data
예제 #37
0
    def init(my):

        base_dir = my.base_dir
        if not os.path.exists(base_dir):
            os.makedirs(base_dir)

        dirs = os.listdir(base_dir)

        # skip local transactions
        server_code = Config.get_value("install", "server")
        dir_set = set(dirs)
        for dirname in dirs:
            if dirname.startswith("%sTRANSACTION" % server_code):
                dir_set.remove(dirname)
        dirs = list(dir_set)

        tmp_set = set(dirs)
        dirs_set = set()
        dirs_dict = {}

        for dir in tmp_set:
            if dir.startswith("."):
                continue
            if dir.find("TRANSACTION") == -1:
                continue
            if dir.find("-") != -1:
                parts = dir.split("-")
                code = parts[0]
            else:
                code = dir.replace(".zip", "")
                code = code.replace(".enc", "")
            dirs_set.add(code)
            dirs_dict[code] = dir

        search = Search("sthpw/transaction_log")
        search.add_filters("code", list(dirs_set))
        search.add_column("code")
        transactions = search.get_sobjects()
        codes = [x.get_code() for x in transactions]
        codes_set = set(codes)

        diff = dirs_set.difference(codes_set)
        diff = list(diff)
        diff.sort()

        total = len(diff) - 1
        for count, transaction_code in enumerate(diff):

            dirname = dirs_dict.get(transaction_code)

            # FIXME: there is a memory growth problem.  Batch clears it
            if total > 1:
                print "Processing file [%s] (%s of %s): " % (dirname, count +
                                                             1, total + 1)
            if count % 10 == 0:
                Batch()

            path = "%s/%s" % (base_dir, dirname)
            if dirname:
                if dirname.endswith(".zip"):
                    path = "%s.zip" % path
                    dirname = "%s.zip" % dirname

                elif dirname.endswith("%s.zip.enc" % path):
                    path = "%s.zip.enc" % path
                    dirname = "%s.zip.enc" % dirname
            else:
                dirname = transaction_code

            try:
                if not my.verify_dir(path):
                    continue

                # see if this is encrypted
                if dirname.endswith(".zip") or dirname.endswith(".enc"):
                    if not my.ticket:
                        raise Exception(
                            "Could not decrypt encrypted transaction due to missing ticket for [%s]"
                            % path)
                    base_dir = os.path.dirname(path)
                    my.handle_encrypted(base_dir, transaction_code, dirname)
                else:
                    print "Running transaction: [%s]" % transaction_code
                    my.handle_transaction(base_dir, transaction_code,
                                          transaction_code)
            except Exception, e:
                print "... ERROR: could not process transaction [%s]" % transaction_code
                print str(e)
                print

            interval = 0.1
            time.sleep(interval)
예제 #38
0
파일: delete_wdg.py 프로젝트: mincau/TACTIC
    def get_display(self):
        top = self.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("width", "400px")
        top.add_class('spt_delete_stype_top')
        top.add_border()

        project_code = Project.get_project_code()
        # Note search types should only really be deleted if they were just
        # created

        search_type = self.kwargs.get("search_type")
        if not search_type:
            node_name = self.kwargs.get("node_name")
            if node_name:
                #project_code = Project.get_project_code()
                search_type = "%s/%s" % (project_code, node_name)

        assert search_type
        built_in_stypes = ['task','note','work_hour','login','login_group','schema','project','login_in_group','snapshot','file','trigger','spt_trigger','widget_config','custom_script','notification','notification_log','file_access','cache','exception_log','milestone','pipeline','pref_list','pref_setting','project_type','repo','remote_repo','search_sobject','sobject_list','ticket','db_resource','wdg_settings','status_log','debug_log','transaction_log', 'sobject_log']

        for tbl in built_in_stypes:
            if search_type == 'sthpw/%s'%tbl:
                top.add("sType [%s] is internal and cannot be deleted!" % search_type)
                top.add_style("font-size: 14px")
                top.add_style('padding: 20px')
                return top

        search_type_obj = SearchType.get(search_type)
        if not search_type:
            top.add("sType [%s] does not exist!" % search_type)
            top.add_style("font-size: 14px")
            top.add_style('padding: 20px')
            return top
        table = search_type_obj.get_table()

        db_val = search_type_obj.get_value('database')
        if db_val == '{project}':
            label = ''
        elif db_val == 'sthpw':
            label = 'built-in'
        else:
            label = 'project-specific'

        
        # warn if more than 1 sType point to the same table in the same project
        expr = "@GET(sthpw/search_type['table_name', '%s']['database', 'in',  '{project}|%s']['namespace','%s'].search_type)" %(table, project_code, project_code)
        rtn = Search.eval(expr)
        
        warning_msg = ''
        if len(rtn) > 1:
            warning_msg = 'Warning: There is more than 1 sType [%s] pointing to the same table [%s]. Deleting will affect both sTypes.' %(', '.join(rtn), table)
           
        title_wdg = DivWdg()

        top.add(title_wdg)
        title_wdg.add(IconWdg(icon=IconWdg.WARNING))
        title_wdg.add("Delete %s sType: %s" % (label,search_type))
        title_wdg.add_color("background", "background", -10)
        title_wdg.add_style("font-weight: bold")
        title_wdg.add_style("font-size: 14px")


        content = DivWdg()
        top.add(content)
        content.add_style("padding: 10px")

        if warning_msg:
            content.add(DivWdg(warning_msg, css='warning'))
            content.add("<br/>")
        content.add("This sType uses the table \"%s\" to store items.<br/>" % table)


        content.add("<br/>")

        search = Search(search_type)
        count = search.get_count()
        content.add("Number of items in the table: %s<br/>" % count)

        content.add("<br/>")

        search.add_column("id")
        sobjects = search.get_sobjects()

        if sobjects:
            items_search_type = sobjects[0].get_search_type()

            search_ids = [x.get_id() for x in sobjects]

            notes_search = Search("sthpw/note")
            notes_search.add_filters("search_id", search_ids)
            notes_search.add_filter("search_type", items_search_type)
            note_count = notes_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/note')
            content.add(cb)
            content.add(SpanWdg("Number of related notes: %s"% note_count, css='small') )
            content.add(HtmlElement.br())

            tasks_search = Search("sthpw/task")
            tasks_search.add_filters("search_id", search_ids)
            tasks_search.add_filter("search_type", items_search_type)
            task_count = tasks_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/task')
            content.add(cb)
            content.add(SpanWdg("Number of related tasks: %s"% task_count, css='small') )
            content.add(HtmlElement.br())


            snapshots_search = Search("sthpw/snapshot")
            snapshots_search.add_filters("search_id", search_ids)
            snapshots_search.add_filter("search_type", items_search_type)
            snapshot_count = snapshots_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/snapshot')
            content.add(cb)
            content.add(SpanWdg("Number of related snapshots: %s"% snapshot_count, css='small') )
            content.add(HtmlElement.br())

        pipelines_search = Search("sthpw/pipeline")
        pipelines_search.add_filter("search_type", search_type)
        pipeline_count = pipelines_search.get_count()
        cb = CheckboxWdg('related_types')
        cb.set_attr('value','sthpw/pipeline')
        content.add(cb)
        content.add(SpanWdg("Number of related pipelines: %s"% pipeline_count, css='small') )
        content.add(HtmlElement.br(2))




        content.add("<b>WARNING: Deleting the sType will delete all of these items.</b> ")
        content.add("<br/>"*2)
        content.add("Do you wish to continue deleting?")
        content.add("<br/>"*2)

        button_div = DivWdg()
        button_div.add_styles('width: 300px; height: 50px')
        button = ActionButtonWdg(title="Delete")
        button_div.add(button)
        content.add(button_div)
        button.add_style("float: left")

        button.add_behavior( {
        'type': 'click_up',
        'search_type': search_type,
        'cbjs_action': '''
        spt.app_busy.show("Deleting sType");
        var class_name = "tactic.ui.tools.DeleteSearchTypeCmd";
        var ui_top = bvr.src_el.getParent(".spt_delete_stype_top");
        var values = spt.api.Utility.get_input_values(ui_top);
        var kwargs = {
            'search_type': bvr.search_type,
             'values': values
        };
        var server = TacticServerStub.get();
        try {
            server.start({'title': 'Delete sType', 'description': 'Delete sType [' + bvr.search_type + ']'});
            server.execute_cmd(class_name, kwargs);
            var top = bvr.src_el.getParent(".spt_popup");
            spt.pipeline.remove_node(top.stype_node);

            // force a schema save
            spt.named_events.fire_event('schema|save', bvr)
            top.destroy();
            
            server.finish();
        
        }
        catch(e) {
            spt.alert(spt.exception.handler(e));
        }

        spt.app_busy.hide();

        spt.notify.show_message("Successfully deleted sType ["+bvr.search_type+"]");
       
        '''
        } )



        button = ActionButtonWdg(title="Cancel")
        button.add_style("float: left")
        button_div.add(button)
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_popup");
        top.destroy();
        '''
        } )


        return top
예제 #39
0
    def get_display(self):

        top = self.top
        top.add_style("margin: 10px")

        search = Search("config/widget_config")
        search.add_column("view")
        search.add_filter("category", "CustomLayoutWdg")
        search.add_filter("view", "pages.%", op="like")
        sobjects = search.get_sobjects()
        self.pages = SObject.get_values(sobjects, "view")

        top.add("<div style='font-size: 16px'>Select page to load</div>")
        top.add("<hr/>")

        pages_div = DivWdg()
        top.add(pages_div)
        pages_div.add_style("margin: 20px")

        pages_div.add_relay_behavior({
            'type':
            'click',
            'bvr_match_class':
            "spt_user_page_item",
            'cbjs_action':
            '''
            var popup = bvr.src_el.getParent(".spt_popup");
            var activator = popup.activator;

            var page = bvr.src_el.getAttribute("spt_page");

            var top = activator.getParent(".spt_panel_top");
            var content = top.getElement(".spt_panel_content");

            var class_name = 'tactic.ui.panel.CustomLayoutWdg';
            var kwargs = {
                view: page,
            }
            spt.panel.load(content, class_name, kwargs);

            spt.popup.close(popup);


            '''
        })

        if self.pages:
            last_parts = self.pages[0].split(".")[:-1]

        self.pages.sort()

        last_parts = []
        for count, page in enumerate(self.pages):

            page = page.replace(".", "/")

            page_div = DivWdg()
            pages_div.add(page_div)
            page_div.add_class("spt_user_page_item")
            page_div.add_style("padding: 3px")
            page_div.add_class("tactic_hover")
            page_div.add_attr("spt_page", page)
            page_div.add_class("hand")
            page_div.add_style("min-width: 400px")

            new_parts = []
            parts = page.split("/")
            parts = parts[1:]
            index = 0
            for part in parts:
                if index < len(last_parts):
                    last_part = last_parts[index]
                    if part == last_part:
                        part = "<i style='opacity: 0.0'>%s</i>" % part

                index += 1
                new_parts.append(part)
            last_parts = parts

            #parts = ["<b>%s</b>" % x for x in parts]
            display_path = "&nbsp;&nbsp;<i style='opacity: 1.0'>/</i>&nbsp;&nbsp;".join(
                new_parts)

            page_div.add(
                "<div style='margin-right: 10px;display: inline-block; width: 20px; text-align: right'>%s: </div>"
                % count)
            page_div.add(display_path)

        return top
예제 #40
0
    def init(my):

        base_dir = my.base_dir
        if not os.path.exists(base_dir):
            os.makedirs(base_dir)

        dirs = os.listdir(base_dir)

        # skip local transactions
        server_code = Config.get_value("install", "server")
        dir_set = set(dirs)
        for dirname in dirs:
            if dirname.startswith("%sTRANSACTION" % server_code):
                dir_set.remove(dirname)
        dirs = list(dir_set)



        tmp_set = set(dirs)
        dirs_set = set()
        dirs_dict = {}

        for dir in tmp_set:
            if dir.startswith("."):
                continue
            if dir.find("TRANSACTION") == -1:
                continue
            if dir.find("-") != -1:
                parts = dir.split("-")
                code = parts[0]
            else:
                code = dir.replace(".zip", "")
                code = code.replace(".enc", "")
            dirs_set.add(code) 
            dirs_dict[code] = dir

        search = Search("sthpw/transaction_log")
        search.add_filters("code", list(dirs_set))
        search.add_column("code")
        transactions = search.get_sobjects()
        codes = [x.get_code() for x in transactions]
        codes_set = set(codes)

        diff = dirs_set.difference(codes_set)
        diff = list(diff)
        diff.sort()

        total = len(diff)-1
        for count, transaction_code in enumerate(diff):

            dirname = dirs_dict.get(transaction_code)

            # FIXME: there is a memory growth problem.  Batch clears it
            if total > 1:
                print "Processing file [%s] (%s of %s): " % (dirname, count+1,total+1)
            if count % 10 == 0:
                Batch()

            path = "%s/%s" % (base_dir, dirname)
            if dirname:
                if dirname.endswith(".zip"):
                    path = "%s.zip" % path
                    dirname = "%s.zip" % dirname

                elif dirname.endswith("%s.zip.enc" % path):
                    path = "%s.zip.enc" % path
                    dirname = "%s.zip.enc" % dirname
            else:
                dirname = transaction_code



            try:
                if not my.verify_dir(path):
                    continue

                # see if this is encrypted
                if dirname.endswith(".zip") or dirname.endswith(".enc"):
                    if not my.ticket:
                        raise Exception("Could not decrypt encrypted transaction due to missing ticket for [%s]" % path)
                    base_dir = os.path.dirname(path)
                    my.handle_encrypted(base_dir, transaction_code, dirname)
                else:
                    print "Running transaction: [%s]" % transaction_code
                    my.handle_transaction(base_dir, transaction_code, transaction_code)
            except Exception, e:
                print "... ERROR: could not process transaction [%s]" % transaction_code
                print str(e)
                print

            interval = 0.1
            time.sleep(interval)
예제 #41
0
    def get_display(my):
        ''' this does not run do_search'''
        search_type = my.options.get("search_type")
        if search_type:
            my.search_type = search_type

        view = my.options.get("view")
        if view:
            my.view = view

        search_type = my.search_type
        pipeline_name = my.pipeline_name
        sobject_filter = my.sobject_filter


        assert search_type != None

        search = Search(search_type)

        widget = Widget()
        
        div = FilterboxWdg()
        widget.add(div)

       
        my.process_filter = ProcessFilterSelectWdg(label="Process: ", \
            search_type=search_type, css='med', name=my.process_filter_name)
        my.process_filter.set_submit_onchange(False)

        
        # get all of the sobjects related to this task
        taskless_filter = FilterCheckboxWdg('show_taskless_assets', \
            label='Show Taskless Assets', css='small')
        taskless_filter.set_submit_onchange(False)

        # add in the asset filter
        if sobject_filter:
            sobject_filter.alter_search(search)
            div.add(sobject_filter)


        # append the process filter and user filter
        div.add_advanced_filter(my.process_filter)
        

        # add a hint
        hint = HintWdg('You can select a single process or the &lt;&lt; heading &gt;&gt; '\
             'which will select the group of processes it contains.')
                
        div.add_advanced_filter(hint)

        if UserFilterWdg.has_restriction():
            user = Environment.get_user_name()
            my.user_filter = HiddenWdg('user_filter', user) 
            my.user_filter.set_persistence() 
        else:
            # it has a special colunn 'assigned'
            my.user_filter = UserFilterWdg(['user_filter', 'Assigned: '])
            my.user_filter.set_search_column('assigned')
        div.add_advanced_filter(my.user_filter)

        # add the show assets with no task option
        div.add_advanced_filter(taskless_filter)
        
        
        # add the task filter
        my.task_status_filter = TaskStatusFilterWdg()
        div.add_advanced_filter(my.task_status_filter)

        div.add_advanced_filter(HtmlElement.br())
        if search_type == 'prod/shot': 
            shot_filter = SObjectStatusFilterWdg()
            div.add_advanced_filter(shot_filter)
            shot_statuses = shot_filter.get_statuses()
            if shot_statuses:
                search.add_filters("status", shot_filter.get_values() )

        # add search limit
        search_limit = SearchLimitWdg()
        search_limit.set_limit(my.search_limit)
        div.add_bottom(search_limit)


        # only show shots that match the task filter
        if not taskless_filter.is_checked(False):
            # filter out the tasks
            search.add_column("id")
            tmp_sobjects = search.get_sobjects()
            sobjects = []
            if tmp_sobjects:

                # get all of the sobject ids corresponding to these tasks
                tasks = my.get_tasks(tmp_sobjects)
                sobject_ids = SObject.get_values(tasks, "search_id", unique=True)

                search = Search(search_type)
                search.add_filters("id", sobject_ids)
                search_limit.alter_search(search)
                sobjects = search.get_sobjects()

        else:
            search_limit.alter_search(search)
            tmp_sobjects = search.get_sobjects()
            sobjects = tmp_sobjects
            
            
        table = TableWdg(search_type, my.view)
        widget.add(HtmlElement.br())
        table.set_sobjects(sobjects)

        widget.add(table)
        return widget