Skip to content

Commit

Permalink
Merge branch 'develop' into multiple-webform-for-same-doctype
Browse files Browse the repository at this point in the history
  • Loading branch information
shariquerik committed Jun 3, 2023
2 parents 042595c + 5185374 commit 38513cc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
3 changes: 0 additions & 3 deletions frappe/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
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
Expand Down Expand Up @@ -351,8 +350,6 @@ def sync_database(rollback: bool) -> bool:
frappe.db.commit()
rollback = False

update_comments_in_parent_after_request()

return rollback


Expand Down
17 changes: 1 addition & 16 deletions frappe/core/doctype/comment/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
9 changes: 8 additions & 1 deletion frappe/core/doctype/view_log/view_log.py
Original file line number Diff line number Diff line change
@@ -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))))
2 changes: 1 addition & 1 deletion frappe/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def _log_query(
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)
Expand Down
6 changes: 6 additions & 0 deletions frappe/public/js/frappe/form/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 38513cc

Please sign in to comment.