Beispiel #1
0
from flask import *
from flask.ext.login import current_user

from parse import normalize
from search import get_searches, search_for
from models.search import Found, Search
from models.car import Car
from forms import ListingForm

listings = Blueprint('listings', __name__)

# Used to make the settings dropdown faster
MAKES = [car.make for car in Car.objects().order_by('make')]
print "Ready"


@listings.route('/landing/', methods=['GET'])
@listings.route('/landing/<string:search>/<int:page>', methods=['GET'])
def landing(search=None, page=0):
    """ Listings page """

    # If there is no search, get the first on off the list
    if current_user.is_anonymous():
        searches = []
    else:
        searches = Search.related(current_user.pk)

    if not search:
        if len(searches) > 0:
            for i in xrange(len(searches)):
                if searches[i].make:
Beispiel #2
0
def get_cars():

  # Reverse query
  cars = Car.objects()
  json_data = cars.to_json()
  return { 'cars' : json.loads(json_data) }
Beispiel #3
0
        if word in CONDITION:
            search.condition = word

        if word in BODYSTYLE:
            search.bodystyle = word

        if word in SPECIALS['P']:
            preposition = word

        preceeding_word = word

        if word in MAKESLANG:
            word = MAKESLANG[ word ]


        cars = Car.objects( make_normal__startswith = word )
        for car in cars:
            if car.make_normal == word:
                search.make = car.make
            elif car.make_normal.startswith( word ):
                make = word + ' ' + words[w+1]
                if car.make_normal == make:
                    search.make = car.make

        cars = Car.objects( models__model_normal__startswith = word )
        if len( cars ) == 1:
            if not search.make:
                search.make = cars[0].make

            if search.make == cars[0].make:
                model = cars[0].get_model( word )