Prevent articles from being readied when they have errors
This commit is contained in:
parent
79cbaf47a5
commit
e63be96dac
|
@ -43,6 +43,7 @@ function update(article) {
|
||||||
if (req.readyState == 4 && req.status == 200) {
|
if (req.readyState == 4 && req.status == 200) {
|
||||||
// Update internal state with the returned article object
|
// Update internal state with the returned article object
|
||||||
params.status = req.response.status;
|
params.status = req.response.status;
|
||||||
|
params.errors = req.response.error.length;
|
||||||
document.getElementById("editor-title").value = req.response.title;
|
document.getElementById("editor-title").value = req.response.title;
|
||||||
// Set editor editability based on article status
|
// Set editor editability based on article status
|
||||||
updateEditorStatus();
|
updateEditorStatus();
|
||||||
|
@ -55,11 +56,13 @@ function update(article) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateEditorStatus() {
|
function updateEditorStatus() {
|
||||||
var ready = !!params.article.status.ready || !!params.article.status.approved;
|
var ready = !!params.status.ready || !!params.status.approved;
|
||||||
document.getElementById("editor-title").disabled = ready;
|
document.getElementById("editor-title").disabled = ready;
|
||||||
document.getElementById("editor-content").disabled = ready;
|
document.getElementById("editor-content").disabled = ready;
|
||||||
|
var hasErrors = params.errors > 0;
|
||||||
var submitButton = document.getElementById("button-submit");
|
var submitButton = document.getElementById("button-submit");
|
||||||
submitButton.innerText = ready ? "Edit article" : "Submit article";
|
submitButton.innerText = ready ? "Edit article" : "Submit article";
|
||||||
|
submitButton.disabled = hasErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePreview(response) {
|
function updatePreview(response) {
|
||||||
|
|
|
@ -114,6 +114,8 @@ def update_draft(lexicon: LexiconModel, article_json):
|
||||||
lexicon, current_user, title)
|
lexicon, current_user, title)
|
||||||
content_infos, content_warnings, content_errors = content_constraint_analysis(
|
content_infos, content_warnings, content_errors = content_constraint_analysis(
|
||||||
lexicon, current_user, article.character, parsed)
|
lexicon, current_user, article.character, parsed)
|
||||||
|
if any(title_errors) or any(content_errors):
|
||||||
|
status['ready'] = False
|
||||||
|
|
||||||
# Article update
|
# Article update
|
||||||
filename = f'{article.character}.{aid}'
|
filename = f'{article.character}.{aid}'
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
article: {
|
article: {
|
||||||
aid: {{ jsonfmt(article.aid) }},
|
aid: {{ jsonfmt(article.aid) }},
|
||||||
status: {{ jsonfmt(article.status) }},
|
status: {{ jsonfmt(article.status) }},
|
||||||
|
errors: 1,
|
||||||
}
|
}
|
||||||
{% else %}
|
{% else %}
|
||||||
article: null
|
article: null
|
||||||
|
|
Loading…
Reference in New Issue