Merge branch 'develop' into multiple-webform-for-same-doctype

This commit is contained in:
Shariq Ansari 2023-06-03 17:27:01 +05:30 committed by GitHub
commit 38513ccac5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 21 deletions

View file

@ -19,7 +19,6 @@ import frappe.recorder
import frappe.utils.response
from frappe import _
from frappe.auth import SAFE_HTTP_METHODS, UNSAFE_HTTP_METHODS, HTTPRequest
from frappe.core.doctype.comment.comment import update_comments_in_parent_after_request
from frappe.middlewares import StaticDataMiddleware
from frappe.utils import cint, get_site_name, sanitize_html
from frappe.utils.error import make_error_snapshot
@ -351,8 +350,6 @@ def sync_database(rollback: bool) -> bool:
frappe.db.commit()
rollback = False
update_comments_in_parent_after_request()
return rollback

View file

@ -152,14 +152,9 @@ def update_comments_in_parent(reference_doctype, reference_name, _comments):
except Exception as e:
if frappe.db.is_column_missing(e) and getattr(frappe.local, "request", None):
# missing column and in request, add column and update after commit
frappe.local._comments = getattr(frappe.local, "_comments", []) + [
(reference_doctype, reference_name, _comments)
]
pass
elif frappe.db.is_data_too_long(e):
raise frappe.DataTooLongException
else:
raise
else:
@ -169,13 +164,3 @@ def update_comments_in_parent(reference_doctype, reference_name, _comments):
# Clear route cache
if route := frappe.get_cached_value(reference_doctype, reference_name, "route"):
clear_cache(route)
def update_comments_in_parent_after_request():
"""update _comments in parent if _comments column is missing"""
if hasattr(frappe.local, "_comments"):
for (reference_doctype, reference_name, _comments) in frappe.local._comments:
add_column(reference_doctype, "_comments", "Text")
update_comments_in_parent(reference_doctype, reference_name, _comments)
frappe.db.commit()

View file

@ -1,8 +1,15 @@
# Copyright (c) 2018, Frappe Technologies and contributors
# License: MIT. See LICENSE
import frappe
from frappe.model.document import Document
class ViewLog(Document):
pass
@staticmethod
def clear_old_logs(days=180):
from frappe.query_builder import Interval
from frappe.query_builder.functions import Now
table = frappe.qb.DocType("View Log")
frappe.db.delete(table, filters=(table.modified < (Now() - Interval(days=days))))

View file

@ -312,7 +312,7 @@ class Database:
frappe.log(f"<<<< query\n{_query}\n>>>>")
if unmogrified_query and is_query_type(
unmogrified_query, ("alter", "drop", "select", "create", "truncate", "rename")
unmogrified_query, ("alter", "drop", "create", "truncate", "rename")
):
_query = _query or str(mogrified_query)
self.logger.warning("DDL Query made to DB:\n" + _query)

View file

@ -365,8 +365,14 @@ frappe.form.formatters = {
</div>`
: "";
},
Attach: format_attachment_url,
AttachImage: format_attachment_url,
};
function format_attachment_url(url) {
return url ? `<a href="${url}" target="_blank">${url}</a>` : "";
}
frappe.form.get_formatter = function (fieldtype) {
if (!fieldtype) fieldtype = "Data";
return frappe.form.formatters[fieldtype.replace(/ /g, "")] || frappe.form.formatters.Data;