feat: posts have a default author of "anon"
This commit is contained in:
parent
95a16aaa47
commit
2b0ae5925e
@ -7,12 +7,14 @@ app = FastAPI()
|
|||||||
class Post:
|
class Post:
|
||||||
id: int
|
id: int
|
||||||
thread_id: int
|
thread_id: int
|
||||||
|
author: str
|
||||||
title: str
|
title: str
|
||||||
content: str
|
content: str
|
||||||
|
|
||||||
def __init__(self, id, thread_id, title, content):
|
def __init__(self, id, thread_id, author, title, content):
|
||||||
self.id = id
|
self.id = id
|
||||||
self.thread_id = thread_id
|
self.thread_id = thread_id
|
||||||
|
self.author = author
|
||||||
self.title = title
|
self.title = title
|
||||||
self.content = content
|
self.content = content
|
||||||
|
|
||||||
@ -24,11 +26,13 @@ class PostCreate(BaseModel):
|
|||||||
|
|
||||||
class Thread:
|
class Thread:
|
||||||
id: int
|
id: int
|
||||||
|
author: str
|
||||||
title: str
|
title: str
|
||||||
closed: bool
|
closed: bool
|
||||||
|
|
||||||
def __init__(self, id, title, closed=False):
|
def __init__(self, id, author, title, closed=False):
|
||||||
self.id = id
|
self.id = id
|
||||||
|
self.author = author
|
||||||
self.title = title
|
self.title = title
|
||||||
self.closed = closed
|
self.closed = closed
|
||||||
|
|
||||||
@ -45,12 +49,14 @@ async def get_threads():
|
|||||||
@app.post("/post")
|
@app.post("/post")
|
||||||
async def create_post(data: PostCreate):
|
async def create_post(data: PostCreate):
|
||||||
id = len(POSTS) + 1
|
id = len(POSTS) + 1
|
||||||
|
author = 'anon'
|
||||||
title = data.title
|
title = data.title
|
||||||
content = data.content
|
content = data.content
|
||||||
|
|
||||||
# Create thread
|
# Create thread
|
||||||
thread = Thread(
|
thread = Thread(
|
||||||
id=id,
|
id=id,
|
||||||
|
author=author,
|
||||||
title=title
|
title=title
|
||||||
)
|
)
|
||||||
THREADS.append(thread)
|
THREADS.append(thread)
|
||||||
@ -59,6 +65,7 @@ async def create_post(data: PostCreate):
|
|||||||
post = Post(
|
post = Post(
|
||||||
id=id,
|
id=id,
|
||||||
thread_id=id,
|
thread_id=id,
|
||||||
|
author=author,
|
||||||
title=title,
|
title=title,
|
||||||
content=content
|
content=content
|
||||||
)
|
)
|
||||||
@ -93,6 +100,7 @@ async def reply_to_post(thread_id: int, data: PostCreate):
|
|||||||
post = Post(
|
post = Post(
|
||||||
id=id,
|
id=id,
|
||||||
thread_id=parent.id,
|
thread_id=parent.id,
|
||||||
|
author='anon',
|
||||||
title=title,
|
title=title,
|
||||||
content=content
|
content=content
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user