forked from p15670423/monkey
island: Separate `island_mode_service.py` to separate files for get and
set mode services
This commit is contained in:
parent
d3de80feed
commit
f1a3e1fc25
|
@ -5,7 +5,8 @@ import flask_restful
|
||||||
from flask import make_response, request
|
from flask import make_response, request
|
||||||
|
|
||||||
from monkey_island.cc.resources.auth.auth import jwt_required
|
from monkey_island.cc.resources.auth.auth import jwt_required
|
||||||
from monkey_island.cc.services.mode.island_mode_service import ModeNotSetError, get_mode, set_mode
|
from monkey_island.cc.services.mode.get_island_mode_service import ModeNotSetError, get_mode
|
||||||
|
from monkey_island.cc.services.mode.set_island_mode_service import set_mode
|
||||||
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
|
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
from monkey_island.cc.models.island_mode_model import IslandMode
|
from monkey_island.cc.models.island_mode_model import IslandMode
|
||||||
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
|
|
||||||
|
|
||||||
|
|
||||||
def set_mode(mode: IslandModeEnum):
|
|
||||||
island_mode_model = IslandMode()
|
|
||||||
island_mode_model.mode = mode.value
|
|
||||||
island_mode_model.save()
|
|
||||||
|
|
||||||
|
|
||||||
def get_mode() -> str:
|
def get_mode() -> str:
|
|
@ -0,0 +1,10 @@
|
||||||
|
from monkey_island.cc.models.island_mode_model import IslandMode
|
||||||
|
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
|
||||||
|
from monkey_island.cc.services.config import ConfigService
|
||||||
|
|
||||||
|
|
||||||
|
def set_mode(mode: IslandModeEnum):
|
||||||
|
island_mode_model = IslandMode()
|
||||||
|
island_mode_model.mode = mode.value
|
||||||
|
island_mode_model.save()
|
||||||
|
ConfigService.update_config_on_mode_set(mode.value)
|
Loading…
Reference in New Issue