aboutsummaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2015-04-01 21:30:26 -0400
committerThibaut Horel <thibaut.horel@gmail.com>2015-04-01 21:30:26 -0400
commitacd73bdf5f351445b4b66c28dd0e3a8883d4face (patch)
tree79dd1e2e2e862ef35b8c9aa56ecdc2fc424e9cc6 /templates
parentbe0df053aff9585b838290d4d6d9bc1716f56b8a (diff)
downloadfamille-flask-acd73bdf5f351445b4b66c28dd0e3a8883d4face.tar.gz
Add edit comment feature
This is handled in javascript. When clicking the edit link: 1. a form is shown to edit the RST source of the comment. 2. on submit, an AJAX POST request is sent to the new "comment" endpoint in the flask app. 3. the endpoint compiles the RST source, update the comment in the database and sends back formatted content to the client. 4. the client then updates the comment content and hides the form.
Diffstat (limited to 'templates')
-rw-r--r--templates/news/show.html17
1 files changed, 16 insertions, 1 deletions
diff --git a/templates/news/show.html b/templates/news/show.html
index 3bdaa9b..8667f5d 100644
--- a/templates/news/show.html
+++ b/templates/news/show.html
@@ -21,9 +21,24 @@
'gfx/'+comment.user_name+'.jpg') }}" alt="{{comment.user_name}}" class="img-circle">
</div>
<div class="media-body" style="width:100%">
- <h4 class="media-heading"><p class="pull-right date">{{comment.date|format_date}}</p>
+ <h4 class="media-heading"><p class="pull-right date">
+ {% if news.user_name==session.user_name %}
+ <a class="edit" href="#">Modifier</a>
+ {% endif %}
+ {{comment.date|format_date}}
+ </p>
<a href="{{url_for('view_user', user_id=comment.user_id)}}">{{comment.user_name}}</a></h4>
+ <div class="comment-content">
{{comment.content_cache|safe}}
+ </div>
+ {% if news.user_name==session.user_name %}
+ <form class="comment-source" data-id="{{comment.id}}">
+ <div class="form-group">
+ <textarea name="content" class="form-control" rows="3">{{comment.content}}</textarea>
+ </div>
+ <button type="submit" class="btn btn-primary">Modifier</button>
+ </form>
+ {% endif %}
</div>
</div>
{% endfor %}