File tree 2 files changed +19
-0
lines changed
readthedocs/organizations
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 2
2
import structlog
3
3
from autoslug import AutoSlugField
4
4
from django .contrib .auth .models import User
5
+ from django .contrib .contenttypes .fields import GenericRelation
5
6
from django .contrib .contenttypes .models import ContentType
6
7
from django .db import models
7
8
from django .urls import reverse
12
13
from readthedocs .core .history import ExtraHistoricalRecords
13
14
from readthedocs .core .permissions import AdminPermission
14
15
from readthedocs .core .utils import slugify
16
+ from readthedocs .notifications .models import Notification
15
17
16
18
from . import constants
17
19
from .managers import TeamManager , TeamMemberManager
@@ -118,6 +120,13 @@ class Organization(models.Model):
118
120
blank = True ,
119
121
)
120
122
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
+
121
130
# Managers
122
131
objects = OrganizationQuerySet .as_manager ()
123
132
history = ExtraHistoricalRecords ()
Original file line number Diff line number Diff line change 9
9
{% block organization-bar-details %}active{% endblock %}
10
10
11
11
{% 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
+
12
22
< div class ="col-major organization-major ">
13
23
< div class ="module organization organization-detail ">
14
24
{% if projects|length == 0 %}
You can’t perform that action at this time.
0 commit comments