diff mbox series

[8/9] views: Add notes to patch-detail view

Message ID 20240313065642.385843-8-andrepapoti@gmail.com
State New
Headers show
Series [1/9] models: Add Note model | expand

Commit Message

andrepapoti March 13, 2024, 6:56 a.m. UTC
The submission template now includes a section to display notes, these
can be filtered out depending if the request user is a maintainer for
the patch's project and on the note maintainer_only attribute

Signed-off-by: andrepapoti <andrepapoti@gmail.com>
---
 patchwork/templates/patchwork/submission.html | 18 ++++++++++++++++++
 patchwork/views/patch.py                      |  9 +++++++++
 2 files changed, 27 insertions(+)
diff mbox series

Patch

diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html
index 85e7be4..0b0a5a7 100644
--- a/patchwork/templates/patchwork/submission.html
+++ b/patchwork/templates/patchwork/submission.html
@@ -266,6 +266,24 @@ 
   </pre>
 </div>
 
+{% for note in notes %}
+{% if forloop.first %}
+<h2>Notes</h2>
+{% endif %}
+<a name="{{ item.id }}"></a>
+<div class="submission-message">
+  <div class="meta">
+    {{ note.submitter|personify:project }}
+    <span class="message-date">
+      Last modified: {{ note.last_modified }} UTC
+    </span>
+  </div>
+  <pre class="content">
+    {{ note.content }}
+  </pre>
+</div>
+{% endfor %}
+
 {% for item in comments %}
 {% if forloop.first %}
 <h2>Comments</h2>
diff --git a/patchwork/views/patch.py b/patchwork/views/patch.py
index 54cf992..0c6ffbb 100644
--- a/patchwork/views/patch.py
+++ b/patchwork/views/patch.py
@@ -122,6 +122,14 @@  def patch_detail(request, project_id, msgid):
         'submitter', 'date', 'id', 'content', 'patch', 'addressed'
     )
 
+    if (
+        request.user.is_authenticated
+        and patch.project not in request.user.profile.maintainer_projects.all()
+    ):
+        notes = patch.note.all()
+    else:
+        notes = patch.note.filter(maintainer_only=False)
+
     if patch.related:
         related_same_project = patch.related.patches.only(
             'name', 'msgid', 'project', 'related'
@@ -136,6 +144,7 @@  def patch_detail(request, project_id, msgid):
         related_same_project = []
         related_different_project = []
 
+    context['notes'] = notes
     context['comments'] = comments
     context['checks'] = Patch.filter_unique_checks(
         patch.check_set.all().select_related('user'),