first commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
from flask import render_template, request, redirect, url_for, abort
|
||||
|
||||
import db
|
||||
|
||||
from core.flask_app import app
|
||||
|
||||
|
||||
@app.route("/game/<slug>/objects/<int:definition_id>/edit", methods=["GET", "POST"])
|
||||
def object_edit(slug, definition_id):
|
||||
game = db.game_meta(slug)
|
||||
definition = db.get_definition(slug, definition_id)
|
||||
if not definition:
|
||||
abort(404)
|
||||
existing_definitions = [d for d in db.list_definitions(slug) if d["id"] != definition_id]
|
||||
|
||||
if request.method == "POST":
|
||||
new_name = request.form.get("object_name", "").strip()
|
||||
if new_name and new_name != definition["name"]:
|
||||
db.rename_definition(slug, definition_id, new_name)
|
||||
return redirect(url_for("object_edit", slug=slug, definition_id=definition_id))
|
||||
|
||||
return render_template(
|
||||
"object_edit.html",
|
||||
game=game,
|
||||
definition=definition,
|
||||
existing_definitions=existing_definitions,
|
||||
field_types=db.FIELD_TYPES,
|
||||
)
|
||||
Reference in New Issue
Block a user