Skip to content

Commit

Permalink
Notifications: render Organization notifications on details page
Browse files Browse the repository at this point in the history
This work was missed when implementing the new notification system.

Related readthedocs/ext-theme#260
  • Loading branch information
humitos committed Jan 10, 2024
1 parent 4a864c3 commit 35725cc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions readthedocs/organizations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import structlog
from autoslug import AutoSlugField
from django.contrib.auth.models import User
from django.contrib.contenttypes.fields import GenericRelation
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.urls import reverse
Expand All @@ -12,6 +13,7 @@
from readthedocs.core.history import ExtraHistoricalRecords
from readthedocs.core.permissions import AdminPermission
from readthedocs.core.utils import slugify
from readthedocs.notifications.models import Notification

from . import constants
from .managers import TeamManager, TeamMemberManager
Expand Down Expand Up @@ -118,6 +120,13 @@ class Organization(models.Model):
blank=True,
)

notifications = GenericRelation(
Notification,
related_query_name="organization",
content_type_field="attached_to_content_type",
object_id_field="attached_to_id",
)

# Managers
objects = OrganizationQuerySet.as_manager()
history = ExtraHistoricalRecords()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
{% block organization-bar-details %}active{% endblock %}

{% block content %}
{% if organization.notifications.exists %}
<ul class="notifications">
{% for notification in organization.notifications.all %}
<li class="notification">
{{ notification.get_message.get_rendered_body|safe }}
</li>
{% endfor %}
</ul>
{% endif %}

<div class="col-major organization-major">
<div class="module organization organization-detail">
{% if projects|length == 0 %}
Expand Down

0 comments on commit 35725cc

Please sign in to comment.