From 3efb4cb188940473a026b9e5bfabc2d7ecc0dfba Mon Sep 17 00:00:00 2001 From: Nala_Alan Date: Thu, 25 Oct 2018 16:52:41 +0200 Subject: [PATCH 1/7] Let user see his own comments --- nyaa/templates/profile.html | 1 + nyaa/views/users.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/nyaa/templates/profile.html b/nyaa/templates/profile.html index dcba274f..653e0781 100644 --- a/nyaa/templates/profile.html +++ b/nyaa/templates/profile.html @@ -14,6 +14,7 @@

Profile of User ID:
{{ g.user.id }}
User Class:
{{ g.user.userlevel_str }}
User Created on:
{{ g.user.created_time }}
+
View all comments
diff --git a/nyaa/views/users.py b/nyaa/views/users.py index 775bf958..ff878f07 100644 --- a/nyaa/views/users.py +++ b/nyaa/views/users.py @@ -208,7 +208,9 @@ def view_user_comments(user_name): flask.abort(404) # Only moderators get to see all comments for now - if not flask.g.user or not flask.g.user.is_moderator: + if user == flask.g.user: + pass + elif not flask.g.user or not flask.g.user.is_moderator: flask.abort(403) page_number = flask.request.args.get('p') @@ -226,6 +228,9 @@ def view_user_comments(user_name): comments_query=comments_query, user=user) +@bp.route('/profile/comments') +def view_own_comments(): + return view_user_comments(flask.g.user.username) @bp.route('/user/activate/') def activate_user(payload): From 0d25936bb1a1faf09a7d68956fe799dba682715f Mon Sep 17 00:00:00 2001 From: Nala_Alan Date: Thu, 25 Oct 2018 17:04:03 +0200 Subject: [PATCH 2/7] Lint correction --- nyaa/views/users.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nyaa/views/users.py b/nyaa/views/users.py index ff878f07..9b25e3e9 100644 --- a/nyaa/views/users.py +++ b/nyaa/views/users.py @@ -208,7 +208,7 @@ def view_user_comments(user_name): flask.abort(404) # Only moderators get to see all comments for now - if user == flask.g.user: + if user == flask.g.user: pass elif not flask.g.user or not flask.g.user.is_moderator: flask.abort(403) @@ -228,10 +228,12 @@ def view_user_comments(user_name): comments_query=comments_query, user=user) + @bp.route('/profile/comments') def view_own_comments(): return view_user_comments(flask.g.user.username) + @bp.route('/user/activate/') def activate_user(payload): if app.config['MAINTENANCE_MODE']: From 6a0f247ebb37d143d01a1c053c661af8377ebf77 Mon Sep 17 00:00:00 2001 From: Nala_Alan Date: Fri, 26 Oct 2018 00:16:09 +0200 Subject: [PATCH 3/7] Better if --- nyaa/views/users.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nyaa/views/users.py b/nyaa/views/users.py index 9b25e3e9..2d3a2490 100644 --- a/nyaa/views/users.py +++ b/nyaa/views/users.py @@ -207,10 +207,8 @@ def view_user_comments(user_name): if not user: flask.abort(404) - # Only moderators get to see all comments for now - if user == flask.g.user: - pass - elif 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') From 2cd6ab1ef95f1812a7f2c49c63a9f49bb730d465 Mon Sep 17 00:00:00 2001 From: Nala_Alan Date: Fri, 26 Oct 2018 01:31:15 +0200 Subject: [PATCH 4/7] Correct indentation --- nyaa/templates/rss.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/nyaa/templates/rss.xml b/nyaa/templates/rss.xml index 0b380194..a9609876 100644 --- a/nyaa/templates/rss.xml +++ b/nyaa/templates/rss.xml @@ -40,6 +40,7 @@ {{- cat_id }} {{- category_name(cat_id) }} {{- torrent.filesize | filesizeformat(True) }} + {{- torrent.comment_count }} {% set torrent_id = use_elastic and torrent.meta.id or torrent.id %} #{{ torrent_id }} | {{ torrent.display_name }} | {{ torrent.filesize | filesizeformat(True) }} | {{ category_name(cat_id) }} | {{ use_elastic and torrent.info_hash or torrent.info_hash_as_hex | upper }}]]> From a255cdd723a153063225d2ad1153c3ed4b78743e Mon Sep 17 00:00:00 2001 From: Nala_Alan Date: Fri, 26 Oct 2018 01:33:45 +0200 Subject: [PATCH 5/7] Correct indentation 2 --- nyaa/templates/profile.html | 116 ++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/nyaa/templates/profile.html b/nyaa/templates/profile.html index 653e0781..2b9f7462 100644 --- a/nyaa/templates/profile.html +++ b/nyaa/templates/profile.html @@ -14,72 +14,72 @@

Profile of User ID:
{{ g.user.id }}
User Class:
{{ g.user.userlevel_str }}
User Created on:
{{ g.user.created_time }}
-
View all comments
+
View all comments
-
-
- {{ form.csrf_token }} -
-
- {{ render_field(form.current_password, class_='form-control', placeholder='Current password') }} -
-
-
-
- {{ render_field(form.new_password, class_='form-control', placeholder='New password') }} -
-
-
-
- {{ render_field(form.password_confirm, class_='form-control', placeholder='New password (confirm)') }} -
-
-
-
- -
-
-
-
-
-
- {{ form.csrf_token }} -
-
- -
{{ g.user.email }}
-
-
-
-
- {{ render_field(form.email, class_='form-control', placeholder='New email address') }} -
-
-
-
- {{ render_field(form.current_password, class_='form-control', placeholder='Current password') }} -
-
-
-
- -
-
-
-
+
+
+ {{ form.csrf_token }} +
+
+ {{ render_field(form.current_password, class_='form-control', placeholder='Current password') }} +
+
+
+
+ {{ render_field(form.new_password, class_='form-control', placeholder='New password') }} +
+
+
+
+ {{ render_field(form.password_confirm, class_='form-control', placeholder='New password (confirm)') }} +
+
+
+
+ +
+
+
+
+
+
+ {{ form.csrf_token }} +
+
+ +
{{ g.user.email }}
+
+
+
+
+ {{ render_field(form.email, class_='form-control', placeholder='New email address') }} +
+
+
+
+ {{ render_field(form.current_password, class_='form-control', placeholder='Current password') }} +
+
+
+
+ +
+
+
+

From a2fe787fc775a5e28867b4939761dc6a4a4a475a Mon Sep 17 00:00:00 2001 From: Nala_Alan Date: Fri, 26 Oct 2018 01:34:30 +0200 Subject: [PATCH 6/7] Correct indentation 2 --- nyaa/templates/profile.html | 114 ++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/nyaa/templates/profile.html b/nyaa/templates/profile.html index 2b9f7462..56798ab7 100644 --- a/nyaa/templates/profile.html +++ b/nyaa/templates/profile.html @@ -20,66 +20,66 @@

Profile of - -
  • - -
  • + +
  • + +
  • -
    -
    - {{ form.csrf_token }} -
    -
    - {{ render_field(form.current_password, class_='form-control', placeholder='Current password') }} -
    -
    -
    -
    - {{ render_field(form.new_password, class_='form-control', placeholder='New password') }} -
    -
    -
    -
    - {{ render_field(form.password_confirm, class_='form-control', placeholder='New password (confirm)') }} -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    - {{ form.csrf_token }} -
    -
    - -
    {{ g.user.email }}
    -
    -
    -
    -
    - {{ render_field(form.email, class_='form-control', placeholder='New email address') }} -
    -
    -
    -
    - {{ render_field(form.current_password, class_='form-control', placeholder='Current password') }} -
    -
    -
    -
    - -
    -
    -
    -
    +
    +
    + {{ form.csrf_token }} +
    +
    + {{ render_field(form.current_password, class_='form-control', placeholder='Current password') }} +
    +
    +
    +
    + {{ render_field(form.new_password, class_='form-control', placeholder='New password') }} +
    +
    +
    +
    + {{ render_field(form.password_confirm, class_='form-control', placeholder='New password (confirm)') }} +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + {{ form.csrf_token }} +
    +
    + +
    {{ g.user.email }}
    +
    +
    +
    +
    + {{ render_field(form.email, class_='form-control', placeholder='New email address') }} +
    +
    +
    +
    + {{ render_field(form.current_password, class_='form-control', placeholder='Current password') }} +
    +
    +
    +
    + +
    +
    +
    +

    From 0dcd0af50102c2691bb2f1475c6764700f7703a2 Mon Sep 17 00:00:00 2001 From: Nala_Alan Date: Fri, 26 Oct 2018 22:06:52 +0200 Subject: [PATCH 7/7] Remove unrelated file --- nyaa/templates/rss.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/nyaa/templates/rss.xml b/nyaa/templates/rss.xml index a9609876..0b380194 100644 --- a/nyaa/templates/rss.xml +++ b/nyaa/templates/rss.xml @@ -40,7 +40,6 @@ {{- cat_id }} {{- category_name(cat_id) }} {{- torrent.filesize | filesizeformat(True) }} - {{- torrent.comment_count }} {% set torrent_id = use_elastic and torrent.meta.id or torrent.id %} #{{ torrent_id }} | {{ torrent.display_name }} | {{ torrent.filesize | filesizeformat(True) }} | {{ category_name(cat_id) }} | {{ use_elastic and torrent.info_hash or torrent.info_hash_as_hex | upper }}]]>