forked from gergely/calendar-social
Make actors and items in notifications links
This commit is contained in:
parent
17cca9380f
commit
0a1701dacd
@ -276,6 +276,15 @@ class Profile(db.Model): # pylint: disable=too-few-public-methods
|
|||||||
.join(UserFollow.follower) \
|
.join(UserFollow.follower) \
|
||||||
.filter(UserFollow.followed == self)
|
.filter(UserFollow.followed == self)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def url(self):
|
||||||
|
from flask import url_for
|
||||||
|
|
||||||
|
if self.user:
|
||||||
|
return url_for('display_profile', username=self.user.username)
|
||||||
|
|
||||||
|
return NotImplemented
|
||||||
|
|
||||||
|
|
||||||
class Event(db.Model):
|
class Event(db.Model):
|
||||||
"""Database model for events
|
"""Database model for events
|
||||||
@ -347,6 +356,15 @@ class Event(db.Model):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f'<Event {self.id} ({self.title}) of {self.profile}>'
|
return f'<Event {self.id} ({self.title}) of {self.profile}>'
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.title
|
||||||
|
|
||||||
|
@property
|
||||||
|
def url(self):
|
||||||
|
from flask import url_for
|
||||||
|
|
||||||
|
return url_for('event_details', event_uuid=self.event_uuid)
|
||||||
|
|
||||||
|
|
||||||
class UserSetting(db.Model): # pylint: disable=too-few-public-methods
|
class UserSetting(db.Model): # pylint: disable=too-few-public-methods
|
||||||
"""Database model for user settings
|
"""Database model for user settings
|
||||||
@ -557,6 +575,22 @@ class Notification(db.Model):
|
|||||||
|
|
||||||
return lazy_gettext(message, actor=self.actor, item=self.item)
|
return lazy_gettext(message, actor=self.actor, item=self.item)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def html(self):
|
||||||
|
"""Get the translated message for ``key`` in HTML format
|
||||||
|
"""
|
||||||
|
|
||||||
|
from flask import url_for, Markup
|
||||||
|
from flask_security import current_user
|
||||||
|
|
||||||
|
messages = NOTIFICATION_ACTION_MESSAGES.get(self.action)
|
||||||
|
message = messages[0 if self.item == current_user.profile else 1]
|
||||||
|
|
||||||
|
actor = f'<a href="{self.actor.url}">{self.actor}</a>'
|
||||||
|
item = f'<a href="{self.item.url}">{self.item}</a>'
|
||||||
|
|
||||||
|
return Markup(lazy_gettext(message, actor=actor, item=item))
|
||||||
|
|
||||||
|
|
||||||
class Invitation(db.Model): # pylint: disable=too-few-public-methods
|
class Invitation(db.Model): # pylint: disable=too-few-public-methods
|
||||||
"""Database model for event invitations
|
"""Database model for event invitations
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% for notif in notifs %}
|
{% for notif in notifs %}
|
||||||
{{ notif.message }}<br>
|
{{ notif.html }}<br>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
Loading…
Reference in New Issue
Block a user