Merge pull request #384 from BogPlaymate/master

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