def test_unpublish(self): _entry = self.add_draft() entry = Entry.update_status(_entry['id'], 'publish') entry = Entry.update_status(_entry['id'], 'draft') self.assertTrue(entry) self.assertEqual(entry['status'], 'draft')
def publish_draft(id): status = request.form['status'] entry = Entry.update_status(id, status) slug = entry['slug'] draft_file = os.path.join('./summer/_draft/', slug + '.md') post_file = os.path.join('./summer/post/', slug + '.md') if status == 'publish': os.rename(draft_file, post_file) elif status == 'draft': os.rename(post_file, draft_file) return jsonify(r=True)