From dcc1a6c6ee790dc5b6ad52be52ee719d4d893425 Mon Sep 17 00:00:00 2001
From: Tobias Mieves <tobias.mieves@tu-dortmund.de>
Date: Thu, 4 Apr 2024 23:51:21 +0200
Subject: [PATCH] New Changes

---
 .gitignore                                 |  5 +++-
 core/settings.py                           | 10 +++++--
 core/urls.py                               | 15 ----------
 requirements.txt                           |  2 +-
 templates/base.html                        |  6 ++--
 templates/django/forms/div.html            | 32 ++++++++++++++++++++++
 templates/django/forms/widgets/input.html  |  3 ++
 templates/django/forms/widgets/select.html | 14 ++++++++++
 8 files changed, 65 insertions(+), 22 deletions(-)
 create mode 100644 templates/django/forms/div.html
 create mode 100644 templates/django/forms/widgets/input.html
 create mode 100644 templates/django/forms/widgets/select.html

diff --git a/.gitignore b/.gitignore
index a4b82db..bb6570f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -145,9 +145,12 @@ cython_debug/
 **/db.sqlite3
 /db/db.sqlite3
 /staticfiles/
+/static/core/css/output.css
+**/node_modules/
+
 
 # Apps
 wedding/
 wishlist/
 trips/
-/static/core/css/output.css
+thw/
diff --git a/core/settings.py b/core/settings.py
index 912e93d..2425f8b 100644
--- a/core/settings.py
+++ b/core/settings.py
@@ -9,6 +9,7 @@ https://docs.djangoproject.com/en/4.1/topics/settings/
 For the full list of settings and their values, see
 https://docs.djangoproject.com/en/4.1/ref/settings/
 """
+
 from os import environ
 from pathlib import Path
 
@@ -40,7 +41,8 @@ INSTALLED_APPS = [
     "whitenoise.runserver_nostatic",
     "django.contrib.staticfiles",
     "django.contrib.humanize",
-    "{{app_to_install}}",
+    "django.forms",
+    "thw",
 ]
 
 MIDDLEWARE = [
@@ -56,6 +58,7 @@ MIDDLEWARE = [
 
 ROOT_URLCONF = "core.urls"
 
+FORM_RENDERER = "django.forms.renderers.TemplatesSetting"
 TEMPLATES = [
     {
         "BACKEND": "django.template.backends.django.DjangoTemplates",
@@ -117,7 +120,10 @@ USE_TZ = True
 # https://docs.djangoproject.com/en/4.1/howto/static-files/
 
 STATIC_URL = "static/"
-STATICFILES_DIRS = (str(BASE_DIR.joinpath("static")), str(BASE_DIR.joinpath("{{app_to_install}}/static")))
+STATICFILES_DIRS = (
+    str(BASE_DIR.joinpath("static")),
+    str(BASE_DIR.joinpath("thw/static")),
+)
 STATIC_ROOT = str(BASE_DIR.joinpath("staticfiles"))
 STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
 MEDIA_ROOT = BASE_DIR.joinpath("media")
diff --git a/core/urls.py b/core/urls.py
index 5d19d70..870a932 100644
--- a/core/urls.py
+++ b/core/urls.py
@@ -1,18 +1,3 @@
-"""wedding URL Configuration
-
-The `urlpatterns` list routes URLs to views. For more information please see:
-    https://docs.djangoproject.com/en/4.1/topics/http/urls/
-Examples:
-Function views
-    1. Add an import:  from my_app import views
-    2. Add a URL to urlpatterns:  path('', views.home, name='home')
-Class-based views
-    1. Add an import:  from other_app.views import Home
-    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
-Including another URLconf
-    1. Import the include() function: from django.urls import include, path
-    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
-"""
 from core import settings
 from django.contrib import admin
 from django.urls import path, include, re_path
diff --git a/requirements.txt b/requirements.txt
index 23c23af..62db08a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,3 @@
 Django==5.0
 whitenoise==6.6.0
-gunicorn==21.2.0
\ No newline at end of file
+gunicorn==21.2.0
diff --git a/templates/base.html b/templates/base.html
index 996ad42..501f953 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -30,7 +30,7 @@
 					</a>
 				{% endblock %}
 			</div>
-			<div class="flex-none hidden lg:block z-10">
+			<div class="flex-none hidden lg:block z-[60]">
 				<ul class="menu menu-horizontal">
 					{% block navbar_links %}
 						<li><a>Item 1</a></li>
@@ -76,7 +76,7 @@
 			{% endblock %}
 		</main>
 	</div>
-	<div class="drawer-side">
+	<div class="drawer-side z-[60]">
 		<label for="drawer" class="drawer-overlay"></label>
 		<ul class="menu p-4 w-80 min-h-full bg-base-200">
 			{% block sidebar_links %}
@@ -89,4 +89,4 @@
 	</div>
 </div>
 </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/templates/django/forms/div.html b/templates/django/forms/div.html
new file mode 100644
index 0000000..35bf7ec
--- /dev/null
+++ b/templates/django/forms/div.html
@@ -0,0 +1,32 @@
+{{ errors }}
+
+{% if errors and not fields %}
+	<div>{% for field in hidden_fields %}{{ field }}{% endfor %}</div>
+{% endif %}
+
+{% for field, errors in fields %}
+	<div class="form-control w-full min-w-fit max-w-sm m-2">
+		{% if field.label %}
+			<div class="label">
+				<span class="label-text">{{ field.label_tag }}</span>
+			</div>
+		{% endif %}
+		{{ field }}
+		{% if field.help_text %}
+			<div class="label">
+				{% if errors %}
+					<span class="label-text-alt text-error">{{ errors }}</span>
+				{% else %}
+					<span class="label-text-alt">{{ field.help_text|safe }}</span>
+				{% endif %}
+			</div>
+		{% endif %}
+		{% if forloop.last %}
+			{% for field in hidden_fields %}{{ field }}{% endfor %}
+		{% endif %}
+	</div>
+{% endfor %}
+
+{% if not fields and not errors %}
+	{% for field in hidden_fields %}{{ field }}{% endfor %}
+{% endif %}
diff --git a/templates/django/forms/widgets/input.html b/templates/django/forms/widgets/input.html
new file mode 100644
index 0000000..8ac554a
--- /dev/null
+++ b/templates/django/forms/widgets/input.html
@@ -0,0 +1,3 @@
+<input type="{{ widget.type }}" name="{{ widget.name }}"{% if widget.value != None %} value="
+{{ widget.value|stringformat:'s' }}"{% endif %}{% include "django/forms/widgets/attrs.html" %}
+       class="input input-bordered w-full">
diff --git a/templates/django/forms/widgets/select.html b/templates/django/forms/widgets/select.html
new file mode 100644
index 0000000..5c9bb25
--- /dev/null
+++ b/templates/django/forms/widgets/select.html
@@ -0,0 +1,14 @@
+<select name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}
+        class="select select-bordered w-full">
+	{% for group_name, group_choices, group_index in widget.optgroups %}
+		{% if group_name %}
+			<optgroup label="{{ group_name }}">
+		{% endif %}
+	{% for option in group_choices %}
+		{% include option.template_name with widget=option %}
+	{% endfor %}
+	{% if group_name %}
+		</optgroup>
+	{% endif %}
+	{% endfor %}
+</select>
-- 
GitLab