mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 09:00:00 +00:00
Disable report button on empty reason (#374)
Previously, people couldn't quite tell you needed to give a report reason. Now we disable the submit button until there is a reason, and flask.flash() if someone manages to submit an empty reason anyway.
This commit is contained in:
parent
0eea181020
commit
214952e7b6
|
@ -200,7 +200,7 @@
|
||||||
{{ render_field(report_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" id="reportSubmit" class="btn btn-danger">Report</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -214,6 +214,14 @@
|
||||||
// Focus the report text field once the modal is opened.
|
// Focus the report text field once the modal is opened.
|
||||||
$('#reportModal').on('shown.bs.modal', function () {
|
$('#reportModal').on('shown.bs.modal', function () {
|
||||||
$('#reason').focus();
|
$('#reason').focus();
|
||||||
|
$('#reportSubmit').attr('disabled', true);
|
||||||
|
});
|
||||||
|
$('#reason').on('input', function(e) {
|
||||||
|
if($('#reason').val().length > 0) {
|
||||||
|
$('#reportSubmit').removeAttr('disabled');
|
||||||
|
} else {
|
||||||
|
$('#reportSubmit').attr('disabled', true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -376,6 +376,8 @@ 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')
|
||||||
|
elif len(form.reason.data) == 0:
|
||||||
|
flask.flash('Please give a report reason!', 'danger')
|
||||||
|
|
||||||
return flask.redirect(flask.url_for('torrents.view', torrent_id=torrent_id))
|
return flask.redirect(flask.url_for('torrents.view', torrent_id=torrent_id))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue