Exemplo n.º 1
0
def store(request, q):
# if search term is at least three chars long, store in db
    if len(q) > 2:
        term = SearchTerm()
        term.q = q
        term.ip_address = request.META.get('REMOTE_ADDR')
        term.user = None
        if request.user.is_authenticated():
            term.user = request.user
            term.save()
Exemplo n.º 2
0
def store(request, q):
    # if search term is at least three chars long, store in db
    if len(q) > 2:
        term = SearchTerm()
        term.q = q
        term.ip_address = request.META.get('REMOTE_ADDR')
        term.tracking_id = stats.tracking_id(request)
        if request.user.is_authenticated():
            term.user = request.user
        term.save()
Exemplo n.º 3
0
def store(request, q):
    if len(q) > 2:
        term = SearchTerm()
        term.q = q
        term.ip_address = request.META.get('REMOTE_ADDR')
        term.tracking_id = stats.tracking_id(request)
        term.user = None
        if request.user.is_authenticated():
            term.user = request.user
        term.save()
Exemplo n.º 4
0
def store(request, q, matching):
    """ stores the search text """
    # if search term is at least three chars long, store in db
    if len(q) > 1:
        term = SearchTerm()
        term.q = q
        term.ip_address = request.META.get('REMOTE_ADDR')
        term.tracking_id = stats.__tracking_id(request)
        term.user = None
        if request.user.is_authenticated():
            term.user = request.user
        # salvamos para que no nos salga el error: <SearchTerm: inst> need to have a value for field "searchterm"
        # before this many-to-many relationship can be used.
        term.save()
        for match in matching:
            term.found_products.add(match)