当前位置: 首页>>代码示例>>Python>>正文


Python Search.add_user_filter方法代码示例

本文整理汇总了Python中pyasm.search.Search.add_user_filter方法的典型用法代码示例。如果您正苦于以下问题:Python Search.add_user_filter方法的具体用法?Python Search.add_user_filter怎么用?Python Search.add_user_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasm.search.Search的用法示例。


在下文中一共展示了Search.add_user_filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_user_filter [as 别名]
    def execute(my):
        my.init()

        # create the filters
        my.filters = []
        """
        for element_name in my.config.get_element_names():
            
            filter = my.config.get_display_widget(element_name)
            my.filters.append(filter)

        # make sure there is at least one filter defined
        assert my.filters

        """
        config = "<config>\n"
        config += "<filter>\n"

        # get all of the serialized versions of the filters
        """
        for filter in my.filters:
            config += filter.serialize() + "\n"
        """
        filter_data = FilterData.get()
        json = filter_data.serialize()
        value_type = "json"
        config += "<values type='%s'>%s</values>\n" % (value_type, json)
        config += "</filter>\n"
        config += "</config>\n"

        # format the xml
        xml = Xml()
        xml.read_string(config)

        if not my.view:
            saved_view = "saved_search:%s" % my.search_type
        else:
            saved_view = my.view
        #    if my.view.startswith("saved_search:"):
        #        saved_view = my.view
        #    else:
        #        saved_view = "saved_search:%s" % my.view

        # use widget config instead
        search = Search("config/widget_config")
        search.add_filter("view", saved_view)
        search.add_filter("search_type", my.search_type)
        if my.personal:
            search.add_user_filter()
        config = search.get_sobject()

        if not config:
            config = SearchType.create("config/widget_config")
            config.set_value("view", saved_view)
            config.set_value("search_type", my.search_type)
            if my.personal:
                config.set_user()

        config.set_value("config", xml.to_string())
        config.commit()
开发者ID:raidios,项目名称:TACTIC,代码行数:62,代码来源:search_wdg.py

示例2: get_subscriptions

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_user_filter [as 别名]
    def get_subscriptions(my, category, mode="new"):

        search = Search("sthpw/subscription")
        search.add_user_filter()
        if category:
            search.add_filter("category", category)



        if mode == "new":
            search.add_op("begin")
            search.add_filter("last_cleared", '"message"."timestamp"', quoted=False, op="<")
            search.add_filter("last_cleared", "NULL", quoted=False, op="is")
            search.add_op("or")


            #project_code = Project.get_project_code()
            #search.add_filter("project_code", project_code )

            # use an inner join because if there are no messages, we don't
            # want the subscription
            search.add_order_by("message.timestamp", direction="desc", join="INNER")

            # don't show user message except when category is certain values
            user = Environment.get_user_name()
            search.add_op("begin")
            search.add_filter("login", user, op="!=", table="message")
            search.add_filters("category", ["script","default","sobject"], table="message")
            search.add_op("or")
        else:
            search.add_order_by("message.timestamp", direction="desc")

        subscriptions = search.get_sobjects()

        return subscriptions
开发者ID:hellios78,项目名称:TACTIC,代码行数:37,代码来源:message_wdg.py

示例3: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_user_filter [as 别名]
    def get_display(my):
        sobject = my.get_current_sobject()
        key = sobject.get_value("key")
        options = sobject.get_value("options")
        type = sobject.get_value("type")

        # get the value of the users preferences
        search = Search("sthpw/pref_setting")
        search.add_user_filter()
        search.add_filter("key", key)
        pref_setting = search.get_sobject()
        if pref_setting:
            value = pref_setting.get_value("value")
        else:
            value = ""

        div = DivWdg()

        element_name = "%s_%s" % (my.get_name(), sobject.get_id() )
      
        script = '''var server = TacticServerStub.get();
                var value = bvr.src_el.value;
                if (!value) return;

                spt.app_busy.show("Saving", "Saving Preference for [%s]");

                setTimeout( function() {
                    try{
                        server.execute_cmd('tactic.ui.table.SetPreferenceCmd', {key: '%s', value: value});
                    }catch(e){
                        spt.alert(spt.exception.handler(e));
                    }
                        
                    spt.app_busy.hide() 
                        
                    }, 200);'''%(key, key)

        if key in ['skin', 'palette', 'js_logging_level']:
            script = '''%s; spt.app_busy.show('Reloading Page ...'); setTimeout('spt.refresh_page()', 200);'''%script

        if type == "sequence":
            from pyasm.prod.web import SelectWdg
            select = SelectWdg(element_name)
            select.add_behavior({'type': "change", 
                'cbjs_action': script})

            select.set_option("values",options)
            if value:
                select.set_value(value)
            div.add(select)
        else:
            text = TextWdg(element_name)
            text.add_behavior({'type': "blur", 
                'cbjs_action': script})
            if value:
                text.set_value(value)
            div.add(text)
     
        return div
开发者ID:0-T-0,项目名称:TACTIC,代码行数:61,代码来源:preference_wdg.py

示例4: get_count

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_user_filter [as 别名]
 def get_count(cls, where=None, category=None):
     search = Search(Clipboard)
     search.add_user_filter()
     if not category:
         search.add_filter("category","select")
     if where:
         search.add_where(where)
     return search.get_count()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:10,代码来源:clipboard.py

示例5: clear_selected

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_user_filter [as 别名]
    def clear_selected(cls):
        # make sure the sobjects exist
        search = Search("sthpw/clipboard")
        search.add_filter("category", "select")
        search.add_user_filter()
        items = search.get_sobjects()

        for item in items:
            item.delete()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:11,代码来源:clipboard.py

示例6: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_user_filter [as 别名]
    def execute(self):
        category = "select"
        search = Search("sthpw/clipboard")
        search.add_filter("category", category)
        search.add_user_filter()
        clipboards = search.get_sobjects()
        for item in clipboards:
            item.delete()

        self.description = "Cleared %s items from clipboard" % len(clipboards)
开发者ID:mincau,项目名称:TACTIC,代码行数:12,代码来源:clipboard_wdg.py

示例7: check_unique

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_user_filter [as 别名]
 def check_unique(my):
     search = Search('config/widget_config')
     search.add_filter("view", my.view)
     search.add_filter("search_type", my.search_type)
     search.add_user_filter()
     config_sobj = search.get_sobject()
     if config_sobj and my.unique:
         view = my.view.replace('link_search:', '')
         raise UserException('This view [%s] already exists' %view)
     return True
开发者ID:hellios78,项目名称:TACTIC,代码行数:12,代码来源:search_wdg.py

示例8: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_user_filter [as 别名]
    def get_display(self):
        # set up the self refresh event for other widgets or callbacks to call
        event_container = WebContainer.get_event_container()
        script = ClipboardWdg.get_self_refresh_script(show_progress=False)
        event_container.add_listener(self.EVENT_ID, script, replace=True )

        if self.is_from_ajax():
            div = Widget()
        else:
            div = DivWdg()
            div.set_id(self.ID)
            div.add_style("display: block")
            div.add_class("background_box")
            div.add_style("padding-left: 3px")
            div.add_style("padding-right: 3px")
            div.add_style("height: 1.5em")
            div.add_style("width: 150px")

        # handle the ajax
        self.set_ajax_top_id(self.ID)
        self.register_cmd(ClipboardClearCbk)
        refresh_script = self.get_refresh_script()

        search = Search("sthpw/clipboard")
        search.add_user_filter()
        search.add_filter("category", "select")
        count = search.get_count()

        div.add("Clipboard: %s items: " % count)


        web = WebContainer.get_web()
        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.widget.ClipboardListWdg")
        ref = url.to_string()

        iframe = WebContainer.get_iframe()
        iframe.set_width(64)
        action = iframe.get_on_script(ref)
       
        button = IconButtonWdg("View Clipboard", IconWdg.LOAD)
        button.add_event("onclick", action)
        div.add(button)



        # add the clear clipboard icon
        clear_icon = IconButtonWdg("Clear Clipboard", IconWdg.CLEAR)
        clear_icon.add_event("onclick", refresh_script)

        div.add(clear_icon)

        return div
开发者ID:mincau,项目名称:TACTIC,代码行数:55,代码来源:clipboard_wdg.py

示例9: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_user_filter [as 别名]
    def execute(self):
        self.init()

        # create the filters
        self.filters = []

        config = "<config>\n"
        config += "<filter>\n"

        # get all of the serialized versions of the filters
        filter_data = FilterData.get()
        json = filter_data.serialize()
        value_type = "json"
        config += "<values type='%s'>%s</values>\n" % (value_type, json)
        config += "</filter>\n"
        config += "</config>\n"
        

        # format the xml
        xml = Xml()
        xml.read_string(config)


        if not self.view:
            saved_view = "saved_search:%s" % self.search_type
        else:
            saved_view = self.view
        #    if self.view.startswith("saved_search:"):
        #        saved_view = self.view
        #    else:
        #        saved_view = "saved_search:%s" % self.view

        # use widget config instead
        search = Search('config/widget_config')
        search.add_filter("view", saved_view)
        search.add_filter("search_type", self.search_type)
        if self.personal:
            search.add_user_filter()
        config = search.get_sobject()

        if not config:
            config = SearchType.create('config/widget_config')
            config.set_value("view", saved_view)
            config.set_value("search_type", self.search_type)
            if self.personal:
                config.set_user()

        config.set_value("category", "search_filter")
        config.set_value("config", xml.to_string())
        config.commit()
开发者ID:mincau,项目名称:TACTIC,代码行数:52,代码来源:search_wdg.py

示例10: get_last_filter_config

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_user_filter [as 别名]
    def get_last_filter_config(search_type):

        # get the last search
        view = "saved_search:%s" % search_type

        search = Search('config/widget_config')
        search.add_filter("view", view)
        search.add_filter("search_type", search_type)
        search.add_user_filter()
        config_sobj = search.get_sobject()
        config = None
        if config_sobj:
            config_xml = config_sobj.get_xml_value("config")
            config = WidgetConfig.get(xml=config_xml, view='filter')
        return config
开发者ID:hellios78,项目名称:TACTIC,代码行数:17,代码来源:search_wdg.py

示例11: get_selected

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_user_filter [as 别名]
    def get_selected(cls):
        # make sure the sobjects exist
        search = Search("sthpw/clipboard")
        search.add_filter("category", "select")
        search.add_user_filter()
        items = search.get_sobjects()

        parents = []
        for item in items:
            parent = item.get_parent()
            if parent:
                parents.append(parent)
            else:
                print "WARNING: parent to clipboard item [%s] does not exist" % item.get_code()
        return parents
开发者ID:0-T-0,项目名称:TACTIC,代码行数:17,代码来源:clipboard.py

示例12: _get_cache

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_user_filter [as 别名]
    def _get_cache(cls, category):
        '''preselect all the clipboard items of a particular category'''

        key = "clipboard:%s" % category
        clipboard_cache = Container.get(key)
        if clipboard_cache == None:
            clipboard_cache = {}
            Container.put(key, clipboard_cache)
        else:
            return clipboard_cache

        search = Search(Clipboard)
        search.add_user_filter()
        search.add_filter("category","select")
        items = search.get_sobjects()

        for item in items:
            search_type = item.get_value("search_type")
            search_id = item.get_value("search_id")
            search_key = "%s|%s" % (search_type, search_id)

            clipboard_cache[search_key] = item

        return clipboard_cache
开发者ID:0-T-0,项目名称:TACTIC,代码行数:26,代码来源:clipboard.py

示例13: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_user_filter [as 别名]
    def get_display(my):

        top = my.top;
        my.set_as_panel(top)
        top.add_class("spt_chat_top")


        inner = DivWdg()
        top.add(inner)
        inner.add_behavior( {
            'type': 'load',
            'cbjs_action': MessageWdg.get_onload_js()
        } )



        search = Search("sthpw/subscription")
        search.add_filter("category", "chat")
        search.add_user_filter()
        chats = search.get_sobjects()
        keys = [x.get_value("message_code") for x in chats]

        chat_list_div = DivWdg()
        chat_list_div.add("<b>Chat Sessions</b><br/>")
        inner.add(chat_list_div)
        for chat in chats:
            chat_div = DivWdg()
            chat_list_div.add(chat_div)

            # find all the users with the same chat
            key = chat.get_value("message_code")
            chat_div.add(key)

            search = Search("sthpw/subscription")
            search.add_filter("message_code", key)
            subscriptions = search.get_sobjects()
            users = [x.get_value("login") for x in subscriptions]
            chat_div.add(" : ")
            chat_div.add(users)

            chat_div.add_behavior( {
                'type': 'click_up',
                'key': key,
                'cbjs_action': '''
                var class_name = 'tactic.ui.app.ChatSessionWdg';
                var kwargs = {
                    'key': bvr.key,
                }
                spt.panel.load_popup("Chat: " + bvr.key, class_name, kwargs);

                '''
            } )



        #keys = my.kwargs.get("keys")
        #if not keys:
        #    return

        inner.add( my.get_add_chat_wdg() )

        for key in keys:
            session_div = DivWdg()
            session_div.add_style("width: 400px")
            inner.add(session_div)
            session_div.add_style("float: left")
            session_div.add_style("margin: 15px")

            session = ChatSessionWdg(key=key)
            session_div.add(session)

        inner.add("<br clear='all'/>")

        if my.kwargs.get("is_refresh") == 'true':
            return inner
        else:
            return top
开发者ID:hellios78,项目名称:TACTIC,代码行数:79,代码来源:message_wdg.py

示例14: preprocess

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_user_filter [as 别名]
    def preprocess(my):
        my.preprocessed = True
        my.today = datetime.date.today()
        wday = int(my.today.strftime("%w"))

        web = WebContainer.get_web()
        start_date = web.get_form_value('start_date')
        web_data = web.get_form_value('web_data')

        if web_data:
            web_data = jsonloads(web_data)
        workhour_data = None
        if web_data:
            web_data = web_data[0]
            workhour_data = web_data.get('workhour_data')
        if start_date:
            start_date = my._get_date_obj(start_date)
        elif workhour_data:
            workhour_data = jsonloads(workhour_data)
            start_date = workhour_data.get('start_date')
            start_date = my._get_date_obj(start_date)
        else:
            if my.days_per_page < 7:
                start_date = my.today
            else:
                start_date = my.today - datetime.timedelta(days=wday)
        
        my.start_date = start_date
        end_date = start_date + datetime.timedelta(days=my.days_per_page -1)
        # this may not be necessary any more
        """
        if not my.sobjects:
            sk = my.kwargs.get('search_key')
            task = SearchKey.get_by_search_key(sk)
            my.sobjects = [task]
        """
        task_codes = [x.get_code() for x in my.sobjects]

        search = Search("sthpw/work_hour")
        
        if my.kwargs.get('show_all_users') != 'true':
            
            search.add_user_filter()

        search.add_filter("day", start_date, ">=")
        search.add_filter("day", end_date, "<=")
        search.add_filters("task_code", task_codes)
        entries = search.get_sobjects()
    
        # NOTE:
        # This widget assumes one entry per day.  This is not the case
        # when time for each entry must be recorded and you may have
        # multiple entries per day

        # organize into days
        my.entries = {}
        for entry in entries:
            day = entry.get_value("day")
            if not day:
                continue
            day = parser.parse(day)
            day = day.strftime("%Y_%m_%d")

            task_code = entry.get_value("task_code")
            task_entries = my.entries.get(task_code)
            if task_entries == None:
                task_entries = {}
                my.entries[task_code] = task_entries
          
            entry_list = task_entries.get(day)
            if entry_list == None:
                entry_list = []
                task_entries[day] = entry_list
            entry_list.append(entry)
        
        # break into 2 categories
        for key, sub_dict in my.entries.items():
            if my.use_straight_time:
                for key2, entry_list in sub_dict.items():
                    entry_list_dict = {my.OT: [], my.ST: []}
                    for entry in entry_list:
                        if entry.get_value('category') == my.OT:
                            entry_list_dict[my.OT].append(entry)
                        elif entry.get_value('category') == my.ST:
                            entry_list_dict[my.ST].append(entry)
                        else: 
                            # in case they haven't run the upgrade script 
                            # (potentially include some custom-entered category) 
                            entry_list_dict[my.ST].append(entry)

                    sub_dict[key2] = entry_list_dict
        
            else:
                for key2, entry_list in sub_dict.items():
                    entry_list_dict = {my.STT: [], my.ENT: []}
                    for entry in entry_list:
                        entry_list_dict[my.STT].append(entry)
                        entry_list_dict[my.ENT].append(entry)

                    sub_dict[key2] = entry_list_dict
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:103,代码来源:work_hours_element_wdg.py

示例15: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_user_filter [as 别名]
    def get_display(my):

        top = my.top;
        my.set_as_panel(top)
        top.add_class("spt_chat_top")


        inner = DivWdg()
        top.add(inner)
        inner.add_behavior( {
            'type': 'load',
            'cbjs_action': MessageWdg.get_onload_js()
        } )



        search = Search("sthpw/subscription")
        search.add_filter("category", "chat")
        search.add_user_filter()
        chats = search.get_sobjects()
        keys = [x.get_value("message_code") for x in chats]


        """
        chat_list_div = DivWdg()
        inner.add(chat_list_div)
        for i, chat in enumerate(chats):
            chat_div = DivWdg()
            chat_list_div.add(chat_div)
            chat_div.add_style("padding: 5px")
            chat_div.add_class("hand")

            # find all the users with the same chat
            key = chat.get_value("message_code")
            #chat_div.add(key)
            chat_div.add("#%s: " % i)

            search = Search("sthpw/subscription")
            search.add_filter("message_code", key)
            subscriptions = search.get_sobjects()
            users = [x.get_value("login") for x in subscriptions]
            chat_div.add(", ".join(users))

            chat_div.add_behavior( {
                'type': 'click_up',
                'key': key,
                'cbjs_action': '''
                var class_name = 'tactic.ui.app.ChatSessionWdg';
                var kwargs = {
                    'key': bvr.key,
                }
                spt.panel.load_popup("Chat: " + bvr.key, class_name, kwargs);

                '''
            } )

            chat_div.add_behavior( {
                'type': 'mouseover',
                'cbjs_action': '''
                bvr.src_el.setStyle("color", "#214e75");
                '''
            } )


            chat_div.add_behavior( {
                'type': 'mouseout',
                'cbjs_action': '''
                bvr.src_el.setStyle("color", "");
                '''
            } )
        """



        #keys = my.kwargs.get("keys")
        #if not keys:
        #    return

        inner.add( my.get_add_chat_wdg() )


        inner.add("<br/>")
        

        from tactic.ui.container import TabWdg
        tab = TabWdg(
                show_add=False,
                show_remove=False
        )
        inner.add(tab)

        for key in keys:
            search = Search("sthpw/subscription")
            search.add_filter("message_code", key)
            subscriptions = search.get_sobjects()
            users = [x.get_value("login") for x in subscriptions]
            users = ", ".join(users)

            session_div = DivWdg()
            session_div.set_name(users)
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:103,代码来源:message_wdg.py


注:本文中的pyasm.search.Search.add_user_filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。