fix: add deprecation warning for social module energy points

(cherry picked from commit 6764a9ed49314ba03a0a6705a124e1e25069f794)

# Conflicts:
#	frappe/patches.txt
#	frappe/social/doctype/energy_point_log/energy_point_log.js
#	frappe/social/doctype/energy_point_rule/energy_point_rule.js
#	frappe/social/doctype/energy_point_settings/energy_point_settings.js
This commit is contained in:
sokumon 2025-04-24 00:12:40 +05:30 committed by Mergify
parent 32bc18b5c3
commit 56d19ed6fa
5 changed files with 199 additions and 0 deletions

View file

@ -245,3 +245,8 @@ frappe.patches.v16_0.move_role_desk_settings_to_user
frappe.printing.doctype.print_format.patches.sets_wkhtmltopdf_as_default_for_pdf_generator_field
frappe.patches.v14_0.fix_user_settings_collation
execute:frappe.core.doctype.system_settings.system_settings.sync_system_settings
<<<<<<< HEAD
=======
frappe.printing.doctype.print_format.patches.sets_wkhtmltopdf_as_default_for_pdf_generator_field
frappe.patches.v16_0.social_eps_deprecation_warning
>>>>>>> 6764a9ed49 (fix: add deprecation warning for social module energy points)

View file

@ -0,0 +1,9 @@
import click
def execute():
click.secho(
"Social Module/Energy Points System is moving to a new app and will removed from the framework in version-16.\n"
"Please install the app to continue using the integration: https://github.com/frappe/eps",
fg="yellow",
)

View file

@ -0,0 +1,59 @@
// Copyright (c) 2018, Frappe Technologies and contributors
// For license information, please see license.txt
frappe.ui.form.on("Energy Point Log", {
refresh: function (frm) {
frm.events.make_reference_name_link(frm);
if (frm.doc.reverted) {
frm.set_intro(__("This document has been reverted"));
} else if (frm.doc.type === "Auto" && frappe.user_roles.includes("System Manager")) {
frm.add_custom_button(__("Revert"), () => frm.events.show_revert_dialog(frm));
}
let app_link = "<a href='https://github.com/frappe/eps' target='_blank'>EPS</a>";
frm.dashboard.add_comment(
__(
"Energy Point System will be removed from Framework in Version 16. Please install {0} app to continue using it.",
[app_link]
),
"yellow",
true
);
},
show_revert_dialog(frm) {
const revert_dialog = new frappe.ui.Dialog({
title: __("Revert"),
fields: [
{
fieldname: "reason",
fieldtype: "Small Text",
label: __("Reason"),
reqd: 1,
},
],
primary_action: (values) => {
return frm
.call("revert", {
reason: values.reason,
})
.then((res) => {
let revert_log = res.message;
revert_dialog.hide();
revert_dialog.clear();
frappe.model.docinfo[frm.doc.reference_doctype][
frm.doc.reference_name
].energy_point_logs.unshift(revert_log);
frm.refresh();
});
},
primary_action_label: __("Submit"),
});
revert_dialog.show();
},
make_reference_name_link(frm) {
let dt = frm.doc.reference_doctype;
let dn = frm.doc.reference_name;
frm.fields_dict.reference_name.$input_wrapper
.find(".control-value")
.wrapInner(`<a href='/app/${frappe.router.slug(dt)}/${dn}'></a>`);
},
});

View file

@ -0,0 +1,67 @@
// Copyright (c) 2018, Frappe Technologies and contributors
// For license information, please see license.txt
frappe.ui.form.on("Energy Point Rule", {
validate(frm) {
frm.set_df_property("user_field", "reqd", !frm.doc.for_assigned_users);
frm.set_df_property("condition", "reqd", frm.doc.for_doc_event === "Custom");
},
refresh(frm) {
frm.events.set_field_options(frm);
let app_link = "<a href='https://github.com/frappe/eps' target='_blank'>EPS</a>";
frm.dashboard.add_comment(
__(
"Energy Point System will be removed from Framework in Version 16. Please install {0} app to continue using it.",
[app_link]
),
"yellow",
true
);
},
for_doc_event(frm) {
if (frm.doc.for_assigned_users) {
frm.set_value("for_assigned_users", !frm.doc.for_doc_event === "New");
}
},
reference_doctype(frm) {
frm.events.set_field_options(frm);
},
set_field_options(frm) {
// sets options for field_to_check, user_field and multiplier fields
// based on reference doctype
const reference_doctype = frm.doc.reference_doctype;
if (!reference_doctype) return;
frappe.model.with_doctype(reference_doctype, () => {
const map_for_options = (df) => ({ label: df.label, value: df.fieldname });
const fields = frappe.meta
.get_docfields(frm.doc.reference_doctype)
.filter(frappe.model.is_value_type);
const fields_to_check = fields.map(map_for_options);
const user_fields = fields
.filter(
(df) =>
(df.fieldtype === "Link" && df.options === "User") ||
df.fieldtype === "Data"
)
.map(map_for_options)
.concat([
{ label: __("Owner"), value: "owner" },
{ label: __("Modified By"), value: "modified_by" },
]);
const multiplier_fields = fields
.filter((df) => ["Int", "Float"].includes(df.fieldtype))
.map(map_for_options);
// blank option for the ability to unset the multiplier field
multiplier_fields.unshift(null);
frm.set_df_property("field_to_check", "options", fields_to_check);
frm.set_df_property("user_field", "options", user_fields);
frm.set_df_property("multiplier_field", "options", multiplier_fields);
});
},
});

View file

@ -0,0 +1,59 @@
// Copyright (c) 2019, Frappe Technologies and contributors
// For license information, please see license.txt
frappe.ui.form.on("Energy Point Settings", {
refresh: function (frm) {
if (frm.doc.enabled) {
frm.add_custom_button(__("Give Review Points"), show_review_points_dialog);
}
let app_link = "<a href='https://github.com/frappe/eps' target='_blank'>EPS</a>";
frm.dashboard.add_comment(
__(
"Energy Point System will be removed from Framework in Version 16. Please install {0} app to continue using it.",
[app_link]
),
"yellow",
true
);
},
});
function show_review_points_dialog() {
const dialog = new frappe.ui.Dialog({
title: __("Give Review Points"),
fields: [
{
label: "User",
fieldname: "user",
fieldtype: "Link",
options: "User",
reqd: 1,
},
{
label: "Points",
fieldname: "points",
fieldtype: "Int",
reqd: 1,
},
],
primary_action: function (values) {
frappe
.xcall(
"frappe.social.doctype.energy_point_log.energy_point_log.add_review_points",
{
user: values.user,
points: values.points,
}
)
.then(() => {
frappe.show_alert({
message: __("Successfully Done"),
indicator: "green",
});
})
.finally(() => dialog.hide());
},
primary_action_label: __("Submit"),
});
dialog.show();
}