Merge branch 'frappe:develop' into develop

This commit is contained in:
Manuel 2021-10-28 10:38:12 +02:00 committed by GitHub
commit e800be46b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 37 additions and 32 deletions

View file

@ -137,10 +137,10 @@ lang = local("lang")
if typing.TYPE_CHECKING:
from frappe.database.mariadb.database import MariaDBDatabase
from frappe.database.postgres.database import PostgresDatabase
from pypika import Query
from frappe.query_builder.builder import MariaDB, Postgres
db: typing.Union[MariaDBDatabase, PostgresDatabase]
qb: Query
qb: typing.Union[MariaDB, Postgres]
# end: static analysis hack

View file

@ -1,6 +1,7 @@
# Copyright (c) 2021, Frappe Technologies and contributors
# License: MIT. See LICENSE
import frappe
from frappe.utils import cstr
from tenacity import retry, retry_if_exception_type, stop_after_attempt
from frappe.model.document import Document
@ -24,25 +25,21 @@ def make_access_log(
page=None,
columns=None,
):
user = frappe.session.user
in_request = frappe.request and frappe.request.method == "GET"
doc = frappe.get_doc(
{
"doctype": "Access Log",
"user": user,
"export_from": doctype,
"reference_document": document,
"file_type": file_type,
"report_name": report_name,
"page": page,
"method": method,
"filters": frappe.utils.cstr(filters) if filters else None,
"columns": columns,
}
)
doc.insert(ignore_permissions=True)
frappe.get_doc({
"doctype": "Access Log",
"user": user,
"export_from": doctype,
"reference_document": document,
"file_type": file_type,
"report_name": report_name,
"page": page,
"method": method,
"filters": cstr(filters) or None,
"columns": columns,
}).db_insert()
# `frappe.db.commit` added because insert doesnt `commit` when called in GET requests like `printview`
# dont commit in test mode

View file

@ -15,11 +15,6 @@ frappe.ui.form.ControlData = class ControlData extends frappe.ui.form.ControlInp
.addClass("input-with-feedback form-control")
.prependTo(this.input_area);
if (in_list(['Data', 'Link', 'Dynamic Link', 'Password', 'Select', 'Read Only', 'Attach', 'Attach Image'],
this.df.fieldtype)) {
this.$input.attr("maxlength", this.df.length || 140);
}
this.$input.on('paste', (e) => {
let pasted_data = frappe.utils.get_clipboard_data(e);
let maxlength = this.$input.attr('maxlength');
@ -199,6 +194,13 @@ frappe.ui.form.ControlData = class ControlData extends frappe.ui.form.ControlInp
}
}
set_input_attributes() {
if (in_list(
['Data', 'Link', 'Dynamic Link', 'Password', 'Select', 'Read Only'],
this.df.fieldtype
)) {
this.$input.attr("maxlength", this.df.length || 140);
}
this.$input
.attr("data-fieldtype", this.df.fieldtype)
.attr("data-fieldname", this.df.fieldname)

View file

@ -30,7 +30,7 @@ frappe.ui.form.Footer = class FormFooter {
fieldname: 'comment'
},
on_submit: (comment) => {
if (strip_html(comment).trim() != "") {
if (strip_html(comment).trim() != "" || comment.includes('img')) {
this.frm.comment_box.disable();
frappe.xcall("frappe.desk.form.utils.add_comment", {
reference_doctype: this.frm.doctype,

View file

@ -1 +1 @@
@import './website/index';
@import './website/index';

View file

@ -145,11 +145,6 @@
.section-with-cards .card {
@include transition();
border: none;
.card-body {
padding: 0 1.5rem 2rem 0;
}
&:hover {
border-color: $gray-500;

View file

@ -10,7 +10,7 @@ class TestWebsite(unittest.TestCase):
frappe.set_user('Guest')
def tearDown(self):
frappe.db.value_cache = {}
frappe.db.delete('Access Log')
frappe.set_user('Administrator')
def test_home_page(self):

View file

@ -5,6 +5,7 @@ from typing import Optional
import frappe
import operator
import json
import base64
import re, datetime, math, time
from code import compile_command
from urllib.parse import quote, urljoin
@ -1013,7 +1014,6 @@ def get_thumbnail_base64_for_image(src):
return cache().hget('thumbnail_base64', src, generator=_get_base64)
def image_to_base64(image, extn):
import base64
from io import BytesIO
buffered = BytesIO()
@ -1023,6 +1023,16 @@ def image_to_base64(image, extn):
img_str = base64.b64encode(buffered.getvalue())
return img_str
def pdf_to_base64(filename):
from frappe.utils.file_manager import get_file_path
file_path = get_file_path(filename)
if not file_path:
return
with open(file_path, 'rb') as pdf_file:
base64_string = base64.b64encode(pdf_file.read())
return base64_string
# from Jinja2 code
_striptags_re = re.compile(r'(<!--.*?-->|<[^>]*>)')

View file

@ -327,6 +327,7 @@ VALID_UTILS = (
"is_image",
"get_thumbnail_base64_for_image",
"image_to_base64",
"pdf_to_base64",
"strip_html",
"escape_html",
"pretty_date",