def get(self, request: Request) -> Response: """Gets recipes view.""" self.logger.debug("Getting recipes view") recipe_objects = models.RecipeModel.objects.all() recipes = [] for recipe_object in recipe_objects: recipes.append(viewers.RecipeViewer(recipe_object)) return Response({"recipes": recipes}, 200)
def get(self, request: Request) -> Response: """Gets recipes view.""" self.logger.debug("Getting recipes view") recipe_objects = models.RecipeModel.objects.all() recipes = [] for recipe_object in recipe_objects: recipes.append(viewers.RecipeViewer(recipe_object)) return Response({"serial_number": os.getenv("SERIAL_NUMBER"), "recipes": recipes}, 200)
def get(self, request: Request) -> Response: """Gets dashboard view.""" self.logger.debug("Getting dashboard view") # Get managers app_config = apps.get_app_config(APP_NAME) coordinator = app_config.coordinator network = coordinator.network recipe = coordinator.recipe # Get current environment state object current_environment = viewers.EnvironmentViewer() # TODO: Fix me! # Get stored recipe objects recipe_objects = models.RecipeModel.objects.all().order_by("name") recipes = [] for recipe_object in recipe_objects: recipes.append(viewers.RecipeViewer(recipe_object)) # Get datetime picker form datetime_form = forms.DateTimeForm() # Build and return response response = { "serial_number": os.getenv("SERIAL_NUMBER"), "manager_modes": coordinator.manager_modes, "manager_healths": coordinator.manager_healths, "current_environment": current_environment, "recipe_mode": recipe.mode, "recipe_name": recipe.recipe_name, "recipe_uuid": recipe.recipe_uuid, "recipe_start_datestring": recipe.start_datestring, "recipe_percent_complete_string": recipe.percent_complete_string, "recipe_time_elapsed_string": recipe.time_elapsed_string, "recipe_time_remaining_string": recipe.time_remaining_string, "recipe_current_phase": recipe.current_phase, "recipe_current_cycle": recipe.current_cycle, "recipe_current_environment_name": recipe.current_environment_name, "recipes": recipes, "datetime_form": datetime_form, "network_is_connected": network.is_connected, } # Return response self.logger.debug("Returning response: {}".format(response)) return Response(response, 200)