Example #1
0
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}
Example #2
0
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}
Example #3
0
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]}
Example #4
0
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]
    }
Example #5
0
    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")
Example #6
0
    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")
Example #7
0
    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")
Example #8
0
    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")