Commit 8ab17e72 authored by Cédric Bonhomme's avatar Cédric Bonhomme
Browse files

Is is now possible to specify a list of condition for each restaurant.

parent 38ff9066
......@@ -14,6 +14,11 @@ def quick():
import datetime
return datetime.datetime.today().weekday() == 4
def not_on_fridays():
"""
"""
return not quick()
def rain():
"""
This test can be used for the 'Chambre de Commerce' because it is far from us.
......
......@@ -3,7 +3,8 @@
"name":"Vapiano",
"url":"",
"coordinates":"",
"comment":"Partir vers 11:45."
"comment":"Partir vers 11:45.",
"condition":"not_on_fridays"
},
{
"name":"Quick",
......@@ -16,56 +17,66 @@
"name":"Chambre de commerce",
"url":"http://www.cc.lu/autres-services/restaurant-la-table-de-mercure/",
"coordinates":"",
"condition":"rain"
"condition":"rain;not_on_fridays"
},
{
"name":"EXKi",
"url":"",
"coordinates":""
"coordinates":"",
"condition":"not_on_fridays"
},
{
"name":"L'Antica-Roma",
"url":"",
"coordinates":""
"coordinates":"",
"condition":"not_on_fridays"
},
{
"name":"La Perla",
"url":"http://www.coque.lu/en/page/la-perla",
"coordinates":""
"coordinates":"",
"condition":"not_on_fridays"
},
{
"name":"Coyote",
"url":"http://www.resto.lu/fr/Luxembourg/restaurant.cfm?restaurant=5724",
"coordinates":""
"coordinates":"",
"condition":"not_on_fridays"
},
{
"name":"Aujourd'hui c'est Sushi",
"url":"http://www.sushishop.lu",
"coordinates":""
"coordinates":"",
"condition":"not_on_fridays"
},
{
"name":"Mercedes",
"url":"",
"coordinates":""
"coordinates":"",
"condition":"not_on_fridays"
},
{
"name":"repas tire du sac alias 'gamelle'",
"url":"",
"coordinates":"DTC"
"coordinates":"DTC",
"condition":"not_on_fridays"
},
{
"name":"Chillers",
"url":"http://www.chillers-nk.de/",
"coordinates":""
"coordinates":"",
"condition":"not_on_fridays"
},
{
"name":"Asie Gourmande",
"url":"http://www.resto.lu/fr/Luxembourg/restaurant.cfm?restaurant=5497",
"coordinates":"Auchan"
"coordinates":"Auchan",
"condition":"not_on_fridays"
},
{
"name":"Tie Break",
"url":"http://www.resto.lu/fr/Luxembourg/restaurant.cfm?restaurant=10746",
"coordinates":""
"coordinates":"",
"condition":"not_on_fridays"
}
]
......@@ -10,9 +10,11 @@ from refuge import app, restaurants
@app.route('/', methods=['GET'])
def index():
currently_available_restaurants = [dict((k , v) for k,v in restaurant.items() if k != "condition") \
for restaurant in restaurants \
if getattr(conditions, restaurant.get("condition", "default"))()]
currently_available_restaurants = [ dict((k , v) for k,v in restaurant.items() if k != "condition") \
for restaurant in restaurants \
if \
all([getattr(conditions, condition)() for condition in restaurant.get("condition", "default").split(";") if hasattr(conditions, condition)])==True
]
return jsonify(random.choice(currently_available_restaurants))
@app.errorhandler(404)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment