forked from rDrama/rDrama
1
0
Fork 0

add /blockers (thx JC <3)

master
Aevann1 2022-09-23 14:58:33 +02:00
parent 340f9e31fe
commit ebf83048be
3 changed files with 38 additions and 12 deletions

View File

@ -899,19 +899,15 @@ def user_id(id):
def redditor_moment_redirect(username, v): def redditor_moment_redirect(username, v):
return redirect(f"/@{username}") return redirect(f"/@{username}")
@app.get("/@<username>/followers") @app.get("/@<username>/blockers")
@auth_required @auth_required
def followers(username, v): def blockers(username, v):
u = get_user(username, v=v) u = get_user(username, v=v)
if u.id == CARP_ID: abort(403)
if not (v.id == u.id or v.admin_level >= PERMS['USER_FOLLOWS_VISIBLE']): users = g.db.query(UserBlock, User).join(UserBlock, UserBlock.target_id == u.id) \
abort(403) .filter(UserBlock.user_id == User.id) \
.order_by(UserBlock.created_utc).all()
users = g.db.query(Follow, User).join(Follow, Follow.target_id == u.id) \ return render_template("blockers.html", v=v, u=u, users=users)
.filter(Follow.user_id == User.id) \
.order_by(Follow.created_utc).all()
return render_template("followers.html", v=v, u=u, users=users)
@app.get("/@<username>/following") @app.get("/@<username>/following")
@auth_required @auth_required

View File

@ -0,0 +1,30 @@
{% extends "default.html" %}
{% block content %}
<pre>
</pre>
<h5>@{{u.username}}'s blockers</h5>
<pre></pre>
<div class="overflow-x-auto"><table class="table table-striped mb-5">
<thead class="bg-primary text-white">
<tr>
<th>#</th>
<th>Name</th>
<td>Blocking Since</td>
</tr>
</thead>
<tbody id="blockers-table">
{% for block, user in users %}
<tr>
<td>{{loop.index}}</td>
<td>{% include "user_in_table.html" %}</td>
<td {% if block.created_utc > 1599343262 %}data-time="{{block.created_utc}}"{% endif %}></td>
</tr>
{% endfor %}
</tbody>
</table>
<script defer src="/assets/js/blockers.js?v=4000"></script>
{% endblock %}

View File

@ -384,7 +384,7 @@
<tr {% if v.id == user.id %}class="self"{% endif %}> <tr {% if v.id == user.id %}class="self"{% endif %}>
<td>{{loop.index}}</td> <td>{{loop.index}}</td>
<td>{% include "user_in_table.html" %}</td> <td>{% include "user_in_table.html" %}</td>
<td><a href="/blockers/{{user.id}}">{{"{:,}".format(num)}}</a></td> <td><a href="/@{{user.username}}/blockers">{{"{:,}".format(num)}}</a></td>
</tr> </tr>
{% endfor %} {% endfor %}
{% if pos16 and (pos16[0] > 25 or not pos16[1]) %} {% if pos16 and (pos16[0] > 25 or not pos16[1]) %}
@ -395,7 +395,7 @@
{% include "user_in_table.html" %} {% include "user_in_table.html" %}
{% endwith %} {% endwith %}
</td> </td>
<td><a href="/blockers/{{v.id}}">{{"{:,}".format(pos16[1])}}</a></td> <td><a href="/@{{v.username}}/blockers">{{"{:,}".format(pos16[1])}}</a></td>
</tr> </tr>
{% endif %} {% endif %}
</table> </table>