Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal setup for development #52

Merged
merged 98 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
b1b7e97
feat: add create group method
Spotika Feb 6, 2024
863d90a
addede a refresh methods and cross origins
Spotika Feb 10, 2024
3276032
added group methods that connected with frontend
Spotika Feb 11, 2024
bbed78f
feat: added contest base model and database manager + create contest …
Spotika Feb 11, 2024
231ee5a
created new get contests in froup method
Spotika Feb 11, 2024
560afea
banana
Spotika Feb 12, 2024
33a1be3
feat: added task creation and base model
Spotika Feb 12, 2024
a05266d
feat: added task creation and base model
Spotika Feb 12, 2024
eaa13a8
fixed merge
Spotika Feb 12, 2024
f249bd5
feat: added more tasks methods
Spotika Feb 12, 2024
b4ae14a
feat: bananas
Spotika Feb 13, 2024
a12de07
refactor: change task to problem
Spotika Feb 13, 2024
7a648fc
feat: added examples and submissions
Spotika Feb 13, 2024
8d821c1
added basic producer and time to submissions
Spotika Feb 14, 2024
5ecc413
fix: fix ./data files
Spotika Feb 14, 2024
840ecb9
chore: create working docker compose for run && test
Spotika Apr 28, 2024
8e09d83
chore: init configuration files for mypy and pytest
Spotika Apr 28, 2024
95b8b1d
chore: the testing and running functional has been removed from manag…
Spotika Apr 28, 2024
890128c
feat: change project configuration structure
Spotika Apr 29, 2024
92cf5db
chore: we can work with mongo in docker
Spotika Apr 29, 2024
87d4801
fix: fix logs
Spotika Apr 29, 2024
0f1f8d4
refactor: delete useless code && comments
Spotika Apr 30, 2024
b7574dc
chore: create example docker-compose with ex. conf
Spotika Apr 30, 2024
6a44c34
chore: hide docker compose and create docker-compose example
Spotika Apr 30, 2024
debb50b
chore: delete .env config
Spotika Apr 30, 2024
ac3ed23
fix: fix init config
Spotika Apr 30, 2024
00c6cf6
fix: add new default values to ex config
Spotika Apr 30, 2024
1b6069e
Merge pull request #49 from elansteam/total-fix-config
difhel Apr 30, 2024
cfe67cd
Total fix (#51)
Spotika Aug 6, 2024
b11bf57
fix(CI): merge pyright and pylint
Spotika Aug 6, 2024
00a71fa
refactor(CI): delete comment
Spotika Aug 6, 2024
1783812
refactor: remove unused line in gitignore
Spotika Aug 6, 2024
0af53a6
fix: fix poetry --no-root
Spotika Aug 6, 2024
8060ac1
refactor: remove garbage credentials
Spotika Aug 6, 2024
ba6379a
refactor: remove container names
Spotika Aug 6, 2024
1be502c
refactor: remove Dockerfile from build docker compose
Spotika Aug 6, 2024
71ab6ed
chore: change python version to 3.12
Spotika Aug 6, 2024
7f1aca0
refactor: fix pylint config
Spotika Aug 6, 2024
8fed1aa
refactor: calculations instead of constants
Spotika Aug 6, 2024
8092821
refactor: fix env variable name
Spotika Aug 6, 2024
49af379
refactor: fix import style && remove comments
Spotika Aug 6, 2024
9854317
style: fix pyproject.toml
Spotika Aug 6, 2024
8a206ba
refactor: remove app_title and change default value to cors in config
Spotika Aug 6, 2024
a9f7d3f
Merge branch 'master' into total-fix
Spotika Aug 6, 2024
7d3f92e
Merge branch 'master' into total-fix
Spotika Aug 6, 2024
6894c5f
ci: fix pylint install
Spotika Aug 6, 2024
39ba798
refactor: remove annotations from regular type hints
Spotika Aug 6, 2024
49949b1
refactor(config): fix error logging
Spotika Aug 6, 2024
365e519
chore: added jobs pylint param
Spotika Aug 6, 2024
32562e0
refactor: remove uneccessary networks
Spotika Aug 6, 2024
a227900
refactor: refactored commends and add some style
Spotika Aug 7, 2024
fc39456
refactor: fix comments
Spotika Aug 7, 2024
996d6b0
chore: resolve conflicts with master
Spotika Aug 7, 2024
d44a931
ci: change pull request rules
Spotika Aug 7, 2024
7fece14
chore: add __init__.py
Spotika Aug 7, 2024
b428760
refactor: methods
Spotika Aug 7, 2024
ab4a822
refactor: sum instead of +
Spotika Aug 7, 2024
ab7cd34
replace + by sum
Spotika Aug 7, 2024
2582836
feat: remove domain field from signup
Spotika Aug 7, 2024
eaf5b43
fix: fix pylint generator error
Spotika Aug 7, 2024
0ff165b
ci: try to fix docker compose
Spotika Aug 7, 2024
2e9b42a
ci: fix docker compose
Spotika Aug 7, 2024
d297c9f
build: change volumes destination
Spotika Aug 7, 2024
6f66f71
refactor: remove superuser
Spotika Aug 7, 2024
f8032e3
fix: fix pylint
Spotika Aug 7, 2024
f4fb241
chore: remove docker-compose version
Spotika Aug 8, 2024
f9b90ee
refactor: move load function in config model
Spotika Aug 8, 2024
091b21c
refactor: refactor auth module
Spotika Aug 8, 2024
08db157
refactor: change resolve entity signature
Spotika Aug 8, 2024
ea3b813
style
Spotika Aug 8, 2024
b98cf31
refactor: remove uneccessary validation in models
Spotika Aug 8, 2024
1268a47
chore: improve pylint config
Spotika Aug 8, 2024
fb96296
ci: remove uneccessary build flag
Spotika Aug 8, 2024
0e8e2b0
chore: refactor according the last meeting
Spotika Aug 9, 2024
e95a9d7
style: fix pylint
Spotika Aug 9, 2024
93605b4
chore: change allowed methods
Spotika Aug 9, 2024
a8b0a0f
style
Spotika Aug 9, 2024
ae44041
feat: mongodb entrypoint
Spotika Aug 21, 2024
54b7a01
chore: moved .env password conf to compose
Spotika Aug 22, 2024
10c69d3
ci: improve configs
Spotika Aug 22, 2024
8ecdbde
ci: selfhosted runner test
Spotika Aug 22, 2024
21dae08
ci: remove sudo in commands
Spotika Aug 22, 2024
5f43aaa
ci: cleanup after docker use
Spotika Aug 22, 2024
04adf1f
ci: fix test logs on error
Spotika Aug 22, 2024
2fa45f2
ci: add docker cleanup
Spotika Aug 22, 2024
0fd9bd0
style
Spotika Aug 22, 2024
22ec6c9
refactor: remove unnecessary user info
Spotika Aug 22, 2024
74a68a0
refactor: remove unnecessary import
Spotika Aug 22, 2024
1a8e4fb
refactor(tests): remove superuser
Spotika Aug 22, 2024
655d4ff
refactor: resolve TODO
Spotika Aug 22, 2024
ddf6f4b
refactor
Spotika Aug 22, 2024
d9998fd
chore: fix mongodb credentials
Spotika Aug 22, 2024
4116be5
fix: fix test mongodb ports
Spotika Aug 22, 2024
ee81a6e
refactor
Spotika Aug 22, 2024
5b1464b
refactor
Spotika Aug 22, 2024
c2e38ab
style
Spotika Aug 22, 2024
f1cb1a2
refactor: change BaseModel source
Spotika Aug 22, 2024
c3267a3
style: replace by response
Spotika Aug 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_ROOT_PASSWORD=admin
ports:
- "42042:42042"
- "42042:27017"
volumes:
- ./mongo_entrypoint:/docker-entrypoint-initdb.d
api_test:
Expand Down
2 changes: 1 addition & 1 deletion src/db/methods/collections/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@


users.create_index([("email", 1)], unique=True, name="email")
domains.create_index([("target_id", 1)], unique=True, name="target_id")
# domains.create_index([("target_id", 1)], unique=True, name="target_id")
1 change: 1 addition & 0 deletions src/db/types/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class _UserBase(BaseModel):
domain: str | None = None
first_name: str
last_name: str | None = None
groups: list[int] = []
roles: list[str] = []
hashed_password: str
Expand Down
8 changes: 2 additions & 6 deletions src/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@


@router.post("/signup", response_model=SuccessfulResponse[RS.AuthSignup])
async def signup(
request: RQ.AuthSignup
):
async def signup(request: RQ.AuthSignup):
hashed_password = utils.auth.hash_password(request.password)

inserted_user_id = methods.users.insert_user_with_id(
Expand All @@ -34,9 +32,7 @@ async def signup(
return utils.auth.create_jwt_pair_by_user_id(inserted_user_id)

@router.post("/signin", response_model=SuccessfulResponse[RS.AuthSignin])
async def signin(
siginin_input: RQ.AuthSignin
):
async def signin(siginin_input: RQ.AuthSignin):
Spotika marked this conversation as resolved.
Show resolved Hide resolved
user: types.user.User | None = None
if siginin_input.id:
user = methods.users.get(siginin_input.id)
Expand Down
8 changes: 4 additions & 4 deletions src/utils/auth/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ def get_auth_header_credentials(

if len(credentials) != 2:
raise response.ErrorResponse(
code=response.ErrorCodes.INCORRECT_AUTH_HEADER_FOMAT,
http_status_code=http_status.HTTP_422_UNPROCESSABLE_ENTITY,
code=response.ErrorCodes.TOKEN_VALIDATION_FAILED,
http_status_code=http_status.HTTP_401_UNAUTHORIZED,
message=error_message
)

current_prefix, token = credentials[0], credentials[1]

if current_prefix != prefix:
raise response.ErrorResponse(
code=response.ErrorCodes.INCORRECT_AUTH_HEADER_FOMAT,
http_status_code=http_status.HTTP_422_UNPROCESSABLE_ENTITY,
code=response.ErrorCodes.TOKEN_VALIDATION_FAILED,
http_status_code=http_status.HTTP_401_UNAUTHORIZED,
message=error_message
)

Expand Down
6 changes: 2 additions & 4 deletions src/utils/response.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import Enum
from typing import Any, Generic, Literal, TypeVar
from typing import Any, Literal

from pydantic import BaseModel, model_validator, model_serializer

Expand Down Expand Up @@ -40,9 +40,7 @@ def __init__(
self.auto_message = auto_message


T = TypeVar("T", bound=BaseModel | None)

class SuccessfulResponse(BaseModel, Generic[T]):
class SuccessfulResponse[T: BaseModel | None](BaseModel):
Spotika marked this conversation as resolved.
Show resolved Hide resolved
@model_validator(mode="before")
@classmethod
def before_validation(cls, data) -> dict[str, Any]:
Expand Down
20 changes: 9 additions & 11 deletions tests/src/helpers/constants.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
const ErrorCodes = {
INTERNAL_SERVER_ERROR: 1,
UNPROCESSABLE_ENTITY: 2,
TOKEN_EXPIRED: 3,
TOKEN_VALIDATION_FAILED: 4,
ENTITY_NOT_FOUND: 5,
INCORRECT_AUTH_HEADER_FOMAT: 6,
ACCESS_DENIED: 7,
NAME_ALREADY_TAKEN: 8
export enum ErrorCodes {
INTERNAL_SERVER_ERROR = 1,
UNPROCESSABLE_ENTITY,
TOKEN_EXPIRED,
TOKEN_VALIDATION_FAILED,
ENTITY_NOT_FOUND,
INCORRECT_AUTH_HEADER_FOMAT,
ACCESS_DENIED,
NAME_ALREADY_TAKEN
}

export {ErrorCodes};