修复参考来源JSON序列化错误
- 手动将Reference对象转换为JSON字符串 - 避免使用tojson过滤器序列化SQLAlchemy对象
This commit is contained in:
@@ -350,7 +350,13 @@ function uploadImage(file, isPaste = false) {
|
||||
}
|
||||
|
||||
// 参考来源管理
|
||||
let references = {% if references %}[{% for ref in references %}{"id": {{ ref.id }}, "title": "{{ ref.title }}", "url": "{{ ref.url or '' }}", "description": "{{ ref.description or '' }}"}{% if not loop.last %}, {% endif %}{% endfor %}]{% else %}[]{% endif %};
|
||||
let references = {% if references %}[
|
||||
{% for ref in references %}
|
||||
{"id": {{ ref.id }}, "title": "{{ ref.title | e }}", "url": "{{ ref.url or '' | e }}", "description": "{{ ref.description or '' | e }}"}
|
||||
{% if not loop.last %},
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
]{% else %}[]{% endif %};
|
||||
|
||||
function addReference() {
|
||||
references.push({id: null, title: '', url: '', description: ''});
|
||||
@@ -425,7 +431,7 @@ function deleteAttachment(id) {
|
||||
|
||||
{% block content %}
|
||||
<form method="POST" class="article-form">
|
||||
<input type="hidden" id="references-json" name="references" value="{{ references | tojson | safe if references else '[]' }}">
|
||||
<input type="hidden" id="references-json" name="references" value="[{% for ref in references %}{"id": {{ ref.id }}, "title": "{{ ref.title | e }}", "url": "{{ ref.url or '' | e }}", "description": "{{ ref.description or '' | e }}"}{% if not loop.last %}, {% endif %}{% endfor %}]">
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group flex-grow">
|
||||
|
||||
Reference in New Issue
Block a user