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