Skip to content

Commit 74fa96c

Browse files
authored
Notifications: render Organization notifications on details page (#11023)
This work was missed when implementing the new notification system. Related readthedocs/ext-theme#260
1 parent 3fee5e8 commit 74fa96c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

readthedocs/organizations/models.py

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import structlog
33
from autoslug import AutoSlugField
44
from django.contrib.auth.models import User
5+
from django.contrib.contenttypes.fields import GenericRelation
56
from django.contrib.contenttypes.models import ContentType
67
from django.db import models
78
from django.urls import reverse
@@ -12,6 +13,7 @@
1213
from readthedocs.core.history import ExtraHistoricalRecords
1314
from readthedocs.core.permissions import AdminPermission
1415
from readthedocs.core.utils import slugify
16+
from readthedocs.notifications.models import Notification
1517

1618
from . import constants
1719
from .managers import TeamManager, TeamMemberManager
@@ -118,6 +120,13 @@ class Organization(models.Model):
118120
blank=True,
119121
)
120122

123+
notifications = GenericRelation(
124+
Notification,
125+
related_query_name="organization",
126+
content_type_field="attached_to_content_type",
127+
object_id_field="attached_to_id",
128+
)
129+
121130
# Managers
122131
objects = OrganizationQuerySet.as_manager()
123132
history = ExtraHistoricalRecords()

readthedocs/organizations/templates/organizations/organization_detail.html

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99
{% block organization-bar-details %}active{% endblock %}
1010

1111
{% block content %}
12+
{% if organization.notifications.exists %}
13+
<ul class="notifications">
14+
{% for notification in organization.notifications.all %}
15+
<li class="notification">
16+
{{ notification.get_message.get_rendered_body|safe }}
17+
</li>
18+
{% endfor %}
19+
</ul>
20+
{% endif %}
21+
1222
<div class="col-major organization-major">
1323
<div class="module organization organization-detail">
1424
{% if projects|length == 0 %}

0 commit comments

Comments
 (0)