Skip to content

Commit

Permalink
Merge branch 'development' into 97.2-adicionar-botao-de-notificacoes-…
Browse files Browse the repository at this point in the history
…no-layout-do-site-1
  • Loading branch information
dalacquar authored Jun 28, 2023
2 parents 895aff3 + 7e0309e commit 4967aed
Show file tree
Hide file tree
Showing 28 changed files with 1,391 additions and 267 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@
- [#13](https://github.com/KozielGPC/championship-platform/issues/13) - Entrar em um Campeonato

### Changed
- [#154](https://github.com/KozielGPC/championship-platform/issues/154) - Atualizado layout da pagina MyChampionships
- [#144](https://github.com/KozielGPC/championship-platform/issues/144) - Atualizado tabela de notifications com campos novos
- [#65](https://github.com/KozielGPC/championship-platform/issues/65) - Atualizado banco de dados para postgresql
- [#160](https://github.com/KozielGPC/championship-platform/issues/160) - Atualizando tela de times, lista de jogadores sendo atualizada ao excluir jogador

### Fixed
- [#126](https://github.com/KozielGPC/championship-platform/issues/127) - Resolvida validação de inserção de um time em um campeonato cheio
- [#84](https://github.com/KozielGPC/championship-platform/issues/84) - Resolvida validação do formulário de campeonato no frontend

### Added
- [#99](https://github.com/KozielGPC/championship-platform/issues/99) - Adicionando botão para iniciar campeonato
- [#91](https://github.com/KozielGPC/championship-platform/issues/51) - Adicionando botão de recriar matchmaking
- [#152](https://github.com/KozielGPC/championship-platform/issues/152) - Adicionado mensagem corretas nos responses
- [#100](https://github.com/KozielGPC/championship-platform/issues/100) - Adicionando geração de chaveamento e funcionamento do campeonato
- [#148](https://github.com/KozielGPC/championship-platform/issues/148) - Adicionado o admin de um time como player na criação do time
- [#145](https://github.com/KozielGPC/championship-platform/issues/145) - Adicionado atributo de round para campeonatos
- [#103](https://github.com/KozielGPC/championship-platform/issues/103) - Adicionado CRUD de partidas
Expand All @@ -32,6 +38,7 @@
- [#56](https://github.com/KozielGPC/championship-platform/issues/56) - Adicionando pagina de dados pessoais
- [#108](https://github.com/KozielGPC/championship-platform/issues/108) - Adicionado rota para atualizar um Campeonato
- [#107](https://github.com/KozielGPC/championship-platform/issues/107) - Adicionado rota para atualizar um Usuário
- [#59](https://github.com/KozielGPC/championship-platform/issues/59) - Adicionado Tela de Visualização de Campeonato
- [#106](https://github.com/KozielGPC/championship-platform/issues/106) - Adicionado rota para cadastrar Time em um Campeonato
- [#96](https://github.com/KozielGPC/championship-platform/issues/96) - Adicionado conexão com Socket
- [#106](https://github.com/KozielGPC/championship-platform/issues/106) - Adicionado rota de update para Teams e validações extras na criação de Teams
Expand Down
1 change: 1 addition & 0 deletions backend/api/routers/championships_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ async def getMatches(id: int, skip: int = 0, limit: int = 100):
matches = (
session.query(Match)
.filter(Match.championship_id == id)
.order_by(Match.bracket)
.offset(skip)
.limit(limit)
.all()
Expand Down
23 changes: 13 additions & 10 deletions backend/api/routers/matches_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ async def create(data: MatchInput, token: Annotated[str, Depends(oauth2_scheme)]
time1 = session.query(Team).filter(Team.id == data.team_1_id).first()
if time1 == None:
raise HTTPException(status_code=404, detail="Team 1 not found")
time2 = session.query(Team).filter(Team.id == data.team_2_id).first()
if time2 == None:
raise HTTPException(status_code=404, detail="Team 2 not found")

if data.team_2_id != None:
time2 = session.query(Team).filter(Team.id == data.team_2_id).first()
if time2 == None:
raise HTTPException(status_code=404, detail="Team 2 not found")
championship = session.query(Championship).filter(Championship.id == data.championship_id).first()
if championship == None:
raise HTTPException(status_code=404, detail="Championship not found")
Expand Down Expand Up @@ -159,13 +161,14 @@ async def update(id: int, update_request: MatchUpdateRequest, token: Annotated[s
if match is None:
raise HTTPException(status_code=404, detail="Match not found")
# winner round result
venc = (
session.query(Team)
.filter(Match.team_1_id == update_request.winner_team_id and Match.team_2_id == update_request.winner_team_id)
.first()
)
if venc is None:
raise HTTPException(status_code=404, detail="Team not found")
# venc = (
# session.query(Team)
# .filter(Match.team_1_id == update_request.winner_team_id and Match.team_2_id == update_request.winner_team_id)
# .first()
# )

# if venc is None:
# raise HTTPException(status_code=404, detail="Team not found")

if update_request.result == None:
raise HTTPException(status_code=400, detail="Result cannot be None")
Expand Down
22 changes: 13 additions & 9 deletions backend/api/schemas/matches.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

T = TypeVar("T")


class MatchSchema(BaseModel):
id: Optional[int] = None
championship_id: Optional[int] = Field(default=None, foreign_hey="championships.id")
Expand All @@ -13,25 +14,28 @@ class MatchSchema(BaseModel):
bracket: Optional[int] = None
round: Optional[int] = None
result: Optional[str] = None

class Config:
orm_mode = True


class MatchInput(MatchSchema):
championship_id: int
championship_id: int
team_1_id: int
team_2_id: int
bracket: int
round: int
team_2_id: Optional[int]
bracket: int
round: int

@validator("championship_id", "team_1_id", "team_2_id", "bracket", "round")
def check_positive_numbers(cls, v):
assert v >= 0, "Negative numbers are not allowed."
if v != None:
assert v >= 0, "Negative numbers are not allowed."
return v

class Config:
orm_mode = True


class MatchUpdateRequest(BaseModel):
winner_team_id: Optional[int] = Field(default=None, foreign_key="teams.id")
result: Optional[str] = None
Expand All @@ -45,13 +49,13 @@ def check_empty_fields(cls, v):
def check_spaced_fields(cls, v):
assert v.strip(), "Empty strings are not allowed."
return v



class Config:
orm_mode = True


class Response(GenericModel, Generic[T]):
code: str
status: str
message: str
result: Optional[T]
result: Optional[T]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""set team 2 id as nullable in matches table
Revision ID: 50762aa2fb9c
Revises: a4ec6fd4cb0b
Create Date: 2023-06-25 12:42:58.676638
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "50762aa2fb9c"
down_revision = "a4ec6fd4cb0b"
branch_labels = None
depends_on = None


def upgrade():
op.alter_column("matches", "team_2_id", existing_type=sa.Integer(), nullable=True)


def downgrade():
op.alter_column("matches", "team_2_id", existing_type=sa.Integer(), nullable=False)
Loading

0 comments on commit 4967aed

Please sign in to comment.