Add Space metadata model and provisional Forgejo content ADR
Introduce tenant-scoped Space/SpaceMembership with list and detail views. Document markdown-in-Forgejo as content SoR (ADR-0002). Run migrations on container start so app.coulomb.social picks up the new tables.
This commit is contained in:
parent
bb6bc6093a
commit
be32432d39
22 changed files with 697 additions and 12 deletions
34
coulomb_social/apps/spaces/views.py
Normal file
34
coulomb_social/apps/spaces/views.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
from django.contrib.auth.decorators import login_required
|
||||
from django.http import HttpRequest, HttpResponse, HttpResponseForbidden, HttpResponseNotFound
|
||||
from django.shortcuts import render
|
||||
|
||||
from coulomb_social.apps.core.principal import build_principal
|
||||
|
||||
from .services import get_space_for_member, spaces_for_member
|
||||
|
||||
|
||||
@login_required
|
||||
def space_detail(request: HttpRequest, slug: str) -> HttpResponse:
|
||||
principal = build_principal(request, authz_resource_id="space_detail")
|
||||
if not principal["authz_allow"]:
|
||||
return HttpResponseForbidden(
|
||||
f"Not authorized to view spaces ({principal['authz_reason']})."
|
||||
)
|
||||
member = principal.get("member")
|
||||
space = get_space_for_member(member, slug)
|
||||
if space is None:
|
||||
return HttpResponseNotFound("Space not found.")
|
||||
return render(
|
||||
request,
|
||||
"spaces/detail.html",
|
||||
{
|
||||
"principal": principal,
|
||||
"display_name": principal["display_name"],
|
||||
"space": space,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
# used by core.app_home — re-export list helper
|
||||
def list_spaces_context(member) -> dict:
|
||||
return {"spaces": list(spaces_for_member(member))}
|
||||
Loading…
Add table
Add a link
Reference in a new issue