Translate the whole site to English: English routes with 301 redirects from the Dutch paths, English UI, docs, seeds and captions, one-time live content migration
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
import hashlib
|
||||
|
||||
from fastapi import APIRouter, Request
|
||||
|
||||
from molodetz import config
|
||||
from molodetz.database import admin_uids_ordered, insert_join_request
|
||||
from molodetz.dependencies import json_or_form
|
||||
from molodetz.models import JoinForm
|
||||
from molodetz.responses import action_result, respond
|
||||
from molodetz.schemas.joins import JoinPageOut
|
||||
from molodetz.seo import base_seo_context
|
||||
from molodetz.seo_meta_text import description_for
|
||||
from molodetz.utils.audit import record
|
||||
from molodetz.utils.notifications import create_notification
|
||||
from molodetz.utils.request_meta import client_ip
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
def _seo(request):
|
||||
return base_seo_context(request, "Join", description_for("join"), breadcrumbs=[("Molodetz", "/"), ("Join", "/join")])
|
||||
|
||||
|
||||
@router.get("")
|
||||
async def join_page(request: Request):
|
||||
submitted = request.query_params.get("ok") == "1"
|
||||
return respond(request, "join.html", {"submitted": submitted, "errors": [], "form": {}, "seo": _seo(request)}, model=JoinPageOut)
|
||||
|
||||
|
||||
@router.post("")
|
||||
async def join_submit(request: Request):
|
||||
data = await json_or_form(request, JoinForm)
|
||||
if data.website:
|
||||
record(request, "join.request.honeypot", result="denied")
|
||||
return action_result(request, "/join?ok=1")
|
||||
ip_hash = hashlib.sha256(f"{config.SECRET_KEY}:{client_ip(request)}".encode()).hexdigest()[:24]
|
||||
row = insert_join_request(data.name, data.contact, data.repo_url, data.message, ip_hash)
|
||||
record(request, "join.request.create", payload={"uid": row["uid"]}, targets=[("join_request", row["uid"])])
|
||||
for uid in admin_uids_ordered():
|
||||
create_notification(uid, "join.request", f"{data.name} wants to write along", "/admin/joins")
|
||||
return action_result(request, "/join?ok=1", data={"uid": row["uid"]})
|
||||
Reference in New Issue
Block a user