From 58cef6005ab5e5864e0dd5e941ffd43c7553f7a8 Mon Sep 17 00:00:00 2001 From: DrZoidberg09 <96449693+DrZoidberg09@users.noreply.github.com> Date: Wed, 2 Nov 2022 08:41:20 +0100 Subject: [PATCH 1/5] fix: search.py after PR #17828 (#18719) * fix search.py After the PR #17828 in some cases an "IndexError: list assignment index out of range" error is thrown. This should fix it. * Update search.py Yes, that should be even better * style: formatting [skip ci] --- frappe/desk/search.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frappe/desk/search.py b/frappe/desk/search.py index c4a94074ba..190cbd99ae 100644 --- a/frappe/desk/search.py +++ b/frappe/desk/search.py @@ -284,7 +284,8 @@ def build_for_autosuggest(res: list[tuple], doctype: str) -> list[dict]: item = list(item) label = item[1] # use title as label item[1] = item[0] # show name in description instead of title - del item[2] # remove redundant title ("label") value + if len(item) >= 3: + del item[2] # remove redundant title ("label") value results.append({"value": item[0], "label": label, "description": to_string(item[1:])}) else: results.extend({"value": item[0], "description": to_string(item[1:])} for item in res) From 11d4cf43961b4c72a5616628dea14c616803ce2e Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Wed, 2 Nov 2022 09:25:09 +0100 Subject: [PATCH 2/5] fix: hide value only if it's equal to the label (#18722) --- frappe/desk/search.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frappe/desk/search.py b/frappe/desk/search.py index 190cbd99ae..b820fabd6d 100644 --- a/frappe/desk/search.py +++ b/frappe/desk/search.py @@ -284,8 +284,9 @@ def build_for_autosuggest(res: list[tuple], doctype: str) -> list[dict]: item = list(item) label = item[1] # use title as label item[1] = item[0] # show name in description instead of title - if len(item) >= 3: - del item[2] # remove redundant title ("label") value + if len(item) >= 3 and item[2] == label: + # remove redundant title ("label") value + del item[2] results.append({"value": item[0], "label": label, "description": to_string(item[1:])}) else: results.extend({"value": item[0], "description": to_string(item[1:])} for item in res) From 5e679bf5399fdb74397b6bdf7412ad1ecdbf0d7d Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Wed, 2 Nov 2022 19:54:55 +0000 Subject: [PATCH 3/5] chore: bump `cryptography` to `38.0.3` (#18730) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a552474a3f..dd51deed3e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ dependencies = [ "cairocffi==1.2.0", "chardet~=4.0.0", "croniter~=1.3.5", - "cryptography~=37.0.2", + "cryptography~=38.0.3", "email-reply-parser~=0.5.12", "git-url-parse~=1.2.2", "gunicorn~=20.1.0", From a1a296ac751d0cbe865925192f8c5e3d6d357765 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Thu, 3 Nov 2022 03:00:03 +0530 Subject: [PATCH 4/5] fix: ignore global translations (#18733) _("string") outside of function/methods don't make any sense cause they are initialized the moment module is imported. This is already checked in CI yet people make this mistake. Ignore and refuse to translate in those cases. --- frappe/tests/test_translate.py | 8 ++++++++ frappe/translate.py | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/frappe/tests/test_translate.py b/frappe/tests/test_translate.py index e546516ade..a5e2876241 100644 --- a/frappe/tests/test_translate.py +++ b/frappe/tests/test_translate.py @@ -112,6 +112,14 @@ class TestTranslate(FrappeTestCase): self.assertIn(return_val, [second_lang, get_parent_language(second_lang)]) + def test_global_translations(self): + """ """ + site = frappe.local.site + frappe.destroy() + _("this shouldn't break") + frappe.init(site=site) + frappe.connect() + def test_guest_request_language_resolution_with_request_header(self): """Test for frappe.translate.get_language diff --git a/frappe/translate.py b/frappe/translate.py index 3f4a5f0c95..339ab6cb05 100644 --- a/frappe/translate.py +++ b/frappe/translate.py @@ -291,7 +291,12 @@ def get_all_translations(lang: str) -> dict[str, str]: return all_translations - return frappe.cache().hget(MERGED_TRANSLATION_KEY, lang, generator=_merge_translations) + try: + return frappe.cache().hget(MERGED_TRANSLATION_KEY, lang, generator=_merge_translations) + except Exception: + # People mistakenly call translation function on global variables + # where locals are not initalized, translations dont make much sense there + return {} def get_translations_from_apps(lang, apps=None): From cc3e70b9ac681019b8acb1f0a5c76ee407f35ebd Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Thu, 3 Nov 2022 14:04:36 +0530 Subject: [PATCH 5/5] fix: file cropper broken in webform --- frappe/public/scss/website/index.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/frappe/public/scss/website/index.scss b/frappe/public/scss/website/index.scss index 109bc8cbb4..e54baf0dd0 100644 --- a/frappe/public/scss/website/index.scss +++ b/frappe/public/scss/website/index.scss @@ -1,6 +1,7 @@ @import '../common/quill'; @import 'variables'; @import '~bootstrap/scss/bootstrap'; +@import '~cropperjs/dist/cropper.min'; @import "../common/mixins"; @import "../common/global"; @import "../common/icons";