Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lets user see his own comments #529

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nyaa/templates/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ <h2 style="margin-bottom: 20px;">Profile of <strong class="text-{{ g.user.userle
<dt class="col-sm-2">User ID:</dt><dd class="col-sm-10">{{ g.user.id }}</dd>
<dt class="col-sm-2">User Class:</dt><dd class="col-sm-10">{{ g.user.userlevel_str }}</dd>
<dt class="col-sm-2">User Created on:</dt><dd class="col-sm-10">{{ g.user.created_time }}</dd>
<dt class="col-sm-2"><a href="{{ url_for('users.view_own_comments') }}">View all comments</a></dt>
</dl>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions nyaa/templates/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<nyaa:categoryId>{{- cat_id }}</nyaa:categoryId>
<nyaa:category> {{- category_name(cat_id) }}</nyaa:category>
<nyaa:size> {{- torrent.filesize | filesizeformat(True) }}</nyaa:size>
<nyaa:comments> {{- torrent.comment_count }}</nyaa:comments>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're now including the comment count from the other PR!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not even sure how did it end up here, ehh.

{% set torrent_id = use_elastic and torrent.meta.id or torrent.id %}
<description><![CDATA[<a href="{{ url_for('torrents.view', torrent_id=torrent_id, _external=True) }}">#{{ torrent_id }} | {{ torrent.display_name }}</a> | {{ torrent.filesize | filesizeformat(True) }} | {{ category_name(cat_id) }} | {{ use_elastic and torrent.info_hash or torrent.info_hash_as_hex | upper }}]]></description>
</item>
Expand Down
9 changes: 7 additions & 2 deletions nyaa/views/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ def view_user_comments(user_name):
if not user:
flask.abort(404)

# Only moderators get to see all comments for now
if not flask.g.user or not flask.g.user.is_moderator:
# Only moderators and users themselves get to see the comments
if not flask.g.user or not (flask.g.user == user or flask.g.user.is_moderator):
flask.abort(403)

page_number = flask.request.args.get('p')
Expand All @@ -227,6 +227,11 @@ def view_user_comments(user_name):
user=user)


@bp.route('/profile/comments')
def view_own_comments():
return view_user_comments(flask.g.user.username)


@bp.route('/user/activate/<payload>')
def activate_user(payload):
if app.config['MAINTENANCE_MODE']:
Expand Down