Skip to content

Commit

Permalink
Notifications: show attached to User, Project and Organization (#…
Browse files Browse the repository at this point in the history
…261)

* Notifications: show attached to `User`, `Project` and `Organization`

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

Closes #260

* Render notifications before project/organization header

* Apply suggestions from code review

Co-authored-by: Anthony <[email protected]>

---------

Co-authored-by: Anthony <[email protected]>
  • Loading branch information
humitos and agjohnson authored Jan 18, 2024
1 parent 178a684 commit df4192b
Show file tree
Hide file tree
Showing 3 changed files with 35 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
10 changes: 10 additions & 0 deletions readthedocsext/theme/templates/organizations/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
{% endcomment %}

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



<div class="ui top attached segment" data-bind="using: CollapsingHeaderView({{ is_collapsed|default_if_none:True|yesno:"true,false" }})">

{% block organization_header_metadata %}
Expand Down
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 @@ -20,6 +20,14 @@
{% endcomment %}

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

<div class="ui top attached segment" data-bind="using: CollapsingHeaderView({{ is_collapsed|default_if_none:True|yesno:"true,false" }})">

{% block project_header_metadata %}
Expand Down

0 comments on commit df4192b

Please sign in to comment.