예제 #1
0
파일: views.py 프로젝트: lsimons/recipeer
def random_recipe(request):
    recipe, details, total_price, total_calories = recipeer.random_recipe()
    ctx = {
        'recipe': recipe,
        'details': details,
        'total_price': total_price,
        'total_calories': total_calories
    }
    content = simplejson.dumps(ctx, indent=4)
    return HttpResponse(content, content_type='application/json')
예제 #2
0
def random_recipe(request):
    recipe, details, total_price, total_calories = recipeer.random_recipe()
    ctx = {
        'recipe': recipe,
        'details': details,
        'total_price': total_price,
        'total_calories': total_calories
    }
    content = simplejson.dumps(ctx, indent=4)
    return HttpResponse(content, content_type='application/json')
예제 #3
0
    def act(self, force=False):
        state = self.get("/1/weavr/state/")
        if not state["awake"]:
            return "Not posting recipe, asleep"

        try:
            recipe, details, total_price, total_calories = recipeer.random_recipe()
            details_model = models.MealDetails(weavr_token=self.token, cost=total_price, calories=total_calories)
            details_model.save()
        except recipeer.NoIngredientsException, e:
            return "No ingredients could be found matching recipe."