@@ 510-531 (lines=22) @@ | ||
507 | ||
508 | return JSONResponse({"response": "enabled"}) |
|
509 | ||
510 | def _disable_napp(self, request: Request) -> JSONResponse: |
|
511 | """Disable an installed NApp.""" |
|
512 | ||
513 | username = request.path_params["username"] |
|
514 | napp_name = request.path_params["napp_name"] |
|
515 | # Check if the NApp is installed |
|
516 | if not self.napps_manager.is_installed(username, napp_name): |
|
517 | return JSONResponse({"response": "not installed"}, |
|
518 | status_code=HTTPStatus.BAD_REQUEST.value) |
|
519 | ||
520 | # Check if the NApp is enabled |
|
521 | if self.napps_manager.is_enabled(username, napp_name): |
|
522 | self.napps_manager.disable(username, napp_name) |
|
523 | ||
524 | # Check if NApp is still enabled |
|
525 | if self.napps_manager.is_enabled(username, napp_name): |
|
526 | # If it is still enabled an admin user must check the log file |
|
527 | status_code = HTTPStatus.INTERNAL_SERVER_ERROR.value |
|
528 | return JSONResponse({"response": "error"}, |
|
529 | status_code=status_code) |
|
530 | ||
531 | return JSONResponse({"response": "disabled"}) |
|
532 | ||
533 | def _install_napp(self, request: Request) -> JSONResponse: |
|
534 | username = request.path_params["username"] |
|
@@ 487-508 (lines=22) @@ | ||
484 | "napps/{username}/{napp_name}/metadata/{key}", |
|
485 | self._get_napp_metadata) |
|
486 | ||
487 | def _enable_napp(self, request: Request) -> JSONResponse: |
|
488 | """Enable an installed NApp.""" |
|
489 | ||
490 | username = request.path_params["username"] |
|
491 | napp_name = request.path_params["napp_name"] |
|
492 | # Check if the NApp is installed |
|
493 | if not self.napps_manager.is_installed(username, napp_name): |
|
494 | return JSONResponse({"response": "not installed"}, |
|
495 | status_code=HTTPStatus.BAD_REQUEST.value) |
|
496 | ||
497 | # Check if the NApp is already been enabled |
|
498 | if not self.napps_manager.is_enabled(username, napp_name): |
|
499 | self.napps_manager.enable(username, napp_name) |
|
500 | ||
501 | # Check if NApp is enabled |
|
502 | if not self.napps_manager.is_enabled(username, napp_name): |
|
503 | # If it is not enabled an admin user must check the log file |
|
504 | status_code = HTTPStatus.INTERNAL_SERVER_ERROR.value |
|
505 | return JSONResponse({"response": "error"}, |
|
506 | status_code=status_code) |
|
507 | ||
508 | return JSONResponse({"response": "enabled"}) |
|
509 | ||
510 | def _disable_napp(self, request: Request) -> JSONResponse: |
|
511 | """Disable an installed NApp.""" |