Commit graph

116 commits

Author SHA1 Message Date
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
Gavin D'souza
1728db8428 fix(file_manager): Correct and => or usage in refactored query 2022-04-01 17:50:33 +05:30
Gavin D'souza
d0bd4730da refactor(file_manager): Refactor raw SQLs to use qb & db_query APIs 2022-03-31 16:12:54 +05:30
Gavin D'souza
b56e6fe4db fix: Safe decode base64 data in case of incorrect padding
This could possibly happen in case of corrupted/partial files. But for
the most part, if there's a missing trailing = or three at the end too.

Traceback:
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 68, in application
    response = frappe.api.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 31, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 67, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1208, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 21, in savedocs
    doc.save()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 285, in save
    return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 307, in _save
    self.insert()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 239, in insert
    self._validate()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 499, in _validate
    self._extract_images_from_text_editor()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 983, in _extract_images_from_text_editor
    extract_images_from_doc(self, df.fieldname)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/file/file.py", line 779, in extract_images_from_doc
    content = extract_images_from_html(doc, content)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/file/file.py", line 822, in extract_images_from_html
    content = re.sub(r']*src\s*=\s*["\'](?=data:)(.*?)["\']', _save_file, content)
  File "/home/frappe/frappe-bench/env/lib/python3.6/re.py", line 191, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/file/file.py", line 814, in _save_file
    _file.save(ignore_permissions=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 285, in save
    return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 307, in _save
    self.insert()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 231, in insert
    self.run_method("before_insert")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 860, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1158, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1141, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 854, in
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/file/file.py", line 56, in before_insert
    self.save_file(content=self.content, decode=self.decode)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/file/file.py", line 436, in save_file
    self.content = base64.b64decode(self.content)
  File "/home/frappe/frappe-bench/env/lib/python3.6/base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)
binascii.Error: Incorrect padding
2021-12-21 14:57:09 +05:30
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
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
Suraj Shetty
44c82276e8 refactor: Remove unused methods 2021-08-19 17:37:01 +05:30
Suraj Shetty
a7fb1816aa refactor: Remove unused and redundant code 2021-08-19 15:27:25 +05:30
MitulDavid
a3430ca2a9 feat: Image optimization 2021-08-02 18:23:26 +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
Joseph Marie Alba
62d81b7610
Python 3 issue with re
Python 3 interprets string literals as Unicode strings, and therefore \s is treated as an escaped Unicode character.

Declare RegEx pattern as a raw string instead by prepending r
2021-05-16 05:59:47 +08:00
KanchanChauhan
613b91735e
fix: Image shown as broken in comment if private 2020-08-21 17:58:37 +05:30
Himanshu
5b1938afdd feat(Comments): add images in comments (#8283)
* feat: add images in comments

* fix: use extract images
2019-09-02 23:28:05 +05:30
FinByz Tech Pvt. Ltd
245a8186af fix: Allowed guest to attach files to web forms (#7017)
Created the fix for the issue [#6774](https://github.com/frappe/frappe/issues/6774), in which guest can attach files in web forms like job application.
2019-03-06 22:48:11 +05:30
Aditya Hase
6b72faf44f style: Linting fixes (#6809)
* style: Remove unused imports

* style: Remove unused local variables
2019-01-23 16:39:55 +05:30
Charles-Henri Decultot
98abda32b4 [Enhancement] Event timeline (#6133)
* Events in timeline wip

* Events in timeline

* Permission issue + split buttons between Frappe and ERPNext

* Add string type check

* Codacy corrections

* Permission issue

* Test and feedback corrections

* Codacy corrections

* Tests and codacy corrections

* Codacy correction

* Py3 correction

* Travis correction

* Py3 corrections"

* Travis and codacy corrections

* Removed space

* Add check for the removal of new lines

* Codacy rollup watch missing semicolon
2018-10-02 10:12:55 +05:30
Rohit Waghchaure
c197ae6278 [Fix] Download report not working 2018-08-17 11:10:51 +05:30
Rushabh Mehta
db51e4441a fix(attach) for web forms 2018-08-04 21:51:49 +05:30
Ameya Shenoy
fc99d691d1 Fix python3 issue reading pdf (#5541)
File types other than plain text files weren't sent properly in email. The initial implementation of try except used to destroy the file object in the try statement, and hence we were getting a blank string in the except block. The fix involves reading the file object separately before trying to decode it.
2018-05-08 15:41:12 +05:30
Faris Ansari
da3e726fde
[fix] GCalendar Account test (#5400)
* [fix] GCalendar Account test

* [py3] fix email account test

* Decode plain text files
2018-04-07 22:38:12 +05:30
Nabin Hait
82f1058ad4 Merge branch 'master' into develop 2018-04-04 11:23:21 +05:30
Zarrar
edd089d4a1 append now_time to the filename incase of duplicate (#5313) 2018-04-02 18:22:12 +05:30
Zlash65
fae68f7d35 encode unicode objects 2018-03-26 14:59:41 +05:30
Achilles Rasquinha
6d8658decd fix content hash 2018-03-26 10:14:45 +05:30
Nabin Hait
3f3d9e52c8 Fixed merge conflict 2018-03-23 15:16:18 +05:30
Zarrar
577ce03fd8 [Hotfix] File upload fix (#5254)
* append hash if same filename found while uploading through socketio

* pass file size

* upload after filename change
2018-03-23 15:13:58 +05:30
Achilles Rasquinha
962f727283 save_file for bytes 2018-03-12 14:37:20 +05:30
Achilles Rasquinha
67132f775c bytes to string 2018-03-12 14:31:04 +05:30
Achilles Rasquinha
3a18f5d47f content bytes 2018-03-09 13:51:27 +05:30
Achilles Rasquinha
b435559c8b fixed upload content of images 2018-03-09 12:51:56 +05:30
Saurabh
3f43899839 resolved merge conflicts 2018-01-15 18:34:11 +05:30
Manas Solanki
edbbf4b464 add the field attach_to_field in the file (#4823) 2018-01-15 18:10:53 +05:30
tundebabzy
27df2485d9 UnboundLocalError When Trying To Upload File #4692 (#4693)
* allow to attach empty files

* PEP8 compliance
2017-12-28 12:56:34 +05:30
Aditya Hase
38d63f7dc7 Python 3 compatibility Frappe test fixes (#4318)
* Read image file in binary mode

* Read files in binary mode

* Don't use bytestrings unnecessarily

* Correctly convert byte strings to unicode in frappe.as_unicode

* Convert content to bytes before writing to file
2017-10-17 17:45:25 +05:30
Aditya Hase
234fca90a3 Encode content if not encoded before hashing 2017-09-27 01:08:07 +05:30
Rushabh Mehta
3b41d031a7 [fix] file_manager.py 2017-09-14 13:07:29 +05:30
Rushabh Mehta
1de26c939c [enhance] use socket-io to upload files 2017-09-14 13:07:29 +05:30
Rushabh Mehta
fd7e8eda62 [wip] file upload with socketio 2017-09-14 13:07:29 +05:30
Aditya Hase
16a9bdfd31 Replaced urllib.unquote imports with six.moves.urllib.parse.unquote (#3836) 2017-08-02 17:09:31 +05:30
Aditya Hase
e6bd1e4995 Replaced all instances of 'unicode' with 'six.text_type' (#3825) 2017-08-02 16:57:39 +05:30
Revant Nandgaonkar
b06f987e55 Download files using REST API and OAuth 2 Token (#3499)
* Download files using REST API and OAuth 2 Token

* Check permissions before file download via API

* Solves Codacy issues

https://www.codacy.com/app/netchampfaris/frappe/file/7377221800/issues/source?bid=4679759&fileBranchId=4768213#l364
2017-06-19 09:11:31 +05:30
tundebabzy
6fbe20caaa Except and raise statement python 3 compatible style (#3216)
* changes exception and raise statements to python 3 style

* changes except statement to python 3 style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* adds six.reraise to fix python 3 style raise statements with traceback

* fixes indentation
2017-05-11 10:51:59 +05:30
Faris Ansari
08da14996f Enhance multi file upload (#2912)
* Allow multiple file upload, show progress while uploading

* Enhance multi file upload

You can now upload files programmatically like
```
frappe.upload.make({
  ...
  files: fileobj_array,
  ...
})
```
No need to use `multifile_upload` method.
Multiple file upload is enabled by default on all Attach dialogs.

* Don't `allow_multiple` in data import tool

* ControlAttach don't allow_multiple

* Show files in a table view

* Narrow width for Is Private column
2017-04-07 13:37:08 +05:30
Rushabh Mehta
d989a95472 [feature] document versioning #2469 (#2523)
* [feature] document versioning #2469

* [minor] remove on_update from WebsiteGenerator

* [fix] delete shares when deleting user

* [test] don't run delete in background if test

* [fix] test_db

* [added] Deleted Document

* [fix] added track_changes in all documents

* [fix] add to deleted only if exists

* [fix] in_install flag in deleted documents

* [minor] name will always be reset
2016-12-29 18:01:42 +05:30
Rushabh Mehta
05268603cf [fix] delete attachments last, fixes #978 2016-12-27 15:34:42 +05:30
Rushabh Mehta
c67d3bfe01 Add attachment from email and copy attachments to Communication Record (#2412)
* Carry over file attachments in email communications

* [fix] style
2016-12-05 14:59:00 +05:30
Rushabh Mehta
7bc7e3bc63 Upgrade Font Awesome (#2410)
* Font-Awesome V3.x to V4.x

Font-Awesome V3.x to V4.x

* Font Tidy

Font Tidy

* FA4 Upgrade - Html Js & Json

FA4 Upgrade - Html Js & Json

* Minor

Minor
2016-12-05 13:07:03 +05:30
RobertSchouten
3730e4fa8f [fix] allow path attachements to be sent my email (#2138) 2016-10-08 11:10:08 +05:30
Rushabh Mehta
f1dd0c0bb8 [fix] web forms remove attachment 2016-09-29 12:38:46 +05:30
Rushabh Mehta
cd7b7ae35b [portal] enhancement to web form, introduced int, custom menu in portal settings etc 2016-09-26 17:03:55 +05:30