simple debug feature - edit game json directly
This commit is contained in:
parent
79d6455236
commit
18b796481d
17
lasertube.py
17
lasertube.py
|
@ -117,9 +117,24 @@ def disc_json(id):
|
||||||
disc = g.db.query(models.Disc).filter_by(id=id).one()
|
disc = g.db.query(models.Disc).filter_by(id=id).one()
|
||||||
return json.dumps(models.toJso(disc))
|
return json.dumps(models.toJso(disc))
|
||||||
|
|
||||||
@app.route('/disc/<int:id>/edit/')
|
@app.route('/disc/<int:id>/edit/', methods=['GET', 'POST'])
|
||||||
@requires_login
|
@requires_login
|
||||||
def disc_edit(id):
|
def disc_edit(id):
|
||||||
|
if request.method == 'POST':
|
||||||
|
try:
|
||||||
|
jsoDisc = json.loads(request.form['jsonNew'])
|
||||||
|
if 'qtes' in jsoDisc:
|
||||||
|
g.db.query(models.Qte).filter(models.Qte.disc_id == id).delete()
|
||||||
|
for jsoQte in jsoDisc['qtes']:
|
||||||
|
qte = models.fromJso(jsoQte, models.Qte)
|
||||||
|
qte.disc_id = id
|
||||||
|
g.db.add(qte)
|
||||||
|
g.db.commit()
|
||||||
|
else:
|
||||||
|
raise Exception("Invalid json")
|
||||||
|
except:
|
||||||
|
g.db.rollback()
|
||||||
|
flask.flash("Could not parse json")
|
||||||
return render_disc(id, urlPostQte=flask.url_for('edit_qte', id=id, _external=True), csrf=create_session(id).guid)
|
return render_disc(id, urlPostQte=flask.url_for('edit_qte', id=id, _external=True), csrf=create_session(id).guid)
|
||||||
|
|
||||||
@app.route('/disc/<int:id>/qte/', methods=['POST'])
|
@app.route('/disc/<int:id>/qte/', methods=['POST'])
|
||||||
|
|
|
@ -3,6 +3,7 @@ a, h1, h2 { color: #377BA8; }
|
||||||
h1, h2 { font-family: 'Georgia', serif; margin: 0; }
|
h1, h2 { font-family: 'Georgia', serif; margin: 0; }
|
||||||
h1 { border-bottom: 2px solid #eee; }
|
h1 { border-bottom: 2px solid #eee; }
|
||||||
h2 { font-size: 1.2em; }
|
h2 { font-size: 1.2em; }
|
||||||
|
textarea { width: 100%;}
|
||||||
|
|
||||||
.page { margin: 2em auto; width: 800px; border: 5px solid #ccc;
|
.page { margin: 2em auto; width: 800px; border: 5px solid #ccc;
|
||||||
padding: 0.8em; background: white; }
|
padding: 0.8em; background: white; }
|
||||||
|
|
|
@ -41,4 +41,12 @@
|
||||||
src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
|
src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
|
||||||
alt="Get Adobe Flash player" /></a></p>
|
alt="Get Adobe Flash player" /></a></p>
|
||||||
</div>
|
</div>
|
||||||
|
{% if 'urlPostQte' in flashvars %}
|
||||||
|
<form method="POST">
|
||||||
|
<textarea rows="5" name="jsonNew">
|
||||||
|
{{ flashvars['jsonDisc'] }}
|
||||||
|
</textarea>
|
||||||
|
<input type="submit" value="edit game"/>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in a new issue