add stats to user page
This commit is contained in:
parent
2345830074
commit
df239fb130
@ -4,6 +4,9 @@ from .constants import PermissionLevel
|
|||||||
class Users(Model):
|
class Users(Model):
|
||||||
table = "users"
|
table = "users"
|
||||||
|
|
||||||
|
def get_avatar_url(self):
|
||||||
|
return Avatars.find({"id": self.avatar_id}).file_path
|
||||||
|
|
||||||
def is_guest(self):
|
def is_guest(self):
|
||||||
return self.permission == PermissionLevel.GUEST.value
|
return self.permission == PermissionLevel.GUEST.value
|
||||||
|
|
||||||
|
@ -24,13 +24,52 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="user-info">
|
||||||
{% with stats = target_user.get_post_stats() %}
|
<div class="user-page-usercard">
|
||||||
<ul>
|
<div class="usercard-inner">
|
||||||
<li>Posts created: {{ stats.post_count }}</li>
|
<img class="avatar" src="{{ target_user.get_avatar_url() }}">
|
||||||
<li>Threads started: {{ stats.thread_count }}</li>
|
<strong class="big">{{ target_user.username }}</strong>
|
||||||
<li>Latest started thread: {{ stats.latest_thread_title }}
|
{% if target_user.status %}
|
||||||
</ul>
|
<em class="user-status">{{ target_user.status }}</em>
|
||||||
{% endwith %}
|
{% endif %}
|
||||||
|
{% if target_user.signature_rendered %}
|
||||||
|
Signature:
|
||||||
|
<div>{{ target_user.signature_rendered | safe }}</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="user-page-stats">
|
||||||
|
{% with stats = target_user.get_post_stats() %}
|
||||||
|
<ul class="user-stats-list">
|
||||||
|
<li>Permission: {{ target_user.permission }}</li>
|
||||||
|
<li>Posts created: {{ stats.post_count }}</li>
|
||||||
|
<li>Threads started: {{ stats.thread_count }}</li>
|
||||||
|
{% if stats.latest_thread_title %}
|
||||||
|
<li>Latest started thread: <a href="{{ url_for("threads.thread", slug = stats.latest_thread_slug) }}">{{ stats.latest_thread_title }}</a>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
{% endwith %}
|
||||||
|
Latest posts:
|
||||||
|
{% with posts = target_user.get_latest_posts() %}
|
||||||
|
<div class="user-page-posts">
|
||||||
|
{% for post in posts %}
|
||||||
|
<div class="post-content-container">
|
||||||
|
<div class="post-info">
|
||||||
|
<a href="{{ url_for("threads.thread", slug=post.thread_slug, after=post.id) }}" title="permalink"><i>
|
||||||
|
{% if (post.edited_at | int) > (post.created_at | int) %}
|
||||||
|
Edited on {{ timestamp(post.edited_at) }}
|
||||||
|
{% else %}
|
||||||
|
Posted on {{ timestamp(post.edited_at) }}
|
||||||
|
{% endif %}
|
||||||
|
</i></a>
|
||||||
|
</div>
|
||||||
|
<div class="post-content wider user-page-post-preview">
|
||||||
|
<div class="post-inner">{{ post.content | safe }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endwith %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user