Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(projectHistoryLogs): record logs for cloned permissions TASK-944 #5302

Merged
merged 11 commits into from
Dec 3, 2024

Conversation

rgraber
Copy link
Contributor

@rgraber rgraber commented Nov 26, 2024

🗒️ Checklist

  1. run linter locally
  2. update all related docs (API, README, inline, etc.), if any
  3. draft PR with a title <type>(<scope>)<!>: <title> TASK-1234
  4. tag PR: at least frontend or backend unless it's global
  5. fill in the template below and delete template comments
  6. review thyself: read the diff and repro the preview as written
  7. open PR & confirm that CI passes
  8. request reviewers, if needed
  9. delete this section before merging

📣 Summary

Record logs when permissions are cloned from one project to another.

👀 Preview steps

Feature/no-change template:

  1. ℹ️ have an account and at least 2 projects
  2. From a terminal, run
curl -X PATCH -H 'Authorization: Token <your token>' -H 'Content-type: application/json' localhost/api/v2/assets/<project_1_uid>/permission_assignments/clone/ -d '{"clone_from": "<project_2_uid>"}'
  1. Go to `localhost/api/v2/audit-logs/?](http://localhost/api/v2/audit-logs/?q=log_type:project-history AND metadata__asset_uid:<project_1_uid>&format=json
  2. 🟢 There should be a new project history log that looks like
app_label:	"kpi",
model_name:	"asset",
user:	"http://localhost/api/v2/users/<user>/?format=json",
user_uid:	"<user_uid>",
username:	"<username>",
action:	"clone-permissions",
metadata: {	
    source:	"curl (Other)"
    asset_uid:	"<project_1_uid>"
    ip_address:	"172.18.0.1"
    cloned_from:	"<project_2_uid>"
    log_subtype:	"permission"
},
date_created:	"2024-12-02T15:21:20Z",
log_type:	"project-history",

💭 Notes

Uses the AuditLoggedModelViewSet base class

@rgraber rgraber changed the base branch from main to rsgraber/TASK-944-permissions-better November 26, 2024 21:01
@rgraber rgraber force-pushed the rsgraber/TASK-944-cloned-perms branch from 77c019d to 6fc38bd Compare November 27, 2024 22:16
Base automatically changed from rsgraber/TASK-944-permissions-better to main December 2, 2024 20:19
@rgraber rgraber marked this pull request as ready for review December 2, 2024 20:22
@rgraber rgraber requested a review from Guitlle December 2, 2024 20:24
Copy link
Contributor

@Guitlle Guitlle 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. It's simpler than what I was going to do

@rgraber rgraber merged commit 7acd5aa into main Dec 3, 2024
5 checks passed
@rgraber rgraber deleted the rsgraber/TASK-944-cloned-perms branch December 3, 2024 13:54
rgraber added a commit that referenced this pull request Dec 3, 2024
…#5302)

### 📣 Summary
Record logs when permissions are cloned from one project to another.


### 👀 Preview steps


Feature/no-change template:
1. ℹ️ have an account and at least 2 projects
2. From a terminal, run
```
curl -X PATCH -H 'Authorization: Token <your token>' -H 'Content-type: application/json' localhost/api/v2/assets/<project_1_uid>/permission_assignments/clone/ -d '{"clone_from": "<project_2_uid>"}'
```
4. Go to
`localhost/api/v2/audit-logs/?](http://localhost/api/v2/audit-logs/?q=log_type:project-history
AND metadata__asset_uid:<project_1_uid>&format=json
5. 🟢 There should be a new project history log that looks like
```
app_label:	"kpi",
model_name:	"asset",
user:	"http://localhost/api/v2/users/<user>/?format=json",
user_uid:	"<user_uid>",
username:	"<username>",
action:	"clone-permissions",
metadata: {	
    source:	"curl (Other)"
    asset_uid:	"<project_1_uid>"
    ip_address:	"172.18.0.1"
    cloned_from:	"<project_2_uid>"
    log_subtype:	"permission"
},
date_created:	"2024-12-02T15:21:20Z",
log_type:	"project-history",
```

### 💭 Notes
Uses the AuditLoggedModelViewSet base class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants