Skip to content

Commit

Permalink
Notifications: show attached to User, Project and Organization
Browse files Browse the repository at this point in the history
Render notifications attached to these objects.
This is the first pass of this work and there are some things we need to make
decisions and improve.

- Where (what pages) these notifications should render?
- How "global" they should be considered?

Note we are rendering these notifications in the template for now,
but in the future they will be rendered using the APIv3: #259
  • Loading branch information
humitos committed Jan 11, 2024
1 parent a39cec9 commit bbfd72c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions readthedocsext/theme/templates/includes/utils/messages.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@
page content pane.
{% endcomment %}

{% comment %}
``user_notifications`` comes from a Context Processor.
We need to use a CustomUser to have access to "user.notifications"
See https://docs.djangoproject.com/en/4.2/ref/settings/#std-setting-AUTH_USER_MODEL
{% endcomment %}
{% if user_notifications %}
{% for notification in user_notifications %}
<div class="ui message">
{% comment %}
Add this Xmark here once we implement dismissing notifications.
<i class="fa-duotone fa-circle-xmark close icon"></i>
{% endcomment %}
{{ notification.get_message.get_rendered_body|safe }}
</div>
{% endfor %}
{% endif %}

{% if messages %}
{% for message in messages %}
{% comment %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,13 @@
</div>
{% endblock organization_header_navigation %}

{# Render all the notifications attached to the organization.#}
{% for notification in organization.notifications.all %}
<div class="ui message">
<i class="fa-solid {{ notification.get_message.get_display_icon_classes }}"></i>
<span>{{ notification.get_message.get_rendered_body|safe }}</span>
</div>
{% endfor %}


{% endblock organization_header %}
8 changes: 8 additions & 0 deletions readthedocsext/theme/templates/projects/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,12 @@
</div>
{% endblock project_header_navigation %}

{# Render all the notifications attached to the project.#}
{% for notification in project.notifications.all %}
<div class="ui message">
<i class="fa-solid {{ notification.get_message.get_display_icon_classes }}"></i>
<span>{{ notification.get_message.get_rendered_body|safe }}</span>
</div>
{% endfor %}

{% endblock project_header %}

0 comments on commit bbfd72c

Please sign in to comment.