diff --git a/CTFd/admin/pages.py b/CTFd/admin/pages.py index 55a256d4..047cdd1a 100644 --- a/CTFd/admin/pages.py +++ b/CTFd/admin/pages.py @@ -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) diff --git a/CTFd/themes/admin/templates/editor.html b/CTFd/themes/admin/templates/editor.html index 4f5124bb..cc7767c2 100644 --- a/CTFd/themes/admin/templates/editor.html +++ b/CTFd/themes/admin/templates/editor.html @@ -154,9 +154,7 @@
- {% if page is defined %} - - {% endif %} +
@@ -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' - }) + }); } } }