Include video progress data in UserClass
See src/templates/nodes/custom/group/view_embed.pug for a crude example.
This commit is contained in:
parent
df078b395d
commit
534d06ca8f
@ -38,6 +38,7 @@ class UserClass(flask_login.UserMixin):
|
||||
self.groups: typing.List[str] = [] # NOTE: these are stringified object IDs.
|
||||
self.group_ids: typing.List[bson.ObjectId] = []
|
||||
self.capabilities: typing.Set[str] = set()
|
||||
self.nodes: dict = {} # see the 'nodes' key in eve_settings.py::user_schema.
|
||||
|
||||
# Lazily evaluated
|
||||
self._has_organizations: typing.Optional[bool] = None
|
||||
@ -57,6 +58,11 @@ class UserClass(flask_login.UserMixin):
|
||||
user.username = db_user.get('username') or ''
|
||||
user.full_name = db_user.get('full_name') or ''
|
||||
|
||||
# Be a little more specific than just db_user['nodes']
|
||||
user.nodes = {
|
||||
'view_progress': db_user.get('nodes', {}).get('view_progress', {}),
|
||||
}
|
||||
|
||||
# Derived properties
|
||||
user.objectid = str(user.user_id or '')
|
||||
user.gravatar = utils.gravatar(user.email)
|
||||
|
@ -61,7 +61,6 @@
|
||||
| {% if child.properties.status != 'published' %}
|
||||
span.status {{ child.properties.status }}
|
||||
| {% endif %}
|
||||
|
||||
span.type
|
||||
| {% if child.properties.content_type %}
|
||||
| {{ child.properties.content_type | undertitle }} ·
|
||||
@ -111,6 +110,17 @@
|
||||
.list-node-children-item-name
|
||||
span {{ child.name }}
|
||||
|
||||
| {% if child.properties.content_type == 'video' %}
|
||||
| {% set progress = current_user.nodes.view_progress[child._id] %}
|
||||
| {% set progress_in_percent = progress.progress_in_percent %}
|
||||
| {% set progress_done = progress.done %}
|
||||
//- TODO(Pablo): turn this into a nice progress bar
|
||||
span.progress(class="{% if progress.done %}done{% endif %}")
|
||||
| {{ progress_in_percent }}%
|
||||
| {% else %}
|
||||
span.jemoeder no progress because not video
|
||||
| {% endif %}
|
||||
|
||||
| {% endfor %}
|
||||
| {% else %}
|
||||
.list-node-children-container
|
||||
|
Loading…
x
Reference in New Issue
Block a user