Compare commits
3 commits
dev
...
artikel/pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cadcbce9ee | ||
|
|
d22ae82ca5 | ||
|
|
65f9f76fa9 |
4
.vscode/rundebug.json
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 1,
|
||||
"configurations": []
|
||||
}
|
||||
11
.vscode/settings.json
vendored
|
|
@ -1,24 +1,15 @@
|
|||
{
|
||||
"cSpell.language": "en,de-DE",
|
||||
"cSpell.words": [
|
||||
"Bilgenpumpe",
|
||||
"Bugstrahlruder",
|
||||
"Chiara",
|
||||
"dotenv",
|
||||
"Elli",
|
||||
"Folierung",
|
||||
"dotenv",
|
||||
"Hobbithöhle",
|
||||
"Klampen",
|
||||
"mailtrap",
|
||||
"Masala",
|
||||
"mausis",
|
||||
"Pomorie",
|
||||
"Reinke",
|
||||
"rundgelutschte",
|
||||
"Törnplanung",
|
||||
"Trintella",
|
||||
"uuidv",
|
||||
"Uvendeli",
|
||||
"vergenusswurzeln"
|
||||
],
|
||||
"python.testing.pytestArgs": [
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ dependencies = [
|
|||
"feedparser==6.0.14",
|
||||
"PyJWT==2.15.0",
|
||||
"python-dotenv>=1.0.0",
|
||||
"validators>=0.35.0",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
BACKEND_URL="http://localhost:8000"
|
||||
FRONTEND_URL="http://localhost:4322"
|
||||
FRONTEND_URL="http://localhost:4321"
|
||||
JWT_SECRET="IamALocalSecretAndMustBeReplacedInProduction"
|
||||
ENVIRONMENT="local"
|
||||
MAILTRAP_API_TOKEN="FakedyFake"
|
||||
|
|
|
|||
|
|
@ -30,10 +30,8 @@ security = HTTPBearer()
|
|||
|
||||
def get_token(credentials = Security(security)) -> str:
|
||||
parts = credentials.credentials.split()
|
||||
if parts[0].lower() == "bearer":
|
||||
if len(parts) == 2 and parts[0].lower() == "bearer":
|
||||
return parts[1]
|
||||
else:
|
||||
return parts[0]
|
||||
raise HTTPException(status_code=403, detail="Invalid authorization format")
|
||||
|
||||
def decode_token(token: str)-> str | None:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
from backend.main import app
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
origins = [
|
||||
"http://localhost",
|
||||
]
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=[
|
||||
|
|
|
|||
|
|
@ -6,25 +6,21 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<div id="card">
|
||||
<div class="center"">
|
||||
<img src=" https://blauwasser-mausis.de/BWM_512.webp">
|
||||
</div>
|
||||
<h4 class="accent">Neuer Artikel</h4>
|
||||
<p>{{data.date}} | Autor: {{data.author}} | Lesezeit: {{data.time2read}} min</p>
|
||||
<h1>{{data.title}}</h1>
|
||||
<h2>{{data.subtitle}}</h2>
|
||||
<div>
|
||||
<h1>Neuer Artikel:</h1>
|
||||
<h3>{{data.title}}</h3>
|
||||
<h4>{{data.subtitle}}</h4>
|
||||
<p>{{data.description}}</p>
|
||||
<a href={{data.link}}>
|
||||
<button>⚓︎ Zum Artikel</button>
|
||||
</a>
|
||||
<hr>
|
||||
<div class="center"><a id="hide" href="https://blauwasser-mausis.de/user">
|
||||
<span>Abbestellen</span>
|
||||
</a></p>
|
||||
</div>
|
||||
|
||||
<a id="admin" href="https://backend.blauwasser-mausis.de/admin/newsletter/{{data.secret}}">Approve</a>
|
||||
<a href={{data.link}}>
|
||||
<button>Zum Artikel</button>
|
||||
</a>
|
||||
|
||||
<a href="https://blauwasser-mausis.de/blog/bootsuche-england">
|
||||
<span>Abbestellen</span>
|
||||
</a>
|
||||
|
||||
<a id="admin" href="https://backend.blauwasser-mausis.de/?secret={{data.secret}}">Approve</a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
|
@ -39,54 +35,18 @@
|
|||
|
||||
}
|
||||
|
||||
#card {
|
||||
background-image: linear-gradient(to bottom, #1d3238, #3c6a7b);
|
||||
padding: 16px 32px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.center {
|
||||
div {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
background-color: lightgrey;
|
||||
padding: 32px 64px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 88px;
|
||||
padding: 0 0 16px 0;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
p {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.accent {
|
||||
color: #ffff00;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#hide {
|
||||
color: #bbbebf;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
p,
|
||||
hr {
|
||||
margin: 16px 0 16px 0;
|
||||
}
|
||||
|
||||
p {
|
||||
line-height: 1.5;
|
||||
font-size: 14px;
|
||||
h4 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
button {
|
||||
|
|
@ -94,14 +54,6 @@
|
|||
background-color: azure;
|
||||
border-radius: 3px;
|
||||
border: none;
|
||||
font-weight: 700;
|
||||
color: #1d3238;
|
||||
margin: 16px 0 24px 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
hr {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#admin {
|
||||
|
|
|
|||
|
|
@ -6,23 +6,19 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<div id="card">
|
||||
<div class="center"">
|
||||
<img src=" https://blauwasser-mausis.de/BWM_512.webp">
|
||||
</div>
|
||||
<h4 class="accent">Neuer Artikel</h4>
|
||||
<p>{{data.article.date}} | Autor: {{data.article.author}} | Lesezeit: {{data.article.time2read}} min</p>
|
||||
<h1>{{data.article.title}}</h1>
|
||||
<h2>{{data.article.subtitle}}</h2>
|
||||
<p>{{data.article.description}}</p>
|
||||
<a href={{data.article.link}}>
|
||||
<button>⚓︎ Zum Artikel</button>
|
||||
<div>
|
||||
<h1>Neuer Artikel:</h1>
|
||||
<h3>{{data.title}}</h3>
|
||||
<h4>{{data.subtitle}}</h4>
|
||||
<p>{{data.description}}</p>
|
||||
|
||||
<a href={{data.link}}>
|
||||
<button>Zum Artikel</button>
|
||||
</a>
|
||||
<hr>
|
||||
<div class="center"><a id="hide" href="https://blauwasser-mausis.de/user">
|
||||
|
||||
<a href="https://blauwasser-mausis.de/blog/bootsuche-england">
|
||||
<span>Abbestellen</span>
|
||||
</a></p>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
|
@ -37,54 +33,18 @@
|
|||
|
||||
}
|
||||
|
||||
#card {
|
||||
background-image: linear-gradient(to bottom, #1d3238, #3c6a7b);
|
||||
padding: 16px 32px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.center {
|
||||
div {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
background-color: lightgrey;
|
||||
padding: 32px 64px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 88px;
|
||||
padding: 0 0 16px 0;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
p {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.accent {
|
||||
color: #ffff00;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#hide {
|
||||
color: #bbbebf;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
p,
|
||||
hr {
|
||||
margin: 16px 0 16px 0;
|
||||
}
|
||||
|
||||
p {
|
||||
line-height: 1.5;
|
||||
font-size: 14px;
|
||||
h4 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
button {
|
||||
|
|
@ -92,13 +52,5 @@
|
|||
background-color: azure;
|
||||
border-radius: 3px;
|
||||
border: none;
|
||||
font-weight: 700;
|
||||
color: #1d3238;
|
||||
margin: 16px 0 24px 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
hr {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -6,31 +6,16 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<div id="card">
|
||||
<div class="center"">
|
||||
<img src="https://blauwasser-mausis.de/BWM_512.webp">
|
||||
</div>
|
||||
<div>
|
||||
<p id="welcome"><strong>⚓︎ Willkommen {{data.name}},</strong> du hast dich erfolgreich registriert.</p>
|
||||
<p id="code-text">Dein persönlicher Code zum Anmelden: </p>
|
||||
<p class="accent">{{data.user_code}}</p>
|
||||
<p id="info-text">Du erhälst nun eine Mail, wenn wir einen neuen Artikel veröffentlichen. Auch die
|
||||
zukünftigen Features des Blogs (z.B. Kommentare) kannst du so nutzen.
|
||||
<br />
|
||||
Alle Einstellung kannst du jederzeit in deinem Profil anpassen.
|
||||
</p>
|
||||
<a href="https://blauwasser-mausis.de/login">
|
||||
<button>⚓︎ Jetzt einloggen ⚓︎</button>
|
||||
<h1>Willkommen, {{data.name}}</h1>
|
||||
<p>Du hast dich bei Blauwasser-Mausis.de angemeldet. Solltest du das nicht gewesen sein, dann lösche die Daten einfach über den untenstehenden Link.</p>
|
||||
|
||||
<p>Dein persönlicher Code, um alle Funktionen nutzen zu können: {{data.user_code}}</p>
|
||||
|
||||
<a href="https://blauwasser-mausis.de/">
|
||||
<span>Daten löschen</span>
|
||||
</a>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="center">
|
||||
<p class="hide">Du hast dich nicht registriert? Einfach <a class="hide"
|
||||
href="https://blauwasser-mausis.de/user">hier</a>
|
||||
löschen. </p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -44,70 +29,12 @@
|
|||
|
||||
}
|
||||
|
||||
#card {
|
||||
background-image: linear-gradient(to bottom, #1d3238, #3c6a7b);
|
||||
padding: 16px 32px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.center {
|
||||
div {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 88px;
|
||||
padding: 0 0 16px 0;
|
||||
}
|
||||
|
||||
p {
|
||||
color: white;
|
||||
}
|
||||
|
||||
#welcome {
|
||||
padding-bottom: 8px;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
#code-text {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.accent {
|
||||
color: #ffff00;
|
||||
font-weight: 600;
|
||||
padding: 0px;
|
||||
margin: 0;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
#info-text {
|
||||
padding-top: 12px;
|
||||
}
|
||||
|
||||
p {
|
||||
line-height: 1.5;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 12px;
|
||||
background-color: azure;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
background-color: lightgrey;
|
||||
padding: 32px 64px;
|
||||
border-radius: 3px;
|
||||
border: none;
|
||||
font-weight: 700;
|
||||
color: #1d3238;
|
||||
margin: 16px 0 24px 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
hr {
|
||||
width: 100%;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.hide {
|
||||
color: #bbbebf;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
from mailtrap import Address
|
||||
from mailtrap import BatchMail
|
||||
from pathlib import Path
|
||||
from backend.config import MAILTRAP_API_TOKEN
|
||||
from mailtrap import BatchEmailRequest
|
||||
|
|
@ -12,27 +10,21 @@ from jinja2 import Environment, FileSystemLoader
|
|||
APP_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
class ArticleData():
|
||||
def __init__(self, title, subtitle, description, link, date, author, time2read):
|
||||
def __init__(self, title, subtitle, description, link):
|
||||
self.title=title
|
||||
self.subtitle=subtitle
|
||||
self.description=description
|
||||
self.link=link
|
||||
self.date=date
|
||||
self.author=author
|
||||
self.time2read = time2read
|
||||
|
||||
title: str
|
||||
subtitle: str
|
||||
description: str
|
||||
link: str
|
||||
date: str
|
||||
author: str
|
||||
time2read: str
|
||||
|
||||
|
||||
class AdminApprovalData(ArticleData):
|
||||
def __init__(self,title, subtitle, description, link, date, author, time2read, secret):
|
||||
ArticleData.__init__(self, title, subtitle, description, link, date, author, time2read)
|
||||
def __init__(self,title, subtitle, description, link, secret):
|
||||
ArticleData.__init__(self, title, subtitle, description, link)
|
||||
self.secret = secret
|
||||
|
||||
secret: str
|
||||
|
|
@ -72,11 +64,13 @@ def send_batch_mail(mails: list[BatchEmailRequest]):
|
|||
else:
|
||||
client = mt.MailtrapClient(token=MAILTRAP_API_TOKEN)
|
||||
params = BatchSendEmailParams(
|
||||
base=BatchMail(
|
||||
sender=Address(
|
||||
email="newsletter@blauwasser-mausis.de",
|
||||
name="Blauwasser Mausis"),
|
||||
subject="Flaschenpost | Blauwasser Mausis"),
|
||||
base={
|
||||
"from": {
|
||||
"name": "Blauwasser Mausis",
|
||||
"email": "newsletter@blauwasser-mausis.de"
|
||||
},
|
||||
"subject": "Flaschenpost | Blauwasser Mausis",
|
||||
},
|
||||
requests=mails
|
||||
)
|
||||
client.batch_send(params)
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
from feedparser import FeedParserDict
|
||||
from backend.config import FRONTEND_URL
|
||||
from backend.internal.authentication import create_access_token
|
||||
|
|
@ -12,17 +13,15 @@ def check_blog_rss_and_send_admin_mail():
|
|||
for article in feed.entries:
|
||||
date_string = str(article["published"])
|
||||
date_object = datetime.strptime(date_string, '%a, %d %b %Y %H:%M:%S %Z')
|
||||
if date_object > (datetime.now() - timedelta(days=1)):
|
||||
|
||||
if date_object > (datetime.now() - timedelta(days=16)):
|
||||
title = str(article["title"])
|
||||
description = str(article["summary"])
|
||||
subtitle = str(article["subtitle"])
|
||||
link = str(article["link"])
|
||||
author = str(article["author"])
|
||||
time2read = str(article["time2read"])
|
||||
date = date_object.strftime('%d.%m.%y')
|
||||
secret = create_access_token({"sub": title})
|
||||
|
||||
data = AdminApprovalData(title, subtitle, description, link, date, author, time2read, secret)
|
||||
data = AdminApprovalData(title, subtitle, description, link, secret)
|
||||
send_newsletter_admin_approval(data)
|
||||
|
||||
def find_article_by_title(title: str) -> FeedParserDict | None:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
|
||||
from dotenv.main import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
from .routers import users, comments, newsletters, health, reactions
|
||||
from .routers import users, comments, newsletters, health
|
||||
from backend.internal.database import create_db_and_tables
|
||||
from fastapi import FastAPI
|
||||
from fastapi_crons import Crons
|
||||
|
|
@ -10,7 +11,7 @@ from backend.internal.rss_reader import check_blog_rss_and_send_admin_mail
|
|||
app = FastAPI()
|
||||
crons = Crons(app)
|
||||
|
||||
@crons.cron("0 13 * * *", name="RSS-Check")
|
||||
@crons.cron("0 14 * * *", name="RSS-Check")
|
||||
async def check_for_new_article():
|
||||
check_blog_rss_and_send_admin_mail()
|
||||
|
||||
|
|
@ -22,6 +23,5 @@ def on_startup():
|
|||
|
||||
app.include_router(users.router)
|
||||
app.include_router(comments.router)
|
||||
app.include_router(reactions.router)
|
||||
app.include_router(newsletters.router)
|
||||
app.include_router(health.router)
|
||||
|
|
@ -3,17 +3,3 @@
|
|||
|
||||
#Reference: https://isaacfei.com/posts/simple-like-system/
|
||||
|
||||
from sqlmodel import UUID
|
||||
import uuid
|
||||
from sqlmodel import table
|
||||
from dataclasses import dataclass
|
||||
from sqlmodel import Field
|
||||
from sqlmodel import SQLModel
|
||||
|
||||
class BaseReaction(SQLModel):
|
||||
pass
|
||||
|
||||
@dataclass
|
||||
class Reaction(BaseReaction, table=True):
|
||||
slug: str = Field(primary_key=True)
|
||||
browser_id: str = Field(primary_key=True)
|
||||
|
|
@ -1,8 +1,12 @@
|
|||
from sqlmodel._compat import ConfigDict
|
||||
from uuid import uuid7
|
||||
from datetime import datetime
|
||||
from backend.internal.user_code_gen import generate_user_code
|
||||
import uuid
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlmodel import Relationship, SQLModel, Field
|
||||
from sqlmodel import Field
|
||||
from sqlmodel import Relationship
|
||||
from sqlmodel import SQLModel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from backend.models.comment import Comment
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter(tags=["health"])
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/health", include_in_schema=False)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime
|
||||
from mailtrap import Address
|
||||
from backend.internal.mail_util import create_html_from_template
|
||||
from mailtrap import BatchEmailRequest
|
||||
from mailtrap import BatchMail
|
||||
from backend.internal.mail_util import send_batch_mail
|
||||
from starlette.status import HTTP_400_BAD_REQUEST
|
||||
from fastapi import HTTPException
|
||||
|
|
@ -23,7 +23,6 @@ router = APIRouter(
|
|||
|
||||
@router.post(
|
||||
path="/approve",
|
||||
tags=["newsletter"],
|
||||
status_code=201
|
||||
)
|
||||
def approve_newsletter(secret: str = Form(), session: Session = Depends(get_session)):
|
||||
|
|
@ -31,20 +30,10 @@ def approve_newsletter(secret: str = Form(), session: Session = Depends(get_sess
|
|||
if title is not None:
|
||||
article = find_article_by_title(title)
|
||||
if article is not None:
|
||||
date_object = datetime.strptime(str(article["published"]), '%a, %d %b %Y %H:%M:%S %Z')
|
||||
article_data = {
|
||||
"title": article["title"],
|
||||
"subtitle": article["subtitle"],
|
||||
"description": article["summary"],
|
||||
"link": article["link"],
|
||||
"author": article["author"],
|
||||
"time2read": article["time2read"],
|
||||
"date": date_object.strftime('%d.%m.%y'),
|
||||
}
|
||||
subscribed_users = session.exec(select(User).where(User.subscription == True))
|
||||
mails: list[BatchEmailRequest] = []
|
||||
for user in subscribed_users:
|
||||
html = create_html_from_template("newsletter", {"user": user, "article": article_data })
|
||||
html = create_html_from_template("newsletter", user)
|
||||
mail = BatchEmailRequest(to=[Address(email=user.email,name=user.name)],html=html)
|
||||
mails.append(mail)
|
||||
send_batch_mail(mails)
|
||||
|
|
|
|||
|
|
@ -1,50 +1,5 @@
|
|||
from os import stat
|
||||
from sqlmodel import select
|
||||
from starlette.status import HTTP_400_BAD_REQUEST
|
||||
from fastapi import HTTPException
|
||||
from backend.models.reaction import Reaction
|
||||
from backend.internal.database import get_session
|
||||
from fastapi import Depends
|
||||
from sqlmodel import Session
|
||||
from fastapi import APIRouter
|
||||
router = APIRouter(
|
||||
prefix="/reactions",
|
||||
tags=["reactions"]
|
||||
)
|
||||
|
||||
@router.post("", status_code=201)
|
||||
def create_reaction(reaction: Reaction, session: Session = Depends(get_session)):
|
||||
print(reaction)
|
||||
try:
|
||||
session.add(reaction)
|
||||
session.commit()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
session.rollback()
|
||||
raise HTTPException(HTTP_400_BAD_REQUEST)
|
||||
|
||||
|
||||
@router.get("/{slug}", status_code=200)
|
||||
def get_reaction_count_for_post(slug: str, session: Session = Depends(get_session))-> int:
|
||||
reactions = session.exec(select(Reaction).where(Reaction.slug == slug)).all()
|
||||
print(reactions)
|
||||
return len(reactions)
|
||||
|
||||
@router.get("/", status_code=200)
|
||||
def have_i_reacted(slug:str, browser_id: str, session: Session = Depends(get_session)) -> bool:
|
||||
result = session.exec(select(Reaction).where(Reaction.slug == slug, Reaction.browser_id == browser_id)).one_or_none()
|
||||
if (result): return True
|
||||
else: return False
|
||||
|
||||
@router.delete("", status_code=200)
|
||||
def delete_reaction(reaction: Reaction, session: Session = Depends(get_session)) :
|
||||
db_reaction = session.exec(select(Reaction).where(Reaction.slug == reaction.slug, Reaction.browser_id == reaction.browser_id)).one_or_none()
|
||||
try:
|
||||
session.delete(db_reaction)
|
||||
session.commit()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
session.rollback()
|
||||
raise HTTPException(HTTP_400_BAD_REQUEST)
|
||||
|
||||
# addReaction
|
||||
# delete Reaction
|
||||
# get Reactions by slug
|
||||
|
|
@ -1,6 +1,3 @@
|
|||
from starlette.status import HTTP_500_INTERNAL_SERVER_ERROR
|
||||
import validators
|
||||
from starlette.status import HTTP_406_NOT_ACCEPTABLE
|
||||
from mailtrap import Address
|
||||
from backend.internal.mail_util import send_mail
|
||||
from backend.internal.mail_util import create_html_from_template
|
||||
|
|
@ -26,7 +23,7 @@ from fastapi_limiter.depends import RateLimiter
|
|||
|
||||
router = APIRouter(
|
||||
prefix="/users",
|
||||
tags=["users"],
|
||||
dependencies=[],
|
||||
responses={404: {"description": "Not found"}},
|
||||
)
|
||||
|
||||
|
|
@ -38,12 +35,6 @@ router = APIRouter(
|
|||
def register_user(new_user: NewUser, session: Session = Depends(get_session)):
|
||||
user = User.model_validate(new_user)
|
||||
|
||||
if (user.name == ''):
|
||||
raise HTTPException(HTTP_406_NOT_ACCEPTABLE, "Nutzername muss einen Wert enthalten")
|
||||
elif(not validators.email(user.email)):
|
||||
raise HTTPException(HTTP_406_NOT_ACCEPTABLE, "Email nicht valide")
|
||||
|
||||
|
||||
try:
|
||||
session.add(user)
|
||||
session.commit()
|
||||
|
|
@ -59,13 +50,6 @@ def register_user(new_user: NewUser, session: Session = Depends(get_session)):
|
|||
|
||||
except IntegrityError as e:
|
||||
session.rollback()
|
||||
|
||||
if ("UNIQUE" in str(e)):
|
||||
if ("user.name" in str(e) or "user.email" in str(e)):
|
||||
raise HTTPException(HTTP_406_NOT_ACCEPTABLE)
|
||||
if ("user.user_code" in str(e)):
|
||||
raise HTTPException(HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
else:
|
||||
raise HTTPException(HTTP_400_BAD_REQUEST)
|
||||
except Exception:
|
||||
session.rollback()
|
||||
|
|
@ -73,7 +57,7 @@ def register_user(new_user: NewUser, session: Session = Depends(get_session)):
|
|||
|
||||
@router.post(
|
||||
path="/login",
|
||||
status_code=200,
|
||||
status_code=201,
|
||||
dependencies=[Depends(RateLimiter(limiter=Limiter(Rate(3, Duration.SECOND * 30))))]
|
||||
)
|
||||
def login(user_code: str = Form(), session: Session = Depends(get_session)) -> str:
|
||||
|
|
@ -94,28 +78,26 @@ def forgot_user_code(email: str = Form(), session: Session = Depends(get_session
|
|||
pass # TODO: send Mail
|
||||
|
||||
|
||||
@router.get(path="/me", status_code=200)
|
||||
@router.get(path="/me", status_code=201)
|
||||
def get_current_user_info(current_user: User = Depends(get_current_user)) -> UserInfo:
|
||||
return UserInfo.model_validate(current_user)
|
||||
|
||||
|
||||
@router.delete(path="/me", status_code=200)
|
||||
@router.delete(path="/me", status_code=201)
|
||||
def delete(current_user: User = Depends(get_current_user), session: Session = Depends(get_session)) :
|
||||
session.delete(current_user)
|
||||
session.commit()
|
||||
|
||||
|
||||
@router.put(path="/me/subscription", status_code=200)
|
||||
@router.put(path="/me/subscribe", status_code=201)
|
||||
def change_subscription(
|
||||
subscription: bool = Form(),
|
||||
current_user: User = Depends(get_current_user),
|
||||
session: Session = Depends(get_session)
|
||||
):
|
||||
|
||||
current_user.subscription = subscription
|
||||
session.add(current_user)
|
||||
session.commit()
|
||||
session.refresh(current_user)
|
||||
|
||||
|
||||
# TODO:
|
||||
|
|
|
|||
11
backend/uv.lock
generated
|
|
@ -202,7 +202,6 @@ dependencies = [
|
|||
{ name = "pytest" },
|
||||
{ name = "python-dotenv" },
|
||||
{ name = "sqlmodel" },
|
||||
{ name = "validators" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
|
|
@ -217,7 +216,6 @@ requires-dist = [
|
|||
{ name = "pytest", specifier = ">=9.1.1" },
|
||||
{ name = "python-dotenv", specifier = ">=1.0.0" },
|
||||
{ name = "sqlmodel", specifier = ">=0.0.42" },
|
||||
{ name = "validators", specifier = ">=0.35.0" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1896,15 +1894,6 @@ wheels = [
|
|||
{ url = "https://files.pythonhosted.org/packages/e4/16/c1fd27e9549f3c4baf1dc9c20c456cd2f822dbf8de9f463824b0c0357e06/uvloop-0.22.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:6cde23eeda1a25c75b2e07d39970f3374105d5eafbaab2a4482be82f272d5a5e", size = 4296730, upload-time = "2025-10-16T22:17:00.744Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "validators"
|
||||
version = "0.35.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/53/66/a435d9ae49850b2f071f7ebd8119dd4e84872b01630d6736761e6e7fd847/validators-0.35.0.tar.gz", hash = "sha256:992d6c48a4e77c81f1b4daba10d16c3a9bb0dbb79b3a19ea847ff0928e70497a", size = 73399, upload-time = "2025-05-01T05:42:06.7Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/fa/6e/3e955517e22cbdd565f2f8b2e73d52528b14b8bcfdb04f62466b071de847/validators-0.35.0-py3-none-any.whl", hash = "sha256:e8c947097eae7892cb3d26868d637f79f47b4a0554bc6b80065dfe5aac3705dd", size = 44712, upload-time = "2025-05-01T05:42:04.203Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "watchfiles"
|
||||
version = "1.2.0"
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
PUBLIC_API_URL="https://api.blauwasser-mausis.de"
|
||||
1
blog/.gitignore
vendored
|
|
@ -15,6 +15,7 @@ pnpm-debug.log*
|
|||
|
||||
# environment variables
|
||||
.env
|
||||
.env.production
|
||||
|
||||
# macOS-specific files
|
||||
.DS_Store
|
||||
|
|
|
|||
|
|
@ -15,32 +15,24 @@ All commands are run from the root of the project, from a terminal:
|
|||
|
||||
## Bilder für Webuseage convertieren
|
||||
|
||||
```
|
||||
for file in *.{jpg,png}; magick "$file" -resize 50% "$file"; end
|
||||
```
|
||||
`for file in *.{jpg,png}; magick "$file" -resize 50% "$file"; end`
|
||||
|
||||
```
|
||||
magick mogrify -format webp -quality 80 *.{jpg,png}
|
||||
```
|
||||
`magick mogrify -format webp -quality 80 *.{jpg,png}`
|
||||
|
||||
```
|
||||
for file in *.{jpg,png}; magick "$file" -auto-orient "$file"; end
|
||||
```
|
||||
`for file in *.{jpg,png}; magick "$file" -auto-orient "$file"; end`
|
||||
|
||||
|
||||
## Vorlage für MDX-Artikel
|
||||
|
||||
```
|
||||
---
|
||||
title:
|
||||
subtitle:
|
||||
description:
|
||||
introduction:
|
||||
image:
|
||||
path: titelbild_artikelordner.webp
|
||||
alt:
|
||||
author: Bernd das Brot
|
||||
date: 2026-11-10
|
||||
date: 2026-08-29
|
||||
slug: Wie-soll-die-URL-aussehen?
|
||||
time2read: 0
|
||||
---
|
||||
|
|
@ -48,11 +40,8 @@ import BlogLink from '../../components/blog/BlogLink.astro'
|
|||
import SingleImage from '../../components/blog/SingleImage.astro'
|
||||
import DoubleImage from '../../components/blog/DoubleImage.astro'
|
||||
|
||||
|
||||
<br />
|
||||
## Große Überschrift für einen Abschnitt
|
||||
|
||||
Textus schreibus.
|
||||
Hier kann man in den Artikel einleiten.<br />
|
||||
Evtl. ist es das gleiche wie die Beschreibung.
|
||||
|
||||
---
|
||||
<br />
|
||||
|
|
@ -88,5 +77,4 @@ Lorem Ipsum
|
|||
alt2=""
|
||||
description=""
|
||||
/>
|
||||
<BlogLink url="https://www.loremipsum.com/">Text</BlogLink>
|
||||
```
|
||||
<BlogLink text="Lorem Ipsum" url="https://www.loremipsum.com/" />
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'astro/config';
|
||||
import mdx from '@astrojs/mdx';
|
||||
import preact from '@astrojs/preact';
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
|
|
@ -10,5 +9,5 @@ export default defineConfig({
|
|||
build: {
|
||||
assets: '_assets',
|
||||
},
|
||||
integrations: [mdx(), preact()]
|
||||
integrations: [mdx()]
|
||||
});
|
||||
|
|
|
|||
1960
blog/package-lock.json
generated
|
|
@ -13,15 +13,9 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@astrojs/mdx": "^7.0.8",
|
||||
"@astrojs/preact": "^6.0.5",
|
||||
"@astrojs/preact": "^6.0.2",
|
||||
"@astrojs/rss": "^4.0.19",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"astro": "^7.2.2",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"preact": "^10.29.8",
|
||||
"uuid": "^14.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jsonwebtoken": "^9.0.10"
|
||||
"preact": "^10.29.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 269 KiB |
|
Before Width: | Height: | Size: 282 KiB |
|
Before Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 253 KiB |
|
Before Width: | Height: | Size: 326 KiB |
|
Before Width: | Height: | Size: 315 KiB |
|
Before Width: | Height: | Size: 169 KiB |
|
Before Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 301 KiB |
|
Before Width: | Height: | Size: 194 KiB |
|
Before Width: | Height: | Size: 173 KiB |
|
Before Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 349 KiB |
|
Before Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 281 KiB |
|
Before Width: | Height: | Size: 302 KiB |
|
Before Width: | Height: | Size: 328 KiB |
|
Before Width: | Height: | Size: 302 KiB |
|
Before Width: | Height: | Size: 251 KiB |
|
Before Width: | Height: | Size: 381 KiB |
|
Before Width: | Height: | Size: 469 KiB |
|
Before Width: | Height: | Size: 235 KiB |
|
Before Width: | Height: | Size: 381 KiB |
|
Before Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 133 KiB |
|
Before Width: | Height: | Size: 272 KiB |
|
Before Width: | Height: | Size: 157 KiB |
|
Before Width: | Height: | Size: 198 KiB |
|
Before Width: | Height: | Size: 187 KiB |
|
Before Width: | Height: | Size: 291 KiB |
|
Before Width: | Height: | Size: 199 KiB |
|
Before Width: | Height: | Size: 412 KiB |
|
Before Width: | Height: | Size: 188 KiB |
|
Before Width: | Height: | Size: 162 KiB |
|
Before Width: | Height: | Size: 120 KiB |
|
Before Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 123 KiB |
|
Before Width: | Height: | Size: 203 KiB |
|
Before Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 358 KiB |
|
Before Width: | Height: | Size: 350 KiB |
|
Before Width: | Height: | Size: 398 KiB |
|
Before Width: | Height: | Size: 345 KiB |
|
Before Width: | Height: | Size: 456 KiB |
|
Before Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 315 KiB |
|
Before Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 234 KiB |
|
Before Width: | Height: | Size: 462 KiB |
|
Before Width: | Height: | Size: 564 KiB |
|
Before Width: | Height: | Size: 687 KiB |
|
Before Width: | Height: | Size: 340 KiB |
|
Before Width: | Height: | Size: 142 KiB |
|
Before Width: | Height: | Size: 165 KiB |
|
Before Width: | Height: | Size: 322 KiB |
|
Before Width: | Height: | Size: 316 KiB |
|
Before Width: | Height: | Size: 243 KiB |
|
Before Width: | Height: | Size: 256 KiB |
|
Before Width: | Height: | Size: 289 KiB |
|
Before Width: | Height: | Size: 162 KiB |
BIN
blog/public/blog_img/praktikum/3x3.jpg
Normal file
|
After Width: | Height: | Size: 302 KiB |
BIN
blog/public/blog_img/praktikum/4x4.jpg
Normal file
|
After Width: | Height: | Size: 319 KiB |
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 94 KiB |
BIN
blog/public/blog_img/praktikum/bauverlauf_1.jpg
Normal file
|
After Width: | Height: | Size: 628 KiB |
BIN
blog/public/blog_img/praktikum/bauverlauf_2.jpg
Normal file
|
After Width: | Height: | Size: 372 KiB |
BIN
blog/public/blog_img/praktikum/beispiel_anwendung.webp
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
blog/public/blog_img/praktikum/beispiel_anwendungszweck.jpg
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
blog/public/blog_img/praktikum/detailansicht.jpg
Normal file
|
After Width: | Height: | Size: 2.2 MiB |
BIN
blog/public/blog_img/praktikum/erste_versuche.jpg
Normal file
|
After Width: | Height: | Size: 281 KiB |
BIN
blog/public/blog_img/praktikum/fahrradfahren_im_regen.jpg
Normal file
|
After Width: | Height: | Size: 160 KiB |
BIN
blog/public/blog_img/praktikum/im_zelt.jpeg
Normal file
|
After Width: | Height: | Size: 315 KiB |
BIN
blog/public/blog_img/praktikum/mein_balkon.jpg
Normal file
|
After Width: | Height: | Size: 457 KiB |
BIN
blog/public/blog_img/praktikum/prinzip.png
Normal file
|
After Width: | Height: | Size: 618 KiB |