Prevent articles from being readied when they have errors

This commit is contained in:
Tim Van Baak 2020-04-28 00:20:51 -07:00
parent 79cbaf47a5
commit e63be96dac
3 changed files with 7 additions and 1 deletions

View File

@ -43,6 +43,7 @@ function update(article) {
if (req.readyState == 4 && req.status == 200) {
// Update internal state with the returned article object
params.status = req.response.status;
params.errors = req.response.error.length;
document.getElementById("editor-title").value = req.response.title;
// Set editor editability based on article status
updateEditorStatus();
@ -55,11 +56,13 @@ function update(article) {
}
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-content").disabled = ready;
var hasErrors = params.errors > 0;
var submitButton = document.getElementById("button-submit");
submitButton.innerText = ready ? "Edit article" : "Submit article";
submitButton.disabled = hasErrors;
}
function updatePreview(response) {

View File

@ -114,6 +114,8 @@ def update_draft(lexicon: LexiconModel, article_json):
lexicon, current_user, title)
content_infos, content_warnings, content_errors = content_constraint_analysis(
lexicon, current_user, article.character, parsed)
if any(title_errors) or any(content_errors):
status['ready'] = False
# Article update
filename = f'{article.character}.{aid}'

View File

@ -22,6 +22,7 @@
article: {
aid: {{ jsonfmt(article.aid) }},
status: {{ jsonfmt(article.status) }},
errors: 1,
}
{% else %}
article: null