mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-22 23:17:09 +00:00
Merge branch 'master' of gitlab.prodcontest.ru:team-15/project
This commit is contained in:
@@ -166,7 +166,6 @@ http {
|
||||
}
|
||||
|
||||
location /admin/grafana/ {
|
||||
rewrite ^/admin/grafana/(.*) /$1 break;
|
||||
proxy_pass http://grafana:3000/;
|
||||
|
||||
proxy_set_header Host $http_host;
|
||||
|
||||
@@ -4,6 +4,7 @@ from typing import Any
|
||||
import jwt
|
||||
from django.conf import settings
|
||||
from django.http import HttpRequest
|
||||
from ninja.errors import AuthenticationError
|
||||
from ninja.security import HttpBearer
|
||||
|
||||
from apps.user.models import User
|
||||
@@ -11,9 +12,12 @@ from apps.user.models import User
|
||||
|
||||
class BearerAuth(HttpBearer):
|
||||
def authenticate(self, request: HttpRequest, token: str) -> Any | None:
|
||||
data = jwt.decode(token, settings.SECRET_KEY, algorithms=["HS256"])
|
||||
if data["exp"] < datetime.datetime.now().timestamp():
|
||||
return None
|
||||
try:
|
||||
data = jwt.decode(token, settings.SECRET_KEY, algorithms=["HS256"])
|
||||
if data["exp"] < datetime.datetime.now().timestamp():
|
||||
return None
|
||||
except Exception:
|
||||
raise AuthenticationError
|
||||
|
||||
user = User.objects.get(id=data["id"])
|
||||
return user
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
from typing import Literal
|
||||
from uuid import UUID
|
||||
|
||||
from django.http import HttpRequest
|
||||
from ninja import ModelSchema, Schema
|
||||
|
||||
from apps.review.models import Reviewer, Review
|
||||
from apps.review.models import Review, Reviewer
|
||||
from apps.task.models import CompetitionTaskSubmission
|
||||
|
||||
|
||||
@@ -34,4 +33,6 @@ class SubmissionsOut(Schema):
|
||||
|
||||
@staticmethod
|
||||
def resolve_submissions(self, context) -> list[SubmissionOut]:
|
||||
return list(Review.objects.filter(reviewer=context.get("request").auth))
|
||||
return list(
|
||||
Review.objects.filter(reviewer=context.get("request").auth)
|
||||
)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import logging
|
||||
from http import HTTPStatus as status
|
||||
from uuid import UUID
|
||||
|
||||
@@ -8,7 +7,6 @@ from ninja import Router
|
||||
|
||||
from api.v1 import schemas as global_schemas
|
||||
from api.v1.review import schemas
|
||||
from api.v1.task.schemas import TaskSubmissionIn
|
||||
from apps.task.models import CompetitionTaskSubmission
|
||||
|
||||
router = Router(tags=["review"])
|
||||
@@ -19,9 +17,11 @@ router = Router(tags=["review"])
|
||||
response={
|
||||
status.OK: schemas.SubmissionsOut,
|
||||
},
|
||||
description="Список отправок, на проверку которых назначен ревьюер"
|
||||
description="Список отправок, на проверку которых назначен ревьюер",
|
||||
)
|
||||
def get_submissions(request: HttpRequest, token: str) -> tuple[status, schemas.SubmissionsOut]:
|
||||
def get_submissions(
|
||||
request: HttpRequest, token: str
|
||||
) -> tuple[status, schemas.SubmissionsOut]:
|
||||
return status.OK, schemas.SubmissionsOut()
|
||||
|
||||
|
||||
@@ -36,12 +36,15 @@ def get_submissions(request: HttpRequest, token: str) -> tuple[status, schemas.S
|
||||
def get_reviewer_profile(request: HttpRequest, token: str):
|
||||
return status.OK, request.auth
|
||||
|
||||
|
||||
@router.get(
|
||||
"{token}/submissions/{submition_id}",
|
||||
response={
|
||||
status.OK: schemas.SubmissionOut,
|
||||
},
|
||||
)
|
||||
def get_submission(request: HttpRequest, token: str, submition_id: UUID) -> tuple[status, schemas.SubmissionsOut]:
|
||||
def get_submission(
|
||||
request: HttpRequest, token: str, submition_id: UUID
|
||||
) -> tuple[status, schemas.SubmissionsOut]:
|
||||
submission = get_object_or_404(CompetitionTaskSubmission, id=submition_id)
|
||||
return status.OK, submission
|
||||
|
||||
@@ -13,9 +13,9 @@ from api.v1.task.schemas import (
|
||||
)
|
||||
from apps.competition.models import State
|
||||
from apps.task.models import (
|
||||
CompetitionTaskSubmission,
|
||||
Competition,
|
||||
CompetitionTask,
|
||||
CompetitionTaskSubmission,
|
||||
)
|
||||
|
||||
router = Router(tags=["competition"])
|
||||
|
||||
@@ -6,7 +6,7 @@ from ninja import Router
|
||||
from ninja.errors import AuthenticationError
|
||||
|
||||
from api.v1.auth import BearerAuth
|
||||
from api.v1.schemas import BadRequestError, ForbiddenError, NotFoundError
|
||||
from api.v1.schemas import BadRequestError, ForbiddenError, NotFoundError, ConflictError
|
||||
from api.v1.user.schemas import (
|
||||
LoginSchema,
|
||||
RegisterSchema,
|
||||
@@ -23,6 +23,7 @@ router = Router(tags=["user"])
|
||||
response={
|
||||
status.CREATED: TokenSchema,
|
||||
status.BAD_REQUEST: BadRequestError,
|
||||
status.CONFLICT: ConflictError,
|
||||
},
|
||||
auth=None,
|
||||
)
|
||||
@@ -45,7 +46,6 @@ def sign_up(request, data: RegisterSchema):
|
||||
)
|
||||
def sign_in(request, data: LoginSchema):
|
||||
user = User.objects.filter(email=data.email).first()
|
||||
print(check_password(data.password, user.password))
|
||||
if not user:
|
||||
raise AuthenticationError
|
||||
if not check_password(data.password, user.password):
|
||||
|
||||
@@ -6,7 +6,17 @@ from apps.task.admin import CompetitionTaskInline
|
||||
|
||||
@admin.register(Competition)
|
||||
class CompetitionAdmin(admin.ModelAdmin):
|
||||
list_display = ("title", "end_date", "type",)
|
||||
search_fields = ("title", "description",)
|
||||
list_filter = ("type", "participation_type",)
|
||||
list_display = (
|
||||
"title",
|
||||
"end_date",
|
||||
"type",
|
||||
)
|
||||
search_fields = (
|
||||
"title",
|
||||
"description",
|
||||
)
|
||||
list_filter = (
|
||||
"type",
|
||||
"participation_type",
|
||||
)
|
||||
inlines = [CompetitionTaskInline]
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from datetime import datetime
|
||||
|
||||
from django.db import models
|
||||
from tinymce.models import HTMLField
|
||||
|
||||
from apps.core.models import BaseModel
|
||||
from apps.user.models import User
|
||||
@@ -49,8 +48,6 @@ class Competition(BaseModel):
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
|
||||
|
||||
class Meta:
|
||||
verbose_name = "соревнование"
|
||||
verbose_name_plural = "соревнования"
|
||||
|
||||
@@ -8,7 +8,7 @@ from django.core.management.base import BaseCommand
|
||||
from django.utils import timezone
|
||||
|
||||
from apps.competition.models import Competition, State
|
||||
from apps.task.models import CompetitionTaskSubmission, CompetitionTask
|
||||
from apps.task.models import CompetitionTask, CompetitionTaskSubmission
|
||||
from apps.user.models import User, UserRole
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ class Reviewer(BaseModel):
|
||||
|
||||
token = models.CharField(max_length=100)
|
||||
|
||||
|
||||
class Review(BaseModel):
|
||||
class ReviewStatusChoices(models.TextChoices):
|
||||
NOT_CHECKED = "not_checked"
|
||||
@@ -17,6 +18,10 @@ class Review(BaseModel):
|
||||
CHECKED = "checked"
|
||||
|
||||
reviewer = models.ForeignKey(Reviewer, on_delete=models.CASCADE)
|
||||
submission = models.ForeignKey(CompetitionTaskSubmission, on_delete=models.CASCADE)
|
||||
submission = models.ForeignKey(
|
||||
CompetitionTaskSubmission, on_delete=models.CASCADE
|
||||
)
|
||||
|
||||
state = models.CharField(choices=ReviewStatusChoices.choices, max_length=11)
|
||||
state = models.CharField(
|
||||
choices=ReviewStatusChoices.choices, max_length=11
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.hashers import check_password, make_password
|
||||
from django.db import models
|
||||
|
||||
from apps.core.models import BaseModel
|
||||
|
||||
|
||||
@@ -463,7 +463,7 @@ TINYMCE_DEFAULT_CONFIG = {
|
||||
"alignright alignjustify | bullist numlist outdent indent | "
|
||||
"removeformat | help",
|
||||
"skin": "oxide-dark",
|
||||
"content_css": "dark"
|
||||
"content_css": "dark",
|
||||
}
|
||||
|
||||
# GUID
|
||||
|
||||
@@ -13,7 +13,7 @@ admin.site.index_title = "DataRush"
|
||||
|
||||
urlpatterns = [
|
||||
# tinymce
|
||||
path('tinymce/', include('tinymce.urls')),
|
||||
path("tinymce/", include("tinymce.urls")),
|
||||
# Admin urls
|
||||
path("admin/", admin.site.urls),
|
||||
# API urls
|
||||
|
||||
Reference in New Issue
Block a user