mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-02 16:21:32 -08:00
render user note
This commit is contained in:
parent
d079a6dab7
commit
1550d9bb70
3 changed files with 15 additions and 1 deletions
|
@ -1022,6 +1022,7 @@ class User(UserMixin, db.Model):
|
|||
db.session.query(PostBookmark).filter(PostBookmark.user_id == self.id).delete()
|
||||
db.session.query(PostReplyBookmark).filter(PostReplyBookmark.user_id == self.id).delete()
|
||||
db.session.query(ModLog).filter(ModLog.user_id == self.id).delete()
|
||||
db.session.query(UserNote).filter(or_(UserNote.user_id == self.id, UserNote.target_id == self.id)).delete()
|
||||
|
||||
def purge_content(self, soft=True):
|
||||
files = File.query.join(Post).filter(Post.user_id == self.id).all()
|
||||
|
@ -1077,7 +1078,13 @@ class User(UserMixin, db.Model):
|
|||
# returns true if the post has been read, false if not
|
||||
def has_read_post(self, post):
|
||||
return self.read_post.filter(read_posts.c.read_post_id == post.id).count() > 0
|
||||
|
||||
|
||||
def get_note(self, by_user):
|
||||
user_note = UserNote.query.filter(UserNote.target_id == self.id, UserNote.user_id == by_user.id).first()
|
||||
if user_note:
|
||||
return user_note.body
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class ActivityLog(db.Model):
|
||||
|
|
|
@ -27,6 +27,12 @@
|
|||
<span class="fe fe-warning orangered" title="Low reputation."> </span>
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
{% if current_user.is_authenticated -%}
|
||||
{% set user_note = user.get_note(current_user) %}
|
||||
{% if user_note -%}
|
||||
<span class="user_note" title="{{ _('User note') }}">[{{ user_note | truncate(12, True) }}]</span>
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
</span>
|
||||
{% endmacro -%}
|
||||
|
|
|
@ -116,6 +116,7 @@
|
|||
{% if current_user.is_authenticated and current_user.is_admin() and user.reputation %}{{ _('Reputation') }}: <span title="{{ _('Reputation: The Karma of the account. Total up votes minus down votes they got.') }}">{{ user.reputation | round | int }}</span><br />{% endif %}
|
||||
{{ _('Posts') }}: {{ user.post_count }}<br />
|
||||
{{ _('Comments') }}: {{ user.post_reply_count }}<br />
|
||||
{% if current_user.is_authenticated %}{{ _('User note') }}: {{ user.get_note(current_user) }}<br />{% endif %}
|
||||
</p>
|
||||
<div class="profile_bio">
|
||||
{{ user.about_html|safe }}
|
||||
|
|
Loading…
Add table
Reference in a new issue