diff --git a/crm/api/__init__.py b/crm/api/__init__.py new file mode 100644 index 00000000..0039c426 --- /dev/null +++ b/crm/api/__init__.py @@ -0,0 +1,12 @@ +import frappe +from frappe.translate import get_all_translations + + +@frappe.whitelist(allow_guest=True) +def get_translations(): + if frappe.session.user != "Guest": + language = frappe.db.get_value("User", frappe.session.user, "language") + else: + language = frappe.db.get_single_value("System Settings", "language") + + return get_all_translations(language) \ No newline at end of file diff --git a/crm/api/doc.py b/crm/api/doc.py index 199c99b1..20da945a 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -1,4 +1,5 @@ import frappe +from frappe import _ from frappe.model.document import get_controller from frappe.model import no_value_fields from pypika import Criterion @@ -13,7 +14,7 @@ def sort_options(doctype: str): fields = [field for field in fields if field.fieldtype not in no_value_fields] fields = [ { - "label": field.label, + "label": _(field.label), "value": field.fieldname, } for field in fields @@ -29,6 +30,7 @@ def sort_options(doctype: str): ] for field in standard_fields: + field["label"] = _(field["label"]) fields.append(field) return fields @@ -101,6 +103,9 @@ def get_filterable_fields(doctype: str): field["name"] = field.get("fieldname") res.append(field) + for field in res: + field["label"] = _(field.get("label")) + return res def get_fields_meta(DocField, doctype, allowed_fieldtypes, restricted_fields): @@ -184,6 +189,7 @@ def get_list_data( for column in columns: if column.get("key") not in rows: rows.append(column.get("key")) + column["label"] = _(column.get("label")) data = frappe.get_list( doctype, @@ -197,7 +203,7 @@ def get_list_data( fields = [field for field in fields if field.fieldtype not in no_value_fields] fields = [ { - "label": field.label, + "label": _(field.label), "type": field.fieldtype, "value": field.fieldname, "options": field.options, @@ -224,6 +230,7 @@ def get_list_data( if field.get('value') not in rows: rows.append(field.get('value')) if field not in fields: + field["label"] = _(field["label"]) fields.append(field) if not is_default and custom_view_name: diff --git a/crm/api/notifications.py b/crm/api/notifications.py index bdbe9118..3dde662c 100644 --- a/crm/api/notifications.py +++ b/crm/api/notifications.py @@ -4,9 +4,6 @@ from frappe.query_builder import Order @frappe.whitelist() def get_notifications(): - if frappe.session.user == "Guest": - frappe.throw("Authentication failed", exc=frappe.AuthenticationError) - Notification = frappe.qb.DocType("CRM Notification") query = ( frappe.qb.from_(Notification) @@ -46,9 +43,6 @@ def get_notifications(): @frappe.whitelist() def mark_as_read(user=None, comment=None): - if frappe.session.user == "Guest": - frappe.throw("Authentication failed", exc=frappe.AuthenticationError) - user = user or frappe.session.user filters = {"to_user": user, "read": False} if comment: diff --git a/crm/api/session.py b/crm/api/session.py index c6218317..3902ff7f 100644 --- a/crm/api/session.py +++ b/crm/api/session.py @@ -1,11 +1,8 @@ import frappe -@frappe.whitelist(allow_guest=True) +@frappe.whitelist() def get_users(): - if frappe.session.user == "Guest": - frappe.throw("Authentication failed", exc=frappe.AuthenticationError) - users = frappe.qb.get_query( "User", fields=["name", "email", "enabled", "user_image", "full_name", "user_type"], @@ -24,9 +21,6 @@ def get_users(): @frappe.whitelist() def get_contacts(): - if frappe.session.user == "Guest": - frappe.throw("Authentication failed", exc=frappe.AuthenticationError) - contacts = frappe.get_all( "Contact", fields=[ @@ -66,9 +60,6 @@ def get_contacts(): @frappe.whitelist() def get_lead_contacts(): - if frappe.session.user == "Guest": - frappe.throw("Authentication failed", exc=frappe.AuthenticationError) - lead_contacts = frappe.get_all( "CRM Lead", fields=[ @@ -88,9 +79,6 @@ def get_lead_contacts(): @frappe.whitelist() def get_organizations(): - if frappe.session.user == "Guest": - frappe.throw("Authentication failed", exc=frappe.AuthenticationError) - organizations = frappe.qb.get_query( "CRM Organization", fields=['*'], diff --git a/crm/api/views.py b/crm/api/views.py index 6a95adbf..f70246e1 100644 --- a/crm/api/views.py +++ b/crm/api/views.py @@ -4,9 +4,6 @@ from pypika import Criterion @frappe.whitelist() def get_views(doctype): - if frappe.session.user == "Guest": - frappe.throw("Authentication failed", exc=frappe.AuthenticationError) - View = frappe.qb.DocType("CRM View Settings") query = ( frappe.qb.from_(View) diff --git a/crm/fcrm/doctype/crm_call_log/crm_call_log.py b/crm/fcrm/doctype/crm_call_log/crm_call_log.py index 6c646e4c..0147b9ac 100644 --- a/crm/fcrm/doctype/crm_call_log/crm_call_log.py +++ b/crm/fcrm/doctype/crm_call_log/crm_call_log.py @@ -93,7 +93,7 @@ def get_call_log(name): if c: return [c.full_name, c.image] return [None, None] - + def get_lead_contact(number): l = frappe.db.get_value("CRM Lead", {"mobile_no": number, "converted": 0}, ["lead_name", "image"], as_dict=True) if l: diff --git a/frontend/src/components/Activities.vue b/frontend/src/components/Activities.vue index c0916c64..8075a792 100644 --- a/frontend/src/components/Activities.vue +++ b/frontend/src/components/Activities.vue @@ -1,7 +1,7 @@ - New Email + {{ __('New Email') }} - New + {{ __('New') }}