Commit graph

34000 commits

Author SHA1 Message Date
Ankush Menat
cfd3fb9341 refactor: PUT == PATCH
Correct conventions for partial updates
2023-10-16 18:13:50 +05:30
Ankush Menat
c8cd658d26 fix: add login and logout methods 2023-10-16 18:13:50 +05:30
Ankush Menat
67a5957056 fix: check for write permission if POST method 2023-10-16 18:13:50 +05:30
Ankush Menat
824229ce0a refactor: no need to cast bools manually 2023-10-16 18:13:50 +05:30
Ankush Menat
43028f51d9 refactor: simplify v2 implementations 2023-10-16 18:13:50 +05:30
Ankush Menat
7996f76ebb fix: Better delete doc for child tables 2023-10-16 18:13:50 +05:30
Ankush Menat
232f080044 feat: run_doc_method v2 2023-10-16 18:13:50 +05:30
Ankush Menat
d117e2c08b fix!: Last overriden method should be considered 2023-10-16 18:13:33 +05:30
Ankush Menat
bfb463e814 refactor!: merge handle.py
This has several breaking changes for v2:
1. No support for following methods which were implicitly present in
   default namespace.
    - run_doc_method
    - ping
    - web_logout
    - logout
    - uploadfile
    - upload_file
    - download_file
2023-10-16 18:12:53 +05:30
Ankush Menat
e63f0c895d refactor: resource => document
This lets us create three types of APIs:

- Document APIs that operate on documents
- DocType APIs that operate on collections - list, count, search
- Method APIs that are RPC calls
2023-10-16 18:12:53 +05:30
Ankush Menat
10ace97ebb fix: backward compatiblity for method calls in v1
Preserves complete path just like before. This broke oauth as oauth code
was expecting 4th part in path even though it's never been supported in
API methods
2023-10-16 18:12:53 +05:30
Ankush Menat
e96ecab00e refactor: OAuth flow without breaking routing convention
Appending `/connected-app` after method breaks routing.
2023-10-16 18:12:53 +05:30
Ankush Menat
0a244b10fc test: basic tests v2 API 2023-10-16 18:12:53 +05:30
Ankush Menat
947e7f6864 test: refactor API test cases for paramterization 2023-10-16 18:12:53 +05:30
Ankush Menat
985c897c95 refactor: simplify request form data 2023-10-16 18:12:53 +05:30
Ankush Menat
825692128f chore: separate out v1 and v2
Any common utils end up becoming a problem, duplicating code here is
better than coupling potentially breaking behaviour
2023-10-16 18:12:53 +05:30
Ankush Menat
275f16060a fix: route ambiguitities and / in name
v1 and v2:
- Use path convertor to consume entire document which MIGHT contain `/`
- Drop string convertor, as it's the default
- Dont merge slashes - avoid consuming something that's part of name

v2:
- `SI/BLAH/BLAH/submit` is not simple to parse without ambiguitity
- `SI/BLAH/BLAH/method/submit` removes ambiguitity for 99.99% cases.
2023-10-16 18:12:53 +05:30
Ankush Menat
0c61e61743 fix: delete oauth stuff when deleting users 2023-10-16 18:12:53 +05:30
Ankush Menat
627b777a9c refactor!: manual creation of response
This contains minor breaking change where `delete` API call now returns `OK` in `data` key instead of `message`.
2023-10-16 18:12:53 +05:30
Ankush Menat
b57ca948ab refactor: common API methods to utils 2023-10-16 18:12:53 +05:30
Ankush Menat
8ce6426c75 refactor: Drop frappe.local for proxies 2023-10-16 18:12:53 +05:30
Ankush Menat
0b0b7f7f60 test: check that document actually got deleted 2023-10-16 18:12:53 +05:30
Ankush Menat
f9e120c104 refactor: remove unnessary manual commits 2023-10-16 18:12:53 +05:30
Ankush Menat
b6b4b98c0f refactor(APIv2): message -> data 2023-10-16 18:12:53 +05:30
Ankush Menat
26b3f6ae96 fix: pass on custom responses as is without any post processing 2023-10-16 18:12:53 +05:30
Ankush Menat
507343f4f6 fix: double response processing 2023-10-16 18:12:53 +05:30
Ankush Menat
d5a21a2676 fix: rename type validation
`None` can be passed which is acceptable here.

TODO: Make slackdict accept none as bool and convert to False
2023-10-16 18:12:53 +05:30
Ankush Menat
e0f87dc4e1 refactor!: move OAuth and token auth code to auth.py
This doesn't belong in api.py
2023-10-16 18:12:53 +05:30
Ankush Menat
b064d12440 feat: Shorthand for whitelisted function call in controllers
```diff
- GET /api/method/frappe.core.doctype.user.user.get_timezones
+ GET /api/method/User/get_timezones
```
2023-10-16 18:12:53 +05:30
Ankush Menat
11dd961d81 refactor!: Method whitelisting
Document.whitelist doesn't work, no idea why it's doing all weird
`__func__` business.

`@frappe.whitelist()` works just fine.
2023-10-16 18:12:53 +05:30
Ankush Menat
5f32952b30 feat(APIv2): Execute doc method using API
e.g. `POST /api/v2/resource/Sales Order/SO-0001/submit`
2023-10-16 18:12:53 +05:30
Ankush Menat
1b51914a83 refactor: create two API versions 2023-10-16 18:12:53 +05:30
Ankush Menat
5af6624cce refactor: Use werkzeug router for API routing 2023-10-16 18:12:53 +05:30
Ankush Menat
c7338f5a83 chore: deprecate form_dict.cmd, globals() 2023-10-16 18:12:53 +05:30
ruthra kumar
d06a5808cc
fix: validation permission on tag creation (#22753)
* fix: validation permission on `tag` creation

* refactor: apply checks on all operations

Add/remove both are controlled by update

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-10-16 12:38:00 +00:00
Ankush Menat
db3e4c9cfc
fix: Check if note has permission (#22750) 2023-10-16 16:43:47 +05:30
Ankush Menat
3effd9e101 test: fix test failure from parallel merge 2023-10-16 16:42:46 +05:30
Ankush Menat
c476c5e6d7
refactor!: Link field search (#22745)
* refactor!: Drop handling for SQL queries

This hasn't been supported in really long time, no need to check that
use cases.

It will still fail but with no special error message.

* fix: Catch all import related errors

* fix!: Use last query from hooks

* refactor!: Return search results like any other function

Search results are returned in `results` key which is incosistent from
most other functions

* refactor: simplify search_link
2023-10-16 15:41:02 +05:30
Corentin Flr
89aab5d748
fix(query_doctypes): Allow search in translated name (#22590)
* fix(query_doctypes): Allow search in translated name

* test: Add test for DocType search in foreign language
2023-10-16 15:13:57 +05:30
Sagar Vora
258c175982 perf: defer db query when saving Event 2023-10-16 12:59:30 +05:30
Anand Chitipothu
aff3f66366
fix: work-around to fix issue with syncing Google Contacts (#22649)
Issue #22648
2023-10-16 12:29:49 +05:30
Maharshi Patel
bbf91b8afc
fix: sync doctype layout on update standard field (#22699)
* fix: sync doctype layout on update standard field

When standard field is deleted & it is not updated in the doctype layout,
Error occurs as it will try to render fields that doesn't exist
and layout won't render.

to fix this, sync doctype layout on update standard field

* refactor: use savepoint decorator

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-10-16 12:19:17 +05:30
Ankush Menat
29cd096e13
Merge pull request #22729 from ankush/search_relevance
fix(UX): Improve search relevance for link field
2023-10-16 12:08:37 +05:30
Sayed Ayman
94263bf4f2
feat (notificaion): email from 'Table Multiselect' field (#22733)
* feat (notificaion): table multiselect field

* refactor: use model.table_fields instead of duplicating

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-10-16 12:02:19 +05:30
Ankush Menat
55a444959e fix: Make search_link query postgres compatible 2023-10-16 11:51:51 +05:30
Ankush Menat
fec7759d00 fix: Give idx higher preference than meta order
Meta order in most cases is default "modified" which doesn't quite help.

idx is # of times a document is referred to somewhere else, which is
more likely to be relevant.
2023-10-16 10:50:57 +05:30
Ankush Menat
31444228c3 fix: Improve search relevance for search_link
When `locate` returns 0 it's shown on top instead it should be shown
last or not shown at all.

This is math hack to avoid using any complex SQL functionality which
isn't allowed in DB query.
2023-10-16 10:46:47 +05:30
Ankush Menat
e20d79bc28
Merge pull request #22730 from nabinhait/server-script-fix
fix: Delete from cache after deleting a server script
2023-10-16 10:22:20 +05:30
Nabin Hait
04c2944886 fix: Delete from cache after deleting a server script 2023-10-15 19:16:13 +05:30
Ankush Menat
e9629bc04e
Merge pull request #22700 from akhilnarang/failed-email-notification
fix(UX): send out a system notification when email sending + retries fail
2023-10-14 13:15:39 +05:30