소스 검색

fix: has_content check for fieldtype TextEditor

When a TextEditor field contains only an image, while checking for
content, HTML tags are stripped off including the only image.
This change adds a loose but explicit check for img tag.

(cherry picked from commit d11692c52f)
version-14
Faris Ansari 2 년 전
committed by Mergify
부모
커밋
bd69c67f42
1개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  1. +10
    -1
      frappe/model/base_document.py

+ 10
- 1
frappe/model/base_document.py 파일 보기

@@ -671,10 +671,19 @@ class BaseDocument:

return _("Error: Value missing for {0}: {1}").format(_(df.parent), _(df.label))

def has_content(df):
value = cstr(self.get(df.fieldname))
has_text_content = strip_html(value).strip()
has_img_tag = "<img" in value
if df.fieldtype == "Text Editor" and (has_text_content or has_img_tag):
return True
else:
return has_text_content

missing = []

for df in self.meta.get("fields", {"reqd": ("=", 1)}):
if self.get(df.fieldname) in (None, []) or not strip_html(cstr(self.get(df.fieldname))).strip():
if self.get(df.fieldname) in (None, []) or not has_content(df):
missing.append((df.fieldname, get_msg(df)))

# check for missing parent and parenttype


불러오는 중...
취소
저장