Commit graph

352 commits

Author SHA1 Message Date
Ankush Menat
9f31723555 refactor: directly map function over lambda call 2022-08-16 10:53:28 +05:30
Ankush Menat
53af10a064 refactor!: python pretty_date consistent with JS
Python pretty date was ceiling month and week instead of flooring them,
this is incorrect AND inconsistent with popular JS library pretty date
that we use on client side
2022-08-16 10:53:28 +05:30
Ankush Menat
9de31d03c1 refactor!: timespan utils consistent output
BREAKING CHANGE:

- `get_year_ending` returns datetime.date instead of str
- `get_timespan_date_range` will always return datetime.date ranges
2022-08-16 10:53:28 +05:30
Ankush Menat
a88819230a refactor: convert get_timespan_date_range to use match 2022-08-16 10:53:28 +05:30
Shariq Ansari
c478673367
fix: allow to import time field (#17677) 2022-08-01 14:50:40 +05:30
Shariq Ansari
a50e0ffa08
refactor: Webform (#17232) 2022-07-19 15:52:15 +05:30
Ankush Menat
29c855b028
fix: db.get_value -> db.get_single_value (#17531)
db.get_value for singles returns string type always, this is confusing
behaviour, db.get_single_value should be used instead.

semgrep rule: https://github.com/frappe/semgrep-rules/pull/16
2022-07-18 15:10:49 +05:30
Suraj Shetty
34b1ea57f9 fix: Show "Queued" status on newsletter
Show "Queued" status on newsletter if emails are queued and "email sending" is not yet started.
2022-07-12 13:03:06 +05:30
Suraj Shetty
d4166dbe20 refactor: Replace html2text with markdownify 2022-07-06 08:23:14 +05:30
Ankush Menat
261fbfcd11
Revert "fix(doc)!: Always cast datetime, date and time fields"
Revert "fix(doc)!: Always cast datetime, date and time fields (#15891)"

This reverts commit d7789ab6ff.
2022-07-05 13:43:32 +05:30
Himanshu
d7789ab6ff
fix(doc)!: Always cast datetime, date and time fields (#15891)
### BREAKING CHANGE
#### Datetime, Date and Time fields will always be cast to respective objects in `setattr`, this will ensure uniformity while accessing the values, no more `getdate`, `get_datetime`, `to_timedelta` wrapper.
- While importing data, the framework does check for `set_only_once`.
- In normal case scenarios, this will work flawlessly since most date fields might not be set_only_once.
- But in Subscription, the date field is set to `set_only_once` and in `after_insert`, `document.save` is called, and while doing so, `set_only_once` is checked [here](1944a547f9/frappe/model/document.py (L566)).
-This works fine if the data imported is in the correct format.
- If the date's data is not in the correct format, the framework throws an error.
- for eg `06-02-2022 00:00:00 != 06-02-2022`
- fixes [Issue/#15370](https://github.com/frappe/frappe/issues/15370)

> no-docs
2022-07-05 07:07:16 +00:00
Ankush Menat
054ad9c30c feat: Allow showing currency symbol to the right 2022-07-05 11:21:23 +05:30
Ankush Menat
4e6ea5b554
fix: handle None as amount in fmt_money (#17395) 2022-07-04 16:27:57 +05:30
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
Ankush Menat
aad7ebc938
fix: extra notification triggered on value change (#17364)
Since value in DB and value on object can be in different type the
notification gets triggered unnecessarily

e.g. data(2012, 10, 10) != "2012-10-10"
2022-06-30 20:25:29 +05:30
Ankush Menat
d35d7ffbe2 fix: remove bare exception catching
A bare except catches lots of things (like generator iteration end) and should never be used.
2022-06-28 18:05:00 +05:30
Gavin D'souza
fc422f4a97 chore(deps): Bump Pillow from 9.0.1 to 9.1.1
Includes security fixes, API & constants deprecations

Changelog: https://pillow.readthedocs.io/en/stable/releasenotes/index.html
2022-06-10 13:12:35 +05:30
Gavin D'souza
b696fa6da5 perf: Pre-compile and re-use regexp pattern
Converted all possible usages of re.* that weren't compiling the regex
separately and re-using it. Separated out the compiled patterns as
global variables. Repetitive patterns could be made DRY-er.

Would be nicer to have all regexes in a single module so that we could
re-use better, keep track of outdated, and keep checks for possible
reDos' etc
2022-06-08 14:07:38 +05:30
Gavin D'souza
5ec2690160 Merge branch 'develop' into refactor-file 2022-06-01 15:47:55 +05:30
Shariq Ansari
8f245be460
fix: Strip all spacing characters from Message-ID & In-Reply-To (#16999) 2022-05-27 21:06:07 +05:30
gavin
7c77bedbf2 refactor: Simplify logic + Add typing hints 2022-05-18 16:57:54 +05:30
Ankush Menat
8c02971224 chore: misleading typehint
[skip ci]
2022-05-12 11:30:05 +05:30
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
Gavin D'souza
97e911e069 Merge branch 'develop' of github.com:frappe/frappe into refactor-file 2022-04-13 10:49:26 +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
Sagar Vora
6993f51bf9 fix: ignore DoesNotExistError inside get_cached_value 2022-03-30 15:40:09 +05:30
Gavin D'souza
47cf46cd49 Merge branch 'develop' of github.com:frappe/frappe into refactor-file 2022-03-24 21:38:21 +05:30
Gavin D'souza
c6bad81f24 fix: Use new direct import paths
The old paths worked too, but it's just better to use the new paths and
not go in circles ;)
2022-03-15 19:39:47 +05:30
phot0n
bebc8058b6 feat: integer primary keys 2022-03-11 23:46:00 +05:30
phot0n
b31f3c24f6 refactor: remove parent, parenttype, parentfield, idx columns from non-child table doctypes
* feat: add parent, parenttype, idx, parentfield columns to doctypes when transitioning from normal -> child table

* fix: remove parent, parenttype, parentfield, idx from DocType DocType
2022-02-07 15:12:37 +05:30
Gavin D'souza
ad1fedf4a8 fix: Return correct types for time utils 2022-02-02 19:46:09 +05:30
Gavin D'souza
5b6ceb5543 Merge branch 'develop' of github.com:frappe/frappe into set_value-refactor 2022-01-28 18:39:12 +05:30
Gavin D'souza
1811f464a9 Merge branch 'set_value-refactor' into set_value-refactor 2022-01-28 18:38:46 +05:30
Gavin D'souza
8037866dc1 fix: Handle parsing and formatting timedeltas
* Added utils parse_timedelta, format_timedelta
* Added to json_handler for de-serializing timedelta objects
2022-01-28 18:33:03 +05:30
saxenabhishek
efd5c197cb fix: sbool converting int stored as string 2022-01-25 03:07:34 +05:30
Gavin D'souza
429f839ea3 style: Add typing, sorted imports# 2022-01-17 15:31:37 +05:30
barredterra
b1383df15a refactor: use is None instead of == None 2022-01-17 10:37:51 +01:00
Gavin D'souza
b403d67845 fix!: Don't use strtobool in sbool util
strtobool would convert 't', 'yes' to True too. Which shouldn't be a
problem generally but could be one possibly.
2022-01-17 14:55:36 +05:30
Gavin D'souza
227dc26707 Merge branch 'develop' of github.com:frappe/frappe into set_value-refactor 2022-01-17 14:04:13 +05:30
Gavin D'souza
f5072af00d fix: sbool before cint in cast for Check types
Noticed an issue when get_single_value wasn't returning the correct
values; by converting true to 0.

Tested it out. Here's the examples:

In [2]: sbool("2")
Out[2]: '2'

In [3]: cint(sbool("2"))
Out[3]: 2

In [4]: cint(sbool("-1"))
Out[4]: -1

In [5]: cint(sbool("0"))
Out[5]: 0

In [6]: cint(sbool("1000"))
Out[6]: 1000

In [7]: cint(sbool("10_000"))
Out[7]: 10000

In [8]: cint(sbool("true"))
Out[8]: 1
2022-01-11 12:57:23 +05:30
Gavin D'souza
981564e544 Merge branch 'develop' into frappe-postgres-changes 2022-01-07 11:37:28 +05:30
Conor
40ba1ac9ba fix: Postgres Compatibility
* Handle inconsistencies in type handling in DatabaseQuery & Database
  APIs
* Update incompatible queries with frappe.qb notation
* Fixed use cases discovered by failing ERPNext CI tests

fix: db independent syntax for user_type

fix: handle postgres datetime values

feat: add ability to auto commit on db inserts

feat: add ability to escape underscore in postgres

fix: handle missing data in test runner bootstrapping

fix: db independent syntax for queries

fix: refactor to use qb

fix: update cache for language

fix: use pluck in email_queue

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

fix: don't auto insert on tests for make_property_setter

fix: remove auto_commit in custom_field insertion

fix: remove auto_commit functionality

fix: review comments

fix: revert link validation

fix: style suggestion for readability

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

fix: revert .lower() in link validation

fix: add rollback for setup_wizard

Revert "fix: add rollback for setup_wizard"

This reverts commit 83b3b0913db17718ccd5edae01858cff15603829.

Revert "feat: add ability to escape underscore in postgres"

This reverts commit 8ed9c2aa3306438e94bb813f60e65b416d0b947b.

fix: more concise representation of order fields

Co-authored-by: gavin <gavin18d@gmail.com>
2022-01-07 10:44:57 +05:30
Suraj Shetty
5d5ad78789 refactor: Rename week_starts_on to first_day_of_the_week
For consistency
2022-01-05 14:54:46 +05:30
Suraj Shetty
42e1c15c18 feat: Add setting to configure the day on which week starts 2022-01-04 13:00:31 +05:30
Suraj Shetty
b5e2f78a88 fix: Start week from Sunday instead of Monday
- Like we do in client-side
2022-01-03 13:36:32 +05:30
mergify[bot]
7e34c27690
fix: Incorrect timespan daterange calculation (backport #15369) (#15431)
Co-authored-by: Kartik Sharma <kartiksharma9319@gmail.com>
2021-12-24 00:20:57 +05:30
Kieran
9421736fb9
feat: add number format for BTC 2021-12-08 12:30:02 +00:00
tahir-zaqout
f3aabb5211
Add Translate To Symbol Field (#14971) 2021-11-22 05:55:19 +00:00
rohitwaghchaure
6ae352a05f
fix: ignore filename with dotted path (#14617)
* fix: ignore dotted path in file name

* fix: condition for checking file

* Update data.py

* fix: only allow pdf files

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2021-10-28 19:23:57 +00:00
Rohit Waghchaure
5ef72dd290 feat: pdf to base64 convert 2021-10-28 12:41:27 +05:30