Commit graph

299 commits

Author SHA1 Message Date
gavin
8394bbeb4c
chore(utils): Add type hints for get_timedelta, getdate
Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2021-08-31 21:50:07 +05:30
Gavin D'souza
9a32513b47 chore: Update frappe.utils.data.cast docstring 2021-08-31 13:11:25 +05:30
Gavin D'souza
176d6d2d06 fix: Check if input is str is_invalid_date_string
This is sort of a breaking change? Because if an int/dict/list/tuple was
passed instead of a str, object doesnt have .startswith (AttributeError)
would be raised instead of just returning None.
2021-08-31 13:07:22 +05:30
Gavin D'souza
8622142d7d fix: Use get_timedelta in cast, add to safe_exec list
* Return date and datetime objects for Date and Datetime field types
  respectively if Falsy output is set
2021-08-31 13:06:10 +05:30
Gavin D'souza
3858e95e80 feat(utils): Add util get_timedelta
get_timedelta returns None in case of invalid or imparsable inputs. This
behaviour is consistent wrt other utils. The util, to_timedelta tries to
convert to timedelta objects only if str object is passed. It returns
the same object if not string, which is absurd...given its called
`to_timedelta`.
2021-08-31 12:57:05 +05:30
Gavin D'souza
b8c51b13e2 fix: Revert to using cast_fieldtype in BaseDocument.cast
* reference: revert Breaking Change -
  https://github.com/frappe/frappe/pull/13989#discussion_r695624003
* Show deprecation warning unless `show_warning` is unset
2021-08-30 13:45:30 +05:30
Gavin D'souza
a2cb9be7a4 feat: frappe.utils.data.cast
Cast the value to the Python native object of the Frappe fieldtype provided. If value is None, the first/lowest value of the `fieldtype` will be returned.

Mapping of Python types => Frappe types:
* float => ("Currency", "Float", "Percent")
* int => ("Int", "Check")
* datetime.datetime => ("Datetime",)
* datetime.date => ("Date",)
* datetime.time => ("Time",)

Deprecate frappe.utils.data.cast_fieldtype in favour of new util cast
which handles types "better"
2021-08-20 12:35:24 +05:30
Gavin D'souza
cb034e4c52 fix: Consistent return types in cast_fieldtype
Note: BREAKING CHANGE
2021-08-20 12:08:39 +05:30
Afshan
c7ad1be6b8 fix: format string for formating date 2021-08-06 22:10:37 +05:30
Ankush
257723cb0a
feat: PythonExpression and Python option with syntax validation for Code field types (#13707)
* feat: `PythonExpression` and `Python` options for `Code` fields

* fix: check python expressions in assignment rule

* fix: replace server script syntax validation

* fix: validate condition in workflow transition

Add PythonExpression in Options.
2021-08-06 04:10:09 +00:00
Gavin D'souza
f6b215938a fix: Use raw string to avoid invalid sequence errors
Escaped when proven easier
2021-05-26 19:30:08 +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
mergify[bot]
8ebc251394
Merge pull request #13065 from gavindsouza/api-updates
fix: Evaluate boolean values better via /api/resource/<doctype>
2021-05-26 04:41:55 +00:00
Kenneth Sequeira
6632b5876a
feat(minor): add number format parameter in fmt_money (#13255)
* feat: add number format parameter in fmt_money

* review fix: move new parameter at the end

Co-authored-by: Kenneth Sequeira <kenneth@Kenneths-MacBook-Air.local>
2021-05-24 16:14:56 +00:00
Gavin D'souza
10fe05da29 Merge branch 'develop' into api-updates 2021-05-20 17:11:43 +05:30
Suraj Shetty
0f94407e6d
Merge pull request #12969 from surajshetty3416/fix-sqli-report-get 2021-05-12 12:57:17 +05:30
leela
72ca7e9753 refactor: remove six dependency 2021-05-07 07:42:04 +05:30
Gavin D'souza
724a5b2536 fix: Evaluate boolean values better via /api/resource/<doctype>
`GET /api/resource/ToDo?limit=10&debug=False&as_dict=0` would be received by the resource handler as debug="False" and as_dict="0" which are both truthy values.

So, even though you requested for a list of lists response without debugging on, you'd get the exact opposite; debug on and a list of dicts.

- Evaluate boolean values for `GET /api/resource/<doctype>`
- Added `limit` parameter as an alias for `limit_page_length`
- Added `frappe.utils.data.sbool` that converts strings to bool values if applicable.
- Added some seemingly stupid comments for the sake of consistency.
2021-04-30 21:18:38 +05:30
Suraj Shetty
d8e91cae32 fix: Strip comments before sanitizing column_name 2021-04-23 01:20:47 +05:30
Syed Mujeer Hashmi
13a57d141e fix: timespan filter for next and last timespans
The timespan filter now considers calendar month, quarter,
half-year, and year for last and next timespans.

Signed-off-by: Syed Mujeer Hashmi <mujeerhashmi@4csolutions.in>
2021-03-16 21:12:07 +05:30
mergify[bot]
465404f66e
Merge pull request #12447 from adityahase/perf-cli
perf: Faster CLI
2021-02-25 01:44:36 +00:00
mergify[bot]
86407e5b48
Merge pull request #12446 from leela/login-attempt-tracker
refactor: Track consecutive login attempts
2021-02-24 10:11:04 +00:00
Saqib
d9737c1d25
Merge branch 'develop' into image-pf-fix 2021-02-24 12:45:21 +05:30
leela
6e5e0890f3 refactor: Cleaned authentication logic
Auth flow is changed to use login attempt tracker.
2021-02-22 21:11:18 +05:30
Aditya Hase
56d1954591
fix: Add missing imports 2021-02-22 11:53:26 +05:30
Aditya Hase
365ad34b40
perf: Remove six.moves.html_parser from import tree 2021-02-21 09:59:48 +05:30
Aditya Hase
0ba2fc0440
perf: Remove dateutil.parser from import tree 2021-02-21 09:59:12 +05:30
Aditya Hase
56deeafe00
perf: Remove dateutil from import tree 2021-02-21 09:46:44 +05:30
Aditya Hase
64517ef272
perf: Remove babel from import tree 2021-02-21 09:46:31 +05:30
Aditya Hase
e209722624
perf: Remove num2words from import tree 2021-02-21 09:45:24 +05:30
Aditya Hase
b35a63c05f
perf: Remove html2text from import tree 2021-02-21 09:44:07 +05:30
Aditya Hase
563e81c22c
perf: Remove markdown2 from import tree 2021-02-21 09:43:22 +05:30
Aditya Hase
2413f7e6ec
perf: Replace markdown2.UnicodeWithAttrs with frappe.utils.UnicodeWithAttrs 2021-02-21 09:41:10 +05:30
Ankush Menat
523112fd8b
docs: update docs of some most used functions
Update following function/methods:

BaseDocument.update
BaseDocument.append
utils.cint
utils.flt
utils.getdate

[skip travis]
2021-02-15 17:41:29 +05:30
Saqib Ansari
d008662f6d Merge branch 'develop' into image-pf-fix 2021-02-10 13:01:16 +05:30
Rushabh Mehta
bca3aecdaf fix(minor): fix routing and titles + added frappe.utils.markdown alias to frappe.utils.md_to_html 2021-01-31 18:18:47 +05:30
Saqib Ansari
3bc1648939 fix: broken image rendering in print format 2021-01-29 12:47:37 +05:30
Suraj Shetty
ce379bc200 Merge branch 'develop' of https://github.com/frappe/frappe into rebrand-ui 2021-01-28 19:56:54 +05:30
Suraj Shetty
b91e05d2d0 fix: Incorrect fix 2021-01-22 12:33:12 +05:30
Suraj Shetty
f468dd0c20 fix: Handle edge case in get_abbr method 2021-01-22 10:05:16 +05:30
Gavin D'souza
16f2b29cb3 style: Trim extra whitespace 2021-01-21 13:19:31 +05:30
Gavin D'souza
33ea496a8b feat: Added get_datetime_in_timezone in frappe.utils to get datetime in specific timezones
* Added util in safe_exec to access via Server Scripts and System
Console
2021-01-21 13:19:31 +05:30
Suraj Shetty
e4bdbed414 Merge branch 'rebrand-ui' of https://github.com/frappe/frappe into rebrand-ui 2021-01-21 11:20:18 +05:30
Suraj Shetty
e2c763c989 feat: Add avatar macro 2021-01-21 11:14:04 +05:30
prssanna
e54a1262b4 Merge branch 'rebrand-ui' of https://github.com/frappe/frappe into rebrand-ui 2021-01-20 17:57:46 +05:30
prssanna
f363863b8c fix: website fixes
-move modal and icon styles to common

primary navbar theme
2021-01-20 17:56:05 +05:30
Suraj Shetty
b94d5778a8 Merge branch 'develop' of https://github.com/frappe/frappe into rebrand-ui 2021-01-19 10:36:50 +05:30
Sagar Vora
54f9b894ed fix: add yesterday and tomorrow to timespan; optimise get_timespan_date_range 2021-01-07 21:24:23 +05:30
Rushabh Mehta
b2686e0623 fix(routing): removed /space from routing 2021-01-01 12:30:35 +05:30
Rushabh Mehta
90363f4ba9 fix(routes): minor fixes to route, favion, setup-wizard 2020-12-18 13:17:28 +05:30