mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 20:19:59 +00:00
Implemented report action
Actions: Close report, Hide torrent, Delete torrent
This commit is contained in:
parent
e6083325d6
commit
354736720b
|
@ -282,7 +282,8 @@ class ReportForm(FlaskForm):
|
||||||
reason = TextAreaField('Report reason', [
|
reason = TextAreaField('Report reason', [
|
||||||
Length(min=3, max=255,
|
Length(min=3, max=255,
|
||||||
message='Report reason must be at least %(min)d characters long '
|
message='Report reason must be at least %(min)d characters long '
|
||||||
'and %(max)d at most.')
|
'and %(max)d at most.'),
|
||||||
|
DataRequired('You must provide a valid report reason.')
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ from urllib.parse import unquote as unquote_url
|
||||||
|
|
||||||
if app.config['USE_MYSQL']:
|
if app.config['USE_MYSQL']:
|
||||||
from sqlalchemy.dialects import mysql
|
from sqlalchemy.dialects import mysql
|
||||||
|
|
||||||
BinaryType = mysql.BINARY
|
BinaryType = mysql.BINARY
|
||||||
DescriptionTextType = mysql.TEXT
|
DescriptionTextType = mysql.TEXT
|
||||||
MediumBlobType = mysql.MEDIUMBLOB
|
MediumBlobType = mysql.MEDIUMBLOB
|
||||||
|
@ -27,7 +28,6 @@ else:
|
||||||
COL_UTF8MB4_BIN = None
|
COL_UTF8MB4_BIN = None
|
||||||
COL_ASCII_GENERAL_CI = 'NOCASE'
|
COL_ASCII_GENERAL_CI = 'NOCASE'
|
||||||
|
|
||||||
|
|
||||||
# For property timestamps
|
# For property timestamps
|
||||||
UTC_EPOCH = datetime.utcfromtimestamp(0)
|
UTC_EPOCH = datetime.utcfromtimestamp(0)
|
||||||
|
|
||||||
|
@ -327,6 +327,7 @@ class User(db.Model):
|
||||||
last_login_ip = db.Column(db.Binary(length=16), default=None, nullable=True)
|
last_login_ip = db.Column(db.Binary(length=16), default=None, nullable=True)
|
||||||
|
|
||||||
torrents = db.relationship('Torrent', back_populates='user', lazy="dynamic")
|
torrents = db.relationship('Torrent', back_populates='user', lazy="dynamic")
|
||||||
|
|
||||||
# session = db.relationship('Session', uselist=False, back_populates='user')
|
# session = db.relationship('Session', uselist=False, back_populates='user')
|
||||||
|
|
||||||
def __init__(self, username, email, password):
|
def __init__(self, username, email, password):
|
||||||
|
@ -398,8 +399,8 @@ class Report(db.Model):
|
||||||
reason = db.Column(db.String(length=255), nullable=False)
|
reason = db.Column(db.String(length=255), nullable=False)
|
||||||
status = db.Column(ChoiceType(ReportStatus, impl=db.Integer()), nullable=False)
|
status = db.Column(ChoiceType(ReportStatus, impl=db.Integer()), nullable=False)
|
||||||
|
|
||||||
user = db.relationship('User', uselist=False)
|
user = db.relationship('User', uselist=False, lazy="joined")
|
||||||
torrent = db.relationship('Torrent', uselist=False)
|
torrent = db.relationship('Torrent', uselist=False, lazy="joined")
|
||||||
|
|
||||||
def __init__(self, torrent_id, user_id, reason):
|
def __init__(self, torrent_id, user_id, reason):
|
||||||
self.torrent_id = torrent_id
|
self.torrent_id = torrent_id
|
||||||
|
@ -416,8 +417,16 @@ class Report(db.Model):
|
||||||
return (self.created_time - UTC_EPOCH).total_seconds()
|
return (self.created_time - UTC_EPOCH).total_seconds()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def not_reviewed(cls):
|
def by_id(cls, id):
|
||||||
reports = cls.query.filter_by(status=0).all()
|
return cls.query.get(id)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def not_reviewed(cls, page):
|
||||||
|
reports = cls.query.filter(cls.status == 0)\
|
||||||
|
.join(Torrent, aliased=True).filter(Torrent.flags != 36, Torrent.flags != 2)\
|
||||||
|
.order_by(db.asc(cls.id))\
|
||||||
|
.paginate(page=page, per_page=20)
|
||||||
|
# reports = cls.query.filter_by(status=0).paginate(page=page, per_page=20)
|
||||||
return reports
|
return reports
|
||||||
|
|
||||||
# class Session(db.Model):
|
# class Session(db.Model):
|
||||||
|
|
|
@ -27,7 +27,6 @@ from email.utils import formatdate
|
||||||
|
|
||||||
from flask_paginate import Pagination
|
from flask_paginate import Pagination
|
||||||
|
|
||||||
|
|
||||||
DEBUG_API = False
|
DEBUG_API = False
|
||||||
DEFAULT_MAX_SEARCH_RESULT = 1000
|
DEFAULT_MAX_SEARCH_RESULT = 1000
|
||||||
DEFAULT_PER_PAGE = 75
|
DEFAULT_PER_PAGE = 75
|
||||||
|
@ -582,7 +581,7 @@ def view_torrent(torrent_id):
|
||||||
return flask.render_template('view.html', torrent=torrent,
|
return flask.render_template('view.html', torrent=torrent,
|
||||||
files=files,
|
files=files,
|
||||||
can_edit=can_edit,
|
can_edit=can_edit,
|
||||||
form=report_form)
|
report_form=report_form)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/view/<int:torrent_id>/edit', methods=['GET', 'POST'])
|
@app.route('/view/<int:torrent_id>/edit', methods=['GET', 'POST'])
|
||||||
|
@ -667,12 +666,13 @@ def download_torrent(torrent_id):
|
||||||
|
|
||||||
@app.route('/view/<int:torrent_id>/submit_report', methods=['POST'])
|
@app.route('/view/<int:torrent_id>/submit_report', methods=['POST'])
|
||||||
def submit_report(torrent_id):
|
def submit_report(torrent_id):
|
||||||
|
if not flask.g.user:
|
||||||
|
flask.abort(403)
|
||||||
|
|
||||||
form = forms.ReportForm(flask.request.form)
|
form = forms.ReportForm(flask.request.form)
|
||||||
|
|
||||||
if flask.request.method == 'POST' and form.validate():
|
if flask.request.method == 'POST' and form.validate():
|
||||||
report_reason = (form.reason.data or '').strip()
|
report_reason = form.reason.data
|
||||||
|
|
||||||
if flask.g.user is not None:
|
|
||||||
current_user_id = flask.g.user.id
|
current_user_id = flask.g.user.id
|
||||||
report = models.Report(
|
report = models.Report(
|
||||||
torrent_id=torrent_id,
|
torrent_id=torrent_id,
|
||||||
|
@ -682,19 +682,38 @@ def submit_report(torrent_id):
|
||||||
db.session.add(report)
|
db.session.add(report)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flask.flash('Successfully reported torrent!', 'success')
|
flask.flash('Successfully reported torrent!', 'success')
|
||||||
else:
|
|
||||||
flask.abort(403)
|
|
||||||
|
|
||||||
return flask.redirect(flask.url_for('view_torrent', torrent_id=torrent_id))
|
return flask.redirect(flask.url_for('view_torrent', torrent_id=torrent_id))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/reports', methods=['GET'])
|
@app.route('/reports', methods=['GET', 'POST'])
|
||||||
def view_reports():
|
def view_reports():
|
||||||
reports = models.Report.not_reviewed()
|
|
||||||
|
|
||||||
if not flask.g.user or not flask.g.user.is_admin:
|
if not flask.g.user or not flask.g.user.is_admin:
|
||||||
flask.abort(403)
|
flask.abort(403)
|
||||||
|
|
||||||
|
page = flask.request.args.get('p', flask.request.args.get('offset', 1, int), int)
|
||||||
|
reports = models.Report.not_reviewed(page)
|
||||||
|
|
||||||
|
if flask.request.method == 'POST':
|
||||||
|
data = flask.request.form
|
||||||
|
torrent = models.Torrent.by_id(data['torrent'])
|
||||||
|
report = models.Report.by_id(data['report'])
|
||||||
|
if not torrent or not report or report.status != 0:
|
||||||
|
flask.abort(404)
|
||||||
|
else:
|
||||||
|
if data['action'] == 'delete':
|
||||||
|
torrent.deleted = True
|
||||||
|
report.status = 1
|
||||||
|
elif data['action'] == 'hide':
|
||||||
|
torrent.hidden = True
|
||||||
|
report.status = 1
|
||||||
|
else:
|
||||||
|
report.status = 2
|
||||||
|
|
||||||
|
db.session.commit()
|
||||||
|
flask.flash('Closed report #{}'.format(report.id), 'success')
|
||||||
|
return flask.redirect(flask.url_for('view_reports'))
|
||||||
|
|
||||||
return flask.render_template('reports.html',
|
return flask.render_template('reports.html',
|
||||||
reports=reports)
|
reports=reports)
|
||||||
|
|
||||||
|
|
|
@ -7,24 +7,45 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>Reported by:</th>
|
<th>Reported by</th>
|
||||||
<th>Torrent:</th>
|
<th>Torrent</th>
|
||||||
<th>Reason:</th>
|
<th>Reason</th>
|
||||||
<th>Date:</th>
|
<th>Date</th>
|
||||||
<th>Action:</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for report in reports %}
|
{% for report in reports.items %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ report.id }}</td>
|
<td>{{ report.id }}</td>
|
||||||
<td><a href="{{ url_for('view_user', user_name=report.user.username) }}">{{ report.user.username }}</a></td>
|
<td>
|
||||||
<td><a href="{{ url_for('view_torrent', torrent_id=report.torrent.id) }}">{{ report.torrent.display_name }}</a></td>
|
<a href="{{ url_for('view_user', user_name=report.user.username) }}">{{ report.user.username }}</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ url_for('view_torrent', torrent_id=report.torrent.id) }}">{{ report.torrent.display_name }}</a>
|
||||||
|
</td>
|
||||||
<td>{{ report.reason }}</td>
|
<td>{{ report.reason }}</td>
|
||||||
<td>{{ report.created_time }}</td>
|
<td>{{ report.created_time }}</td>
|
||||||
|
<td style="width: 15%">
|
||||||
|
<form method="post">
|
||||||
|
<select name="action" class="pull-left">
|
||||||
|
<option value="close">Close</option>
|
||||||
|
<option value="delete">Delete</option>
|
||||||
|
<option value="hide">Hide</option>
|
||||||
|
</select>
|
||||||
|
<input type="hidden" value="{{ report.torrent.id }}" name="torrent">
|
||||||
|
<input type="hidden" value="{{ report.id }}" name="report">
|
||||||
|
<button type="submit" class="btn btn-primary pull-right">Review</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class=pagination>
|
||||||
|
{% from "bootstrap/pagination.html" import render_pagination %}
|
||||||
|
{{ render_pagination(reports) }}
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{% block title %}{{ torrent.display_name }} :: {{ config.SITE_NAME }}{% endblock %}
|
{% block title %}{{ torrent.display_name }} :: {{ config.SITE_NAME }}{% endblock %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{% from "_formhelpers.html" import render_field %}
|
{% from "_formhelpers.html" import render_field %}
|
||||||
<div class="panel panel-{% if torrent.deleted %}deleted{% elif torrent.remake %}danger{% elif torrent.trusted %}success{% else %}default{% endif %}">
|
<div class="panel panel-{% if torrent.deleted %}deleted{% elif torrent.remake %}danger{% elif torrent.trusted %}success{% else %}default{% endif %}">
|
||||||
<div class="panel-heading"{% if torrent.hidden %} style="background-color: darkgray;"{% endif %}>
|
<div class="panel-heading"{% if torrent.hidden %} style="background-color: darkgray;"{% endif %}>
|
||||||
<h3 class="panel-title">
|
<h3 class="panel-title">
|
||||||
{% if can_edit %}
|
{% if can_edit %}
|
||||||
|
@ -15,19 +15,25 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-1">Category:</div>
|
<div class="col-md-1">Category:</div>
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<a href="{{ url_for("home", c=torrent.main_category.id_as_string) }}">{{ torrent.main_category.name }}</a> - <a href="{{ url_for("home", c=torrent.sub_category.id_as_string) }}">{{ torrent.sub_category.name }}</a>
|
<a href="{{ url_for("home", c=torrent.main_category.id_as_string) }}">{{ torrent.main_category.name }}</a>
|
||||||
|
- <a
|
||||||
|
href="{{ url_for("home", c=torrent.sub_category.id_as_string) }}">{{ torrent.sub_category.name }}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-1">Date:</div>
|
<div class="col-md-1">Date:</div>
|
||||||
<div class="col-md-5" data-timestamp="{{ torrent.created_utc_timestamp|int }}">{{ torrent.created_time.strftime('%Y-%m-%d %H:%M UTC') }}</div>
|
<div class="col-md-5"
|
||||||
|
data-timestamp="{{ torrent.created_utc_timestamp|int }}">{{ torrent.created_time.strftime('%Y-%m-%d %H:%M UTC') }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-1">Submitter:</div>
|
<div class="col-md-1">Submitter:</div>
|
||||||
<div class="col-md-5">{% if not torrent.anonymous and torrent.user %}<a href="{{ url_for('view_user', user_name=torrent.user.username) }}">{{ torrent.user.username }}</a>{% else %}Anonymous{% endif %}</div>
|
<div class="col-md-5">{% if not torrent.anonymous and torrent.user %}
|
||||||
|
<a href="{{ url_for('view_user', user_name=torrent.user.username) }}">{{ torrent.user.username }}</a>{% else %}
|
||||||
|
Anonymous{% endif %}</div>
|
||||||
|
|
||||||
<div class="col-md-1">Seeders:</div>
|
<div class="col-md-1">Seeders:</div>
|
||||||
<div class="col-md-5"><span style="color: green;">{% if config.ENABLE_SHOW_STATS %}{{ torrent.stats.seed_count }}{% else %}Coming soon{% endif %}</span></div>
|
<div class="col-md-5"><span style="color: green;">{% if config.ENABLE_SHOW_STATS %}
|
||||||
|
{{ torrent.stats.seed_count }}{% else %}Coming soon{% endif %}</span></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -38,11 +44,12 @@
|
||||||
{{ torrent.information_as_link | safe }}
|
{{ torrent.information_as_link | safe }}
|
||||||
{% else %}
|
{% else %}
|
||||||
No information.
|
No information.
|
||||||
{% endif%}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-1">Leechers:</div>
|
<div class="col-md-1">Leechers:</div>
|
||||||
<div class="col-md-5"><span style="color: red;">{% if config.ENABLE_SHOW_STATS %}{{ torrent.stats.leech_count }}{% else %}Coming soon{% endif %}</span></div>
|
<div class="col-md-5"><span style="color: red;">{% if config.ENABLE_SHOW_STATS %}
|
||||||
|
{{ torrent.stats.leech_count }}{% else %}Coming soon{% endif %}</span></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -50,33 +57,41 @@
|
||||||
<div class="col-md-5">{{ torrent.filesize | filesizeformat(True) }}</div>
|
<div class="col-md-5">{{ torrent.filesize | filesizeformat(True) }}</div>
|
||||||
|
|
||||||
<div class="col-md-1">Downloads:</div>
|
<div class="col-md-1">Downloads:</div>
|
||||||
<div class="col-md-5">{% if config.ENABLE_SHOW_STATS %}{{ torrent.stats.download_count }}{% else %}Coming soon{% endif %}</div>
|
<div class="col-md-5">
|
||||||
|
{% if config.ENABLE_SHOW_STATS %}{{ torrent.stats.download_count }}{% else %}Coming
|
||||||
|
soon{% endif %}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-footer">
|
<div class="panel-footer">
|
||||||
{% if torrent.has_torrent %}<a href="/view/{{ torrent.id }}/torrent"><i class="fa fa-download fa-fw"></i>Download Torrent</a> or {% endif %}<a href="{{ torrent.magnet_uri }}" class="card-footer-item"><i class="fa fa-magnet fa-fw"></i>Magnet</a>
|
{% if torrent.has_torrent %}
|
||||||
<button type="button" class="btn btn-danger pull-right" data-toggle="modal" data-target="#reportModal">Report</button>
|
<a href="/view/{{ torrent.id }}/torrent"><i class="fa fa-download fa-fw"></i>Download Torrent</a>
|
||||||
|
or {% endif %}<a href="{{ torrent.magnet_uri }}" class="card-footer-item"><i
|
||||||
|
class="fa fa-magnet fa-fw"></i>Magnet</a>
|
||||||
|
<button type="button" class="btn btn-danger pull-right" data-toggle="modal" data-target="#reportModal">
|
||||||
|
Report
|
||||||
|
</button>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-body" id="torrent-description">
|
<div class="panel-body" id="torrent-description">
|
||||||
{% if torrent.description %}
|
{% if torrent.description %}
|
||||||
{# Escape newlines into html entities because CF strips blank newlines #}
|
{# Escape newlines into html entities because CF strips blank newlines #}
|
||||||
{{ torrent.description | escape | replace('\r\n', '\n') | replace('\n', ' '|safe) }}
|
{{ torrent.description | escape | replace('\r\n', '\n') | replace('\n', ' '|safe) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
#### No description.
|
#### No description.
|
||||||
{% endif%}
|
{% endif %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if files and files.__len__() <= config.MAX_FILES_VIEW %}
|
{% if files and files.__len__() <= config.MAX_FILES_VIEW %}
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading panel-heading-collapse">
|
<div class="panel-heading panel-heading-collapse">
|
||||||
<h3 class="panel-title">
|
<h3 class="panel-title">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<a class="collapsed col-md-12" data-target="#collapseFileList" data-toggle="collapse" style="color:inherit;text-decoration:none;">File list</a>
|
<a class="collapsed col-md-12" data-target="#collapseFileList" data-toggle="collapse"
|
||||||
|
style="color:inherit;text-decoration:none;">File list</a>
|
||||||
</div>
|
</div>
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
|
@ -91,11 +106,13 @@
|
||||||
{%- for key, value in files.items() recursive %}
|
{%- for key, value in files.items() recursive %}
|
||||||
<tr>
|
<tr>
|
||||||
{%- if value is iterable %}
|
{%- if value is iterable %}
|
||||||
<td colspan="2" {% if loop.depth0 is greaterthan 0 %}style="padding-left: {{ loop.depth0 * 20 }}px"{% endif %}>
|
<td colspan="2"
|
||||||
|
{% if loop.depth0 is greaterthan 0 %}style="padding-left: {{ loop.depth0 * 20 }}px"{% endif %}>
|
||||||
<i class="glyphicon glyphicon-folder-open"></i> <b>{{ key }}</b></td>
|
<i class="glyphicon glyphicon-folder-open"></i> <b>{{ key }}</b></td>
|
||||||
{{ loop(value.items()) }}
|
{{ loop(value.items()) }}
|
||||||
{%- else %}
|
{%- else %}
|
||||||
<td{% if loop.depth0 is greaterthan 0 %} style="padding-left: {{ loop.depth0 * 20 }}px"{% endif %}>
|
<td{% if loop.depth0 is greaterthan 0 %}
|
||||||
|
style="padding-left: {{ loop.depth0 * 20 }}px"{% endif %}>
|
||||||
<i class="glyphicon glyphicon-file"></i> {{ key }}</td>
|
<i class="glyphicon glyphicon-file"></i> {{ key }}</td>
|
||||||
<td class="col-md-2">{{ value | filesizeformat(True) }}</td>
|
<td class="col-md-2">{{ value | filesizeformat(True) }}</td>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
@ -103,24 +120,28 @@
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% elif files %}
|
{% elif files %}
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading panel-heading-collapse">
|
<div class="panel-heading panel-heading-collapse">
|
||||||
<h3 class="panel-title">
|
<h3 class="panel-title">
|
||||||
<div class="row"><div class="col-md-12">Too many files to display.</div></div>
|
<div class="row">
|
||||||
|
<div class="col-md-12">Too many files to display.</div>
|
||||||
|
</div>
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading panel-heading-collapse">
|
<div class="panel-heading panel-heading-collapse">
|
||||||
<h3 class="panel-title">
|
<h3 class="panel-title">
|
||||||
<div class="row"><div class="col-md-12">File list is not available for this torrent.</div></div>
|
<div class="row">
|
||||||
|
<div class="col-md-12">File list is not available for this torrent.</div>
|
||||||
|
</div>
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="modal fade" id="reportModal" tabindex="-1" role="dialog" aria-labelledby="reportModalLabel">
|
<div class="modal fade" id="reportModal" tabindex="-1" role="dialog" aria-labelledby="reportModalLabel">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
|
@ -132,8 +153,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<form method="POST" action="{{ request.url }}/submit_report">
|
<form method="POST" action="{{ request.url }}/submit_report">
|
||||||
{{ form.csrf_token }}
|
{{ report_form.csrf_token }}
|
||||||
{{ render_field(form.reason, class_='form-control', maxlength=255) }}
|
{{ render_field(report_form.reason, class_='form-control', maxlength=255) }}
|
||||||
<div style="float: right;">
|
<div style="float: right;">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||||
<button type="submit" class="btn btn-danger">Report</button>
|
<button type="submit" class="btn btn-danger">Report</button>
|
||||||
|
@ -147,13 +168,13 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var target = document.getElementById('torrent-description');
|
var target = document.getElementById('torrent-description');
|
||||||
var text = target.innerHTML;
|
var text = target.innerHTML;
|
||||||
var reader = new commonmark.Parser({safe: true});
|
var reader = new commonmark.Parser({safe: true});
|
||||||
var writer = new commonmark.HtmlRenderer({safe: true, softbreak: '<br />'});
|
var writer = new commonmark.HtmlRenderer({safe: true, softbreak: '<br />'});
|
||||||
var parsed = reader.parse(text.trim());
|
var parsed = reader.parse(text.trim());
|
||||||
target.innerHTML = writer.render(parsed);
|
target.innerHTML = writer.render(parsed);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue