コード例 #1
0
ファイル: delapi.py プロジェクト: krondor/Bookie
def tags_complete(request):
    """Complete a tag based on the given text

    :@param tag: GET string, tag=sqlalchemy
    :@param current: GET string of tags we already have python+database

    """
    params = request.GET
    request.response.content_type = 'text/xml'

    if 'current' in params and params['current'] != "":
        current_tags = params['current'].split()
    else:
        current_tags = None

    LOG.debug('current_tags')
    LOG.debug(current_tags)

    if 'tag' in params and params['tag']:
        tag = params['tag']
        tags = TagMgr.complete(tag,
                               current=current_tags,
                               username=request.user.username)

        # we need to escape any html entities in things
        return {'tags': tags}
コード例 #2
0
ファイル: delapi.py プロジェクト: cambot/Bookie
def tags_complete(request):
    """Complete a tag based on the given text

    :@param tag: GET string, tag=sqlalchemy
    :@param current: GET string of tags we already have python+database

    """
    params = request.GET
    request.response.content_type = 'text/xml'

    if 'current' in params and params['current'] != "":
        current_tags = params['current'].split()
    else:
        current_tags = None

    LOG.debug('current_tags')
    LOG.debug(current_tags)

    if 'tag' in params and params['tag']:
        tag = params['tag']
        tags = TagMgr.complete(tag,
                               current=current_tags,
                               username=request.user.username)

        # we need to escape any html entities in things
        return {'tags': tags}
コード例 #3
0
ファイル: api.py プロジェクト: xuanhan863/Bookie
def tag_complete(request):
    """Complete a tag based on the given text

    :@param tag: GET string, tag=sqlalchemy
    :@param current: GET string of tags we already have python+database

    """
    params = request.GET

    if request.user:
        username = request.user.username
    else:
        username = None

    if 'current' in params and params['current'] != "":
        current_tags = params['current'].split()
    else:
        current_tags = None

    if 'tag' in params and params['tag']:
        tag = params['tag']

        tags = TagMgr.complete(tag, current=current_tags, username=username)
    else:
        tags = []

    # reset this for the payload join operation
    if current_tags is None:
        current_tags = []

    return {'current': ",".join(current_tags), 'tags': [t.name for t in tags]}
コード例 #4
0
ファイル: api.py プロジェクト: lmorchard/Bookie
def tag_complete(request):
    """Complete a tag based on the given text

    :@param tag: GET string, tag=sqlalchemy
    :@param current: GET string of tags we already have python+database

    """
    params = request.GET
    username = request.user.username

    if 'current' in params and params['current'] != "":
        current_tags = params['current'].split()
    else:
        current_tags = None

    if 'tag' in params and params['tag']:
        tag = params['tag']

        tags = TagMgr.complete(tag,
                               current=current_tags,
                               username=username)

        # reset this for the payload join operation
        if current_tags is None:
            current_tags = []

    return {
        'current': ",".join(current_tags),
        'tags': [tag.name for tag in tags]
    }
コード例 #5
0
ファイル: test_tagmgr.py プロジェクト: Cfhansen/Bookie
    def test_case_insensitive(self):
        """Suggestion does not care about case of the prefix."""
        # Generate demo tag into the system
        tags = [make_tag() for i in range(5)]
        [DBSession.add(t) for t in tags]

        test_str = tags[0].name[0:4].upper()
        suggestions = TagMgr.complete(test_str)
        ok_(tags[0] in suggestions,
            "The sample tag was found in the completion set")
コード例 #6
0
ファイル: test_tagmgr.py プロジェクト: xuanhan863/Bookie
    def test_case_insensitive(self):
        """Suggestion does not care about case of the prefix."""
        # Generate demo tag into the system
        tags = [make_tag() for i in range(5)]
        [DBSession.add(t) for t in tags]

        test_str = tags[0].name[0:4].upper()
        suggestions = TagMgr.complete(test_str)
        ok_(tags[0] in suggestions,
            "The sample tag was found in the completion set")
コード例 #7
0
ファイル: test_tagmgr.py プロジェクト: Cfhansen/Bookie
    def test_basic_complete(self):
        """Tags should provide completion options."""
        # Generate demo tag into the system
        tags = [make_tag() for i in range(5)]
        [DBSession.add(t) for t in tags]

        test_str = tags[0].name[0:2]
        suggestions = TagMgr.complete(test_str)

        ok_(tags[0] in suggestions,
            "The sample tag was found in the completion set")
コード例 #8
0
ファイル: test_tagmgr.py プロジェクト: xuanhan863/Bookie
    def test_basic_complete(self):
        """Tags should provide completion options."""
        # Generate demo tag into the system
        tags = [make_tag() for i in range(5)]
        [DBSession.add(t) for t in tags]

        test_str = tags[0].name[0:2]
        suggestions = TagMgr.complete(test_str)

        ok_(tags[0] in suggestions,
            "The sample tag was found in the completion set")