Feature/notifications#331
Merged
yammesicka merged 27 commits intoPythonFreeCourse:developfrom Feb 24, 2021
Merged
Conversation
yammesicka
requested changes
Feb 24, 2021
app/database/schemas.py
Outdated
| email: str | ||
| full_name: str | ||
|
|
||
| # TODO: Add language_id field |
| message_id: int, | ||
| session: Session, | ||
| ) -> Union[Message, None]: | ||
| """Returns an invitation by an id. |
Member
There was a problem hiding this comment.
Leave blank line after the summary line.
The closing """ should be in their own line.
See PEP 257 for further details.
app/internal/notification.py
Outdated
| MessageStatusEnum.UNREAD, | ||
| ] | ||
|
|
||
| ARCHIVED = [ |
Member
There was a problem hiding this comment.
You check if things are in ARCHIVED/UNREAD_STATUS- prefer{to create aset`
app/internal/notification.py
Outdated
| func: Union[_is_unread, _is_archived], | ||
| ) -> List[NOTIFICATION_TYPE]: | ||
| """Filters notifications by "func".""" | ||
| return list(filter(func, get_all_notifications(session, user_id))) |
Member
There was a problem hiding this comment.
yield from instead list to imitate the behavior of real filter
app/internal/notification.py
Outdated
| def filter_notifications( | ||
| session: Session, | ||
| user_id: int, | ||
| func: Union[_is_unread, _is_archived], |
Member
There was a problem hiding this comment.
_is_unread and is_archived are not a type. Use Callable. See PEP 484 or mypy documentations for more details.
Prefer validating your code using mypy.
app/routers/notification.py
Outdated
Comment on lines
7
to
13
| get_invitation_by_id, | ||
| get_unread_notifications, | ||
| get_all_messages, | ||
| get_message_by_id, | ||
| get_archived_notifications, | ||
| raise_wrong_id_error, | ||
| is_owner, |
app/routers/notification.py
Outdated
| @@ -0,0 +1,188 @@ | |||
| from fastapi import APIRouter, Depends, Request, Form | |||
app/routers/notification.py
Outdated
| from sqlalchemy.orm import Session | ||
|
|
||
| from app.database.models import MessageStatusEnum | ||
| from app.dependencies import templates, get_db |
yammesicka
approved these changes
Feb 24, 2021
| @@ -1,30 +1,37 @@ | |||
| from typing import Generator, Iterator | |||
| from typing import Generator, Iterator, Dict | |||
Comment on lines
3
to
5
| import pytest | ||
| from fastapi.testclient import TestClient | ||
| from sqlalchemy.orm import Session |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Notification page:
The notification page binds all the messages and the invitations the user received.
to create a new message use
from app.routers.notification import create_message.* bonus:
create_messagecan get an extra parameter (link), that turns the message into a link.Possible useses: