Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
frappe.pages['account-management'].on_page_load = function(wrapper) {
if (!frappe.user_roles.includes('Accounts Manager')) {
var page = frappe.ui.make_app_page({
parent: wrapper,
title: 'Flash Account Manager',
single_column: true
});

page.main.html(`
<div class="text-center mt-5">
<div class="alert alert-warning">
<h4>Access Denied</h4>
<p>You do not have permission to access this page. Please contact your administrator to get the "Account Manager" role.</p>
</div>
</div>
`);
return;
}

var page = frappe.ui.make_app_page({
parent: wrapper,
title: 'Flash Account Manager',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"creation": "2025-09-22 10:00:00.000000",
"docstatus": 0,
"doctype": "Page",
"idx": 0,
"modified": "2025-09-22 10:00:00.000000",
"modified_by": "Administrator",
"module": "Admin Panel",
"name": "account-management",
"owner": "Administrator",
"page_name": "account-management",
"roles": [
{
"role": "Accounts Manager"
},
{
"role": "System Manager"
}
],
"script": "",
"standard": "Yes",
"style": "",
"system_page": 0,
"title": "Account Management"
}
9 changes: 9 additions & 0 deletions admin_panel/api/admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ def update_account_level(uid, level):
frappe.logger().error(f"Unexpected error updating account {uid} to level {level}: {str(e)}")
frappe.response['http_status_code'] = 500
return GENERIC_ERROR

def has_app_permission():
"""Check if the current user has permission to access the admin panel app"""
if frappe.session.user == "Guest":
return False
if "Accounts Manager" in frappe.get_roles():
return True

return False
27 changes: 27 additions & 0 deletions admin_panel/fixtures/page.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"creation": "2024-09-15 10:00:00.000000",
"docstatus": 0,
"doctype": "Page",
"idx": 0,
"modified": "2024-09-15 10:00:00.000000",
"modified_by": "Administrator",
"module": "Admin Panel",
"name": "account-management",
"owner": "Administrator",
"page_name": "account-management",
"roles": [
{
"role": "Accounts Manager"
},
{
"role": "System Manager"
}
],
"script": "",
"standard": "Yes",
"style": "",
"system_page": 0,
"title": "Account Management"
}
]
28 changes: 19 additions & 9 deletions admin_panel/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
# required_apps = []

# Each item in the list will be shown as an app in the apps page
# add_to_apps_screen = [
# {
# "name": "admin_panel",
# "logo": "/assets/admin_panel/logo.png",
# "title": "Admin Panel",
# "route": "/admin_panel",
# "has_permission": "admin_panel.api.permission.has_app_permission"
# }
# ]
add_to_apps_screen = [
{
"name": "admin_panel",
"logo": "/assets/admin_panel/logo-black.png",
"title": "Admin Panel",
"route": "/app/account-management",
"has_permission": "admin_panel.api.admin_api.has_app_permission"
}
]

# Includes in <head>
# ------------------
Expand Down Expand Up @@ -237,3 +237,13 @@
# "Logging DocType Name": 30 # days to retain logs
# }

# Fixtures for installation
# -------------------------
fixtures = [
{
"doctype": "Page",
"filters": {
"name": ["in", ["account-management"]]
}
}
]
Binary file added admin_panel/public/logo-black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.