fix: mention email link

This commit is contained in:
Jannat Patel
2023-11-22 13:04:04 +05:30
parent 8cdaa7877a
commit 81db6c544d
2 changed files with 4 additions and 45 deletions

View File

@@ -119,7 +119,7 @@ fixtures = ["Custom Field", "Function", "Industry"]
# ------------------------------
#
override_whitelisted_methods = {
"frappe.desk.search.get_names_for_mentions": "lms.lms.utils.get_names_for_mentions",
# "frappe.desk.search.get_names_for_mentions": "lms.lms.utils.get_names_for_mentions",
}
#
# each overriding function accepts a `data` argument;

View File

@@ -617,7 +617,7 @@ def handle_notifications(doc, method):
["reference_doctype", "reference_docname", "owner", "title"],
as_dict=1,
)
if topic.reference_doctype != "Course Lesson":
if topic.reference_doctype not in ["Course Lesson", "LMS Batch"]:
return
create_notification_log(doc, topic)
notify_mentions(doc, topic)
@@ -652,7 +652,6 @@ def create_notification_log(doc, topic):
def notify_mentions(doc, topic):
mentions = extract_mentions(doc.reply)
print(mentions)
if not mentions:
return
@@ -671,8 +670,9 @@ def notify_mentions(doc, topic):
args = {
"sender": sender_fullname,
"content": doc.reply,
"batch_link": "/batches/" + topic.reference_docname,
"batch_link": "/batches/" + topic.reference_docname + "#discussions",
}
for recipient in recipients:
frappe.sendmail(
recipients=recipient,
@@ -1136,44 +1136,3 @@ def change_currency(amount, currency, country=None):
amount = cint(amount)
amount, currency = check_multicurrency(amount, currency, country)
return fmt_money(amount, 0, currency)
@frappe.whitelist()
def get_names_for_mentions(search_term):
print(search_term)
users_for_mentions = frappe.cache.get_value(
"users_for_mentions", get_users_for_mentions
)
print(users_for_mentions)
user_groups = frappe.cache.get_value("user_groups", get_user_groups)
filtered_mentions = []
for mention_data in users_for_mentions + user_groups:
if search_term.lower() not in mention_data.value.lower():
continue
mention_data["link"] = frappe.utils.get_url_to_form(
"User Group" if mention_data.get("is_group") else "User Profile", mention_data["id"]
)
filtered_mentions.append(mention_data)
return sorted(filtered_mentions, key=lambda d: d["value"])
def get_users_for_mentions():
print("this.is.users")
filters = (
{
"name": ["not in", ("Administrator", "Guest")],
"allowed_in_mentions": True,
"enabled": True,
},
)
print(frappe.utils.get_url())
print("this.is.url")
return frappe.get_all(
"User",
filters=filters,
fields=["name as id", "full_name as value", "user_type"],
)