Commit graph

1388 commits

Author SHA1 Message Date
gavin
cac25f1229 feat(minor): Add support for for_update in get_last_doc 2022-05-24 19:19:53 +05:30
Abhishek M
378149375d
fix: Passing dev server variable to jenv globals correctly (#16843)
Encountered the same issue during a fresh setup: https://discuss.erpnext.com/t/v13-fresh-install-develop-socket-io-using-wrong-port/74562

The problem originates from the `socketio_client.js` file.  During development, the `socket.io` client by default sends request to port 8000 but ideally it should've been 9000 (that's where it's actually running) since the latter is defined in `frappe.boot.socketio_port`. This is happening because the `jenv` variable `dev_server` is always being returned as 0.

In [this](0f7d8e7903/frappe/__init__.py (L237)) line, we are seting `frappe.local.dev_server` but in safe exec we are using `frappe._dev_server` as the source to populate the variable `dev_server` which eventually gets pushed to the `app.html` via `jinja`. (`frappe._dev_server` evaluates to `None`)

In `socketio_client`, we are using [this](0f7d8e7903/frappe/public/js/frappe/socketio_client.js (L112)) variable as a flag to decide whether or not `frappe.boot.socketio_port` should be the port that the `socket.io` client connects to.
2022-05-18 09:19:24 +00:00
Ankush Menat
c55c8e4f97
refactor(DX): add type hints for some utilities (#16871)
- Added type hints to majority of most used functions in `utils/data.py`
- added overloads for functions whose output depends on input type. This helps A LOT if your LSP supports type narrowing (like pyright)


Example:
Same function with 3 diff singatures narrowed by input value. 
<img width="1270" alt="Screenshot 2022-05-10 at 8 02 02 PM" src="https://user-images.githubusercontent.com/9079960/167653595-2ab9441f-da40-4645-aa87-9ec0d96cbec9.png">
2022-05-11 06:14:31 +00:00
Saqib Ansari
61223092e0
fix: frappe.throw in case of list of errors (#16855) 2022-05-09 18:42:54 +05:30
Ritwik Puri
b41379c78b
fix: misc fixes (integer primary keys) (#16307)
* fix: misc fixes

local.x gets resetted on every request so switched to a simple dict

simplified is_val_used in set_next_val function for sequences

* chore: use multisql for sequence methods

* fix: fields not updating on form

* minor(base_input): removed unnecessary branching in update_input

* chore: remove prints and rename autoincremented_status_map

* chore: added proper type hint + comment + formatting

* fix: added searching in cast_name rather than handling it manually

* fix: share condition query + test_build_match_conditions

* fix: add cast_name to more places

* test: test for sequence

* fix: sequence functions

* fix: inherit frappetestcase

* minor: attach sequence methods to db context local

* chore: update sequence function names in Database

use frappe.db for sequences in naming.py

* fix: convert filename to str (for autoincremented doctypes)

* chore: better regex for modifying values for postgres

* minor: allow changing name column type (if no data is present in the doctype)

* refactor: validate_autoname

converted it to a simple function
enabled changing autoincrement autoname from customize form

* fix: use sql_ddl for change_column_type in postgres

* fix: use not null constraint in postgres when changing name type

* fix(test): updated test_autoincremented_doctype_transition with transitioning when no data is present

* fix(test): updated test_cast_name

probably messed up during rebase

* fix(test): used rollback upon error in transaction for postgres

* chore: use frappe.db.x methods for sequences

* minor: use temporary sequences in test

* minor: use generate_hash for sequence naming in sequence tests

* chore: replace sequence imports with frappe.db.x

* chore: move out casting name fields to a separate method

* refactor: cast_name

more explicit cases for casts and added docstring

* fix: added space in test_cast_name

* chore: fix linter

* chore: better naming for can_change_name_column_type

* chore: add comment for autoincremented_site_status_map

* chore: update/add docstrings
2022-04-29 15:06:03 +05:30
gavin
f4394f124a
Merge pull request #16715 from ChillarAnand/v3.11
refactor!: Remove wrapt package
2022-04-27 12:28:13 +05:30
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
gavin
5f2f387a9c
Merge pull request #16130 from gavindsouza/bg-rename_doc
feat: Async Document Renaming
2022-04-26 12:57:31 +05:30
gavin
2da85fa8da
Merge pull request #16698 from gavindsouza/traceback-with-context
feat: Traceback with context
2022-04-22 13:04:07 +05:30
Gavin D'souza
ffc2b9427f Merge branch 'develop' of github.com:frappe/frappe into bg-rename_doc 2022-04-22 12:14:21 +05:30
Gavin D'souza
b6683db57e refactor: frappe.rename_doc definition
Use explicit naming of args, kwargs and don't accept cmd and
ignore_permissions explicitly
2022-04-21 16:09:08 +05:30
Gavin D'souza
5ecc9fe4ff refactor(log_error): de-clutter & log context with traceback 2022-04-21 13:27:01 +05:30
Gavin D'souza
4e533682ba feat: get_traceback with context 2022-04-21 13:26:12 +05:30
Gavin D'souza
892e05fdc1 Merge branch 'develop' of github.com:frappe/frappe into bg-rename_doc 2022-04-20 16:04:27 +05:30
Rushabh Mehta
78bddb4127
Merge pull request #16653 from rmehta/error-log-ref
feat(minor): Add document reference to Error Log and doc.log_error
2022-04-20 15:54:59 +05:30
Ankush Menat
dcee40046a
perf!: simpler frappe.get_system_setting (#16685)
Not sure why this needs to be "cached" in locals again when db object
already caches it in value_cache.
2022-04-20 15:16:04 +05:30
Rushabh Mehta
d9fbee3b9c fix(minor): frappe.log_error 2022-04-18 17:29:03 +05:30
Rushabh Mehta
6e6fe9521e fix(linting): no single quotes :'| 2022-04-18 17:29:03 +05:30
Rushabh Mehta
57a55e4225 feat(minor): Add document reference to Error Log and doc.log_error 2022-04-18 17:29:03 +05:30
Gavin D'souza
66655eb8ed Merge branch 'develop' of github.com:frappe/frappe into bg-rename_doc 2022-04-14 13:41:56 +05:30
Sagar Vora
d2dfc8c335 fix: define __slots__ to avoid __dict__ creation 2022-04-13 11:19:20 +05:30
Sagar Vora
594e653347 refactor: improved frappe._dict 2022-04-13 11:19:19 +05:30
Ankush Menat
da5a5eda02
fix: incorrect type in make_property_setter query (#16584)
* fix: incorrect type in make_property_setter query

* fix: Remove redundant as_list kwarg

Co-authored-by: gavin <gavin18d@gmail.com>
2022-04-12 12:00:11 +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
Abhishek Saxena
5c8856d66e
refactor: db.sql calls to frappe.qb (#16107)
# Changes

- Introduces `subqry` class to use in where clause when there is a non-column condition. eg.
> .where(subqry(no_of_roles) == 0)
- Convert SQL queries to frappe.qb 

# Testing

Functions with query refactors
- frappe.boot.get_user_pages_or_reports() -> Same output of `get_bootinfo()` as develop
- frappe.boot.get_unseen_notes() -> Forms the same query as develop 
```sql
SELECT `name`,`title`,`content`,`notify_on_every_login`
FROM `tabNote` WHERE `notify_on_every_login`=1
AND `expire_notification_on`>'2022-03-30 01:10:53.393874'
AND (SELECT `nsb`.`user` FROM `tabNote Seen By` `nsb` WHERE `nsb`.`parent`=`tabNote`.`name`) NOT IN ('Administrator')
```
- frappe.installer._delete_doctypes() -> installed and uninsalled a dummy app to drop tables

### Not tested
- frappe.make_property_setter()
- frappe.realtime.get_pending_tasks_for_doc() [whitelist method]
- frappe.sessions.Session.start()
- frappe.twofactor.cache_2fa_data()
2022-04-12 05:07:25 +00:00
Sagar Vora
2775364afd perf: 90% faster get_cached_value from Redis cache 2022-04-01 13:45:21 +05:30
Sagar Vora
6993f51bf9 fix: ignore DoesNotExistError inside get_cached_value 2022-03-30 15:40:09 +05:30
gavin
bc7cf8beff
Merge pull request #16322 from gavindsouza/as_json-handler
fix(as_json): sort keys always (even when not valid JSON)
2022-03-28 12:34:02 +05:30
leoajr
a9b8fe8197
docs: incorrect argname in docs for get_list #16384 2022-03-23 18:29:39 +05:30
Suraj Shetty
cd8bd4ccf0
Merge pull request #16278 from surajshetty3416/is-system-generated-customization 2022-03-23 10:52:21 +05:30
Gavin D'souza
448fb8a207 Merge branch 'develop' of github.com:frappe/frappe into bg-rename_doc 2022-03-22 12:29:43 +05:30
mergify[bot]
aa42efe1de
Merge pull request #16363 from alyf-de/fullargspec
refactor: call getfullargspec only once
2022-03-22 06:24:28 +00:00
barredterra
8cf2bf8953 refactor: call getfullargspec only once 2022-03-21 23:09:58 +01:00
barredterra
179c9f117c perf: exists is already called in delete_doc 2022-03-21 21:12:05 +01:00
Gavin D'souza
1c8d2fd536 fix: Sort keys for illegal JSON 2022-03-21 17:49:26 +05:30
Gavin D'souza
4f1d00442c fix(as_json): Pop None key if exists
JSON doesn't allow null key as per spec, it should be a string only: https://datatracker.ietf.org/doc/html/rfc7159#section-4

ref discussions:
* https://github.com/frappe/frappe/issues/14292
* https://github.com/frappe/frappe/pull/14504/files#r821526085
2022-03-17 17:39:27 +05:30
Suraj Shetty
127b5477e1
Merge branch 'develop' into is-system-generated-customization 2022-03-17 14:09:11 +05:30
Rushabh Mehta
dd02496dad
Merge pull request #15964 from phot0n/integer-primary-keys
feat: integer primary keys
2022-03-16 17:07:20 +05:30
Sagar Vora
a2b02f9f33 fix: more succinct docstring 2022-03-14 15:59:32 +05:30
Sagar Vora
290628ba3f style: use inline if 2022-03-13 15:02:24 +05:30
Sagar Vora
dc4d07cb61 style: use walrus operator 2022-03-13 12:54:04 +05:30
Sagar Vora
f6c546159c perf: cache single documents 2022-03-12 00:10:36 +05:30
phot0n
b876520ef0 fix: logic for is_autoincremented 2022-03-11 23:46:00 +05:30
phot0n
bebc8058b6 feat: integer primary keys 2022-03-11 23:46:00 +05:30
Gavin D'souza
9e36005c70 fix: Remove taken file locks at end of background job 2022-03-03 20:05:05 +05:30
Suraj Shetty
c51a581e2c feat: Set is_system_generated as false if customization is created via Customize Form 2022-03-01 09:20:47 +05:30
Raffael Meyer
4750ff69e6
Merge branch 'develop' into msgprint-title-backend 2022-02-09 10:34:05 +01:00
Gavin D'souza
5b6ceb5543 Merge branch 'develop' of github.com:frappe/frappe into set_value-refactor 2022-01-28 18:39:12 +05:30
barredterra
aba467307f fix: translate default msgprint title in backend 2022-01-27 20:14:51 +01:00
barredterra
dac9349aef refactor: use is bool instead of == bool 2022-01-17 15:40:33 +01:00