Skip to content

Commit

Permalink
chore: use MultiSelectList Link fields in reports
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r committed Nov 28, 2024
1 parent 905fcb9 commit f78696c
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 18 deletions.
12 changes: 8 additions & 4 deletions mail_client/mail_client/report/mail_tracker/mail_tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@ frappe.query_reports["Mail Tracker"] = {
{
fieldname: "domain_name",
label: __("Domain Name"),
fieldtype: "Link",
options: "Mail Domain",
fieldtype: "MultiSelectList",
get_data: (txt) => {
return frappe.db.get_link_options("Mail Domain", txt);
},
},
{
fieldname: "sender",
label: __("Sender"),
fieldtype: "Link",
options: "Mailbox",
fieldtype: "MultiSelectList",
get_data: (txt) => {
return frappe.db.get_link_options("Mailbox", txt);
},
},
{
fieldname: "message_id",
Expand Down
9 changes: 7 additions & 2 deletions mail_client/mail_client/report/mail_tracker/mail_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,19 @@ def get_data(filters: dict | None = None) -> list[dict]:
for field in [
"name",
"status",
"domain_name",
"sender",
"message_id",
"tracking_id",
]:
if filters.get(field):
query = query.where(OM[field] == filters.get(field))

for field in [
"domain_name",
"sender",
]:
if filters.get(field):
query = query.where(OM[field].isin(filters.get(field)))

user = frappe.session.user
if not is_system_manager(user):
conditions = []
Expand Down
12 changes: 8 additions & 4 deletions mail_client/mail_client/report/outbound_delay/outbound_delay.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ frappe.query_reports["Outbound Delay"] = {
{
fieldname: "domain_name",
label: __("Domain Name"),
fieldtype: "Link",
options: "Mail Domain",
fieldtype: "MultiSelectList",
get_data: (txt) => {
return frappe.db.get_link_options("Mail Domain", txt);
},
},
{
fieldname: "ip_address",
Expand All @@ -48,8 +50,10 @@ frappe.query_reports["Outbound Delay"] = {
{
fieldname: "sender",
label: __("Sender"),
fieldtype: "Link",
options: "Mailbox",
fieldtype: "MultiSelectList",
get_data: (txt) => {
return frappe.db.get_link_options("Mailbox", txt);
},
},
{
fieldname: "email",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,19 @@ def get_data(filters: dict | None = None) -> list[dict]:

for field in [
"name",
"domain_name",
"ip_address",
"sender",
"message_id",
]:
if filters.get(field):
query = query.where(OM[field] == filters.get(field))

for field in [
"domain_name",
"sender",
]:
if filters.get(field):
query = query.where(OM[field].isin(filters.get(field)))

for field in ["status", "email"]:
if filters.get(field):
query = query.where(MR[field] == filters.get(field))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ frappe.query_reports["Outgoing Mail Summary"] = {
{
fieldname: "domain_name",
label: __("Domain Name"),
fieldtype: "Link",
options: "Mail Domain",
fieldtype: "MultiSelectList",
get_data: (txt) => {
return frappe.db.get_link_options("Mail Domain", txt);
},
},
{
fieldname: "ip_address",
Expand All @@ -48,8 +50,10 @@ frappe.query_reports["Outgoing Mail Summary"] = {
{
fieldname: "sender",
label: __("Sender"),
fieldtype: "Link",
options: "Mailbox",
fieldtype: "MultiSelectList",
get_data: (txt) => {
return frappe.db.get_link_options("Mailbox", txt);
},
},
{
fieldname: "email",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,19 @@ def get_data(filters: dict | None = None) -> list[dict]:

for field in [
"name",
"domain_name",
"ip_address",
"sender",
"message_id",
]:
if filters.get(field):
query = query.where(OM[field] == filters.get(field))

for field in [
"domain_name",
"sender",
]:
if filters.get(field):
query = query.where(OM[field].isin(filters.get(field)))

for field in ["status", "email"]:
if filters.get(field):
query = query.where(MR[field] == filters.get(field))
Expand Down

0 comments on commit f78696c

Please sign in to comment.