Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications: render Organization notifications on details page #11023

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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