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')
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."