Skip to content

[ENG-10146] Changes in Admin by Support Staff should be visible in activity logs#11697

Open
antkryt wants to merge 2 commits into
CenterForOpenScience:feature/pbs-26-9from
antkryt:feature/ENG-10146
Open

[ENG-10146] Changes in Admin by Support Staff should be visible in activity logs#11697
antkryt wants to merge 2 commits into
CenterForOpenScience:feature/pbs-26-9from
antkryt:feature/ENG-10146

Conversation

@antkryt
Copy link
Copy Markdown
Contributor

@antkryt antkryt commented Apr 16, 2026

Ticket

Purpose

add missing logs for admin actions

Changes

  • expose foreign_user in logs response
  • add requested logs for admin actions

Side Effects

QE Notes

CE Notes

Documentation

@antkryt
Copy link
Copy Markdown
Contributor Author

antkryt commented Apr 17, 2026

tests passed on my local branch

Copy link
Copy Markdown
Contributor

@mkovalua mkovalua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, small changings are needed for Front End side to render foreign_user

An OSF Support Team member made a node private

for logs

image

@mkovalua
Copy link
Copy Markdown
Contributor

@adlius try please test job rerun , maybe some CI/CD issue

@antkryt antkryt changed the base branch from feature/pbs-26-6 to feature/pbs-26-9 May 26, 2026 16:34
@antkryt antkryt force-pushed the feature/ENG-10146 branch from f70f672 to 85f02ee Compare May 27, 2026 13:12
Copy link
Copy Markdown
Collaborator

@cslzchen cslzchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall 👍 with a few questions to help me understand and some nitpicking suggestions.

Comment thread admin/nodes/views.py
Comment on lines +229 to +230
params = dict(node.log_params)
params['contributors'] = user.pk
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar with this part, curious on why we change from

params={
    'project': node.parent_id,
    'node': node.pk,
    'contributors': user.pk
}

to

params = dict(node.log_params)
params['contributors'] = user.pk

Is this a functional change where the the params? e.g. node.log_params may have more than just the three keys.

Comment thread admin/nodes/views.py
permissions=permission,
notification_type=None
notification_type=None,
log=False,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand why log=False here? From the ticket, looks like we want changes to be logged but "anonymously" but I may have misunderstood.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I might have figured it out. We disable the log here and manually call add_log() later.

Comment thread admin/nodes/views.py

if permissions_changed:
params = resource.log_params
params['contributors'] = permissions_changed
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am noticed that the type of params['contributors'] can be a integer (user.pk) earlier and a dict here. Seems inconsistent to me?

Comment thread admin/nodes/views.py
).save()
auth=None,
foreign_user=NodeLog.SUPPORT_USER_LABEL,
params=dict(node.log_params),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to an earlier question, node.log_params vs params={'project': node.parent_id}. Is this a required functional change? i.e. passing everything instead of just the one needed.

Comment thread admin/nodes/views.py
Comment on lines +912 to +915
params={
'project': node.parent_id,
'node': node._primary_key,
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related, why don't use log.params as you did in other places? (a question, not a suggestion)

Comment thread admin/nodes/views.py
Comment on lines +956 to +961
params={
'project': node.parent_id,
'node': node._primary_key,
'pathType': 'file',
'path': file_path,
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Maybe there is a reason we have to manually / explicitly set the params in some cases like this and a couple of following ones.

view = setup_log_view(self.view(), self.request, guid=self.node._id, user_id=self.user_2.id)
view.post(self.request)
assert self.node.logs.latest().action != NodeLog.CONTRIB_REMOVED
assert self.node.logs.filter(action=NodeLog.CONTRIB_REMOVED).exists()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not specific on this one test, should we also test that the anonymous label shows up in the log instead of the admin user.

In addition, we only updated two tests here but here are probably 10 places in the code we updated? Does the other ones don't have a test at all (so nothing to fix)? Should we also update/add tests for each cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants