Skip to content

Commit

Permalink
Сделал все откомменченное
Browse files Browse the repository at this point in the history
Осталось только разобраться с базой данных и тестами
  • Loading branch information
BombinBM committed Dec 12, 2024
1 parent bc7a101 commit 76d631d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions print_service/routes/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def validate_pages(cls, value: str):


class SendInput(BaseModel):
surname: str = Field(
surname: str | None = Field(
default=None,
description='Фамилия',
example='Иванов',
)
Expand Down Expand Up @@ -111,7 +112,7 @@ class ReceiveOutput(BaseModel):
)
async def send(
inp: SendInput,
_=Depends(UnionAuth(scopes=["print.file.send"]), allow_none=True),
user_auth=Depends(UnionAuth(scopes=["print.file.send"])),
settings: Settings = Depends(get_settings),
):
"""Получить пин код для загрузки и скачивания файла.
Expand All @@ -125,7 +126,7 @@ async def send(
if not settings.ALLOW_STUDENT_NUMBER:
user = user.filter(UnionMember.union_number != None)

if inp.number is not None:
if inp.number is not None and inp.surname is not None:
user = user.filter(
or_(
func.upper(UnionMember.student_number) == inp.number.upper(),
Expand All @@ -134,10 +135,10 @@ async def send(
func.upper(UnionMember.surname) == inp.surname.upper(),
).one_or_none()
else:
if not "print.file.send" in [scope["name"] for scope in user.get('session_scopes')]:
if not "print.file.send" in [scope["name"] for scope in user_auth.get('session_scopes')]:
raise NotInUnion()

if not user:
if user is None:
raise NotInUnion()
try:
pin = generate_pin(db.session)
Expand Down
2 changes: 1 addition & 1 deletion print_service/routes/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class UpdateUserList(BaseModel):
)
async def check_union_member(
surname: constr(strip_whitespace=True, to_upper=True, min_length=1),
number: Optional[str] = constr(strip_whitespace=True, to_upper=True, min_length=1),
number: constr(strip_whitespace=True, to_upper=True, min_length=1),
v: Optional[str] = __version__,
):
"""Проверяет наличие пользователя в списке."""
Expand Down

0 comments on commit 76d631d

Please sign in to comment.