Add controller for new events.
This commit is contained in:
23
app.py
23
app.py
@@ -314,6 +314,29 @@ def episode_edit(season_id: int, episode_id: int):
|
|||||||
@app.route("/seasons/<season_id>/episodes/<episode_id>/events/new", methods=["GET"])
|
@app.route("/seasons/<season_id>/episodes/<episode_id>/events/new", methods=["GET"])
|
||||||
@authorize
|
@authorize
|
||||||
def event_new(season_id: int, episode_id: int):
|
def event_new(season_id: int, episode_id: int):
|
||||||
|
model = {
|
||||||
|
"page_title": "New Event",
|
||||||
|
"form_title": "Create New Event",
|
||||||
|
"post_url": f"/seasons/{season_id}/episodes/{episode_id}/events/null/edit",
|
||||||
|
}
|
||||||
|
|
||||||
|
return render_template("event_editor.html", model=model)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route(
|
||||||
|
"/seasons/<season_id>/episodes/<episode_id>/events/<event_id>/edit",
|
||||||
|
methods=["GET", "POST"],
|
||||||
|
)
|
||||||
|
@authorize
|
||||||
|
def event_edit(season_id: int, episode_id: int, event_id: int):
|
||||||
|
model = {
|
||||||
|
"page_title": "Edit Event",
|
||||||
|
"form_title": "Edit Event",
|
||||||
|
"post_url": f"/seasons/{season_id}/episodes/{episode_id}/events/{event_id}/edit"
|
||||||
|
}
|
||||||
|
if request.method == "GET":
|
||||||
|
return render_template("event_editor.html", model=model)
|
||||||
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
25
templates/event_editor.html
Normal file
25
templates/event_editor.html
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% import "bootstrap/wtf.html" as wtf %}
|
||||||
|
{% set active_page = "seasons" %}
|
||||||
|
{% block title %}{{ model.page_title }} {{ super() }}{% endblock %}
|
||||||
|
|
||||||
|
{% block page %}
|
||||||
|
<div class="text-center">
|
||||||
|
<h1>{{ model.form_title }}</h1>
|
||||||
|
|
||||||
|
{% if model.errors %}
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
{% for field, errors in model.errors.items() %}
|
||||||
|
<div>
|
||||||
|
<strong class="text-capitalize">{{ field }}</strong>:
|
||||||
|
{{ errors|join(', ') }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<form action="{{ model.post_url }}" method="post">
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user