From 70bd8ebf6e0de202cb3a4f52f39766e69f146053 Mon Sep 17 00:00:00 2001 From: Bobby <30593201+luciferreeves@users.noreply.github.com> Date: Tue, 17 Dec 2024 20:58:14 +0000 Subject: journals just became somewhat real --- apps/core/views.py | 4 +- apps/journals/urls.py | 4 +- apps/journals/views.py | 17 +++++ templates/en/core/my/journals.html | 2 +- templates/en/journals/single.html | 140 +++++++++++++++++++++++++++++++++++++ thatcomputerscientist/settings.py | 2 +- 6 files changed, 164 insertions(+), 5 deletions(-) create mode 100644 templates/en/journals/single.html diff --git a/apps/core/views.py b/apps/core/views.py index 1790098a..abe1d539 100644 --- a/apps/core/views.py +++ b/apps/core/views.py @@ -13,7 +13,7 @@ def home(request): "title": "Home", } LANGUAGE_CODE = i18npatterns(request.LANGUAGE_CODE) - request.META.update(META) + request.meta.update(META) announcements = Announcement.objects.filter(is_public=True).order_by("-created_at") context = { "announcements": announcements, @@ -29,7 +29,7 @@ def my_journals(request): "title": "My Journals", } LANGUAGE_CODE = i18npatterns(request.LANGUAGE_CODE) - request.META.update(META) + request.meta.update(META) journals = Journal.objects.filter(owner=request.user).order_by("-created_at") context = { "journals": journals, diff --git a/apps/journals/urls.py b/apps/journals/urls.py index 1f7413c2..b4e7db01 100644 --- a/apps/journals/urls.py +++ b/apps/journals/urls.py @@ -3,4 +3,6 @@ from django.urls import path from . import views app_name = "journal" -urlpatterns = [] +urlpatterns = [ + path("/", views.single_journal, name="single"), +] diff --git a/apps/journals/views.py b/apps/journals/views.py index 91ea44a2..9c3f99f7 100644 --- a/apps/journals/views.py +++ b/apps/journals/views.py @@ -1,3 +1,20 @@ from django.shortcuts import render +from apps.journals.models import Journal +from thatcomputerscientist.utils import i18npatterns + # Create your views here. +def single_journal(request, slug): + try: + journal = Journal.objects.get(slug=slug) + except Journal.DoesNotExist: + journal = None + META = { + "title": f"Journal: {journal.name}" if journal else "Journal Not Found", + } + LANGUAGE_CODE = i18npatterns(request.LANGUAGE_CODE) + request.meta.update(META) + context = { + "journal": journal, + } + return render(request, f"{LANGUAGE_CODE}/journals/single.html", context) diff --git a/templates/en/core/my/journals.html b/templates/en/core/my/journals.html index a3be14bb..b265aed8 100644 --- a/templates/en/core/my/journals.html +++ b/templates/en/core/my/journals.html @@ -78,7 +78,7 @@
{{ journal.private }}
{{ journal.entries.all|length }}
- View + View Manage
diff --git a/templates/en/journals/single.html b/templates/en/journals/single.html new file mode 100644 index 00000000..e538949f --- /dev/null +++ b/templates/en/journals/single.html @@ -0,0 +1,140 @@ +{% extends 'shared/base.html' %} +{% load static %} +{% block head %} + +{% endblock head %} +{% block content %} +
+

{{ journal.name }}

+

+
+
+
+ {% with journal.owner.userprofile_set.first as journal_holder_profile %} +

Journal Holder's Profile

+ {{ journal.owner.first_name }}'s Avatar +
+

Profile

+

{{ journal.owner.first_name }} {{ journal.owner.last_name }}

+
+
+

Bio

+

{{ journal_holder_profile.bio|linebreaksbr }}

+
+
+

XP

+

{{ journal_holder_profile.experience }} / 1000

+
+
+

Level

+

{{ journal_holder_profile.level }}

+
+
+

Journal Entries

+

{{ journal.entries.all|length }}

+
+
+

Journal Streak

+

{{ journal_holder_profile.journal_streak }} days

+
+
+

Weblog Posts

+

{{ journal_holder_profile.weblogs_created }}

+
+ {% endwith %} +
+
+
+

{{ journal.entries.all|length }} entries

+ {% for entry in journal.entries.all %} +
+

{{ entry.title }}

+

Posted on {{ entry.created_at|date:"F j, Y" }}

+
+

{{ entry.body|linebreaksbr }}

+
+ {% endfor %} +
+
+{% endblock content %} \ No newline at end of file diff --git a/thatcomputerscientist/settings.py b/thatcomputerscientist/settings.py index a2f3b817..726415a3 100644 --- a/thatcomputerscientist/settings.py +++ b/thatcomputerscientist/settings.py @@ -116,9 +116,9 @@ MIDDLEWARE = [ "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", # "whitenoise.middleware.WhiteNoiseMiddleware", + "middleware.globalmetamiddleware.GlobalMetaMiddleware", "middleware.i18nmiddleware.I18NMiddleware", "middleware.userprofilemiddleware.UserProfileMiddleware", - "middleware.globalmetamiddleware.GlobalMetaMiddleware", # "middleware.oldbrowsermiddleware.OldBrowserMiddleware", # "middleware.ignismiddleware.IgnisMiddleware", # "middleware.uuidmiddleware.UserUUIDMiddleware", -- cgit v1.2.3