def test_get_update_editor_contents(client, admin): login(client, admin) data = {'edit_data': 'test', 'editor_name': 'admin'} client.post(url_for('admin.update_editor_contents'), data=data) editor_contents = EditableHTML.objects(editor_name='admin').first() assert editor_contents.value == 'test'
def update_editor_contents(): """Update the contents of an editor.""" edit_data = request.form.get('edit_data') editor_name = request.form.get('editor_name') editor_contents = EditableHTML.objects(editor_name=editor_name).first() if editor_contents is None: editor_contents = EditableHTML(editor_name=editor_name) editor_contents.value = edit_data editor_contents.save() return 'OK', 200