Added hard delete functionality

This commit is contained in:
Sn0wCrack 2017-05-14 09:52:57 +10:00 committed by nyaadev
parent 6d608ab2f4
commit 1a9ebc19ed
2 changed files with 12 additions and 11 deletions

View File

@ -591,12 +591,7 @@ def view_torrent(torrent_id):
if torrent.filelist:
files = json.loads(torrent.filelist.filelist_blob.decode('utf-8'))
if flask.g.user is not None and flask.g.user.is_admin:
comments = models.Comment.query.filter(models.Comment.torrent == torrent_id)
else:
comments = models.Comment.query.filter(models.Comment.torrent == torrent_id,
models.Comment.deleted == False)
comments = models.Comment.query.filter_by(torrent=torrent_id)
comment_count = comments.count()
return flask.render_template('view.html', torrent=torrent,
@ -627,6 +622,16 @@ def submit_comment(torrent_id):
return flask.redirect(flask.url_for('view_torrent', torrent_id=torrent_id))
@app.route('/view/<int:torrent_id>/delete_comment/<int:comment_id>')
def delete_comment(torrent_id, comment_id):
if flask.g.user is not None and flask.g.user.is_admin:
models.Comment.query.filter_by(id=comment_id).delete()
db.session.commit()
else:
flask.abort(403)
return flask.redirect(flask.url_for('view_torrent', torrent_id=torrent_id))
@app.route('/view/<int:torrent_id>/edit', methods=['GET', 'POST'])
def edit_torrent(torrent_id):

View File

@ -150,11 +150,7 @@
<tr>
{% if g.user.is_admin %}
<td class="col-md-1">
{% if not comment.deleted %}
<a href="/"><i class="fa fa-ban"></i></a>
{% else %}
<a href="/"><i class="fa fa-circle-o"></i></a>
{% endif %}
<a href="{{ url_for('delete_comment', torrent_id=torrent.id, comment_id=comment.id )}}"><i class="fa fa-ban"></i></a>
</td>
{% endif %}
<td class="col-md-1">