Skip to content

Commit c5a42a5

Browse files
committed
Store a separate activity for private notes
1 parent 1dbd0c4 commit c5a42a5

File tree

8 files changed

+27
-17
lines changed

8 files changed

+27
-17
lines changed

src/olympia/abuse/actions.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,28 @@ def __init__(self, decision):
5757
)
5858

5959
def log_action(self, activity_log_action, *extra_args, extra_details=None):
60+
user_kw = (
61+
{'user': self.decision.reviewer_user} if self.decision.reviewer_user else {}
62+
)
63+
if self.decision.private_notes:
64+
# If the decision contained private notes, add a separate action
65+
# for them.
66+
log_create(
67+
amo.LOG.REVIEWER_PRIVATE_COMMENT,
68+
self.target,
69+
self.decision,
70+
**user_kw,
71+
details={
72+
'comments': self.decision.private_notes,
73+
},
74+
)
6075
return log_create(
6176
activity_log_action,
6277
self.target,
6378
self.decision,
6479
*(self.decision.policies.all()),
6580
*extra_args,
66-
**(
67-
{'user': self.decision.reviewer_user}
68-
if self.decision.reviewer_user
69-
else {}
70-
),
71-
# FIXME: if the decision had private notes, either record them as
72-
# extra details under a specific key, or as a separate activity log
73-
# to be consistent with how we do it in reviewer tools.
81+
**user_kw,
7482
details={
7583
'comments': self.decision.reasoning,
7684
**(

src/olympia/activity/tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ def test_review_url_unlisted(self, send_mail_mock):
536536
self.grant_permission(self.reviewer, 'Addons:ReviewUnlisted', 'Addon Reviewers')
537537

538538
# One from the reviewer.
539-
self._create(amo.LOG.COMMENT_VERSION, self.reviewer)
539+
self._create(amo.LOG.REVIEWER_PRIVATE_COMMENT, self.reviewer)
540540
# One from the developer. So the developer is on the 'thread'
541541
self._create(amo.LOG.DEVELOPER_REPLY_VERSION, self.developer)
542542
action = amo.LOG.DEVELOPER_REPLY_VERSION

src/olympia/activity/tests/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def _set_tested_url(self, pk=None, version_pk=None, addon_pk=None):
349349

350350
def test_admin_activity_hidden_from_developer(self):
351351
# Add an extra activity note but a type we don't show the developer.
352-
self.log('sécrets', amo.LOG.COMMENT_VERSION, self.days_ago(0))
352+
self.log('sécrets', amo.LOG.REVIEWER_PRIVATE_COMMENT, self.days_ago(0))
353353
self._login_developer()
354354
# _test_url will check only the 3 notes defined in setup are there.
355355
self._test_url()

src/olympia/constants/activity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ class REQUEST_SUPER_REVIEW(_LOG):
242242
obsolete = True
243243

244244

245-
class COMMENT_VERSION(_LOG):
245+
class REVIEWER_PRIVATE_COMMENT(_LOG):
246246
id = 49
247-
format = '{addon} {version} reviewer comment.'
247+
format = 'Reviewer made a private comment.'
248248
short = 'Commented'
249249
keep = True
250250
review_queue = True

src/olympia/devhub/tests/test_feeds.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,9 @@ def test_xss_versions_unlisted_addon(self):
292292

293293
def test_hidden(self):
294294
version = Version.objects.create(addon=self.addon)
295-
ActivityLog.objects.create(amo.LOG.COMMENT_VERSION, self.addon, version)
295+
ActivityLog.objects.create(
296+
amo.LOG.REVIEWER_PRIVATE_COMMENT, self.addon, version
297+
)
296298
res = self.get_response(addon=self.addon.id)
297299
key = RssKey.objects.get()
298300
res = self.get_response(privaterss=key.key)

src/olympia/devhub/tests/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ def add_log(self, action=amo.LOG.ADD_RATING):
639639
core.set_user(self.action_user)
640640
ActivityLog.objects.create(action, self.addon, self.version)
641641

642-
def add_hidden_log(self, action=amo.LOG.COMMENT_VERSION):
642+
def add_hidden_log(self, action=amo.LOG.REVIEWER_PRIVATE_COMMENT):
643643
self.add_log(action=action)
644644

645645
def test_feed_hidden(self):

src/olympia/reviewers/tests/test_views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def test_addon_missing(self):
450450
)
451451

452452
def test_comment_logs(self):
453-
self.make_an_approval(amo.LOG.COMMENT_VERSION)
453+
self.make_an_approval(amo.LOG.REVIEWER_PRIVATE_COMMENT)
454454
response = self.client.get(self.url)
455455
assert response.status_code == 200
456456
assert pq(response.content)('#log-listing tbody td').eq(1).html().strip() == (
@@ -2627,7 +2627,7 @@ def test_comment(self):
26272627
assert response.status_code == 302
26282628
assert len(mail.outbox) == 0
26292629

2630-
comment_version = amo.LOG.COMMENT_VERSION
2630+
comment_version = amo.LOG.REVIEWER_PRIVATE_COMMENT
26312631
assert ActivityLog.objects.filter(action=comment_version.id).count() == 1
26322632

26332633
@mock.patch('olympia.reviewers.utils.report_decision_to_cinder_and_notify.delay')

src/olympia/reviewers/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ def sign_file(self):
12081208
sign_file(self.file)
12091209

12101210
def process_comment(self):
1211-
self.log_action(amo.LOG.COMMENT_VERSION)
1211+
self.log_action(amo.LOG.REVIEWER_PRIVATE_COMMENT)
12121212

12131213
def resolve_reports_job(self):
12141214
if self.data.get('cinder_jobs_to_resolve', ()):

0 commit comments

Comments
 (0)