feat: 各マスタメンテ画面の側だけ作成

This commit is contained in:
shimoda.m@nds-tyo.co.jp 2023-06-30 15:26:24 +09:00
parent 646dd4f7d9
commit ae6aa29994
8 changed files with 180 additions and 1 deletions

View File

@ -4,8 +4,13 @@ from starlette import status
from src.depends.services import get_service
from src.model.internal.session import UserSession
from src.model.view.inst_emp_csv_download_view_model import \
InstEmpCsvDownloadViewModel
from src.model.view.inst_emp_csv_upload_view_model import \
InstEmpCsvUploadViewModel
from src.model.view.master_mainte_menu_view_model import \
MasterMainteMenuViewModel
from src.model.view.table_override_view_model import TableOverrideViewModel
from src.router.session_router import AuthenticatedRoute
from src.services.batch_status_service import BatchStatusService
from src.services.session_service import set_session
@ -58,3 +63,123 @@ def menu_view(
headers={'session_key': session.session_key}
)
return templates_response
@router.get('/instEmpCsvUL', response_class=HTMLResponse)
def inst_emp_csv_upload_view(
request: Request,
batch_status_service: BatchStatusService = Depends(get_service(BatchStatusService))
):
session: UserSession = request.session
# マスタメンテメニューへのアクセス権がない場合、ログアウトさせる
if session.master_mainte_flg != '1':
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN)
# バッチ処理中の場合、ログアウトさせる
if batch_status_service.is_batch_processing():
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN,
detail=constants.LOGOUT_REASON_BATCH_PROCESSING_FOR_MAINTE)
# dump処理中の場合、ログアウトさせる
if batch_status_service.is_dump_processing():
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail=constants.LOGOUT_REASON_BACKUP_PROCESSING)
# 画面表示用のモデル
view_model = InstEmpCsvUploadViewModel()
# セッション書き換え
session.update(
actions=[
UserSession.last_access_time.set(UserSession.new_last_access_time()),
UserSession.record_expiration_time.set(UserSession.new_record_expiration_time()),
]
)
set_session(session)
templates_response = templates.TemplateResponse(
'instEmpCsvUL.html',
{
'request': request,
'view': view_model
},
headers={'session_key': session.session_key}
)
return templates_response
@router.get('/instEmpCsvDL', response_class=HTMLResponse)
def new_inst_view(
request: Request,
batch_status_service: BatchStatusService = Depends(get_service(BatchStatusService))
):
session: UserSession = request.session
# マスタメンテメニューへのアクセス権がない場合、ログアウトさせる
if session.master_mainte_flg != '1':
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN)
# バッチ処理中の場合、ログアウトさせる
if batch_status_service.is_batch_processing():
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN,
detail=constants.LOGOUT_REASON_BATCH_PROCESSING_FOR_MAINTE)
# dump処理中の場合、ログアウトさせる
if batch_status_service.is_dump_processing():
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail=constants.LOGOUT_REASON_BACKUP_PROCESSING)
# 画面表示用のモデル
view_model = InstEmpCsvDownloadViewModel()
# セッション書き換え
session.update(
actions=[
UserSession.last_access_time.set(UserSession.new_last_access_time()),
UserSession.record_expiration_time.set(UserSession.new_record_expiration_time()),
]
)
set_session(session)
templates_response = templates.TemplateResponse(
'instEmpCsvDL.html',
{
'request': request,
'view': view_model
},
headers={'session_key': session.session_key}
)
return templates_response
@router.get('/tableOverride', response_class=HTMLResponse)
def table_override_view(
request: Request,
batch_status_service: BatchStatusService = Depends(get_service(BatchStatusService))
):
session: UserSession = request.session
# マスタメンテメニューへのアクセス権がない場合、ログアウトさせる
if session.master_mainte_flg != '1':
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN)
# バッチ処理中の場合、ログアウトさせる
if batch_status_service.is_batch_processing():
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN,
detail=constants.LOGOUT_REASON_BATCH_PROCESSING_FOR_MAINTE)
# dump処理中の場合、ログアウトさせる
if batch_status_service.is_dump_processing():
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail=constants.LOGOUT_REASON_BACKUP_PROCESSING)
# 画面表示用のモデル
view_model = TableOverrideViewModel()
# セッション書き換え
session.update(
actions=[
UserSession.last_access_time.set(UserSession.new_last_access_time()),
UserSession.record_expiration_time.set(UserSession.new_record_expiration_time()),
]
)
set_session(session)
templates_response = templates.TemplateResponse(
'tableOverride.html',
{
'request': request,
'view': view_model
},
headers={'session_key': session.session_key}
)
return templates_response

View File

@ -0,0 +1,5 @@
from pydantic import BaseModel
class InstEmpCsvDownloadViewModel(BaseModel):
subtitle: str = '施設担当者データCSVダウンロード'

View File

@ -0,0 +1,5 @@
from pydantic import BaseModel
class InstEmpCsvUploadViewModel(BaseModel):
subtitle: str = '施設担当者データCSVアップロード'

View File

@ -0,0 +1,5 @@
from pydantic import BaseModel
class TableOverrideViewModel(BaseModel):
subtitle: str = 'テーブル上書きコピー'

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="ja">
<head>
{% with subtitle = view.subtitle %}
{% include '_header.html' %}
{% endwith %}
<!-- TODO: CSS変える -->
<link href="/static/css/menuStyle.css" rel="stylesheet" />
</head>
<body>
<h1>施設担当者データCSVダウンロード</h1>
</body>
</html>

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="ja">
<head>
{% with subtitle = view.subtitle %}
{% include '_header.html' %}
{% endwith %}
<!-- TODO: CSS変える -->
<link href="/static/css/menuStyle.css" rel="stylesheet" />
</head>
<body>
<h1>施設担当者データCSVアップロード</h1>
</body>
</html>

View File

@ -10,7 +10,7 @@
<h1>MeDaCA<br/>マスターメンテメニュー</h1>
<br><br>
<!-- 施設担当者データExcelアップロード -->
<a href="/masterMainte/instEmpCSVUL" class="btn btn-primary btn-lg btn_width">施設担当者データCSVアップロード</a><br><br>
<a href="/masterMainte/instEmpCsvUL" class="btn btn-primary btn-lg btn_width">施設担当者データCSVアップロード</a><br><br>
<!-- 施設担当者データCSVダウンロード -->
<a href="/masterMainte/instEmpCsvDL" class="btn btn-primary btn-lg btn_width">施設担当者データCSVダウンロード</a><br><br>

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="ja">
<head>
{% with subtitle = view.subtitle %}
{% include '_header.html' %}
{% endwith %}
<!-- TODO: CSS変える -->
<link href="/static/css/menuStyle.css" rel="stylesheet" />
</head>
<body>
<h1>テーブル上書きコピー</h1>
</body>
</html>