diff --git a/lasertube.py b/lasertube.py
index 04a62d6..f048e60 100644
--- a/lasertube.py
+++ b/lasertube.py
@@ -117,9 +117,24 @@ def disc_json(id):
disc = g.db.query(models.Disc).filter_by(id=id).one()
return json.dumps(models.toJso(disc))
-@app.route('/disc//edit/')
+@app.route('/disc//edit/', methods=['GET', 'POST'])
@requires_login
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)
@app.route('/disc//qte/', methods=['POST'])
diff --git a/static/style.css b/static/style.css
index 7a47324..c7e14b9 100644
--- a/static/style.css
+++ b/static/style.css
@@ -3,6 +3,7 @@ a, h1, h2 { color: #377BA8; }
h1, h2 { font-family: 'Georgia', serif; margin: 0; }
h1 { border-bottom: 2px solid #eee; }
h2 { font-size: 1.2em; }
+textarea { width: 100%;}
.page { margin: 2em auto; width: 800px; border: 5px solid #ccc;
padding: 0.8em; background: white; }
diff --git a/templates/disc.html b/templates/disc.html
index bd4000d..cc0737a 100644
--- a/templates/disc.html
+++ b/templates/disc.html
@@ -41,4 +41,12 @@
src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
alt="Get Adobe Flash player" />
+{% if 'urlPostQte' in flashvars %}
+
+{% endif %}
{% endblock %}
\ No newline at end of file