Commit graph

94 commits

Author SHA1 Message Date
Ankush Menat
fa6dc03cc8
refactor: frappe.cache() usage to frappe.cache (#21282) 2023-06-08 11:47:17 +05:30
Ankush Menat
109a549a23
fix: pass reference_doctype to search query methods (#20842)
frappe.call ensures that it's only passed to functions which can accept
it, so nothing to worry about ~ backward compatible change.
2023-04-25 18:31:14 +05:30
Ankush Menat
b55bbd0a8c
fix(UX): Sort case-insensitive where it makes sense (#20088) 2023-02-20 13:07:32 +05:30
Gavin D'souza
d357af1533 refactor: Add a maxsplit limit to string splits 2023-01-24 19:22:51 +05:30
Daizy Modi
4d9be26ada fix: use stricter regex for sanitize_searchfield 2022-12-14 16:11:04 +05:30
Sagar Vora
f3c00c2bdc
perf: dont fetch meta unless required (#18907) 2022-11-17 13:15:35 +05:30
Raffael Meyer
11d4cf4396
fix: hide value only if it's equal to the label (#18722) 2022-11-02 13:55:09 +05:30
DrZoidberg09
58cef6005a
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]
2022-11-02 13:11:20 +05:30
Raffael Meyer
3d17e1589e
feat: search in translated title, if we show title (#17828)
* refactor: use meta.translated_doctype

* refactor: get_title_field_query

* feat: search in title, if we show title

* refactor: build_for_autosuggest

* style: black

* fix: don't order translated doctypes by untranslated relevance

* feat: match all fields for translated doctypes

* feat: translate all fields in description, remove redundant title

* refactor: title in link

* fix: show name in description for title links
2022-10-12 16:31:53 +05:30
hrwx
42a3fe0fa2 chore: remove untranslated matching 2022-08-12 17:04:37 +01:00
hrwx
b01929405d refactor: translatable doctypes 2022-08-05 21:38:10 +01:00
Ankush Menat
81b37cb7d2
refactor: clean up code to py310 supported features (#17367)
refactor: clean up code to py39+ supported syntax

- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes

Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30
Ritwik Puri
d9900d4742 Revert "fix: mention only users that can be read (#16978)"
This reverts commit 576af52ec6.
2022-06-06 13:14:09 +05:30
Raffael Meyer
576af52ec6
fix: mention only users that can be read (#16978)
Full Name and Email ID of a **User** are sensitive data.

With **Role and User Permissions** we can restrict which other users a user can see, thus maintaining data protection. This could be circumvented by using the `@mention` functionality in comments. It allows us to see all users and their names, regardless of our permissions.

This PR aims to fix this issue by using `get_list` instead of `get_all` while retrieving options for `@mention`.
2022-05-24 16:26:34 +00:00
chillaranand
a9492ba5fa refactor: Remove wrapt package
Also replaced inspect.getfullargspec with inspect.signature to
preserve signature of a decorated functions.
2022-04-27 11:36:07 +05:30
Suraj Shetty
c0c5b2ebdd
style: format all python files using black (#16453)
Co-authored-by: Frappe Bot <developers@frappe.io>
2022-04-12 10:59:25 +05:30
Raffael Meyer
f80a16ed14
feat: add translated search doctypes to hooks (#16197)
In `search.py` it was hardcoded that **DocType** and **Role** get translated before matching against the search text. This way, a user can type in his local language and still see correct results.

This feature is useful for other DocTypes as well. The criterion would be: there is a small, fairly static number of records, so that the performance impact of translating all names first is not too bad.

This PR adds a hook `translated_search_doctypes` that determines which DocType names get translated before search.

I also added **Country** to `translated_search_doctypes` for frappe. The link to **Country** is frequently used in **Address**, but until now there was no way to use it in the local language. There are ~70% less Countries than DocTypes (including ERPNext), so the performance should be fine.

ERPNext could, for example, add the **Gender** DocType to this hook. As there are very few genders, translating them is fast and improves the UX.

Docs: https://frappeframework.com/docs/v13/user/en/python-api/hooks/edit?wiki_page_patch=b4d7c8d6fc
2022-03-23 10:43:04 +00:00
phot0n
bebc8058b6 feat: integer primary keys 2022-03-11 23:46:00 +05:30
Saqib Ansari
ea3ec5e2a7 Merge branch 'develop' of https://github.com/frappe/frappe into link_title_refactor 2022-01-18 09:52:30 +05:30
barredterra
b1383df15a refactor: use is None instead of == None 2022-01-17 10:37:51 +01:00
Saqib Ansari
7c4221df79 feat: show link titles for standard queries 2022-01-13 17:05:14 +05:30
Saqib Ansari
4f340f4aba perf: avoid get_doc while fetching title field 2022-01-13 17:03:54 +05:30
Saqib Ansari
05d80e3b6d refactor: build_for_autosuggest 2022-01-07 18:43:09 +05:30
Saqib Ansari
2b80cabaea chore: remove unused parameter 2022-01-07 16:46:49 +05:30
Saqib Ansari
ab9700d947 Merge branch 'develop' of https://github.com/frappe/frappe into link_title_refactor 2021-12-15 19:32:16 +05:30
Gavin D'souza
3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30
Mohammad Hasnain Mohsin Rajan
7ab7da5c65
fix: only enabled users in mentions (#14017)
* fix: only enabled users in mentions

* Update frappe/desk/search.py

Co-authored-by: gavin <gavin18d@gmail.com>

* test: add test cases to disallow disabled in mention

* test: pass roles as single values

* style: Remove extra space and line

Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com>
Co-authored-by: gavin <gavin18d@gmail.com>
2021-08-27 05:09:40 +00:00
hrwx
bee72ee6ff fix: Null query error 2021-08-03 17:15:29 +05:30
hrwx
d056beb0ef feat: show title links in Link Fields 2021-08-03 15:55:32 +05:30
codescientist703
79124873c3 fix: fixed sider recommendation 2021-07-13 18:43:34 +05:30
Gavin D'souza
ba062adca8 refactor(search): Improvements in search_widget, search_link APIs
* Minor perf enhancements
* Renamed sorting_comparator to relevance_sorter
2021-07-08 13:37:39 +05:30
codescientist703
ecfa8c843f fix: child results should appear for parent search query 2021-07-07 17:33:59 +05:30
codescientist703
85bbcaaac4 fix: added sorting and filtering logic for relevant input results 2021-06-23 13:14:17 +05:30
codescientist703
aa6520b5b0 fix: add sorting for paren tree doctype to appear above child 2021-06-23 13:14:17 +05:30
Gavin D'souza
e407b78506 chore: Drop dead and deprecated code
* Remove six for PY2 compatability since our dependencies are not, PY2
  is legacy.
* Removed usages of utils from future/past libraries since they are
  deprecated. This includes 'from __future__ ...' and 'from past...'
  statements.
* Removed compatibility imports for PY2, switched from six imports to
  standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
  versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass
2021-05-26 15:31:29 +05:30
Suraj Shetty
43a4f1861e fix: Typo 2021-04-30 11:09:13 +05:30
Suraj Shetty
395eed225f style: Fix formatting 2021-04-30 11:03:18 +05:30
Suraj Shetty
183af96465 fix: Link user mention to User Profile 2021-04-30 10:53:20 +05:30
Suraj Shetty
1af59ce16c refactor: Move mention list generation logic to server-side
- Moved mention list generation logic to server-side to get latest mention list everytime
- To indicate group option, added a users icon.
2021-04-30 10:42:19 +05:30
Sagar Vora
497ea861f4 feat: frappe.whitelist for class methods 2021-03-30 13:07:58 +05:30
pateljannat
6e667a7cbd fix: method-not-found-error 2021-02-12 16:00:43 +05:30
Saurabh
97b693c6b0
feat: Added permission to grant only Select access to document (#12063)
* feat: add permtype 'select' to DocPerm and CustomDocPerm

* feat: add 'select' perm in rights tupple

* feat: provisions to handle select permission

* feat: toggle href based on permissions

* feat: pass permission type explicitly while validating link in permission check

* fix: sider

* feat: added test cases to validate select perm

* feat: add method frappe.only_has_select_perm to explicitly check the select perm

* fix: if user only has select perm then do not show anchor tag for link fields

* fix: sider
2020-12-29 16:58:28 +05:30
Suraj Shetty
3368d83238
fix: Remove @ from relevance query (#11837) 2020-11-02 13:07:09 +05:30
Suraj Shetty
cd1ab8e23c
feat: Add validate_and_sanitize_search_inputs decorator (#11194)
* feat: Add validate_and_sanitize_search_inputs decorator

Co-authored-by: Nabin Hait <nabinhait@gmail.com>
Co-authored-by: Prssanna Desai <prssud@gmail.com>
Co-authored-by: Shivam Mishra <scmmishra@users.noreply.github.com>

* refactor: Move validate_and_sanitize_search_inputs to init

* refactor: Move validate_and_sanitize_search_inputs to search.py

* test: validate_and_sanitize_search_inputs decorator

* chore: Add wrapt module

* refactor: Use @wrapt to define validate_and_sanitize_search_inputs decorator

* test: Add a case to make sure frappe.call works as well

Co-authored-by: Nabin Hait <nabinhait@gmail.com>
Co-authored-by: Prssanna Desai <prssud@gmail.com>
Co-authored-by: Shivam Mishra <scmmishra@users.noreply.github.com>
2020-08-05 19:41:41 +05:30
Chinmay D. Pai
d2c4b170a8
fix: get_attr before checking for whitelist
Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2020-07-01 21:07:41 +05:30
Suraj Shetty
0ff59b88d8
Merge branch 'develop' into search_whitelist-fix 2020-06-30 08:17:17 +05:30
Suraj Shetty
70871a344a
fix: Escape user input before regex search (#10812) 2020-06-26 10:33:45 +05:30
Chinmay D. Pai
2ea74dee36
fix: check for whitelist before calling from search
search widget takes query as an input, but does not check whether the
query function that is called is whitelisted, basically allowing anyone
logged-in to call any function regardless of the whitelist.

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2020-05-26 18:47:17 +05:30
Khushal Trivedi
6ab38c2af5 fix: link field search taking trailing and leading spaces (#9031) 2019-12-12 19:24:17 +05:30
Himanshu
720b6bc70f fix(Customize Form): Strip column name in search field list (#8337) 2019-09-05 15:03:57 +05:30