Skip to content

Commit

Permalink
feat(db-perm-manager): add new actitvities in site activity doctype
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmoysrt committed Nov 26, 2024
1 parent e442a1b commit 23e9a20
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions press/press/doctype/site_activity/site_activity.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Action",
"options": "Activate Site\nAdd Domain\nArchive\nBackup\nCreate\nClear Cache\nDeactivate Site\nInstall App\nLogin as Administrator\nMigrate\nReinstall\nRestore\nSuspend Site\nUninstall App\nUnsuspend Site\nUpdate\nUpdate Configuration\nDrop Offsite Backups\nEnable Database Access\nDisable Database Access",
"options": "Activate Site\nAdd Domain\nArchive\nBackup\nCreate\nClear Cache\nDeactivate Site\nInstall App\nLogin as Administrator\nMigrate\nReinstall\nRestore\nSuspend Site\nUninstall App\nUnsuspend Site\nUpdate\nUpdate Configuration\nDrop Offsite Backups\nEnable Database Access\nDisable Database Access\nCreate Database User\nRemove Database User\nModify Database User Permissions",
"read_only": 1,
"reqd": 1,
"search_index": 1
Expand All @@ -56,7 +56,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-10-20 18:48:39.472990",
"modified": "2024-11-26 11:53:47.035359",
"modified_by": "Administrator",
"module": "Press",
"name": "Site Activity",
Expand Down
3 changes: 3 additions & 0 deletions press/press/doctype/site_activity/site_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class SiteActivity(Document):
"Drop Offsite Backups",
"Enable Database Access",
"Disable Database Access",
"Create Database User",
"Remove Database User",
"Modify Database User Permissions",
]
job: DF.Link | None
reason: DF.SmallText | None
Expand Down
8 changes: 5 additions & 3 deletions press/press/doctype/site_database_user/site_database_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def before_insert(self):

def after_insert(self):
log_site_activity(

Check warning on line 73 in press/press/doctype/site_database_user/site_database_user.py

View check run for this annotation

Codecov / codecov/patch

press/press/doctype/site_database_user/site_database_user.py#L73

Added line #L73 was not covered by tests
self.site, "Create Database User", reason=f"Created user {self.username} with {self.mode} mode"
self.site,
"Create Database User",
reason=f"Created user {self.username} with {self.mode} permission",
)
if hasattr(self.flags, "ignore_after_insert_hooks") and self.flags.ignore_after_insert_hooks:
"""
Expand All @@ -85,7 +87,7 @@ def on_update(self):
log_site_activity(

Check warning on line 87 in press/press/doctype/site_database_user/site_database_user.py

View check run for this annotation

Codecov / codecov/patch

press/press/doctype/site_database_user/site_database_user.py#L86-L87

Added lines #L86 - L87 were not covered by tests
self.site,
"Remove Database User",
reason=f"Removed user {self.username} with {self.mode} mode",
reason=f"Removed user {self.username} with {self.mode} permission",
)

def _raise_error_if_archived(self):
Expand Down Expand Up @@ -192,7 +194,7 @@ def modify_permissions(self):
log_site_activity(

Check warning on line 194 in press/press/doctype/site_database_user/site_database_user.py

View check run for this annotation

Codecov / codecov/patch

press/press/doctype/site_database_user/site_database_user.py#L194

Added line #L194 was not covered by tests
self.site,
"Modify Database User Permissions",
reason=f"Modified user {self.username} with {self.mode} mode",
reason=f"Modified user {self.username} with {self.mode} permission",
)
server = frappe.db.get_value("Site", self.site, "server")
agent = Agent(server)
Expand Down

0 comments on commit 23e9a20

Please sign in to comment.