Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 835274e

Browse filesBrowse files
committed
updated
1 parent 13c85af commit 835274e
Copy full SHA for 835274e

File tree

3 files changed

+44
-43
lines changed
Filter options

3 files changed

+44
-43
lines changed

‎app/email.py

Copy file name to clipboardExpand all lines: app/email.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ async def sendMail(self, subject, template):
3232
MAIL_FROM=settings.EMAIL_FROM,
3333
MAIL_PORT=settings.EMAIL_PORT,
3434
MAIL_SERVER=settings.EMAIL_HOST,
35-
MAIL_TLS=True,
36-
MAIL_SSL=False,
35+
MAIL_STARTTLS=False,
36+
MAIL_SSL_TLS=False,
3737
USE_CREDENTIALS=True,
3838
VALIDATE_CERTS=True
3939
)

‎app/routers/post.py

Copy file name to clipboardExpand all lines: app/routers/post.py
+10-9Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from datetime import datetime
21
import uuid
32
from .. import schemas, models
43
from sqlalchemy.orm import Session
@@ -31,20 +30,18 @@ def create_post(post: schemas.CreatePostSchema, db: Session = Depends(get_db), o
3130
@router.put('/{id}', response_model=schemas.PostResponse)
3231
def update_post(id: str, post: schemas.UpdatePostSchema, db: Session = Depends(get_db), user_id: str = Depends(require_user)):
3332
post_query = db.query(models.Post).filter(models.Post.id == id)
34-
db_post = post_query.first()
33+
updated_post = post_query.first()
3534

36-
if not db_post:
35+
if not updated_post:
3736
raise HTTPException(status_code=status.HTTP_200_OK,
3837
detail=f'No post with this id: {id} found')
39-
if db_post.user_id != uuid.UUID(user_id):
38+
if updated_post.user_id != uuid.UUID(user_id):
4039
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN,
4140
detail='You are not allowed to perform this action')
42-
post.user_id = db_post.user_id
43-
post.created_at = db_post.created_at
44-
post.updated_at = datetime.utcnow()
45-
post_query.update(post.dict(exclude_none=True), synchronize_session=False)
41+
post.user_id = user_id
42+
post_query.update(post.dict(exclude_unset=True), synchronize_session=False)
4643
db.commit()
47-
return db_post
44+
return updated_post
4845

4946

5047
@router.get('/{id}', response_model=schemas.PostResponse)
@@ -63,6 +60,10 @@ def delete_post(id: str, db: Session = Depends(get_db), user_id: str = Depends(r
6360
if not post:
6461
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND,
6562
detail=f'No post with this id: {id} found')
63+
64+
if str(post.user_id) != user_id:
65+
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN,
66+
detail='You are not allowed to perform this action')
6667
post_query.delete(synchronize_session=False)
6768
db.commit()
6869
return Response(status_code=status.HTTP_204_NO_CONTENT)

‎requirements.txt

Copy file name to clipboard
+32-32Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
alembic==1.8.0
2-
anyio==3.6.1
3-
asgiref==3.5.2
4-
autopep8==1.6.0
5-
bcrypt==3.2.2
6-
certifi==2022.6.15
1+
aiosmtplib==1.1.7
2+
alembic==1.9.0
3+
anyio==3.6.2
4+
autopep8==2.0.1
5+
bcrypt==4.0.1
6+
blinker==1.5
7+
certifi==2022.12.7
78
cffi==1.15.1
8-
charset-normalizer==2.1.0
99
click==8.1.3
10-
colorama==0.4.5
10+
colorama==0.4.6
1111
cryptography==3.4.8
1212
dnspython==2.2.1
13-
email-validator==1.2.1
14-
fastapi==0.78.0
13+
email-validator==1.3.0
14+
fastapi==0.88.0
1515
fastapi-jwt-auth==0.5.0
16-
greenlet==1.1.2
17-
h11==0.13.0
18-
httptools==0.4.0
19-
idna==3.3
16+
fastapi-mail==1.2.2
17+
greenlet==2.0.1
18+
h11==0.14.0
19+
httpcore==0.16.3
20+
httptools==0.5.0
21+
httpx==0.23.1
22+
idna==3.4
2023
itsdangerous==2.1.2
2124
Jinja2==3.1.2
22-
Mako==1.2.1
25+
Mako==1.2.4
2326
MarkupSafe==2.1.1
24-
orjson==3.7.6
27+
orjson==3.8.3
2528
passlib==1.7.4
26-
psycopg2==2.9.3
27-
pycodestyle==2.8.0
29+
psycopg2==2.9.5
30+
pycodestyle==2.10.0
2831
pycparser==2.21
29-
pydantic==1.9.1
32+
pydantic==1.10.2
3033
PyJWT==1.7.1
31-
python-dotenv==0.20.0
34+
python-dotenv==0.21.0
3235
python-multipart==0.0.5
3336
PyYAML==6.0
34-
requests==2.28.1
37+
rfc3986==1.5.0
3538
six==1.16.0
36-
sniffio==1.2.0
37-
SQLAlchemy==1.4.39
38-
starlette==0.19.1
39-
toml==0.10.2
40-
typing_extensions==4.3.0
41-
tzdata==2022.1
42-
ujson==5.4.0
43-
urllib3==1.26.9
44-
uvicorn==0.17.6
45-
watchgod==0.8.2
46-
websockets==10.3
39+
sniffio==1.3.0
40+
SQLAlchemy==1.4.45
41+
starlette==0.21.0
42+
typing_extensions==4.4.0
43+
ujson==5.6.0
44+
uvicorn==0.20.0
45+
watchfiles==0.18.1
46+
websockets==10.4

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.