Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
仰若水
frappe
Commits
288b98ca
Commit
288b98ca
authored
6 years ago
by
Nabin Hait
Browse files
Options
Download
Plain Diff
Merge branch 'hotfix'
parents
b9fffc99
cdfba6fd
develop
v11.1.5
v11.1.4
v11.1.3
v11.1.2
v11.1.1
v11.1.0
v11.0.3
v11.0.3-beta.51
v11.0.3-beta.50
v11.0.3-beta.49
v11.0.3-beta.48
v11.0.3-beta.47
v11.0.3-beta.46
v11.0.3-beta.45
v11.0.3-beta.44
v11.0.3-beta.43
v11.0.3-beta.42
v11.0.3-beta.41
v11.0.3-beta.40
v11.0.3-beta.39
v11.0.3-beta.38
v11.0.3-beta.37
v11.0.3-beta.36
v11.0.3-beta.35
v11.0.3-beta.34
v11.0.3-beta.33
v11.0.3-beta.32
v11.0.3-beta.31
v11.0.3-beta.30
v11.0.3-beta.29
v11.0.3-beta.28
v11.0.3-beta.27
v11.0.3-beta.26
v11.0.3-beta.25
v11.0.3-beta.24
v11.0.3-beta.23
v11.0.3-beta.22
v11.0.3-beta.21
v11.0.3-beta.20
v11.0.3-beta.19
v11.0.3-beta.18
v11.0.3-beta.17
v11.0.3-beta.16
v11.0.3-beta.15
v11.0.3-beta.14
v11.0.3-beta.13
v11.0.3-beta.12
v11.0.3-beta.11
v11.0.3-beta.10
v11.0.3-beta.9
v11.0.3-beta.8
v11.0.3-beta.7
v11.0.3-beta.6
v11.0.3-beta.5
v11.0.3-beta.4
v11.0.3-beta.3
v11.0.3-beta.2
v11.0.3-beta.1
v11.0.2
v11.0.1
v11.0.0-beta
v10.1.71
v10.1.70
v10.1.69
v10.1.68
v10.1.67
v10.1.66
v10.1.65
v10.1.64
v10.1.63
v10.1.62
v10.1.61
v10.1.60
v10.1.59
v10.1.58
v10.1.57
v10.1.56
v10.1.55
v10.1.54
v10.1.53
v10.1.52
v10.1.51
v10.1.50
v10.1.49
v10.1.49-beta.1
v10.1.48
v10.1.47
v10.1.46
v10.1.45
v10.1.44
v10.1.43
No related merge requests found
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
frappe/__init__.py
+1
-1
frappe/__init__.py
frappe/core/doctype/user/test_user.py
+2
-0
frappe/core/doctype/user/test_user.py
frappe/core/doctype/user/user.py
+1
-0
frappe/core/doctype/user/user.py
frappe/desk/doctype/calendar_view/calendar_view.json
+7
-3
frappe/desk/doctype/calendar_view/calendar_view.json
frappe/public/js/frappe/form/footer/timeline.js
+2
-2
frappe/public/js/frappe/form/footer/timeline.js
frappe/public/js/frappe/ui/base_list.js
+0
-1
frappe/public/js/frappe/ui/base_list.js
frappe/public/js/frappe/views/reports/reportview.js
+13
-3
frappe/public/js/frappe/views/reports/reportview.js
frappe/utils/__init__.py
+34
-0
frappe/utils/__init__.py
frappe/utils/pdf.py
+8
-6
frappe/utils/pdf.py
with
68 additions
and
16 deletions
+68
-16
frappe/__init__.py
View file @
288b98ca
...
...
@@ -14,7 +14,7 @@ import os, sys, importlib, inspect, json
from
.exceptions
import
*
from
.utils.jinja
import
get_jenv
,
get_template
,
render_template
,
get_email_from_template
__version__
=
'10.1.4
2
'
__version__
=
'10.1.4
3
'
__title__
=
"Frappe Framework"
local
=
Local
()
...
...
This diff is collapsed.
Click to expand it.
frappe/core/doctype/user/test_user.py
View file @
288b98ca
...
...
@@ -260,6 +260,8 @@ class TestUser(unittest.TestCase):
def
test_comment_mentions
(
self
):
user_name
=
"@test.comment@example.com"
self
.
assertEqual
(
extract_mentions
(
user_name
)[
0
],
"test.comment@example.com"
)
user_name
=
"@test.comment@test-example.com"
self
.
assertEqual
(
extract_mentions
(
user_name
)[
0
],
"test.comment@test-example.com"
)
user_name
=
"Testing comment, @test-user please check."
self
.
assertEqual
(
extract_mentions
(
user_name
)[
0
],
"test-user"
)
user_name
=
"Testing comment, @test.user@example.com please check."
...
...
This diff is collapsed.
Click to expand it.
frappe/core/doctype/user/user.py
View file @
288b98ca
...
...
@@ -901,6 +901,7 @@ def notify_admin_access_to_system_manager(login_manager=None):
def
extract_mentions
(
txt
):
"""Find all instances of @name in the string.
The mentions will be separated by non-word characters or may appear at the start of the string"""
txt
=
re
.
sub
(
r
'(<[a-zA-Z\/][^>]*>)'
,
''
,
txt
)
return
re
.
findall
(
r
'(?:[^\w\.\-\@]|^)@([\w\.\-\@]*)'
,
txt
)
...
...
This diff is collapsed.
Click to expand it.
frappe/desk/doctype/calendar_view/calendar_view.json
View file @
288b98ca
...
...
@@ -42,6 +42,7 @@
"reqd"
:
1
,
"search_index"
:
0
,
"set_only_once"
:
0
,
"translatable"
:
0
,
"unique"
:
0
},
{
...
...
@@ -72,6 +73,7 @@
"reqd"
:
1
,
"search_index"
:
0
,
"set_only_once"
:
0
,
"translatable"
:
0
,
"unique"
:
0
},
{
...
...
@@ -99,9 +101,10 @@
"read_only"
:
0
,
"remember_last_selected_value"
:
0
,
"report_hide"
:
0
,
"reqd"
:
0
,
"reqd"
:
1
,
"search_index"
:
0
,
"set_only_once"
:
0
,
"translatable"
:
0
,
"unique"
:
0
},
{
...
...
@@ -129,9 +132,10 @@
"read_only"
:
0
,
"remember_last_selected_value"
:
0
,
"report_hide"
:
0
,
"reqd"
:
0
,
"reqd"
:
1
,
"search_index"
:
0
,
"set_only_once"
:
0
,
"translatable"
:
0
,
"unique"
:
0
}
],
...
...
@@ -145,7 +149,7 @@
"issingle"
:
0
,
"istable"
:
0
,
"max_attachments"
:
0
,
"modified"
:
"201
7-11-14 14:14:11.544811
"
,
"modified"
:
"201
8-07-20 08:23:23.737254
"
,
"modified_by"
:
"Administrator"
,
"module"
:
"Desk"
,
"name"
:
"Calendar View"
,
...
...
This diff is collapsed.
Click to expand it.
frappe/public/js/frappe/form/footer/timeline.js
View file @
288b98ca
...
...
@@ -310,9 +310,9 @@ frappe.ui.form.Timeline = Class.extend({
// bold @mentions
if
(
c
.
comment_type
===
"
Comment
"
&&
// avoid adding <b> tag a 2nd time
!
c
.
content_html
.
match
(
/
(
^|
\W)
<b>
(
@
\w
+
)
<
\/
b>/
)
!
c
.
content_html
.
match
(
/
(
^|
\W)
<b>
(
@
[^\s]
+
)
<
\/
b>/
)
)
{
c
.
content_html
=
c
.
content_html
.
replace
(
/
(
^|
\W)(
@
\w
+
)
/g
,
"
$1<b>$2</b>
"
);
c
.
content_html
=
c
.
content_html
.
replace
(
/
(
^|
\W)(
@
[^\s]
+
)
/g
,
"
$1<b>$2</b>
"
);
}
if
(
this
.
is_communication_or_comment
(
c
))
{
...
...
This diff is collapsed.
Click to expand it.
frappe/public/js/frappe/ui/base_list.js
View file @
288b98ca
...
...
@@ -322,7 +322,6 @@ frappe.ui.BaseList = Class.extend({
return
frappe
.
call
({
method
:
this
.
opts
.
method
||
'
frappe.desk.query_builder.runquery
'
,
type
:
"
GET
"
,
freeze
:
this
.
opts
.
freeze
!==
undefined
?
this
.
opts
.
freeze
:
true
,
args
:
args
,
callback
:
function
(
r
)
{
...
...
This diff is collapsed.
Click to expand it.
frappe/public/js/frappe/views/reports/reportview.js
View file @
288b98ca
...
...
@@ -391,7 +391,7 @@ frappe.views.ReportView = frappe.ui.BaseList.extend({
var
me
=
this
;
var
data
=
this
.
get_unique_data
(
this
.
column_info
);
this
.
set_totals_row
(
data
);
this
.
set_totals_row
(
data
,
this
.
column_info
);
// add sr in data
$
.
each
(
data
,
function
(
i
,
v
)
{
...
...
@@ -617,13 +617,23 @@ frappe.views.ReportView = frappe.ui.BaseList.extend({
});
},
set_totals_row
:
function
(
data
)
{
set_totals_row
:
function
(
data
,
columns
)
{
const
field_map
=
{};
const
numeric_fieldtypes
=
[
'
Int
'
,
'
Currency
'
,
'
Float
'
];
columns
.
forEach
(
function
(
row
)
{
if
(
row
.
docfield
)
{
let
r
=
row
.
docfield
;
if
(
numeric_fieldtypes
.
includes
(
r
.
fieldtype
))
{
field_map
[
r
.
fieldname
]
=
[
r
.
fieldtype
];
}
}
})
if
(
this
.
add_totals_row
)
{
var
totals_row
=
{
_totals_row
:
1
};
if
(
data
.
length
)
{
data
.
forEach
(
function
(
row
,
ri
)
{
$
.
each
(
row
,
function
(
key
,
value
)
{
if
(
$
.
isNumeric
(
value
)
)
{
if
(
key
in
field_map
)
{
totals_row
[
key
]
=
(
totals_row
[
key
]
||
0
)
+
value
;
}
});
...
...
This diff is collapsed.
Click to expand it.
frappe/utils/__init__.py
View file @
288b98ca
...
...
@@ -548,3 +548,37 @@ def get_site_info():
# dumps -> loads to prevent datatype conflicts
return
json
.
loads
(
frappe
.
as_json
(
site_info
))
def
get_db_count
(
*
args
):
"""
Pass a doctype or a series of doctypes to get the count of docs in them
Parameters:
*args: Variable length argument list of doctype names whose doc count you need
Returns:
dict: A dict with the count values.
Example:
via terminal:
bench --site erpnext.local execute frappe.utils.get_db_count --args "['DocType', 'Communication']"
"""
db_count
=
{}
for
doctype
in
args
:
db_count
[
doctype
]
=
frappe
.
db
.
count
(
doctype
)
return
json
.
loads
(
frappe
.
as_json
(
db_count
))
def
call
(
fn
,
*
args
,
**
kwargs
):
"""
Pass a doctype or a series of doctypes to get the count of docs in them
Parameters:
fn: frappe function to be called
Returns:
based on the function you call: output of the function you call
Example:
via terminal:
bench --site erpnext.local execute frappe.utils.call --args '''["frappe.get_all", "Activity Log"]''' --kwargs '''{"fields": ["user", "creation", "full_name"], "filters":{"Operation": "Login", "Status": "Success"}, "limit": "10"}'''
"""
return
json
.
loads
(
frappe
.
as_json
(
frappe
.
call
(
fn
,
*
args
,
**
kwargs
)))
This diff is collapsed.
Click to expand it.
frappe/utils/pdf.py
View file @
288b98ca
...
...
@@ -7,6 +7,7 @@ from frappe.utils import scrub_urls
from
frappe
import
_
from
bs4
import
BeautifulSoup
from
PyPDF2
import
PdfFileWriter
,
PdfFileReader
import
re
def
get_pdf
(
html
,
options
=
None
,
output
=
None
):
html
=
scrub_urls
(
html
)
...
...
@@ -16,7 +17,7 @@ def get_pdf(html, options=None, output = None):
try
:
pdfkit
.
from_string
(
html
,
fname
,
options
=
options
or
{})
if
output
:
append_pdf
(
PdfFileReader
(
f
ile
(
fname
,
"rb"
)
),
output
)
append_pdf
(
PdfFileReader
(
f
name
),
output
)
else
:
with
open
(
fname
,
"rb"
)
as
fileobj
:
filedata
=
fileobj
.
read
()
...
...
@@ -88,12 +89,13 @@ def read_options_from_html(html):
toggle_visible_pdf
(
soup
)
#
extract pdfkit options from html
for
html_id
in
(
"margin-top"
,
"margin-bottom"
,
"margin-left"
,
"margin-right"
,
"page-size"
):
#
use regex instead of soup-parser
for
attr
in
(
"margin-top"
,
"margin-bottom"
,
"margin-left"
,
"margin-right"
,
"page-size"
):
try
:
tag
=
soup
.
find
(
id
=
html_id
)
if
tag
and
tag
.
contents
:
options
[
html_id
]
=
tag
.
contents
pattern
=
re
.
compile
(
r
"(\.print-format)([\S|\s][^}]*?)("
+
str
(
attr
)
+
r
":)(.+)(mm;)"
)
match
=
pattern
.
findall
(
html
)
if
match
:
options
[
attr
]
=
str
(
match
[
-
1
][
3
]).
strip
()
except
:
pass
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help