mirror of https://github.com/JohnHammond/CTFd.git
Fix publishing after a user saves the document by populating the ID that the page received (#540)
parent
d861b70603
commit
a87f4f962e
|
@ -55,14 +55,20 @@ def admin_pages_view():
|
||||||
page.draft = False
|
page.draft = False
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
db.session.close()
|
|
||||||
|
|
||||||
cache.clear()
|
data = {
|
||||||
|
|
||||||
return jsonify({
|
|
||||||
'result': 'success',
|
'result': 'success',
|
||||||
'operation': page_op
|
'operation': page_op,
|
||||||
})
|
'page': {
|
||||||
|
'id': page.id,
|
||||||
|
'route': page.route,
|
||||||
|
'title': page.title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
db.session.close()
|
||||||
|
cache.clear()
|
||||||
|
return jsonify(data)
|
||||||
|
|
||||||
if page_op == 'publish':
|
if page_op == 'publish':
|
||||||
page = Pages(title, route, html, draft=False, auth_required=auth_required)
|
page = Pages(title, route, html, draft=False, auth_required=auth_required)
|
||||||
|
@ -71,14 +77,21 @@ def admin_pages_view():
|
||||||
|
|
||||||
db.session.add(page)
|
db.session.add(page)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
db.session.close()
|
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'result': 'success',
|
||||||
|
'operation': page_op,
|
||||||
|
'page': {
|
||||||
|
'id': page.id,
|
||||||
|
'route': page.route,
|
||||||
|
'title': page.title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
db.session.close()
|
||||||
cache.clear()
|
cache.clear()
|
||||||
|
|
||||||
return jsonify({
|
return jsonify(data)
|
||||||
'result': 'success',
|
|
||||||
'operation': page_op
|
|
||||||
})
|
|
||||||
|
|
||||||
pages = Pages.query.all()
|
pages = Pages.query.all()
|
||||||
return render_template('admin/pages.html', pages=pages)
|
return render_template('admin/pages.html', pages=pages)
|
||||||
|
|
|
@ -154,9 +154,7 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<textarea id="admin-pages-editor" class="d-none" name="html">{% if page is defined %}{{ page.html }}{% endif %}</textarea>
|
<textarea id="admin-pages-editor" class="d-none" name="html">{% if page is defined %}{{ page.html }}{% endif %}</textarea>
|
||||||
{% if page is defined %}
|
<input name='id' type='hidden' {% if page is defined %}value="{{ page.id }}"{% endif %}>
|
||||||
<input name='id' type='hidden' value="{{ page.id }}">
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div role="tabpanel" class="tab-pane content" id="content-preview" style="height:400px">
|
<div role="tabpanel" class="tab-pane content" id="content-preview" style="height:400px">
|
||||||
|
@ -322,13 +320,14 @@
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (data.result == 'success'){
|
if (data.result == 'success'){
|
||||||
if (data.operation == 'publish'){
|
if (data.operation == 'publish'){
|
||||||
window.location = script_root + '/admin/pages'
|
window.location = script_root + '/admin/pages';
|
||||||
} else if (data.operation == 'save'){
|
} else if (data.operation == 'save'){
|
||||||
|
$('input[name=id]').val(data.page.id);
|
||||||
ezal({
|
ezal({
|
||||||
title: 'Saved',
|
title: 'Saved',
|
||||||
body: 'Your changes have been saved',
|
body: 'Your changes have been saved',
|
||||||
button: 'Okay'
|
button: 'Okay'
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue