Пример #1
0
    def link_delete(self):
        id = request.form.get("id")
        link = Link.query.get(id)

        if not link:
            return {'status': 'not_found'}, 404

        if not current_user.is_owner_of(link):
            return {'status': 'unauthorized'}, 401

        # At this point we're ready to delete

        link.delete()
        return {'status': 'ok'}
Пример #2
0
    def link_put(self, id):
        link = Link.query.get(id)

        if not link:
            return {'status': 'not_found'}, 404

        if not current_user.is_owner_of(link):
            return {'status': 'unauthorized'}, 401
        
        
        link.title = request.form.get("title")
        link.link = request.form.get("url")
        link.tags = request.form.getlist("tags[]")

        session.commit()

        return {'status': 'ok'}