Skip to content
Snippets Groups Projects
Commit 1d3f3607 authored by kaiyou's avatar kaiyou
Browse files

Support public and private histoy entries

parent 70750d29
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,8 @@ import json
import uuid
def log(category, value=None, comment=None, user=None, profile=None, service=None, actor=None):
def log(category, value=None, comment=None, user=None, profile=None,
service=None, actor=None, public=True):
""" Log a history event
"""
event = History()
......@@ -21,6 +22,7 @@ def log(category, value=None, comment=None, user=None, profile=None, service=Non
event.profile = profile
event.service = service
event.actor = actor
event.public = public
db.session.add(event)
......@@ -214,7 +216,8 @@ class History(db.Model):
DESCRIPTION = {
SIGNUP: _("signed up for this account"),
CREATE: _("created the profile {this.profile.username} on {this.service.name}"),
PASSWORD: _("changed your password")
PASSWORD: _("changed your password"),
STATUS: _("{this.value} the profile {this.profile.username} on {this.service.name}")
}
user_uuid = db.Column(db.String(36), db.ForeignKey(User.uuid))
......@@ -230,6 +233,7 @@ class History(db.Model):
actor = db.relationship(User, foreign_keys=[actor_uuid],
backref=db.backref('actions', cascade='all, delete-orphan'))
public = db.Column(db.Boolean(), default=True)
category = db.Column(db.String(25))
value = db.Column(db.String())
......
{% macro timeline(events) %}
{% macro timeline(events, public_only=True) %}
<ul class="timeline">
{% set dates = [] %}
{% for event in events | reverse %}
{% if event.public or not public_only %}
{% if not event.created_at.date() == dates[-1] %}
{% set _ = dates.append(event.created_at.date()) %}
<li class="time-label">
......@@ -13,7 +14,7 @@
<div class="timeline-item">
<span class="time"><i class="fa fa-clock-o"></i> {{ event.created_at.time().strftime("%H:%M") }}</span>
<h3 class="timeline-header">
<strong>{{ event.actor.username or "You" }}</strong>
<strong>{{ event.actor.username or event.user.username }}</strong>
{{ event.description }}
</h3>
{% if event.comment %}
......@@ -23,6 +24,7 @@
{% endif %}
</div>
</li>
{% endif %}
{% endfor %}
</ul>
{% endmacro %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment