-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
212 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors | ||
// For license information, please see license.txt | ||
|
||
// frappe.ui.form.on("Mail Group Member", { | ||
// refresh(frm) { | ||
|
||
// }, | ||
// }); |
84 changes: 84 additions & 0 deletions
84
mail/mail/doctype/mail_group_member/mail_group_member.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
"actions": [], | ||
"allow_rename": 1, | ||
"autoname": "hash", | ||
"creation": "2025-01-06 15:47:23.657133", | ||
"doctype": "DocType", | ||
"engine": "InnoDB", | ||
"field_order": [ | ||
"section_break_hw88", | ||
"mail_group", | ||
"column_break_upc0", | ||
"member_type", | ||
"member_name" | ||
], | ||
"fields": [ | ||
{ | ||
"fieldname": "section_break_hw88", | ||
"fieldtype": "Section Break" | ||
}, | ||
{ | ||
"fieldname": "mail_group", | ||
"fieldtype": "Link", | ||
"in_list_view": 1, | ||
"in_standard_filter": 1, | ||
"label": "Mail Group", | ||
"no_copy": 1, | ||
"options": "Mail Group", | ||
"reqd": 1, | ||
"set_only_once": 1 | ||
}, | ||
{ | ||
"fieldname": "member_type", | ||
"fieldtype": "Select", | ||
"in_list_view": 1, | ||
"in_standard_filter": 1, | ||
"label": "Member (Type)", | ||
"no_copy": 1, | ||
"options": "\nMail Account\nMail Group", | ||
"reqd": 1, | ||
"set_only_once": 1 | ||
}, | ||
{ | ||
"fieldname": "column_break_upc0", | ||
"fieldtype": "Column Break" | ||
}, | ||
{ | ||
"fieldname": "member_name", | ||
"fieldtype": "Dynamic Link", | ||
"in_list_view": 1, | ||
"in_standard_filter": 1, | ||
"label": "Member (Name)", | ||
"no_copy": 1, | ||
"options": "member_type", | ||
"reqd": 1, | ||
"set_only_once": 1 | ||
} | ||
], | ||
"index_web_pages_for_search": 1, | ||
"links": [], | ||
"modified": "2025-01-06 17:50:56.129594", | ||
"modified_by": "Administrator", | ||
"module": "Mail", | ||
"name": "Mail Group Member", | ||
"naming_rule": "Random", | ||
"owner": "Administrator", | ||
"permissions": [ | ||
{ | ||
"create": 1, | ||
"delete": 1, | ||
"email": 1, | ||
"export": 1, | ||
"print": 1, | ||
"read": 1, | ||
"report": 1, | ||
"role": "System Manager", | ||
"share": 1, | ||
"write": 1 | ||
} | ||
], | ||
"sort_field": "creation", | ||
"sort_order": "DESC", | ||
"states": [], | ||
"track_changes": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors | ||
# For license information, please see license.txt | ||
|
||
import frappe | ||
from frappe import _ | ||
from frappe.model.document import Document | ||
|
||
from mail.mail.doctype.mail_agent_job.mail_agent_job import ( | ||
create_group_member_on_agents, | ||
delete_group_member_from_agents, | ||
) | ||
|
||
|
||
class MailGroupMember(Document): | ||
def validate(self) -> None: | ||
self.validate_member_name() | ||
|
||
def validate_member_name(self) -> None: | ||
if self.mail_group == self.member_name: | ||
if self.member_type == "Mail Group": | ||
frappe.throw(_("Mail Group cannot be a member of itself")) | ||
else: | ||
frappe.throw(_("Member cannot be the same as the Mail Group")) | ||
|
||
def after_insert(self) -> None: | ||
create_group_member_on_agents(self.mail_group, self.member_name) | ||
|
||
def on_trash(self) -> None: | ||
delete_group_member_from_agents(self.mail_group, self.member_name) | ||
|
||
|
||
def on_doctype_update() -> None: | ||
frappe.db.add_unique( | ||
"Mail Group Member", | ||
["mail_group", "member_name"], | ||
constraint_name="unique_mail_group_member", | ||
) |
29 changes: 29 additions & 0 deletions
29
mail/mail/doctype/mail_group_member/test_mail_group_member.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and Contributors | ||
# See license.txt | ||
|
||
# import frappe | ||
from frappe.tests import IntegrationTestCase, UnitTestCase | ||
|
||
# On IntegrationTestCase, the doctype test records and all | ||
# link-field test record dependencies are recursively loaded | ||
# Use these module variables to add/remove to/from that list | ||
EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] | ||
IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] | ||
|
||
|
||
class UnitTestMailGroupMember(UnitTestCase): | ||
""" | ||
Unit tests for MailGroupMember. | ||
Use this class for testing individual functions and methods. | ||
""" | ||
|
||
pass | ||
|
||
|
||
class IntegrationTestMailGroupMember(IntegrationTestCase): | ||
""" | ||
Integration tests for MailGroupMember. | ||
Use this class for testing interactions between multiple components. | ||
""" | ||
|
||
pass |