Commit 3d1c08f6 authored by MP's avatar MP

implement board deletion and fix typo in posts

parent c2ecac81
......@@ -43,6 +43,15 @@ def posts(id, page=1, size=10):
data = Post.query.filter_by(board_id=id).order_by(Post.created.desc()).paginate(page, size, False)
return parse_page(data)
def delete(id, user=1):
board = Board.query.get(id)
if not board or board.author_id is not user:
raise BoardNotFound(id)
db.session.delete(board)
db.session.commit()
def show_all(page=1, size=10):
data = Board.query.order_by(Board.created.desc()).paginate(page, size, False)
......
......@@ -15,7 +15,7 @@ def get(id):
def delete(id, user=1):
post = Post.query.get(id)
if not Post or post.author_id is not user:
if not post or post.author_id is not user:
raise PostNotFound(id)
db.session.delete(post)
......
......@@ -166,6 +166,20 @@ paths:
422:
description: 'Unprocessable Entity'
delete:
description: 'Delete a board with the selected ID'
operationId: boards.delete
tags:
- Boards
parameters:
- $ref: '#/components/parameters/id'
responses:
204:
description: "No Content"
/boards:
get:
description: 'Get a list of boards'
......@@ -350,6 +364,3 @@ components:
application/json:
schema:
$ref: '#/components/schemas/Post'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment