mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 19:49:59 +00:00
Added ability for users to leave anonymous comments
This commit is contained in:
parent
1a9ebc19ed
commit
fe6abf33c1
|
@ -132,6 +132,8 @@ class CommentForm(FlaskForm):
|
||||||
Required()
|
Required()
|
||||||
])
|
])
|
||||||
|
|
||||||
|
is_anonymous = BooleanField('Anonymous')
|
||||||
|
|
||||||
|
|
||||||
class EditForm(FlaskForm):
|
class EditForm(FlaskForm):
|
||||||
display_name = StringField('Torrent display name', [
|
display_name = StringField('Torrent display name', [
|
||||||
|
|
|
@ -611,7 +611,11 @@ def submit_comment(torrent_id):
|
||||||
comment_text = (form.comment.data or '').strip()
|
comment_text = (form.comment.data or '').strip()
|
||||||
|
|
||||||
# Null entry for User just means Anonymous
|
# Null entry for User just means Anonymous
|
||||||
current_user_id = flask.g.user.id if flask.g.user else None
|
if flask.g.user is None or form.is_anonymous.data:
|
||||||
|
current_user_id = None
|
||||||
|
else:
|
||||||
|
current_user_id = flask.g.user.id
|
||||||
|
|
||||||
comment = models.Comment(
|
comment = models.Comment(
|
||||||
torrent=torrent_id,
|
torrent=torrent_id,
|
||||||
user_id=current_user_id,
|
user_id=current_user_id,
|
||||||
|
|
|
@ -173,6 +173,7 @@
|
||||||
<form method="POST" action="{{ request.url }}/submit_comment">
|
<form method="POST" action="{{ request.url }}/submit_comment">
|
||||||
{{ form.csrf_token }}
|
{{ form.csrf_token }}
|
||||||
{{ render_field(form.comment, class_='form-control') }}
|
{{ render_field(form.comment, class_='form-control') }}
|
||||||
|
{{ render_field(form.is_anonymous) }}
|
||||||
<input type="submit" value="Submit" class="btn btn-primary">
|
<input type="submit" value="Submit" class="btn btn-primary">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue