Invite Church Persons to be Portal Users

This commit is contained in:
meichthys 2026-02-03 04:54:30 +00:00
parent 7c1b2c5c9d
commit 2925339347
5 changed files with 50 additions and 12 deletions

View File

@ -1,6 +1,6 @@
{
"charts": [],
"content": "[{\"id\":\"nnvMTG5Sl5\",\"type\":\"paragraph\",\"data\":{\"text\":\"<span class=\\\"h1\\\" style=\\\"font-weight: normal;\\\">\ud83c\udf10Website&nbsp;Manual</span>\",\"col\":12}},{\"id\":\"B-CtTCmVDX\",\"type\":\"paragraph\",\"data\":{\"text\":\"<span style=\\\"font-weight: normal;\\\">The website module manages and configures a public facing website for the church using data from other modules (i.e. Foundations, Missions, Ministries, etc).</span>\",\"col\":12}},{\"id\":\"8qBfIl0adi\",\"type\":\"paragraph\",\"data\":{\"text\":\"Various information in the system (i.e. Beliefs, Missionaries, Ministries, etc), may be used to populate the public facing website.\",\"col\":12}},{\"id\":\"kHbqzTGDhX\",\"type\":\"paragraph\",\"data\":{\"text\":\"The website 'feature' has not been fully developed but is on the <a href=\\\"https://github.com/meichthys/church#%EF%B8%8F-feature-roadmap\\\">roadmap</a>.\",\"col\":12}}]",
"content": "[{\"id\":\"nnvMTG5Sl5\",\"type\":\"paragraph\",\"data\":{\"text\":\"<span class=\\\"h1\\\" style=\\\"font-weight: normal;\\\">\ud83c\udf10Website&nbsp;Manual</span>\",\"col\":12}},{\"id\":\"B-CtTCmVDX\",\"type\":\"paragraph\",\"data\":{\"text\":\"<span style=\\\"font-weight: normal;\\\">The website module consists of two main features: a public website, and a user portal.</span>\",\"col\":12}},{\"id\":\"kHbqzTGDhX\",\"type\":\"paragraph\",\"data\":{\"text\":\"\u26a0\ufe0f&nbsp;The website and portal 'features' have not been fully developed but the features are on the <a href=\\\"https://github.com/meichthys/church#%EF%B8%8F-feature-roadmap\\\" draggable=\\\"false\\\">roadmap</a>.\",\"col\":12}},{\"id\":\"fAFxFk8rny\",\"type\":\"header\",\"data\":{\"text\":\"\ud83c\udf0e<span class=\\\"h4\\\"><b>Website</b></span>\",\"col\":12}},{\"id\":\"WCW6FzkHwB\",\"type\":\"paragraph\",\"data\":{\"text\":\"<span style=\\\"font-weight: normal;\\\">The public facing website is accessible by anyone and can be dynamically updated based on information in the Church App </span>(i.e. Beliefs, Missionaries, Ministries, etc).<br><span style=\\\"font-weight: normal;\\\">User accounts with \\\"Church Manager\\\" permissions can <i>modify</i> the website.<br>No user account is required to <i>view</i> the website - anyone with an internet connection and a web browser can view the public website.</span>\",\"col\":12}},{\"id\":\"nZdduTPzRH\",\"type\":\"header\",\"data\":{\"text\":\"\ud83d\udc64<span class=\\\"h4\\\"><b>User Portal</b></span>\",\"col\":12}},{\"id\":\"8qBfIl0adi\",\"type\":\"paragraph\",\"data\":{\"text\":\"The user portal requires login credentials and provides users a personalized interface for accessing church information (i.e. Personal Profile, Prayer Requests, Alms Requests, etc).<br>Portal users cannot access all information in the Church App, they can only access information related to their 'Church Person', or information shared with them (i.e. non-private prayer requests).\",\"col\":12}}]",
"creation": "2025-10-26 22:57:00.373845",
"custom_blocks": [],
"docstatus": 0,
@ -13,7 +13,7 @@
"is_hidden": 0,
"label": "Manual: Website",
"links": [],
"modified": "2025-11-02 01:31:42.840957",
"modified": "2026-02-02 23:18:28.432425",
"modified_by": "Administrator",
"module": "Church Foundations",
"name": "Manual: Website",

View File

@ -8,11 +8,20 @@ frappe.ui.form.on("Church Person", {
frm.add_custom_button(__('New Family From Person'), function () {
frm.call("new_family_from_person")
})
};
}
// Add 'Invite to Portal' button if email is provided and no Portal User is linked
if (frm.doc.email && !frm.doc.portal_user) {
frm.add_custom_button(__('Invite to Portal'), function () {
frm.call("invite_to_portal")
});
}
// Add 'Church Person Tour' button
frm.add_custom_button(__('Tutorial'), function () {
frm.tour.init("Church Person").then(() => frm.tour.start());
});
},
after_save(frm) {
@ -20,5 +29,3 @@ frappe.ui.form.on("Church Person", {
},
});

View File

@ -18,7 +18,7 @@
"photo",
"birthday",
"alergies",
"app_user",
"portal_user",
"church_records_section",
"is_member",
"membership_date",
@ -296,9 +296,9 @@
"print_hide": 1
},
{
"fieldname": "app_user",
"fieldname": "portal_user",
"fieldtype": "Link",
"label": "App User",
"label": "Portal User",
"options": "User"
}
],
@ -327,7 +327,7 @@
"link_fieldname": "recipient"
}
],
"modified": "2025-12-18 23:37:10.065945",
"modified": "2026-02-02 22:55:22.764479",
"modified_by": "Administrator",
"module": "Church People",
"name": "Church Person",

View File

@ -122,10 +122,41 @@ class ChurchPerson(Document):
else:
role.is_current_role = 0
@frappe.whitelist()
def invite_to_portal(self):
# Check if user already exists with this email
user = frappe.db.exists("User", {"email": self.email})
if not user:
# Create a new portal user
new_user = frappe.new_doc("User")
new_user.email = self.email
new_user.first_name = self.first_name
new_user.last_name = self.last_name
new_user.send_welcome_email = 1
new_user.enabled = 1
new_user.role_profile_name = "Church User"
new_user.save(ignore_permissions=True)
# Update Church Person to mark as portal user
self.portal_user = new_user.name
self.save(ignore_permissions=True)
frappe.msgprint(
f"👤 Portal user created and linked: <a href='/app/user/{new_user.name}'>{self.full_name}</a>"
)
else:
# User already exists, just update the portal_user field
self.portal_user = user
self.save(ignore_permissions=True)
frappe.msgprint(
f"⚠️ Portal user <a href='/app/user/{user}'>{user}</a> already exists. User is now linked to this person."
)
def get_list_context(context):
# Only show documents related to the active user
context.filters = {"app_user": frappe.session.user}
context.filters = {"portal_user": frappe.session.user}
# Sort the portal list view by status descending
context.order_by = "modified desc"
return context

File diff suppressed because one or more lines are too long