Esempio n. 1
0
 def delete(self, entry_id):
     logging.info("test")
     entry = EntryModel.get_by_id(int(entry_id))
     if entry is None:
         return {'status' : 404, 'message' : 'entry not found'}, 404
     entry.delete()
     return '', 204
Esempio n. 2
0
def edit_entry(post_id):
    post = EntryModel.get_by_id(post_id)

    if not post:
        return render_template('404.html'), 404
    form = EntryForm()
    if form.validate_on_submit():
        post.title = form.title.data
        post.text = markdown(form.text.data)
        post.slug = make_slug(post.title)
        try:
            post.put()
        except CapabilityDisabledError:
            flash(u'Read-only mode.')
    return redirect(url_for('projects'))
Esempio n. 3
0
    def put(self, entry_id):
        parser = reqparse.RequestParser()
        parser.add_argument('title')
        parser.add_argument('description')

        args = parser.parse_args()
        entry = EntryModel.get_by_id(int(entry_id))
        if entry is None:
            return {'status' : 404, 'message' : 'entry not found'}, 404

        entry.title = args['title']
        entry.description = args['description']

        try:
            entry.put()
            return Entry.format(entry), 201
        except CapabilityDisabledError:
            return {'status' : 500, 'message' : 'can\'t access database'}, 500
Esempio n. 4
0
def del_entry(post_id):
    EntryModel.get_by_id(post_id).key.delete()
    return redirect(url_for('projects'))
Esempio n. 5
0
    def get(self, entry_id):
        entry = EntryModel.get_by_id(int(entry_id))
        if entry is None:
            return {'status' : 404, 'message' : 'entry not found'}, 404

        return Entry.format(entry), 200