Merge pull request #384 from BogPlaymate/master
This commit is contained in:
Vendored
+15
@@ -0,0 +1,15 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2023 Marlon W (Mawoka)
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
|
{
|
||||||
|
"sqltools.connections": [
|
||||||
|
{
|
||||||
|
"previewLimit": 50,
|
||||||
|
"server": "localhost",
|
||||||
|
"driver": "PostgreSQL",
|
||||||
|
"connectString": "postgresql://postgres:mysecretpassword@localhost:5432/classquiz",
|
||||||
|
"name": "ClassQuiz"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ python-jose = "*"
|
|||||||
alembic = "*"
|
alembic = "*"
|
||||||
email-validator = "*"
|
email-validator = "*"
|
||||||
python-multipart = "*"
|
python-multipart = "*"
|
||||||
pydantic = "1.10.8"
|
pydantic = "*"
|
||||||
redis = "*"
|
redis = "*"
|
||||||
aiohttp = "*"
|
aiohttp = "*"
|
||||||
gunicorn = "*"
|
gunicorn = "*"
|
||||||
@@ -46,6 +46,7 @@ starlette = "*"
|
|||||||
pyopenssl = "*"
|
pyopenssl = "*"
|
||||||
python-dotenv = "*"
|
python-dotenv = "*"
|
||||||
webauthn = "==1.*"
|
webauthn = "==1.*"
|
||||||
|
pydantic-settings = "==2.2.1"
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
coverage = "*"
|
coverage = "*"
|
||||||
|
|||||||
Generated
+1062
-500
File diff suppressed because it is too large
Load Diff
+17
-19
@@ -7,9 +7,9 @@ from functools import lru_cache
|
|||||||
|
|
||||||
from redis import asyncio as redis_lib
|
from redis import asyncio as redis_lib
|
||||||
import redis as redis_base_lib
|
import redis as redis_base_lib
|
||||||
from pydantic import BaseSettings, RedisDsn, PostgresDsn, BaseModel
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
from pydantic import RedisDsn, PostgresDsn, BaseModel
|
||||||
import meilisearch as MeiliSearch
|
import meilisearch as MeiliSearch
|
||||||
from typing import Optional
|
|
||||||
from arq import create_pool
|
from arq import create_pool
|
||||||
from arq.connections import RedisSettings, ArqRedis
|
from arq.connections import RedisSettings, ArqRedis
|
||||||
|
|
||||||
@@ -28,10 +28,13 @@ class Settings(BaseSettings):
|
|||||||
Settings class for the shop app.
|
Settings class for the shop app.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
model_config = SettingsConfigDict(
|
||||||
|
env_file=".env", extra="ignore", env_nested_delimiter="__", env_file_encoding="utf-8"
|
||||||
|
)
|
||||||
root_address: str = "http://127.0.0.1:8000"
|
root_address: str = "http://127.0.0.1:8000"
|
||||||
redis: RedisDsn = "redis://localhost:6379/0?decode_responses=True"
|
redis: RedisDsn = "redis://localhost:6379/0?decode_responses=True"
|
||||||
skip_email_verification: bool = False
|
skip_email_verification: bool = False
|
||||||
db_url: str | PostgresDsn = "postgresql://postgres:mysecretpassword@localhost:5432/classquiz"
|
db_url: PostgresDsn | str = "postgresql://postgres:mysecretpassword@localhost:5432/classquiz"
|
||||||
hcaptcha_key: str | None = None
|
hcaptcha_key: str | None = None
|
||||||
recaptcha_key: str | None = None
|
recaptcha_key: str | None = None
|
||||||
mail_address: str
|
mail_address: str
|
||||||
@@ -42,13 +45,13 @@ class Settings(BaseSettings):
|
|||||||
secret_key: str
|
secret_key: str
|
||||||
access_token_expire_minutes: int = 30
|
access_token_expire_minutes: int = 30
|
||||||
cache_expiry: int = 86400
|
cache_expiry: int = 86400
|
||||||
sentry_dsn: str | None
|
sentry_dsn: str | None = None
|
||||||
meilisearch_url: str = "http://127.0.0.1:7700"
|
meilisearch_url: str = "http://127.0.0.1:7700"
|
||||||
meilisearch_index: str = "classquiz"
|
meilisearch_index: str = "classquiz"
|
||||||
google_client_id: Optional[str]
|
google_client_id: str | None = None
|
||||||
google_client_secret: Optional[str]
|
google_client_secret: str | None = None
|
||||||
github_client_id: Optional[str]
|
github_client_id: str | None = None
|
||||||
github_client_secret: Optional[str]
|
github_client_secret: str | None = None
|
||||||
custom_openid_provider: CustomOpenIDProvider | None = None
|
custom_openid_provider: CustomOpenIDProvider | None = None
|
||||||
telemetry_enabled: bool = True
|
telemetry_enabled: bool = True
|
||||||
free_storage_limit: int = 1074000000
|
free_storage_limit: int = 1074000000
|
||||||
@@ -57,21 +60,16 @@ class Settings(BaseSettings):
|
|||||||
registration_disabled: bool = False
|
registration_disabled: bool = False
|
||||||
|
|
||||||
# storage_backend
|
# storage_backend
|
||||||
storage_backend: str | None = "local"
|
storage_backend: str # either "local" or "s3"
|
||||||
|
|
||||||
# if storage_backend == "local":
|
# if storage_backend == "local":
|
||||||
storage_path: str | None
|
storage_path: str | None = None
|
||||||
|
|
||||||
# if storage_backend == "s3":
|
# if storage_backend == "s3":
|
||||||
s3_access_key: str | None
|
s3_access_key: str | None = None
|
||||||
s3_secret_key: str | None
|
s3_secret_key: str | None = None
|
||||||
s3_bucket_name: str = "classquiz"
|
s3_bucket_name: str = "classquiz"
|
||||||
s3_base_url: str | None
|
s3_base_url: str | None = None
|
||||||
|
|
||||||
class Config:
|
|
||||||
env_file = ".env"
|
|
||||||
env_file_encoding = "utf-8"
|
|
||||||
env_nested_delimiter = "__"
|
|
||||||
|
|
||||||
|
|
||||||
async def initialize_arq():
|
async def initialize_arq():
|
||||||
@@ -85,7 +83,7 @@ def settings() -> Settings:
|
|||||||
return Settings()
|
return Settings()
|
||||||
|
|
||||||
|
|
||||||
pool = redis_lib.ConnectionPool().from_url(settings().redis)
|
pool = redis_lib.ConnectionPool().from_url(str(settings().redis))
|
||||||
|
|
||||||
redis: redis_base_lib.client.Redis = redis_lib.Redis(connection_pool=pool)
|
redis: redis_base_lib.client.Redis = redis_lib.Redis(connection_pool=pool)
|
||||||
arq: ArqRedis = ArqRedis(pool_or_conn=pool)
|
arq: ArqRedis = ArqRedis(pool_or_conn=pool)
|
||||||
|
|||||||
+36
-75
@@ -10,7 +10,7 @@ from typing import Optional
|
|||||||
|
|
||||||
import ormar
|
import ormar
|
||||||
from ormar import ReferentialAction
|
from ormar import ReferentialAction
|
||||||
from pydantic import BaseModel, Json, validator
|
from pydantic import BaseModel, Json, validator, RootModel
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from . import metadata, database
|
from . import metadata, database
|
||||||
from .quiztivity import QuizTivityPage
|
from .quiztivity import QuizTivityPage
|
||||||
@@ -45,13 +45,7 @@ class User(ormar.Model):
|
|||||||
totp_secret: str = ormar.String(max_length=32, min_length=32, nullable=True, default=None)
|
totp_secret: str = ormar.String(max_length=32, min_length=32, nullable=True, default=None)
|
||||||
storage_used: int = ormar.BigInteger(nullable=False, default=0, minimum=0)
|
storage_used: int = ormar.BigInteger(nullable=False, default=0, minimum=0)
|
||||||
|
|
||||||
class Meta:
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="users")
|
||||||
tablename = "users"
|
|
||||||
metadata = metadata
|
|
||||||
database = database
|
|
||||||
|
|
||||||
class Config:
|
|
||||||
use_enum_values = True
|
|
||||||
|
|
||||||
|
|
||||||
class FidoCredentials(ormar.Model):
|
class FidoCredentials(ormar.Model):
|
||||||
@@ -61,20 +55,14 @@ class FidoCredentials(ormar.Model):
|
|||||||
sign_count: int = ormar.Integer()
|
sign_count: int = ormar.Integer()
|
||||||
user: Optional[User] = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
user: Optional[User] = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
||||||
|
|
||||||
class Meta:
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="fido_credentials")
|
||||||
tablename = "fido_credentials"
|
|
||||||
metadata = metadata
|
|
||||||
database = database
|
|
||||||
|
|
||||||
|
|
||||||
class ApiKey(ormar.Model):
|
class ApiKey(ormar.Model):
|
||||||
key: str = ormar.String(max_length=48, min_length=48, primary_key=True)
|
key: str = ormar.String(max_length=48, min_length=48, primary_key=True)
|
||||||
user: Optional[User] = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
user: Optional[User] = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
||||||
|
|
||||||
class Meta:
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="api_keys")
|
||||||
tablename = "api_keys"
|
|
||||||
metadata = metadata
|
|
||||||
database = database
|
|
||||||
|
|
||||||
|
|
||||||
class UserSession(ormar.Model):
|
class UserSession(ormar.Model):
|
||||||
@@ -90,16 +78,13 @@ class UserSession(ormar.Model):
|
|||||||
user_agent: str = ormar.String(max_length=255, nullable=True)
|
user_agent: str = ormar.String(max_length=255, nullable=True)
|
||||||
last_seen: datetime = ormar.DateTime(default=datetime.now())
|
last_seen: datetime = ormar.DateTime(default=datetime.now())
|
||||||
|
|
||||||
class Meta:
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="user_sessions")
|
||||||
tablename = "user_sessions"
|
|
||||||
metadata = metadata
|
|
||||||
database = database
|
|
||||||
|
|
||||||
|
|
||||||
class ABCDQuizAnswer(BaseModel):
|
class ABCDQuizAnswer(BaseModel):
|
||||||
right: bool
|
right: bool
|
||||||
answer: str
|
answer: str
|
||||||
color: str | None
|
color: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class RangeQuizAnswer(BaseModel):
|
class RangeQuizAnswer(BaseModel):
|
||||||
@@ -112,7 +97,7 @@ class RangeQuizAnswer(BaseModel):
|
|||||||
class VotingQuizAnswer(BaseModel):
|
class VotingQuizAnswer(BaseModel):
|
||||||
answer: str
|
answer: str
|
||||||
image: str | None = None
|
image: str | None = None
|
||||||
color: str | None
|
color: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class QuizQuestionType(str, Enum):
|
class QuizQuestionType(str, Enum):
|
||||||
@@ -160,10 +145,10 @@ class QuizInput(BaseModel):
|
|||||||
public: bool = False
|
public: bool = False
|
||||||
title: str
|
title: str
|
||||||
description: str
|
description: str
|
||||||
cover_image: str | None
|
cover_image: str | None = None
|
||||||
background_color: str | None
|
background_color: str | None = None
|
||||||
questions: list[QuizQuestion]
|
questions: list[QuizQuestion]
|
||||||
background_image: str | None
|
background_image: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class Quiz(ormar.Model):
|
class Quiz(ormar.Model):
|
||||||
@@ -186,19 +171,13 @@ class Quiz(ormar.Model):
|
|||||||
views: int = ormar.Integer(nullable=False, default=0, server_default="0")
|
views: int = ormar.Integer(nullable=False, default=0, server_default="0")
|
||||||
mod_rating: int | None = ormar.SmallInteger(nullable=True)
|
mod_rating: int | None = ormar.SmallInteger(nullable=True)
|
||||||
|
|
||||||
class Meta:
|
ormar_config = ormar.OrmarConfig(tablename="quiz", metadata=metadata, database=database)
|
||||||
tablename = "quiz"
|
|
||||||
metadata = metadata
|
|
||||||
database = database
|
|
||||||
|
|
||||||
|
|
||||||
class InstanceData(ormar.Model):
|
class InstanceData(ormar.Model):
|
||||||
instance_id: uuid.UUID = ormar.UUID(primary_key=True, default=uuid.uuid4(), nullable=False, unique=True)
|
instance_id: uuid.UUID = ormar.UUID(primary_key=True, default=uuid.uuid4(), nullable=False, unique=True)
|
||||||
|
|
||||||
class Meta:
|
ormar_config = ormar.OrmarConfig(tablename="instance_data", metadata=metadata, database=database)
|
||||||
tablename = "instance_data"
|
|
||||||
metadata = metadata
|
|
||||||
database = database
|
|
||||||
|
|
||||||
|
|
||||||
class Token(BaseModel):
|
class Token(BaseModel):
|
||||||
@@ -228,18 +207,18 @@ class PlayGame(BaseModel):
|
|||||||
game_pin: str
|
game_pin: str
|
||||||
started: bool = False
|
started: bool = False
|
||||||
captcha_enabled: bool = False
|
captcha_enabled: bool = False
|
||||||
cover_image: str | None
|
cover_image: str | None = None
|
||||||
game_mode: str | None
|
game_mode: str | None = None
|
||||||
current_question: int = -1
|
current_question: int = -1
|
||||||
background_color: str | None
|
background_color: str | None = None
|
||||||
background_image: str | None
|
background_image: str | None = None
|
||||||
custom_field: str | None
|
custom_field: str | None = None
|
||||||
question_show: bool = False
|
question_show: bool = False
|
||||||
|
|
||||||
|
|
||||||
class GamePlayer(BaseModel):
|
class GamePlayer(BaseModel):
|
||||||
username: str
|
username: str
|
||||||
sid: str | None
|
sid: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class GameAnswer2(BaseModel):
|
class GameAnswer2(BaseModel):
|
||||||
@@ -273,9 +252,9 @@ class AnswerData(BaseModel):
|
|||||||
score: int
|
score: int
|
||||||
|
|
||||||
|
|
||||||
class AnswerDataList(BaseModel):
|
class AnswerDataList(RootModel):
|
||||||
# Just a method to make a top-level list
|
# Just a method to make a top-level list
|
||||||
__root__: list[AnswerData]
|
root: list[AnswerData]
|
||||||
|
|
||||||
|
|
||||||
class GameInLobby(BaseModel):
|
class GameInLobby(BaseModel):
|
||||||
@@ -307,10 +286,7 @@ class GameResults(ormar.Model):
|
|||||||
description: str = ormar.Text(nullable=False)
|
description: str = ormar.Text(nullable=False)
|
||||||
questions: Json[list[QuizQuestion]] = ormar.JSON(nullable=False)
|
questions: Json[list[QuizQuestion]] = ormar.JSON(nullable=False)
|
||||||
|
|
||||||
class Meta:
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="game_results")
|
||||||
tablename = "game_results"
|
|
||||||
metadata = metadata
|
|
||||||
database = database
|
|
||||||
|
|
||||||
|
|
||||||
class QuizTivityInput(BaseModel):
|
class QuizTivityInput(BaseModel):
|
||||||
@@ -325,10 +301,7 @@ class QuizTivity(ormar.Model):
|
|||||||
user: User | None = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
user: User | None = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
||||||
pages: list[QuizTivityPage] = ormar.JSON(nullable=False)
|
pages: list[QuizTivityPage] = ormar.JSON(nullable=False)
|
||||||
|
|
||||||
class Meta:
|
ormar_config = ormar.OrmarConfig(tablename="quiztivitys", metadata=metadata, database=database)
|
||||||
tablename = "quiztivitys"
|
|
||||||
metadata = metadata
|
|
||||||
database = database
|
|
||||||
|
|
||||||
|
|
||||||
class QuizTivityShare(ormar.Model):
|
class QuizTivityShare(ormar.Model):
|
||||||
@@ -338,10 +311,7 @@ class QuizTivityShare(ormar.Model):
|
|||||||
quiztivity: QuizTivity | None = ormar.ForeignKey(QuizTivity, ondelete=ReferentialAction.CASCADE)
|
quiztivity: QuizTivity | None = ormar.ForeignKey(QuizTivity, ondelete=ReferentialAction.CASCADE)
|
||||||
user: User | None = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
user: User | None = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
||||||
|
|
||||||
class Meta:
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="quiztivityshares")
|
||||||
tablename = "quiztivityshares"
|
|
||||||
metadata = metadata
|
|
||||||
database = database
|
|
||||||
|
|
||||||
|
|
||||||
class OnlyId(BaseModel):
|
class OnlyId(BaseModel):
|
||||||
@@ -350,8 +320,8 @@ class OnlyId(BaseModel):
|
|||||||
|
|
||||||
class PublicQuizTivityShare(BaseModel):
|
class PublicQuizTivityShare(BaseModel):
|
||||||
id: uuid.UUID
|
id: uuid.UUID
|
||||||
name: str | None
|
name: str | None = None
|
||||||
expire_in: int | None
|
expire_in: int | None = None
|
||||||
quiztivity: OnlyId
|
quiztivity: OnlyId
|
||||||
user: OnlyId
|
user: OnlyId
|
||||||
|
|
||||||
@@ -386,23 +356,20 @@ class StorageItem(ormar.Model):
|
|||||||
server: str | None = ormar.Text(default=None, nullable=True)
|
server: str | None = ormar.Text(default=None, nullable=True)
|
||||||
imported: bool = ormar.Boolean(default=False, nullable=True)
|
imported: bool = ormar.Boolean(default=False, nullable=True)
|
||||||
|
|
||||||
class Meta:
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="storage_items")
|
||||||
tablename = "storage_items"
|
|
||||||
metadata = metadata
|
|
||||||
database = database
|
|
||||||
|
|
||||||
|
|
||||||
class PublicStorageItem(BaseModel):
|
class PublicStorageItem(BaseModel):
|
||||||
id: uuid.UUID
|
id: uuid.UUID
|
||||||
uploaded_at: datetime
|
uploaded_at: datetime
|
||||||
mime_type: str
|
mime_type: str
|
||||||
hash: str | None
|
hash: str | None = None
|
||||||
size: int
|
size: int
|
||||||
deleted_at: datetime | None
|
deleted_at: datetime | None = None
|
||||||
alt_text: str | None
|
alt_text: str | None = None
|
||||||
filename: str | None
|
filename: str | None = None
|
||||||
thumbhash: str | None
|
thumbhash: str | None = None
|
||||||
server: str | None
|
server: str | None = None
|
||||||
imported: bool
|
imported: bool
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -458,8 +425,8 @@ class PrivateStorageItem(PublicStorageItem):
|
|||||||
|
|
||||||
|
|
||||||
class UpdateStorageItem(BaseModel):
|
class UpdateStorageItem(BaseModel):
|
||||||
filename: str | None
|
filename: str | None = None
|
||||||
alt_text: str | None
|
alt_text: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class Controller(ormar.Model):
|
class Controller(ormar.Model):
|
||||||
@@ -473,10 +440,7 @@ class Controller(ormar.Model):
|
|||||||
os_version: str | None = ormar.Text(nullable=True)
|
os_version: str | None = ormar.Text(nullable=True)
|
||||||
wanted_os_version: str = ormar.Text(nullable=True, default=None)
|
wanted_os_version: str = ormar.Text(nullable=True, default=None)
|
||||||
|
|
||||||
class Meta:
|
ormar_config = ormar.OrmarConfig(tablename="controller", metadata=metadata, database=database)
|
||||||
tablename = "controller"
|
|
||||||
metadata = metadata
|
|
||||||
database = database
|
|
||||||
|
|
||||||
|
|
||||||
class Rating(ormar.Model):
|
class Rating(ormar.Model):
|
||||||
@@ -486,7 +450,4 @@ class Rating(ormar.Model):
|
|||||||
created_at: datetime = ormar.DateTime(nullable=False, server_default=func.now())
|
created_at: datetime = ormar.DateTime(nullable=False, server_default=func.now())
|
||||||
quiz: uuid.UUID | Quiz = ormar.ForeignKey(Quiz)
|
quiz: uuid.UUID | Quiz = ormar.ForeignKey(Quiz)
|
||||||
|
|
||||||
class Meta:
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="rating")
|
||||||
tablename = "rating"
|
|
||||||
metadata = metadata
|
|
||||||
database = database
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ class Pdf(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class _MemoryCard(BaseModel):
|
class _MemoryCard(BaseModel):
|
||||||
image: str | None
|
image: str | None = None
|
||||||
text: str | None
|
text: str | None = None
|
||||||
id: str
|
id: str
|
||||||
|
|
||||||
|
|
||||||
@@ -53,6 +53,6 @@ TYPE_CLASS_LIST = {
|
|||||||
|
|
||||||
|
|
||||||
class QuizTivityPage(BaseModel):
|
class QuizTivityPage(BaseModel):
|
||||||
title: str | None
|
title: str | None = None
|
||||||
type: QuizTivityTypes
|
type: QuizTivityTypes
|
||||||
data: Pdf | Memory | Markdown | Abcd
|
data: Pdf | Memory | Markdown | Abcd
|
||||||
|
|||||||
@@ -10,19 +10,19 @@ from pydantic import BaseModel
|
|||||||
|
|
||||||
|
|
||||||
class _CoverMetadata(BaseModel):
|
class _CoverMetadata(BaseModel):
|
||||||
id: UUID | None
|
id: UUID | None = None
|
||||||
resources: str | None
|
resources: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class _CreatorAvatar(BaseModel):
|
class _CreatorAvatar(BaseModel):
|
||||||
url: str | None
|
url: str | None = None
|
||||||
id: UUID | None
|
id: UUID | None = None
|
||||||
type: str | None
|
type: str | None = None
|
||||||
bitmojiAvatarId: str | None
|
bitmojiAvatarId: str | None = None
|
||||||
altText: str | None
|
altText: str | None = None
|
||||||
contentType: str | None
|
contentType: str | None = None
|
||||||
width: int | None
|
width: int | None = None
|
||||||
height: int | None
|
height: int | None = None
|
||||||
|
|
||||||
|
|
||||||
class _LastEdit(BaseModel):
|
class _LastEdit(BaseModel):
|
||||||
@@ -32,19 +32,19 @@ class _LastEdit(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class _ImageMetadata(BaseModel):
|
class _ImageMetadata(BaseModel):
|
||||||
id: UUID | None
|
id: UUID | None = None
|
||||||
content_type: Optional[str]
|
content_type: Optional[str] = None
|
||||||
width: Optional[int]
|
width: Optional[int] = None
|
||||||
height: Optional[int]
|
height: Optional[int] = None
|
||||||
resources: Optional[str]
|
resources: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
class _SampleQuestion(BaseModel):
|
class _SampleQuestion(BaseModel):
|
||||||
image: str | None
|
image: str | None = None
|
||||||
imageMetadata: _ImageMetadata | None
|
imageMetadata: _ImageMetadata | None = None
|
||||||
title: str
|
title: str
|
||||||
type: str
|
type: str
|
||||||
time: int | None
|
time: int | None = None
|
||||||
|
|
||||||
|
|
||||||
class _Access(BaseModel):
|
class _Access(BaseModel):
|
||||||
@@ -57,19 +57,19 @@ class _Card(BaseModel):
|
|||||||
title: str
|
title: str
|
||||||
description: str
|
description: str
|
||||||
slug: str
|
slug: str
|
||||||
cover: str | None
|
cover: str | None = None
|
||||||
coverMetadata: _CoverMetadata | dict[None, None] | None
|
coverMetadata: _CoverMetadata | dict[None, None] | None = None
|
||||||
draftExists: bool
|
draftExists: bool
|
||||||
inventoryItemIds: List[Any]
|
inventoryItemIds: List[Any] = None
|
||||||
number_of_questions: int
|
number_of_questions: int
|
||||||
creator: UUID
|
creator: UUID
|
||||||
creator_username: str
|
creator_username: str
|
||||||
creator_avatar: _CreatorAvatar | dict[None, None] | None
|
creator_avatar: _CreatorAvatar | dict[None, None] | None = None
|
||||||
badges: List[str]
|
badges: List[str]
|
||||||
visibility: int
|
visibility: int
|
||||||
locked: bool
|
locked: bool
|
||||||
writeProtection: bool
|
writeProtection: bool
|
||||||
lastEdit: _LastEdit | None
|
lastEdit: _LastEdit | None = None
|
||||||
featured: bool
|
featured: bool
|
||||||
young_featured: bool
|
young_featured: bool
|
||||||
sponsored: bool
|
sponsored: bool
|
||||||
@@ -111,8 +111,8 @@ class _LanguageInfo(BaseModel):
|
|||||||
|
|
||||||
class _Metadata(BaseModel):
|
class _Metadata(BaseModel):
|
||||||
access: _Access
|
access: _Access
|
||||||
duplicationProtection: bool | None
|
duplicationProtection: bool | None = None
|
||||||
lastEdit: _LastEdit | None
|
lastEdit: _LastEdit | None = None
|
||||||
|
|
||||||
|
|
||||||
class _Parent(BaseModel):
|
class _Parent(BaseModel):
|
||||||
@@ -123,15 +123,15 @@ class _Parent(BaseModel):
|
|||||||
class _Choice(BaseModel):
|
class _Choice(BaseModel):
|
||||||
answer: str
|
answer: str
|
||||||
correct: bool
|
correct: bool
|
||||||
languageInfo: _LanguageInfo | None
|
languageInfo: _LanguageInfo | None = None
|
||||||
|
|
||||||
|
|
||||||
class _Video(BaseModel):
|
class _Video(BaseModel):
|
||||||
startTime: float
|
startTime: float
|
||||||
endTime: float
|
endTime: float
|
||||||
service: str
|
service: str
|
||||||
full_url: Optional[str]
|
full_url: Optional[str] = None
|
||||||
id: Optional[str]
|
id: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
class _Question(BaseModel):
|
class _Question(BaseModel):
|
||||||
@@ -141,12 +141,12 @@ class _Question(BaseModel):
|
|||||||
points: bool
|
points: bool
|
||||||
pointsMultiplier: int
|
pointsMultiplier: int
|
||||||
choices: List[_Choice]
|
choices: List[_Choice]
|
||||||
image: str | None
|
image: str | None = None
|
||||||
imageMetadata: _ImageMetadata | None
|
imageMetadata: _ImageMetadata | None = None
|
||||||
resources: Optional[str]
|
resources: Optional[str] = None
|
||||||
video: _Video
|
video: _Video
|
||||||
questionFormat: int
|
questionFormat: int
|
||||||
languageInfo: _LanguageInfo | None
|
languageInfo: _LanguageInfo | None = None
|
||||||
media: List[Any]
|
media: List[Any]
|
||||||
|
|
||||||
|
|
||||||
@@ -157,23 +157,23 @@ class _Kahoot(BaseModel):
|
|||||||
creator_username: str
|
creator_username: str
|
||||||
compatibilityLevel: int
|
compatibilityLevel: int
|
||||||
creator_primary_usage: str
|
creator_primary_usage: str
|
||||||
folderId: UUID | None
|
folderId: UUID | None = None
|
||||||
visibility: int
|
visibility: int
|
||||||
difficulty: int | None
|
difficulty: int | None = None
|
||||||
audience: str
|
audience: str
|
||||||
audience: str
|
audience: str
|
||||||
title: str
|
title: str
|
||||||
description: str
|
description: str
|
||||||
quizType: str
|
quizType: str
|
||||||
tags: str | None | List[str]
|
tags: str | None | List[str] = None
|
||||||
cover: str | None
|
cover: str | None = None
|
||||||
coverMetadata: _CoverMetadata | dict[None, None] | None
|
coverMetadata: _CoverMetadata | dict[None, None] | None = None
|
||||||
questions: List[_Question]
|
questions: List[_Question]
|
||||||
metadata: _Metadata
|
metadata: _Metadata
|
||||||
parent: _Parent | None
|
parent: _Parent | None = None
|
||||||
resources: str | None
|
resources: str | None = None
|
||||||
slug: str
|
slug: str
|
||||||
languageInfo: _LanguageInfo | None
|
languageInfo: _LanguageInfo | None = None
|
||||||
inventoryItemIds: List[Any]
|
inventoryItemIds: List[Any]
|
||||||
type: str
|
type: str
|
||||||
created: int
|
created: int
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ from classquiz.kahoot_importer import _Entity
|
|||||||
class _Response(BaseModel):
|
class _Response(BaseModel):
|
||||||
entities: List[_Entity]
|
entities: List[_Entity]
|
||||||
totalHits: int
|
totalHits: int
|
||||||
cursor: int | None
|
cursor: int | None = None
|
||||||
pageTimestamp: int
|
pageTimestamp: int
|
||||||
|
|
||||||
|
|
||||||
async def search(
|
async def search(
|
||||||
query: str | None,
|
query: str | None = None,
|
||||||
limit: int | None = 9,
|
limit: int | None = 9,
|
||||||
cursor: int | None = 1,
|
cursor: int | None = 1,
|
||||||
search_cluster: int | None = 1,
|
search_cluster: int | None = 1,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ router = APIRouter()
|
|||||||
|
|
||||||
|
|
||||||
class SetControllerUpInput(BaseModel):
|
class SetControllerUpInput(BaseModel):
|
||||||
player_name: str | None
|
player_name: str | None = None
|
||||||
name: str
|
name: str
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class LoginSession(BaseModel):
|
|||||||
user_id: str
|
user_id: str
|
||||||
step_1: set[StartLoginResponseTypes]
|
step_1: set[StartLoginResponseTypes]
|
||||||
step_2: set[StartLoginResponseTypes]
|
step_2: set[StartLoginResponseTypes]
|
||||||
webauthn_challenge: str | None
|
webauthn_challenge: str | None = None
|
||||||
step1_success: bool = False
|
step1_success: bool = False
|
||||||
|
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ class StartLoginResponse(BaseModel):
|
|||||||
step_1: set[StartLoginResponseTypes]
|
step_1: set[StartLoginResponseTypes]
|
||||||
step_2: set[StartLoginResponseTypes]
|
step_2: set[StartLoginResponseTypes]
|
||||||
session_id: str
|
session_id: str
|
||||||
webauthn_data: None | str
|
webauthn_data: None | str = None
|
||||||
|
|
||||||
|
|
||||||
def verify_webauthn(data, fidocredentialss: list[FidoCredentials], login_session: LoginSession):
|
def verify_webauthn(data, fidocredentialss: list[FidoCredentials], login_session: LoginSession):
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ async def get_newest_quizzes(
|
|||||||
|
|
||||||
|
|
||||||
class SetModRatingForQuizInput(BaseModel):
|
class SetModRatingForQuizInput(BaseModel):
|
||||||
rating: int | None
|
rating: int | None = None
|
||||||
|
|
||||||
|
|
||||||
@router.post("/rating/set/{quiz_id}")
|
@router.post("/rating/set/{quiz_id}")
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ from classquiz.config import redis, settings, storage, meilisearch
|
|||||||
from classquiz.db.models import Quiz, User, PlayGame, GameInLobby, QuizQuestion, QuizQuestionType
|
from classquiz.db.models import Quiz, User, PlayGame, GameInLobby, QuizQuestion, QuizQuestionType
|
||||||
from classquiz.helpers.box_controller import generate_code
|
from classquiz.helpers.box_controller import generate_code
|
||||||
from classquiz.kahoot_importer.import_quiz import import_quiz
|
from classquiz.kahoot_importer.import_quiz import import_quiz
|
||||||
|
from uuid import UUID
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
settings = settings()
|
settings = settings()
|
||||||
@@ -54,7 +55,7 @@ class PublicQuizResponseUser(BaseModel):
|
|||||||
id: uuid.UUID
|
id: uuid.UUID
|
||||||
|
|
||||||
|
|
||||||
class PublicQuizResponse(Quiz.get_pydantic()):
|
class PublicQuizResponse(Quiz.get_pydantic(exclude={"questions"})):
|
||||||
user_id: PublicQuizResponseUser
|
user_id: PublicQuizResponseUser
|
||||||
questions: list[QuizQuestion]
|
questions: list[QuizQuestion]
|
||||||
likes: int
|
likes: int
|
||||||
@@ -143,8 +144,8 @@ async def start_quiz(
|
|||||||
|
|
||||||
class CheckIfCaptchaEnabledResponse(BaseModel):
|
class CheckIfCaptchaEnabledResponse(BaseModel):
|
||||||
enabled: bool
|
enabled: bool
|
||||||
game_mode: str | None
|
game_mode: str | None = None
|
||||||
custom_field: str | None
|
custom_field: str | None = None
|
||||||
|
|
||||||
|
|
||||||
@router.get("/play/check_captcha/{game_pin}", response_model=CheckIfCaptchaEnabledResponse)
|
@router.get("/play/check_captcha/{game_pin}", response_model=CheckIfCaptchaEnabledResponse)
|
||||||
@@ -229,7 +230,8 @@ async def export_quiz_answers(export_token: str, game_pin: str):
|
|||||||
data = json.loads(data)
|
data = json.loads(data)
|
||||||
data2 = await redis.get(f"game:{game_pin}")
|
data2 = await redis.get(f"game:{game_pin}")
|
||||||
game_data = PlayGame.parse_raw(data2)
|
game_data = PlayGame.parse_raw(data2)
|
||||||
quiz = await Quiz.objects.get_or_none(id=game_data.quiz_id)
|
print(type(game_data.quiz_id))
|
||||||
|
quiz = await Quiz.objects.get_or_none(id=UUID(game_data.quiz_id))
|
||||||
if quiz is None:
|
if quiz is None:
|
||||||
raise HTTPException(status_code=404, detail="quiz not found")
|
raise HTTPException(status_code=404, detail="quiz not found")
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ async def get_shares(user: User = Depends(get_current_user)) -> list[PublicQuizT
|
|||||||
|
|
||||||
|
|
||||||
class CreateShareInput(BaseModel):
|
class CreateShareInput(BaseModel):
|
||||||
name: str | None
|
name: str | None = None
|
||||||
quiztivity: UUID
|
quiztivity: UUID
|
||||||
expire_in: int | None
|
expire_in: int | None = None
|
||||||
|
|
||||||
|
|
||||||
@router.post("/")
|
@router.post("/")
|
||||||
@@ -55,8 +55,8 @@ async def delete_share(uuid: UUID, user: User = Depends(get_current_user)):
|
|||||||
|
|
||||||
|
|
||||||
class UpdateShareInput(BaseModel):
|
class UpdateShareInput(BaseModel):
|
||||||
name: str | None
|
name: str | None = None
|
||||||
expire_in: int | None
|
expire_in: int | None = None
|
||||||
|
|
||||||
|
|
||||||
@router.put("/{uuid}")
|
@router.put("/{uuid}")
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class SitemapQuiz(BaseModel):
|
|||||||
updated_at: datetime.datetime
|
updated_at: datetime.datetime
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
orm_mode = True
|
from_attributes = True
|
||||||
|
|
||||||
|
|
||||||
@router.get("/get")
|
@router.get("/get")
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ async def get_other_avatar(respo: Response, user_id: uuid.UUID):
|
|||||||
|
|
||||||
class InternalAuthData(BaseModel):
|
class InternalAuthData(BaseModel):
|
||||||
rememberme: str
|
rememberme: str
|
||||||
jwt: str | None
|
jwt: str | None = None
|
||||||
|
|
||||||
|
|
||||||
@router.post("/auth/internal")
|
@router.post("/auth/internal")
|
||||||
|
|||||||
@@ -61,10 +61,10 @@ def calculate_score(z: float, t: int) -> int:
|
|||||||
|
|
||||||
async def set_answer(answers, game_pin: str, q_index: int, data: AnswerData) -> AnswerDataList:
|
async def set_answer(answers, game_pin: str, q_index: int, data: AnswerData) -> AnswerDataList:
|
||||||
if answers is None:
|
if answers is None:
|
||||||
answers = AnswerDataList(__root__=[data])
|
answers = AnswerDataList([data])
|
||||||
else:
|
else:
|
||||||
answers = AnswerDataList.parse_raw(answers)
|
answers = AnswerDataList.parse_raw(answers)
|
||||||
answers.__root__.append(data)
|
answers.root.append(data)
|
||||||
await redis.set(
|
await redis.set(
|
||||||
f"game_session:{game_pin}:{q_index}",
|
f"game_session:{game_pin}:{q_index}",
|
||||||
answers.json(),
|
answers.json(),
|
||||||
@@ -76,8 +76,8 @@ async def set_answer(answers, game_pin: str, q_index: int, data: AnswerData) ->
|
|||||||
class _JoinGameData(BaseModel):
|
class _JoinGameData(BaseModel):
|
||||||
username: str
|
username: str
|
||||||
game_pin: str
|
game_pin: str
|
||||||
captcha: str | None
|
captcha: str | None = None
|
||||||
custom_field: str | None
|
custom_field: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class _RejoinGameData(BaseModel):
|
class _RejoinGameData(BaseModel):
|
||||||
@@ -280,7 +280,7 @@ async def get_question_results(sid: str, data: dict):
|
|||||||
if redis_res is None:
|
if redis_res is None:
|
||||||
redis_res = []
|
redis_res = []
|
||||||
else:
|
else:
|
||||||
redis_res = AnswerDataList.parse_raw(redis_res).dict()["__root__"]
|
redis_res = AnswerDataList.parse_raw(redis_res).model_dump()
|
||||||
game_data = PlayGame.parse_raw(await redis.get(f"game:{session['game_pin']}"))
|
game_data = PlayGame.parse_raw(await redis.get(f"game:{session['game_pin']}"))
|
||||||
game_data.question_show = False
|
game_data.question_show = False
|
||||||
await redis.set(f"game:{session['game_pin']}", game_data.json())
|
await redis.set(f"game:{session['game_pin']}", game_data.json())
|
||||||
@@ -291,7 +291,7 @@ async def get_question_results(sid: str, data: dict):
|
|||||||
|
|
||||||
class ABCDQuizAnswerWithoutSolution(BaseModel):
|
class ABCDQuizAnswerWithoutSolution(BaseModel):
|
||||||
answer: str
|
answer: str
|
||||||
color: str | None
|
color: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class RangeQuizAnswerWithoutSolution(BaseModel):
|
class RangeQuizAnswerWithoutSolution(BaseModel):
|
||||||
@@ -360,7 +360,7 @@ class _SubmitAnswerDataOrderType(BaseModel):
|
|||||||
class _SubmitAnswerData(BaseModel):
|
class _SubmitAnswerData(BaseModel):
|
||||||
question_index: int
|
question_index: int
|
||||||
answer: str
|
answer: str
|
||||||
complex_answer: list[_SubmitAnswerDataOrderType] | None
|
complex_answer: list[_SubmitAnswerDataOrderType] | None = None
|
||||||
|
|
||||||
|
|
||||||
@sio.event
|
@sio.event
|
||||||
@@ -448,7 +448,7 @@ async def submit_answer(sid: str, data: dict):
|
|||||||
)
|
)
|
||||||
player_count = await redis.scard(f"game_session:{session['game_pin']}:players")
|
player_count = await redis.scard(f"game_session:{session['game_pin']}:players")
|
||||||
await sio.emit("player_answer", {})
|
await sio.emit("player_answer", {})
|
||||||
if len(answers.__root__) == player_count:
|
if len(answers.root) == player_count:
|
||||||
# await sio.emit(
|
# await sio.emit(
|
||||||
# "question_results",
|
# "question_results",
|
||||||
# await redis.get(f"game_session:{session['game_pin']}:{data.question_index}"),
|
# await redis.get(f"game_session:{session['game_pin']}:{data.question_index}"),
|
||||||
|
|||||||
@@ -27,4 +27,4 @@ class WorkerSettings:
|
|||||||
cron_jobs = [cron(clean_editor_images_up, hour={0, 6, 12, 18}, minute=0)]
|
cron_jobs = [cron(clean_editor_images_up, hour={0, 6, 12, 18}, minute=0)]
|
||||||
on_startup = startup
|
on_startup = startup
|
||||||
on_shutdown = shutdown
|
on_shutdown = shutdown
|
||||||
redis_settings = RedisSettings.from_dsn(settings.redis)
|
redis_settings = RedisSettings.from_dsn(str(settings.redis))
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ services:
|
|||||||
- 9000:9000
|
- 9000:9000
|
||||||
- 9001:9001
|
- 9001:9001
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
redis:
|
||||||
|
image: redis
|
||||||
|
ports:
|
||||||
|
- 6379:6379
|
||||||
volumes:
|
volumes:
|
||||||
db:
|
db:
|
||||||
search:
|
search:
|
||||||
|
|||||||
+7
-7
@@ -29,7 +29,7 @@ services:
|
|||||||
# --- DON'T CHANGE FROM HERE ---
|
# --- DON'T CHANGE FROM HERE ---
|
||||||
DB_URL: "postgresql://postgres:classquiz@db:5432/classquiz" # DON'T CHANGE
|
DB_URL: "postgresql://postgres:classquiz@db:5432/classquiz" # DON'T CHANGE
|
||||||
REDIS: "redis://redis:6379/0?decode_responses=True" # DON'T CHANGE
|
REDIS: "redis://redis:6379/0?decode_responses=True" # DON'T CHANGE
|
||||||
SECRET_KEY: "TOP_SECRET" # Don't change it manually, use the one-liner provided in the documentation
|
SECRET_KEY: "f2a08b44a104b4b4836fe4da9b25b795e1669f08bd1578397ecb19d176952780" # Don't change it manually, use the one-liner provided in the documentation
|
||||||
MAX_WORKERS: "1" # Very important and DON'T CHANGE
|
MAX_WORKERS: "1" # Very important and DON'T CHANGE
|
||||||
ACCESS_TOKEN_EXPIRE_MINUTES: 30 # DON'T CHANGE
|
ACCESS_TOKEN_EXPIRE_MINUTES: 30 # DON'T CHANGE
|
||||||
MEILISEARCH_URL: "http://meilisearch:7700" # DON'T CHANGE
|
MEILISEARCH_URL: "http://meilisearch:7700" # DON'T CHANGE
|
||||||
@@ -39,15 +39,15 @@ services:
|
|||||||
ROOT_ADDRESS: "https://classquiz.de" # CHANGE IT (without a "/" at the end)
|
ROOT_ADDRESS: "https://classquiz.de" # CHANGE IT (without a "/" at the end)
|
||||||
|
|
||||||
# --- MAIL CONFIG ---
|
# --- MAIL CONFIG ---
|
||||||
MAIL_PORT: "587"
|
MAIL_PORT: "993"
|
||||||
MAIL_ADDRESS: "email@email@email.email"
|
MAIL_ADDRESS: "temp"
|
||||||
MAIL_PASSWORD: "PASSWORT"
|
MAIL_PASSWORD: "temp"
|
||||||
MAIL_USERNAME: "email@email@email.email"
|
MAIL_USERNAME: "temp"
|
||||||
MAIL_SERVER: "email@email@email.emai"
|
MAIL_SERVER: "imap.gmail.com"
|
||||||
SKIP_EMAIL_VERIFICATION: "True" # Does the user have to confirm its email by clicking a link?
|
SKIP_EMAIL_VERIFICATION: "True" # Does the user have to confirm its email by clicking a link?
|
||||||
|
|
||||||
# --- EXTERNAL API CONFIG ---
|
# --- EXTERNAL API CONFIG ---
|
||||||
# HCAPTCHA_KEY: "HCAPTCHA_PRIVATE_KEY"
|
# HCAPTCHA_KEY: "3852831a-48b4-4236-b0de-9769a1998468"
|
||||||
# PIXABAY_API_KEY: "" # Get it from here: https://pixabay.com/api/docs/
|
# PIXABAY_API_KEY: "" # Get it from here: https://pixabay.com/api/docs/
|
||||||
# RECAPTCHA_KEY: "" Get it from Google for the Captcha.
|
# RECAPTCHA_KEY: "" Get it from Google for the Captcha.
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -11,11 +11,12 @@ ENV API_URL=https://mawoka.eu
|
|||||||
ENV REDIS_URL=redis://localhost:6379
|
ENV REDIS_URL=redis://localhost:6379
|
||||||
ENV VITE_MAPBOX_ACCESS_TOKEN=pk.eyJ1IjoibWF3b2thIiwiYSI6ImNsMjBob3d4ZjBhcGszYnE0bWp4aXB1ZW4ifQ.IByxV1qeIuEWpHCWsuB88A
|
ENV VITE_MAPBOX_ACCESS_TOKEN=pk.eyJ1IjoibWF3b2thIiwiYSI6ImNsMjBob3d4ZjBhcGszYnE0bWp4aXB1ZW4ifQ.IByxV1qeIuEWpHCWsuB88A
|
||||||
# This Mapbox-token is restricted to the following urls: classquiz.de, classquiz.mawoka.eu, test.com
|
# This Mapbox-token is restricted to the following urls: classquiz.de, classquiz.mawoka.eu, test.com
|
||||||
ENV VITE_HCAPTCHA=ee81b2a1-acf3-4d20-b2a4-a7ea94c7eba5
|
ENV VITE_HCAPTCHA=3852831a-48b4-4236-b0de-9769a1998468
|
||||||
|
# Hacaptcha secret ES_e0f8139cb5ad467d892e8d73a020cd2b
|
||||||
# ENV VITE_SENTRY=https://75cb4ef1be624d8f81bbaf864b722f8a@glitch.mawoka.eu/2
|
# ENV VITE_SENTRY=https://75cb4ef1be624d8f81bbaf864b722f8a@glitch.mawoka.eu/2
|
||||||
#ENV VITE_GOOGLE_AUTH_ENABLED=true
|
#ENV VITE_GOOGLE_AUTH_ENABLED=true
|
||||||
#ENV VITE_GITHUB_AUTH_ENABLED=true
|
#ENV VITE_GITHUB_AUTH_ENABLED=true
|
||||||
#ENV VITE_CAPTCHA_ENABLED=true
|
ENV VITE_CAPTCHA_ENABLED=true
|
||||||
#ENV VITE_REGISTRATION_DISABLED=True
|
#ENV VITE_REGISTRATION_DISABLED=True
|
||||||
#ENV VITE_PLAUSIBLE_DATA_URL=
|
#ENV VITE_PLAUSIBLE_DATA_URL=
|
||||||
# change working directory
|
# change working directory
|
||||||
|
|||||||
@@ -16,12 +16,12 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@beyonk/svelte-mapbox": "^9.0.5",
|
"@beyonk/svelte-mapbox": "^9.0.5",
|
||||||
"@ckeditor/ckeditor5-autoformat": "^37.1.0",
|
"@ckeditor/ckeditor5-autoformat": "^41.1.0",
|
||||||
"@ckeditor/ckeditor5-basic-styles": "^37.1.0",
|
"@ckeditor/ckeditor5-basic-styles": "^41.1.0",
|
||||||
"@ckeditor/ckeditor5-build-balloon": "^37.1.0",
|
"@ckeditor/ckeditor5-build-balloon": "^41.1.0",
|
||||||
"@ckeditor/ckeditor5-editor-balloon": "^37.1.0",
|
"@ckeditor/ckeditor5-editor-balloon": "^41.1.0",
|
||||||
"@ckeditor/ckeditor5-essentials": "^37.1.0",
|
"@ckeditor/ckeditor5-essentials": "^41.1.0",
|
||||||
"@ckeditor/ckeditor5-theme-lark": "^37.1.0",
|
"@ckeditor/ckeditor5-theme-lark": "^41.1.0",
|
||||||
"@felte/reporter-tippy": "^1.1.5",
|
"@felte/reporter-tippy": "^1.1.5",
|
||||||
"@felte/validator-yup": "^1.0.11",
|
"@felte/validator-yup": "^1.0.11",
|
||||||
"@ffmpeg/core": "^0.11.0",
|
"@ffmpeg/core": "^0.11.0",
|
||||||
|
|||||||
Generated
+2232
-561
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,10 @@ SPDX-FileCopyrightText: 2023 Marlon W (Mawoka)
|
|||||||
SPDX-License-Identifier: MPL-2.0
|
SPDX-License-Identifier: MPL-2.0
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
<!--
|
||||||
|
This should be okay, right?
|
||||||
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { tinykeys } from '$lib/tinykeys';
|
import { tinykeys } from '$lib/tinykeys';
|
||||||
@@ -231,6 +235,7 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
<div
|
<div
|
||||||
class="fixed top-0 left-0 w-screen h-screen flex bg-black bg-opacity-50 z-50"
|
class="fixed top-0 left-0 w-screen h-screen flex bg-black bg-opacity-50 z-50"
|
||||||
on:click={close_on_outside}
|
on:click={close_on_outside}
|
||||||
|
on:keyup={close_on_outside}
|
||||||
transition:fade={{ duration: 60 }}
|
transition:fade={{ duration: 60 }}
|
||||||
>
|
>
|
||||||
<div class="m-auto w-1/3 h-2/3 rounded bg-black flex flex-col">
|
<div class="m-auto w-1/3 h-2/3 rounded bg-black flex flex-col">
|
||||||
@@ -242,7 +247,6 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
</p>
|
</p>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
autofocus
|
|
||||||
class="col-start-1 row-start-1 bg-transparent w-full p-4 outline-none bg-gray-700 rounded"
|
class="col-start-1 row-start-1 bg-transparent w-full p-4 outline-none bg-gray-700 rounded"
|
||||||
bind:value={input}
|
bind:value={input}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -259,6 +259,9 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
on:click={() => {
|
on:click={() => {
|
||||||
selected_create_thing = SelectedCreateThing.Create;
|
selected_create_thing = SelectedCreateThing.Create;
|
||||||
}}
|
}}
|
||||||
|
on:keyup={() => {
|
||||||
|
selected_create_thing = SelectedCreateThing.Create;
|
||||||
|
}}
|
||||||
class:shadow-2xl={selected_create_thing === SelectedCreateThing.Create}
|
class:shadow-2xl={selected_create_thing === SelectedCreateThing.Create}
|
||||||
class:opacity-70={selected_create_thing !== SelectedCreateThing.Create}
|
class:opacity-70={selected_create_thing !== SelectedCreateThing.Create}
|
||||||
>
|
>
|
||||||
@@ -289,6 +292,9 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
on:click={() => {
|
on:click={() => {
|
||||||
selected_create_thing = SelectedCreateThing.Find;
|
selected_create_thing = SelectedCreateThing.Find;
|
||||||
}}
|
}}
|
||||||
|
on:keyup={() => {
|
||||||
|
selected_create_thing = SelectedCreateThing.Find;
|
||||||
|
}}
|
||||||
class:shadow-2xl={selected_create_thing === SelectedCreateThing.Find}
|
class:shadow-2xl={selected_create_thing === SelectedCreateThing.Find}
|
||||||
class:opacity-70={selected_create_thing !== SelectedCreateThing.Find}
|
class:opacity-70={selected_create_thing !== SelectedCreateThing.Find}
|
||||||
>
|
>
|
||||||
@@ -396,6 +402,9 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
on:click={() => {
|
on:click={() => {
|
||||||
selected_play_thing = SelectedPlayThing.Select;
|
selected_play_thing = SelectedPlayThing.Select;
|
||||||
}}
|
}}
|
||||||
|
on:keyup={() => {
|
||||||
|
selected_play_thing = SelectedPlayThing.Select;
|
||||||
|
}}
|
||||||
class:shadow-2xl={selected_play_thing === SelectedPlayThing.Select}
|
class:shadow-2xl={selected_play_thing === SelectedPlayThing.Select}
|
||||||
class:opacity-70={selected_play_thing !== SelectedPlayThing.Select}
|
class:opacity-70={selected_play_thing !== SelectedPlayThing.Select}
|
||||||
>
|
>
|
||||||
@@ -426,6 +435,9 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
on:click={() => {
|
on:click={() => {
|
||||||
selected_play_thing = SelectedPlayThing.Results;
|
selected_play_thing = SelectedPlayThing.Results;
|
||||||
}}
|
}}
|
||||||
|
on:keyup={() => {
|
||||||
|
selected_play_thing = SelectedPlayThing.Results;
|
||||||
|
}}
|
||||||
class:shadow-2xl={selected_play_thing === SelectedPlayThing.Results}
|
class:shadow-2xl={selected_play_thing === SelectedPlayThing.Results}
|
||||||
class:opacity-70={selected_play_thing !== SelectedPlayThing.Results}
|
class:opacity-70={selected_play_thing !== SelectedPlayThing.Results}
|
||||||
>
|
>
|
||||||
@@ -456,6 +468,9 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
on:click={() => {
|
on:click={() => {
|
||||||
selected_play_thing = SelectedPlayThing.Winners;
|
selected_play_thing = SelectedPlayThing.Winners;
|
||||||
}}
|
}}
|
||||||
|
on:keyup={() => {
|
||||||
|
selected_play_thing = SelectedPlayThing.Winners;
|
||||||
|
}}
|
||||||
class:shadow-2xl={selected_play_thing === SelectedPlayThing.Winners}
|
class:shadow-2xl={selected_play_thing === SelectedPlayThing.Winners}
|
||||||
class:opacity-70={selected_play_thing !== SelectedPlayThing.Winners}
|
class:opacity-70={selected_play_thing !== SelectedPlayThing.Winners}
|
||||||
>
|
>
|
||||||
@@ -511,6 +526,9 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
on:click={() => {
|
on:click={() => {
|
||||||
selected_classquiz_reason = index;
|
selected_classquiz_reason = index;
|
||||||
}}
|
}}
|
||||||
|
on:keyup={() => {
|
||||||
|
selected_classquiz_reason = index;
|
||||||
|
}}
|
||||||
class:shadow-2xl={selected_classquiz_reason === index}
|
class:shadow-2xl={selected_classquiz_reason === index}
|
||||||
class:opacity-70={selected_classquiz_reason !== index}
|
class:opacity-70={selected_classquiz_reason !== index}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
on:click={() => {
|
on:click={() => {
|
||||||
selected_method = 'PASSKEY';
|
selected_method = 'PASSKEY';
|
||||||
}}
|
}}
|
||||||
|
on:keyup={() => {
|
||||||
|
selected_method = 'PASSKEY';
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<!-- heroicons/key -->
|
<!-- heroicons/key -->
|
||||||
<svg
|
<svg
|
||||||
@@ -61,6 +64,9 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
on:click={() => {
|
on:click={() => {
|
||||||
selected_method = 'PASSWORD';
|
selected_method = 'PASSWORD';
|
||||||
}}
|
}}
|
||||||
|
on:keyup={() => {
|
||||||
|
selected_method = 'PASSWORD';
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<!-- iconoir/password-cursor -->
|
<!-- iconoir/password-cursor -->
|
||||||
<svg
|
<svg
|
||||||
@@ -104,6 +110,9 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
on:click={() => {
|
on:click={() => {
|
||||||
selected_method = 'TOTP';
|
selected_method = 'TOTP';
|
||||||
}}
|
}}
|
||||||
|
on:keyup={() => {
|
||||||
|
selected_method = 'TOTP';
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<!-- heroicons/clock -->
|
<!-- heroicons/clock -->
|
||||||
<svg
|
<svg
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ SPDX-FileCopyrightText: 2023 Marlon W (Mawoka)
|
|||||||
SPDX-License-Identifier: MPL-2.0
|
SPDX-License-Identifier: MPL-2.0
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getLocalization } from '$lib/i18n';
|
import { getLocalization } from '$lib/i18n';
|
||||||
import OAuthBlock from './oauth_block.svelte';
|
import OAuthBlock from './oauth_block.svelte';
|
||||||
@@ -17,11 +19,13 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
let isSubmitting = false;
|
let isSubmitting = false;
|
||||||
|
|
||||||
$: emailEmpty = email === '';
|
$: emailEmpty = email === '';
|
||||||
|
|
||||||
const start_login = async (): Promise<void> => {
|
const start_login = async (): Promise<void> => {
|
||||||
if (emailEmpty) {
|
if (emailEmpty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isSubmitting = true;
|
isSubmitting = true;
|
||||||
|
|
||||||
const res = await fetch('/api/v1/login/start', {
|
const res = await fetch('/api/v1/login/start', {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -32,6 +32,14 @@ const config = {
|
|||||||
build: {
|
build: {
|
||||||
sourcemap: true
|
sourcemap: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Trying
|
||||||
|
|
||||||
|
ssr: {
|
||||||
|
noExternal: ['@ckeditor/*'],
|
||||||
|
}
|
||||||
|
|
||||||
|
end trying*/
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
|||||||
+7
-10
@@ -9,18 +9,15 @@ run_tests() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
$CONTAINER_BIN container stop classquiz_db
|
$CONTAINER_BIN compose -f docker-compose.dev.yml down --volumes
|
||||||
$CONTAINER_BIN container stop test_redis
|
|
||||||
$CONTAINER_BIN container stop test_meili
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
if [ ! -d /tmp/storage ]; then
|
||||||
mkdir /tmp/storage
|
mkdir /tmp/storage
|
||||||
$CONTAINER_BIN run --rm -d -p 6379:6379 --name test_redis redis:alpine
|
fi
|
||||||
$CONTAINER_BIN run -it --rm -d -p 7700:7700 --name test_meili getmeili/meilisearch:v0.28.0
|
$CONTAINER_BIN compose -f docker-compose.dev.yml up -d
|
||||||
$CONTAINER_BIN volume create classquiz_db_data
|
sleep 2
|
||||||
$CONTAINER_BIN run --name classquiz_db -p 5432:5432 --rm -d -e POSTGRES_PASSWORD=mysecretpassword -v classquiz_db_data:/var/lib/postgresql/data -e POSTGRES_DB=classquiz postgres
|
|
||||||
sleep 1
|
|
||||||
pipenv run alembic upgrade head
|
pipenv run alembic upgrade head
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,14 +25,14 @@ case $1 in
|
|||||||
+) init ;;
|
+) init ;;
|
||||||
-) stop ;;
|
-) stop ;;
|
||||||
a)
|
a)
|
||||||
$CONTAINER_BIN volume rm classquiz_db_data
|
$CONTAINER_BIN volume rm classquiz_db
|
||||||
init
|
init
|
||||||
run_tests
|
run_tests
|
||||||
stop
|
stop
|
||||||
;;
|
;;
|
||||||
prepare)
|
prepare)
|
||||||
stop
|
stop
|
||||||
$CONTAINER_BIN volume rm classquiz_db_data
|
$CONTAINER_BIN volume rm classquiz_db
|
||||||
init
|
init
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|||||||
Reference in New Issue
Block a user