Skip to content

Commit 687280e

Browse files
DATVenanciovictor-accarini
authored andcommitted
views: update note visualization
Signed-off-by: DATVenancio <daniel.venancio@profusion.mobi> Signed-off-by: Victor Accarini <victor.accarini@profusion.mobi>
1 parent 2fd7f8d commit 687280e

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

patchwork/tests/views/test_patch.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,10 @@ def test_comment_redirect(self):
248248
self.assertRedirects(response, redirect_url)
249249

250250
def test_show_maintainer_note(self):
251-
patch = create_patch()
251+
project = create_project()
252+
user_default = create_user(project)
253+
user_maintainer = create_maintainer(project)
254+
patch = create_patch(project=project)
252255
note = create_patch_comment(patch=patch, msgid='')
253256
requested_url = reverse(
254257
'patch-detail',
@@ -257,6 +260,20 @@ def test_show_maintainer_note(self):
257260
'msgid': patch.encoded_msgid,
258261
},
259262
)
263+
264+
# No authentication
265+
response = self.client.get(requested_url)
266+
self.assertNotIn('# Maintainer Note'.encode('utf-8'), response.content)
267+
self.assertNotIn(note.content.encode('utf-8'), response.content)
268+
269+
# Auth with default user
270+
self.client.login(username=user_default.username, password=user_default.username)
271+
response = self.client.get(requested_url)
272+
self.assertNotIn('# Maintainer Note'.encode('utf-8'), response.content)
273+
self.assertNotIn(note.content.encode('utf-8'), response.content)
274+
275+
# Auth with maintainer user
276+
self.client.login(username=user_maintainer.username, password=user_maintainer.username)
260277
response = self.client.get(requested_url)
261278
self.assertIn('# Maintainer Note'.encode('utf-8'), response.content)
262279
self.assertIn(note.content.encode('utf-8'), response.content)

patchwork/views/cover.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ def cover_detail(request, project_id, msgid):
5858
handle_post_maintainer_note(cover, request)
5959
)
6060

61+
if is_maintainer:
62+
context['note'] = note
63+
6164
context['comments'] = comments
62-
context['note'] = note
6365
context['is_maintainer'] = is_maintainer
6466
context['create_note_form'] = create_note_form
6567
context['edit_note_form'] = edit_note_form

patchwork/views/patch.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ def patch_detail(request, project_id, msgid):
165165
related_same_project = []
166166
related_different_project = []
167167

168-
context['note'] = note
168+
if is_maintainer:
169+
context['note'] = note
170+
169171
context['comments'] = comments
170172
context['checks'] = Patch.filter_unique_checks(
171173
patch.check_set.all().select_related('user'),

0 commit comments

Comments
 (0)