Skip to content

Commit a27335f

Browse files
committed
Merge branch 'v12-pre-release' into version-12
2 parents bb608ca + b41a37b commit a27335f

File tree

27 files changed

+212
-50
lines changed

27 files changed

+212
-50
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
"Cypress": true,
141141
"cy": true,
142142
"it": true,
143+
"describe": true,
143144
"expect": true,
144145
"context": true,
145146
"before": true,

frappe/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
reload(sys)
2424
sys.setdefaultencoding("utf-8")
2525

26-
__version__ = '12.17.0'
26+
__version__ = '12.18.0'
2727
__title__ = "Frappe Framework"
2828

2929
local = Local()

frappe/change_log/v12/v12_18_0.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Version 12.18.0 Release Notes
2+
3+
### Fixes & Enhancements
4+
5+
- Moving Site folder across different FileSystems failed ([#13033](https://github.com/frappe/frappe/pull/13033))
6+
- Revert naming for custom naming series ([#13178](https://github.com/frappe/frappe/pull/13178))
7+
- Show delete button on portal if user has permission to delete document ([#13183](https://github.com/frappe/frappe/pull/13183))
8+
- Conditionally hide grid Add Row & Add Multiple buttons ([#12960](https://github.com/frappe/frappe/pull/12960))
9+
- Grid Form buttons Insert Above, Insert Below not hidden when can… ([#12906](https://github.com/frappe/frappe/pull/12906))
10+
- Do not skip data in save while using shortcut ([#13181](https://github.com/frappe/frappe/pull/13181))
11+
- Multi currency in print view shows same currency symbol ([#12569](https://github.com/frappe/frappe/pull/12569))
12+
- Reverting of series with a variable ([#12811](https://github.com/frappe/frappe/pull/12811))
13+
- Grid Form buttons Insert Above, Insert Below not hidden when can… ([#12931](https://github.com/frappe/frappe/pull/12931))
14+
- Check if same value is set to avoid unnecessary change triggers ([#12963](https://github.com/frappe/frappe/pull/12963))
15+
- Default values were not triggering change event ([#12975](https://github.com/frappe/frappe/pull/12975))
16+
- Preload URLs breaking for external requests ([#13058](https://github.com/frappe/frappe/pull/13058))
17+
- Forward message action in communication form view not working ([#12800](https://github.com/frappe/frappe/pull/12800))
18+
- Redirect Web Form user directly to success URL, if no amount is due ([#12661](https://github.com/frappe/frappe/pull/12661))
19+
- Check if response contains signature before setting ([#13185](https://github.com/frappe/frappe/pull/13185))
20+
- Replace parseFloat by Number ([#13011](https://github.com/frappe/frappe/pull/13011))
21+
- Only allow user's attachments to show in attachments tree ([#12822](https://github.com/frappe/frappe/pull/12822))

frappe/commands/site.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def move(dest_dir, site):
513513
site_dump_exists = os.path.exists(final_new_path)
514514
count = int(count or 0) + 1
515515

516-
os.rename(old_path, final_new_path)
516+
shutil.move(old_path, final_new_path)
517517
frappe.destroy()
518518
return final_new_path
519519

frappe/core/doctype/file/file.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,10 +947,18 @@ def validate_filename(filename):
947947

948948
@frappe.whitelist()
949949
def get_files_in_folder(folder):
950-
return frappe.db.get_all('File',
950+
attachment_folder = frappe.db.get_value('File',
951+
'Home/Attachments',
952+
['name', 'file_name', 'file_url', 'is_folder', 'modified'],
953+
as_dict=1
954+
)
955+
files = frappe.db.get_list('File',
951956
{ 'folder': folder },
952957
['name', 'file_name', 'file_url', 'is_folder', 'modified']
953958
)
959+
if folder == 'Home' and attachment_folder not in files:
960+
files.insert(0, attachment_folder)
961+
return files
954962

955963
def update_existing_file_docs(doc):
956964
# Update is private and file url of all file docs that point to the same file

frappe/core/doctype/file/test_file.py

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import os
99
import unittest
1010
from frappe import _
11-
from frappe.core.doctype.file.file import move_file
11+
from frappe.core.doctype.file.file import move_file, get_files_in_folder
1212
from frappe.utils import get_files_path
1313
# test_records = frappe.get_test_records('File')
1414

@@ -390,3 +390,61 @@ def test_parent_directory_validation_in_file_url(self):
390390
file1.reload()
391391
file1.file_url = '/private/files/parent_dir2.txt'
392392
file1.save()
393+
394+
395+
class TestAttachmentsAccess(unittest.TestCase):
396+
397+
def test_attachments_access(self):
398+
399+
frappe.set_user('test4@example.com')
400+
self.attached_to_doctype, self.attached_to_docname = make_test_doc()
401+
402+
frappe.get_doc({
403+
"doctype": "File",
404+
"file_name": 'test_user.txt',
405+
"attached_to_doctype": self.attached_to_doctype,
406+
"attached_to_name": self.attached_to_docname,
407+
"content": 'Testing User'
408+
}).insert()
409+
410+
frappe.get_doc({
411+
"doctype": "File",
412+
"file_name": "test_user_home.txt",
413+
"content": 'User Home',
414+
}).insert()
415+
416+
frappe.set_user('test@example.com')
417+
418+
frappe.get_doc({
419+
"doctype": "File",
420+
"file_name": 'test_system_manager.txt',
421+
"attached_to_doctype": self.attached_to_doctype,
422+
"attached_to_name": self.attached_to_docname,
423+
"content": 'Testing System Manager'
424+
}).insert()
425+
426+
frappe.get_doc({
427+
"doctype": "File",
428+
"file_name": "test_sm_home.txt",
429+
"content": 'System Manager Home',
430+
}).insert()
431+
432+
system_manager_files = [file.file_name for file in get_files_in_folder('Home')]
433+
system_manager_attachments_files = [file.file_name for file in get_files_in_folder('Home/Attachments')]
434+
435+
frappe.set_user('test4@example.com')
436+
user_files = [file.file_name for file in get_files_in_folder('Home')]
437+
user_attachments_files = [file.file_name for file in get_files_in_folder('Home/Attachments')]
438+
439+
self.assertIn('test_sm_home.txt', system_manager_files)
440+
self.assertNotIn('test_sm_home.txt', user_files)
441+
self.assertIn('test_user_home.txt', system_manager_files)
442+
self.assertIn('test_user_home.txt', user_files)
443+
444+
self.assertIn('test_system_manager.txt', system_manager_attachments_files)
445+
self.assertNotIn('test_system_manager.txt', user_attachments_files)
446+
self.assertIn('test_user.txt', system_manager_attachments_files)
447+
self.assertIn('test_user.txt', user_attachments_files)
448+
449+
frappe.set_user('Administrator')
450+
frappe.db.rollback()

frappe/core/doctype/user/test_records.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@
3838
"new_password": "Eastern_43A1W",
3939
"enabled": 1
4040
},
41+
{
42+
"doctype": "User",
43+
"email": "test4@example.com",
44+
"first_name": "_Test4",
45+
"new_password": "Eastern_43A1W",
46+
"enabled": 1
47+
},
4148
{
4249
"doctype": "User",
4350
"email": "testperm@example.com",

frappe/integrations/oauth2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def get_token(*args, **kwargs):
101101
http_method = r.method
102102
body = r.form
103103
headers = r.headers
104-
104+
105105
#Check whether frappe server URL is set
106106
frappe_server_url = frappe.db.get_value("Social Login Key", "frappe", "base_url") or None
107107
if not frappe_server_url:
@@ -130,7 +130,7 @@ def get_token(*args, **kwargs):
130130
}
131131
import jwt
132132
id_token_encoded = jwt.encode(id_token, client_secret, algorithm='HS256', headers=id_token_header)
133-
out.update({"id_token":str(id_token_encoded)})
133+
out.update({"id_token": frappe.safe_decode(id_token_encoded)})
134134
frappe.local.response = out
135135

136136
except FatalClientError as e:
@@ -177,7 +177,7 @@ def openid_profile(*args, **kwargs):
177177
"email": name,
178178
"picture": picture
179179
})
180-
180+
181181
frappe.local.response = user_profile
182182

183183
def validate_url(url_string):
@@ -188,4 +188,4 @@ def validate_url(url_string):
188188
else:
189189
return False
190190
except:
191-
return False
191+
return False

frappe/model/base_document.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,11 @@ def get_formatted(self, fieldname, doc=None, currency=None, absolute_value=False
743743
from frappe.model.meta import get_default_df
744744
df = get_default_df(fieldname)
745745

746+
if not currency:
747+
currency = self.get(df.get("options"))
748+
if not frappe.db.exists('Currency', currency, cache=True):
749+
currency = None
750+
746751
val = self.get(fieldname)
747752

748753
if translated:

frappe/model/delete_doc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ def update_naming_series(doc):
153153
if doc.meta.autoname:
154154
if doc.meta.autoname.startswith("naming_series:") \
155155
and getattr(doc, "naming_series", None):
156-
revert_series_if_last(doc.naming_series, doc.name)
156+
revert_series_if_last(doc.naming_series, doc.name, doc)
157157

158158
elif doc.meta.autoname.split(":")[0] not in ("Prompt", "field", "hash"):
159-
revert_series_if_last(doc.meta.autoname, doc.name)
159+
revert_series_if_last(doc.meta.autoname, doc.name, doc)
160160

161161
def delete_from_table(doctype, name, ignore_doctypes, doc):
162162
if doctype!="DocType" and doctype==name:

0 commit comments

Comments
 (0)