diff --git a/src/wishlists/templates/public/index.html b/src/wishlists/templates/public/index.html new file mode 100644 index 0000000..1d602cf --- /dev/null +++ b/src/wishlists/templates/public/index.html @@ -0,0 +1,9 @@ +{% if wishlist %} +

{{ wishlist.name }}

+ Created on {{ wishlist.created_at }} + {% if wishlist.description %} +

{{ wishlist.description }}

+ {% endif %} +{% else %} +

Wishlist not found.

+{% endif %} \ No newline at end of file diff --git a/src/wishlists/urls.py b/src/wishlists/urls.py index a9d7f56..be37554 100644 --- a/src/wishlists/urls.py +++ b/src/wishlists/urls.py @@ -3,5 +3,7 @@ from django.urls import path from . import views urlpatterns = [ + path("public//", views.public, name="public"), + path("owner//", views.owner, name="owner"), path("", views.index, name="index"), -] \ No newline at end of file +] diff --git a/src/wishlists/views.py b/src/wishlists/views.py index 7aad3ac..ecdbfec 100644 --- a/src/wishlists/views.py +++ b/src/wishlists/views.py @@ -1,5 +1,24 @@ +from uuid import UUID + from django.http import HttpResponse +from django.template import loader +from .models import Wishlist + # Create your views here. def index(request): - return HttpResponse("Hello, world. You're at the wishlists index.") \ No newline at end of file + return HttpResponse("Hello, world. You're at the wishlists index.") + + +def owner(request, wishlist_id: UUID): + wishlist = Wishlist.objects.get(id=wishlist_id) + return HttpResponse(f"You are the owner of wishlist '{wishlist.name}'.") + + +def public(request, wishlist_id: UUID): + wishlist = Wishlist.objects.get(id=wishlist_id) + template = loader.get_template("public/index.html") + context = { + "wishlist": wishlist, + } + return HttpResponse(template.render(context, request)) diff --git a/src/zauberkiste/urls.py b/src/zauberkiste/urls.py index 2af8a93..f16d636 100644 --- a/src/zauberkiste/urls.py +++ b/src/zauberkiste/urls.py @@ -16,4 +16,4 @@ Including another URLconf """ from django.urls import path, include -urlpatterns = [path("wishlist/", include("wishlists.urls"))] +urlpatterns = [path("", include("wishlists.urls"))]