必要なもの一覧
イベント参加許可画面
patic.html
<!DOCTYPE html> <html lang="jp"> <head> <meta charset="UTF-8"> <title>Patic - 参加管理</title> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="description" content="pythonとdeta.spaceのサンプルページです" > <meta name="keywords" content="プログラム,教育,python,deta.space,bootstrap,flask" > <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/style.css')}}"> </head> <body> <div class="container"> <nav class="navbar w-100 navbar-expand-sm navbar-dark bg-dark" aria-label="Third navbar example"> <div class="container-fluid"> <a class="navbar-brand" href="#">Event Photos</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarsExample03" aria-controls="navbarsExample03" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarsExample03"> <ul class="navbar-nav me-auto mb-2 mb-sm-0"> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="/">Home</a> </li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="dropdown03" data-bs-toggle="dropdown" aria-expanded="false">操作</a> <ul class="dropdown-menu" aria-labelledby="dropdown03"> <li><a class="dropdown-item" href="/event">イベント追加</a></li> <li><a class="dropdown-item" href="/logout">ログアウト</a></li> </ul> </li> </ul> </div> </div> </nav> <main> <div id="wrapper"> <header class="d-flex justify-content-end"> <p>ID: {{id}} </p> </header> <div class="py-5 text-center"> <h2>イベント参加希望</h2> <p class="lead">あなたのイベントへの参加希望です。許可、拒否などの管理をしてください。</p> </div> <div class="row"> <div class="col-md-12 col-lg-12"> <h4 class="mb-2">イベント情報</h4> <form action="/patic" method="POST" > <p class="text-danger">{{errmess}}</p> <div class="row g-3"> <div class="col-12"> <label for="eventname" class="form-label">イベント名</label> <input type="eventname" value="{{pdata.items[0].eventname}}" class="form-control" name="eventname" disabled> </div> <div class="col-12"> <label for="eventid" class="form-label">申請者ID</label> <input type="text" value="{{pdata.items[0].userid}}" class="form-control" name="eventid" disabled> </div> <div class="col-12"> <label for="rmemo" class="form-label">申請メモ</label> <input type="text" value="{{pdata.items[0].rmemo}}" class="form-control" name="rmemo" placeholder="イベント代表へのメモです" disabled> </div> <input type="hidden" value="{{pdata.items[0].userid}}" name="fromid"> <input type="hidden" value="{{pdata.items[0].key}}" name="pkey"> <input type="hidden" value="{{pdata.items[0].eventid}}" name="ekey"> <button class="w-100 btn btn-primary btn-lg" type="submit" name="accept" value="accept">許可</button> <button class="w-100 btn btn-danger btn-lg" type="submit" name="ban" value="ban">拒否</button> <button class="w-100 btn btn-secondary btn-lg" type="submit" name="cancel" value="cancel">キャンセル</button> </div> </form> </div> </div> </div> </main> </div> <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script> </body> </html>
許可しても、拒否しても一覧から消えます
main イベント参加許可部分
main.py(抜粋)
@app.route("/patic/<pkey>/<fromid>", methods = ["GET"]) def sendPatic(pkey,fromid): # 許可の入り if "id" in session: patic = paticip.Paticip() pdata = patic.getRequest({"key":pkey}) return render_template("patic.html", id=session["id"],pdata=pdata) else: return render_template("login.html") @app.route("/patic", methods = ["POST"]) def postPatic(): # 許可の保存 if "id" in session: fromid = request.form.get("fromid") pkey = request.form.get("pkey") ekey = request.form.get("ekey") patic = paticip.Paticip() if request.form.get("accept"): #許可 events = event.Event() edataorg = events.getEvent({"key":ekey}) paticList = edataorg.items[0]["paticip"] #許可追加 if not fromid in paticList: paticList.append(fromid) events.updateEvent(ekey, session["id"], edataorg.items[0]["eventname"], edataorg.items[0]["firstDay"], edataorg.items[0]["limitdate"], edataorg.items[0]["comment"], edataorg.items[0]["email"], paticList) patic.deleteRequest(pkey) elif request.form.get("ban"): patic.deleteRequest(pkey) return redirect(url_for("top")) else: return render_template("login.html")
許可画面の表示のデータをsendPaticで行い、postされたデータをpostPaticで処理しています。許可されたIDは各イベントのpaticipリストに追加されます。