コード例 #1
0
ファイル: spurl.py プロジェクト: hzlf/openbroadcast.org
    def handle_active_mquery(self, value):



        active = None

        query_to_trigger = self.prepare_value(value)
        if isinstance(query_to_trigger, basestring):
            query_to_trigger = QueryString(query_to_trigger).dict
        current_query = self.url.query.dict

        for key, value in query_to_trigger.items():

            # exact match of query -> unset it
            if key in current_query and query_to_trigger[key] == current_query[key]:
                active = True

            # check if current query has multiple items
            try:
                ext = current_query[key]
                ext = ext.split(',')
            except Exception as e:
                ext = None

            if ext and len(ext) > 1:

                if key in current_query and value in ext:
                    active = True

        self.url = active
コード例 #2
0
    def handle_active_mquery(self, value):

        active = None

        query_to_trigger = self.prepare_value(value)
        if isinstance(query_to_trigger, basestring):
            query_to_trigger = QueryString(query_to_trigger).dict
        current_query = self.url.query.dict

        for key, value in query_to_trigger.items():

            # exact match of query -> unset it
            if key in current_query and query_to_trigger[key] == current_query[
                    key]:
                active = True

            # check if current query has multiple items
            try:
                ext = current_query[key]
                ext = ext.split(',')
            except Exception as e:
                ext = None

            if ext and len(ext) > 1:

                if key in current_query and value in ext:
                    active = True

        self.url = active
コード例 #3
0
    def handle_active_query(self, value):
        query_to_toggle = self.prepare_value(value)
        if isinstance(query_to_toggle, basestring):
            query_to_toggle = QueryString(query_to_toggle).dict
        current_query = self.url.query.dict
        for key, value in query_to_toggle.items():

            if key in current_query and value in current_query[key]:
                self.url = True
            else:
                self.url = False
コード例 #4
0
ファイル: spurl.py プロジェクト: hzlf/openbroadcast.org
    def handle_active_query(self, value):
        query_to_toggle = self.prepare_value(value)
        if isinstance(query_to_toggle, basestring):
            query_to_toggle = QueryString(query_to_toggle).dict
        current_query = self.url.query.dict
        for key, value in query_to_toggle.items():

            if key in current_query and value in current_query[key]:
                self.url = True
            else:
                self.url = False
コード例 #5
0
ファイル: spurl.py プロジェクト: leevg/KpiGirls-Redux
 def handle_toggle_query(self, value):
     query_to_toggle = self.prepare_value(value)
     if isinstance(query_to_toggle, six.string_types):
         query_to_toggle = QueryString(query_to_toggle).dict
     current_query = self.url.query.dict
     for key, value in list(query_to_toggle.items()):
         if isinstance(value, six.string_types):
             value = value.split(',')
         first, second = value
         if key in current_query and first in current_query[key]:
             self.url = self.url.set_query_param(key, second)
         else:
             self.url = self.url.set_query_param(key, first)
コード例 #6
0
ファイル: spurl.py プロジェクト: albertkoch/django-spurl
 def handle_toggle_query(self, value):
     query_to_toggle = self.prepare_value(value)
     if isinstance(query_to_toggle, six.string_types):
         query_to_toggle = QueryString(query_to_toggle).dict
     current_query = self.url.query.dict
     for key, value in list(query_to_toggle.items()):
         if isinstance(value, six.string_types):
             value = value.split(',')
         first, second = value
         if key in current_query and first in current_query[key]:
             self.url = self.url.set_query_param(key, second)
         else:
             self.url = self.url.set_query_param(key, first)
コード例 #7
0
    def handle_trigger_query(self, value):
        query_to_trigger = self.prepare_value(value)
        if isinstance(query_to_trigger, basestring):
            query_to_trigger = QueryString(query_to_trigger).dict
        current_query = self.url.query.dict
        for key, value in query_to_trigger.items():

            if isinstance(value, basestring):
                value = value

            if key in current_query and value in current_query[key]:
                # unset
                self.url = self.url.del_query_param(key)
            else:
                # set
                self.url = self.url.set_query_param(key, value)
コード例 #8
0
ファイル: spurl.py プロジェクト: hzlf/openbroadcast.org
    def handle_trigger_query(self, value):
        query_to_trigger = self.prepare_value(value)
        if isinstance(query_to_trigger, basestring):
            query_to_trigger = QueryString(query_to_trigger).dict
        current_query = self.url.query.dict
        for key, value in query_to_trigger.items():

            if isinstance(value, basestring):
                value = value

            if key in current_query and value in current_query[key]:
                # unset
                self.url = self.url.del_query_param(key)
            else:
                # set
                self.url = self.url.set_query_param(key, value)
コード例 #9
0
    def handle_trigger_mquery(self, value):

        query_to_trigger = self.prepare_value(value)
        if isinstance(query_to_trigger, basestring):
            query_to_trigger = QueryString(query_to_trigger).dict
        current_query = self.url.query.dict

        for key, value in query_to_trigger.items():

            # exact match of query -> unset it
            if key in current_query and query_to_trigger[key] == current_query[
                    key]:

                self.url = self.url.del_query_param(key)
                return

            # check if current query has multiple items
            try:
                ext = current_query[key]
                ext = ext.split(',')
            except Exception as e:
                ext = None

            if ext and len(ext) > 1:

                if key in current_query and value in ext:

                    # we have a key-match, so remove it from the string
                    ext = [x for x in ext if x != value]

                else:

                    # no key match, so add it to the string
                    ext.append(value)

                ext.sort()

                self.url = self.url.set_query_param(key, ",".join(ext))

            elif ext and len(ext) == 1:

                # param already here > append
                ext.append(value)
                ext.sort()

                ext = list(set(ext))

                self.url = self.url.set_query_param(key, ",".join(ext))

            else:

                if isinstance(value, basestring):
                    value = value

                if key in current_query and value in current_query[key]:
                    # unset
                    pass
                    #self.url = self.url.del_query_param(key)
                else:
                    # set
                    self.url = self.url.set_query_param(key, value)
コード例 #10
0
ファイル: spurl.py プロジェクト: hzlf/openbroadcast.org
    def handle_trigger_mquery(self, value):

        query_to_trigger = self.prepare_value(value)
        if isinstance(query_to_trigger, basestring):
            query_to_trigger = QueryString(query_to_trigger).dict
        current_query = self.url.query.dict

        for key, value in query_to_trigger.items():

            # exact match of query -> unset it
            if key in current_query and query_to_trigger[key] == current_query[key]:

                self.url = self.url.del_query_param(key)
                return

            # check if current query has multiple items
            try:
                ext = current_query[key]
                ext = ext.split(',')
            except Exception as e:
                ext = None

            if ext and len(ext) > 1:

                if key in current_query and value in ext:

                    # we have a key-match, so remove it from the string
                    ext = [x for x in ext if x != value]

                else:

                    # no key match, so add it to the string
                    ext.append(value)

                ext.sort()

                self.url = self.url.set_query_param(key, ",".join(ext))


            elif ext and len(ext) == 1:

                # param already here > append
                ext.append(value)
                ext.sort()

                ext = list(set(ext))

                self.url = self.url.set_query_param(key, ",".join(ext))


            else:

                if isinstance(value, basestring):
                    value = value

                if key in current_query and value in current_query[key]:
                    # unset
                    pass
                    #self.url = self.url.del_query_param(key)
                else:
                    # set
                    self.url = self.url.set_query_param(key, value)