mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-22 23:17:09 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+3
-1
@@ -2,4 +2,6 @@
|
|||||||
sidebar_position: 1
|
sidebar_position: 1
|
||||||
---
|
---
|
||||||
|
|
||||||
# Начала!
|
# Начало!
|
||||||
|
|
||||||
|
Выбирай интересующий раздел слева и просвещайся!
|
||||||
|
|||||||
+66
-62
@@ -1,77 +1,81 @@
|
|||||||
import {themes as prismThemes} from 'prism-react-renderer';
|
import { themes as prismThemes } from "prism-react-renderer";
|
||||||
import type {Config} from '@docusaurus/types';
|
import type { Config } from "@docusaurus/types";
|
||||||
import type * as Preset from '@docusaurus/preset-classic';
|
import type * as Preset from "@docusaurus/preset-classic";
|
||||||
|
|
||||||
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
|
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
|
||||||
|
|
||||||
const config: Config = {
|
const config: Config = {
|
||||||
title: 'DataRush',
|
title: "DataRush",
|
||||||
tagline: 'Изучите основы анализа данных здесь!',
|
tagline: "Изучите основы анализа данных здесь!",
|
||||||
favicon: 'https://prod-team-15-2pc0i3lc.final.prodcontest.ru/dr.svg',
|
favicon: "https://prod-team-15-2pc0i3lc.final.prodcontest.ru/dr.svg",
|
||||||
|
|
||||||
url: 'https://prod-team-15-2pc0i3lc.final.prodcontest.ru',
|
url: "https://prod-team-15-2pc0i3lc.final.prodcontest.ru",
|
||||||
baseUrl: '/docs/',
|
baseUrl: "/docs/",
|
||||||
|
|
||||||
organizationName: 'megazord',
|
organizationName: "megazord",
|
||||||
projectName: 'megazord',
|
projectName: "megazord",
|
||||||
|
|
||||||
onBrokenLinks: 'throw',
|
onBrokenLinks: "throw",
|
||||||
onBrokenMarkdownLinks: 'warn',
|
onBrokenMarkdownLinks: "warn",
|
||||||
|
|
||||||
i18n: {
|
i18n: {
|
||||||
defaultLocale: 'ru',
|
defaultLocale: "ru",
|
||||||
locales: ['ru'],
|
locales: ["ru"],
|
||||||
},
|
|
||||||
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
'classic',
|
|
||||||
{
|
|
||||||
docs: {},
|
|
||||||
theme: {
|
|
||||||
customCss: './src/css/custom.css',
|
|
||||||
},
|
|
||||||
} satisfies Preset.Options,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
|
|
||||||
themeConfig: {
|
|
||||||
image: 'https://prod-team-15-2pc0i3lc.final.prodcontest.ru/dr.svg',
|
|
||||||
navbar: {
|
|
||||||
title: 'DataRush',
|
|
||||||
logo: {
|
|
||||||
alt: 'DataRush',
|
|
||||||
src: 'https://prod-team-15-2pc0i3lc.final.prodcontest.ru/dr.svg',
|
|
||||||
},
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
type: 'docSidebar',
|
|
||||||
sidebarId: 'defaultSidebar',
|
|
||||||
position: 'left',
|
|
||||||
label: 'Документация',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
footer: {
|
|
||||||
style: 'dark',
|
presets: [
|
||||||
links: [
|
[
|
||||||
{
|
"classic",
|
||||||
title: 'Документация',
|
|
||||||
items: [
|
|
||||||
{
|
{
|
||||||
label: 'Начало',
|
docs: {
|
||||||
to: '/docs/intro',
|
routeBasePath: "/",
|
||||||
|
},
|
||||||
|
theme: {
|
||||||
|
customCss: "./src/css/custom.css",
|
||||||
|
},
|
||||||
|
} satisfies Preset.Options,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
themeConfig: {
|
||||||
|
image: "https://prod-team-15-2pc0i3lc.final.prodcontest.ru/dr.svg",
|
||||||
|
navbar: {
|
||||||
|
title: "DataRush",
|
||||||
|
logo: {
|
||||||
|
alt: "DataRush",
|
||||||
|
src: "https://prod-team-15-2pc0i3lc.final.prodcontest.ru/dr.svg",
|
||||||
},
|
},
|
||||||
],
|
items: [
|
||||||
|
{
|
||||||
|
type: "docSidebar",
|
||||||
|
sidebarId: "defaultSidebar",
|
||||||
|
position: "left",
|
||||||
|
label: "Документация",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
footer: {
|
||||||
copyright: `Создано для Megazord ♥`,
|
style: "dark",
|
||||||
},
|
links: [
|
||||||
prism: {
|
{
|
||||||
theme: prismThemes.github,
|
title: "Документация",
|
||||||
darkTheme: prismThemes.dracula,
|
items: [
|
||||||
},
|
{
|
||||||
} satisfies Preset.ThemeConfig,
|
label: "Начало",
|
||||||
|
to: "/intro",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
copyright: `Создано для Megazord ♥`,
|
||||||
|
},
|
||||||
|
prism: {
|
||||||
|
theme: prismThemes.github,
|
||||||
|
darkTheme: prismThemes.dracula,
|
||||||
|
},
|
||||||
|
} satisfies Preset.ThemeConfig,
|
||||||
|
|
||||||
|
staticDirectories: ["static"],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ class BearerAuth(HttpBearer):
|
|||||||
except Exception:
|
except Exception:
|
||||||
raise AuthenticationError
|
raise AuthenticationError
|
||||||
|
|
||||||
user = User.objects.get(id=data["id"])
|
try:
|
||||||
|
user = User.objects.get(id=data["id"])
|
||||||
|
except User.DoesNotExist:
|
||||||
|
raise AuthenticationError
|
||||||
return user
|
return user
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
from datetime import timedelta, datetime, tzinfo
|
||||||
|
|
||||||
|
from dateutil.parser import isoparse
|
||||||
|
import pytz
|
||||||
from django.contrib.auth.hashers import make_password
|
from django.contrib.auth.hashers import make_password
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
@@ -101,3 +104,158 @@ class CompetitionEndpointTests(TestCase):
|
|||||||
HTTP_AUTHORIZATION=header,
|
HTTP_AUTHORIZATION=header,
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, expected_status)
|
self.assertEqual(response.status_code, expected_status)
|
||||||
|
|
||||||
|
|
||||||
|
class CompetitionsEndpointTests(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.user = User.objects.create(
|
||||||
|
email="user@example.com",
|
||||||
|
password=make_password("password123"),
|
||||||
|
username="t1wk4"
|
||||||
|
)
|
||||||
|
|
||||||
|
resp = self.client.post(
|
||||||
|
"/api/v1/sign-in",
|
||||||
|
data={"email": self.user.email, "password": "password123"},
|
||||||
|
content_type="application/json",
|
||||||
|
).json()
|
||||||
|
token = resp["token"]
|
||||||
|
|
||||||
|
# Create test competitions
|
||||||
|
now = datetime.now(tz=pytz.utc)
|
||||||
|
self.competitions = []
|
||||||
|
for i in range(1, 6):
|
||||||
|
competition = Competition.objects.create(
|
||||||
|
title=f"Competition {i}",
|
||||||
|
description=f"Description {i}",
|
||||||
|
type=Competition.CompetitionType.SOLO,
|
||||||
|
participation_type=(
|
||||||
|
Competition.CompetitionParticipationType.EDU if i % 2 == 0
|
||||||
|
else Competition.CompetitionParticipationType.COMPETITIVE
|
||||||
|
),
|
||||||
|
start_date=(now + timedelta(days=i)).isoformat(),
|
||||||
|
end_date=(now + timedelta(days=i + 7)).isoformat(),
|
||||||
|
)
|
||||||
|
if i <= 2:
|
||||||
|
competition.participants.add(self.user)
|
||||||
|
self.competitions.append(competition)
|
||||||
|
|
||||||
|
self.valid_headers = {
|
||||||
|
"HTTP_AUTHORIZATION": f"Bearer {token}"
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_url(self, params=None):
|
||||||
|
base_url = "/api/v1/competitions"
|
||||||
|
return f"{base_url}?{params}" if params else base_url
|
||||||
|
|
||||||
|
def test_get_participating_competitions(self):
|
||||||
|
"""Test filtering competitions where user is participating"""
|
||||||
|
response = self.client.get(
|
||||||
|
self.get_url("is_participating=true"),
|
||||||
|
**self.valid_headers
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
data = response.json()
|
||||||
|
self.assertEqual(len(data), 2)
|
||||||
|
self.assertEqual(
|
||||||
|
{item["id"] for item in data},
|
||||||
|
{str(self.competitions[0].id), str(self.competitions[1].id)}
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_competition_type_values(self):
|
||||||
|
"""Test competition type choices are respected"""
|
||||||
|
response = self.client.get(
|
||||||
|
self.get_url("is_participating=true"),
|
||||||
|
**self.valid_headers
|
||||||
|
)
|
||||||
|
|
||||||
|
for item in response.json():
|
||||||
|
self.assertEqual(item["type"], "solo")
|
||||||
|
|
||||||
|
def test_participation_type_values(self):
|
||||||
|
"""Test participation type alternates between edu/competitive"""
|
||||||
|
response = self.client.get(
|
||||||
|
self.get_url("is_participating=false"),
|
||||||
|
**self.valid_headers
|
||||||
|
)
|
||||||
|
|
||||||
|
types = [item["participation_type"] for item in response.json()]
|
||||||
|
self.assertCountEqual(
|
||||||
|
types,
|
||||||
|
["competitive", "edu", "competitive"]
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_datetime_formatting(self):
|
||||||
|
"""Test start/end date ISO formatting"""
|
||||||
|
response = self.client.get(
|
||||||
|
self.get_url("is_participating=true"),
|
||||||
|
**self.valid_headers
|
||||||
|
)
|
||||||
|
|
||||||
|
for item in response.json():
|
||||||
|
if item["start_date"]:
|
||||||
|
try:
|
||||||
|
isoparse(item["start_date"])
|
||||||
|
except ValueError:
|
||||||
|
self.fail("Invalid start_date format")
|
||||||
|
if item["end_date"]:
|
||||||
|
try:
|
||||||
|
isoparse(item["end_date"])
|
||||||
|
except ValueError:
|
||||||
|
self.fail("Invalid end_date format")
|
||||||
|
|
||||||
|
def test_competition_metadata(self):
|
||||||
|
"""Test competition metadata fields"""
|
||||||
|
response = self.client.get(
|
||||||
|
self.get_url("is_participating=true"),
|
||||||
|
**self.valid_headers
|
||||||
|
)
|
||||||
|
|
||||||
|
item = response.json()[0]
|
||||||
|
self.assertEqual(item["title"], "Competition 1")
|
||||||
|
self.assertEqual(item["description"], "Description 1")
|
||||||
|
self.assertEqual(item["type"], "solo")
|
||||||
|
self.assertEqual(item["participation_type"], "competitive")
|
||||||
|
|
||||||
|
def test_verbose_name_consistency(self):
|
||||||
|
"""Test model verbose names don't affect API schema"""
|
||||||
|
response = self.client.get(
|
||||||
|
self.get_url("is_participating=true"),
|
||||||
|
**self.valid_headers
|
||||||
|
)
|
||||||
|
|
||||||
|
item = response.json()[0]
|
||||||
|
self.assertNotIn("название", item) # Russian verbose name
|
||||||
|
self.assertIn("title", item) # Actual API field name
|
||||||
|
|
||||||
|
def test_null_dates_handling(self):
|
||||||
|
"""Test competitions with null dates"""
|
||||||
|
competition = Competition.objects.create(
|
||||||
|
title="No Dates Competition",
|
||||||
|
description="Test competition",
|
||||||
|
type=Competition.CompetitionType.SOLO,
|
||||||
|
participation_type=Competition.CompetitionParticipationType.EDU
|
||||||
|
)
|
||||||
|
|
||||||
|
response = self.client.get(
|
||||||
|
self.get_url("is_participating=false"),
|
||||||
|
**self.valid_headers
|
||||||
|
)
|
||||||
|
|
||||||
|
test_item = next(
|
||||||
|
item for item in response.json()
|
||||||
|
if item["id"] == str(competition.id)
|
||||||
|
)
|
||||||
|
self.assertIsNone(test_item["start_date"])
|
||||||
|
self.assertIsNone(test_item["end_date"])
|
||||||
|
|
||||||
|
def test_participation_status_filtering(self):
|
||||||
|
"""Test filtering by participation_type"""
|
||||||
|
response = self.client.get(
|
||||||
|
self.get_url("is_participating=false"),
|
||||||
|
**self.valid_headers
|
||||||
|
)
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
self.assertEqual(len(data), 3)
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ class CompetitionTask(BaseModel):
|
|||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
verbose_name = "задание"
|
||||||
verbose_name_plural = "задания"
|
verbose_name_plural = "задания"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ dependencies = [
|
|||||||
"psycopg2-binary>=2.9.10",
|
"psycopg2-binary>=2.9.10",
|
||||||
"pydantic>=2.10.5",
|
"pydantic>=2.10.5",
|
||||||
"pyjwt>=2.10.1",
|
"pyjwt>=2.10.1",
|
||||||
|
"python-dateutil>=2.9.0.post0",
|
||||||
"python-gettext>=5.0",
|
"python-gettext>=5.0",
|
||||||
"python-json-logger>=3.2.1",
|
"python-json-logger>=3.2.1",
|
||||||
"pytz>=2024.2",
|
"pytz>=2024.2",
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
const DataRush = ({ size = 52 }: { size?: number }) => {
|
const DataRush = ({
|
||||||
|
size = 52,
|
||||||
|
className,
|
||||||
|
}: {
|
||||||
|
size?: number;
|
||||||
|
className?: string;
|
||||||
|
}) => {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
height={size}
|
height={size}
|
||||||
viewBox="0 0 149 52"
|
viewBox="0 0 149 52"
|
||||||
fill="none"
|
fill="none"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
className={className}
|
||||||
>
|
>
|
||||||
<rect width="149" height="52" fill="#333333" />
|
<rect width="149" height="52" fill="#333333" />
|
||||||
<path
|
<path
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ const LoginPage = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-screen flex-col items-center gap-10 px-4 py-10 sm:gap-18 sm:py-18">
|
<div className="flex flex-col items-center gap-10 px-4 py-10 sm:gap-18 sm:py-18">
|
||||||
<DataRush size={52} />
|
<DataRush size={52} className="min-h-[52px]" />
|
||||||
<div className="flex w-full max-w-96 flex-col items-center gap-7">
|
<div className="flex w-full max-w-96 flex-col items-center gap-7">
|
||||||
<h1 className="text-center text-4xl font-semibold">
|
<h1 className="text-center text-4xl font-semibold">
|
||||||
Добро пожаловать!
|
Добро пожаловать!
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const NavbarLayout = () => {
|
|||||||
<>
|
<>
|
||||||
<Header />
|
<Header />
|
||||||
<div className="px-4 sm:px-6">
|
<div className="px-4 sm:px-6">
|
||||||
<div className="m-auto mt-6 w-full max-w-5xl">
|
<div className="m-auto my-6 w-full max-w-5xl">
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user