Esempio n. 1
0
def get_price(price_name):
    "Looks up the current price for the given cost code."
    price = Price.query(Price.name == price_name).get()

    if not price:
        raise ValueError("Price %s not found." % price_name)

    return price.price
Esempio n. 2
0
def get_price(price_name):
    "Looks up the current price for the given cost code."
    price = Price.query(Price.name == price_name).get()
    
    if not price:
        raise ValueError("Price %s not found." % price_name)
    
    return price.price
Esempio n. 3
0
def GetPrices(prediction_id):
    prices = Price.query(Price.prediction_id == ndb.Key(
        urlsafe=prediction_id)).order(-Price.date).fetch(30)
    print(str(prices))
    prices = [{
        'price': p.value,
        'date': {
            'year': p.date.year,
            'month': p.date.month,
            'day': p.date.day
        }
    } for p in prices]
    return prices
Esempio n. 4
0
def prices_management():
    if request.method == "POST":
        form = CreatePriceForm(request.form)
        if form.validate():
            price = Price(name=form.name.data, price=form.price.data)
            price.put()
    else:
        form = CreatePriceForm()

    existing_prices = Price.query().fetch(100)

    return render_template("admin/prices.html",
                           existing_prices=existing_prices,
                           form=form)
Esempio n. 5
0
def prices_management():
    if request.method == "POST":
        form = CreatePriceForm(request.form)
        if form.validate():
            price = Price(name=form.name.data, price=form.price.data)
            price.put()
    else:
        form = CreatePriceForm()
        
    existing_prices = Price.query().fetch(100)
    
    return render_template("admin/prices.html",
                            existing_prices=existing_prices,
                            form=form)