diff --git a/Hotails/settings.py b/Hotails/settings.py
index 5de0a2d..4e1232c 100644
--- a/Hotails/settings.py
+++ b/Hotails/settings.py
@@ -41,6 +41,7 @@
'review.apps.ReviewConfig',
'orders.apps.OrdersConfig',
'message.apps.MessageConfig',
+ 'crispy_forms',
]
MIDDLEWARE = [
@@ -66,6 +67,7 @@
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
+ 'main.context_processors.navbar_extras'
],
},
},
@@ -121,7 +123,10 @@
BASE_DIR / "static",
]
+
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
+LOGIN_REDIRECT_URL = 'index'
+LOGIN_URL = 'login'
diff --git a/Hotails/urls.py b/Hotails/urls.py
index 2f233c6..4513ba6 100644
--- a/Hotails/urls.py
+++ b/Hotails/urls.py
@@ -15,10 +15,15 @@
"""
from django.contrib import admin
from django.urls import path, include
-
+from main import views
+from django.contrib.auth import views as auth_views
urlpatterns = [
path('admin/', admin.site.urls),
- path('', include('main.urls')),
-
+ path('', views.index, name='index'),
+ path('login/', auth_views.LoginView.as_view(template_name='main/login.html',
+ redirect_authenticated_user=True), name='login'),
+ path('homepage/', views.homepage, name='homepage'),
+ path('logout/', views.logout_view, name='logout'),
+ path('about/', views.about, name='about'),
]
diff --git a/Pipfile b/Pipfile
index e766c4a..73770b5 100644
--- a/Pipfile
+++ b/Pipfile
@@ -5,6 +5,7 @@ name = "pypi"
[packages]
django = "*"
+django-crispy-forms = "*"
pytest = "*"
[dev-packages]
diff --git a/Pipfile.lock b/Pipfile.lock
index b9f7bbb..dcef38b 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "fb6110748728e6c8707f1823bd5f6e7717e1b9f8918fd291f601355d56033d51"
+ "sha256": "d04ab47de98888d33adda80a4909359973adb79262bace96499ba1ecf2f7b755"
},
"pipfile-spec": 6,
"requires": {
@@ -24,14 +24,6 @@
"markers": "python_version >= '3.7'",
"version": "==3.5.0"
},
- "atomicwrites": {
- "hashes": [
- "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197",
- "sha256:ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a"
- ],
- "markers": "sys_platform == 'win32'",
- "version": "==1.4.0"
- },
"attrs": {
"hashes": [
"sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4",
@@ -40,14 +32,6 @@
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==21.4.0"
},
- "colorama": {
- "hashes": [
- "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b",
- "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"
- ],
- "markers": "sys_platform == 'win32'",
- "version": "==0.4.4"
- },
"django": {
"hashes": [
"sha256:1239218849e922033a35d2a2f777cb8bee18bd725416744074f455f34ff50d0c",
@@ -56,6 +40,14 @@
"index": "pypi",
"version": "==4.0.3"
},
+ "django-crispy-forms": {
+ "hashes": [
+ "sha256:35887b8851a931374dd697207a8f56c57a9c5cb9dbf0b9fa54314da5666cea5b",
+ "sha256:bc4d2037f6de602d39c0bc452ac3029d1f5d65e88458872cc4dbc01c3a400604"
+ ],
+ "index": "pypi",
+ "version": "==1.14.0"
+ },
"iniconfig": {
"hashes": [
"sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3",
@@ -118,25 +110,9 @@
],
"markers": "python_version >= '3.7'",
"version": "==2.0.1"
- },
- "tzdata": {
- "hashes": [
- "sha256:238e70234214138ed7b4e8a0fab0e5e13872edab3be586ab8198c407620e2ab9",
- "sha256:8b536a8ec63dc0751342b3984193a3118f8fca2afe25752bb9b7fffd398552d3"
- ],
- "markers": "sys_platform == 'win32'",
- "version": "==2022.1"
}
},
"develop": {
- "atomicwrites": {
- "hashes": [
- "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197",
- "sha256:ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a"
- ],
- "markers": "sys_platform == 'win32'",
- "version": "==1.4.0"
- },
"attrs": {
"hashes": [
"sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4",
@@ -145,14 +121,6 @@
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==21.4.0"
},
- "colorama": {
- "hashes": [
- "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b",
- "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"
- ],
- "markers": "sys_platform == 'win32'",
- "version": "==0.4.4"
- },
"flake8": {
"hashes": [
"sha256:479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d",
diff --git a/main/context_processors.py b/main/context_processors.py
new file mode 100644
index 0000000..7f4f3a5
--- /dev/null
+++ b/main/context_processors.py
@@ -0,0 +1,21 @@
+from daycare.models import DayCare, Image
+from dogowner.models import DogOwner
+
+
+def navbar_extras(request):
+ navbar_picture_url = navbar_name = None
+ if request.user.is_authenticated:
+ if DogOwner.objects.filter(user=request.user).exists():
+ dog_owner = DogOwner.objects.filter(user=request.user).first()
+ navbar_picture_url = dog_owner.dog_picture_url
+ navbar_name = dog_owner.first_name + ' ' + dog_owner.last_name
+
+ elif DayCare.objects.filter(user=request.user).exists():
+ daycare = DayCare.objects.filter(user=request.user).first()
+ navbar_picture_url = Image.objects.filter(daycare_id=daycare).first().url
+ navbar_name = daycare.name
+ context = {
+ 'navbar_picture_url': navbar_picture_url,
+ 'navbar_name': navbar_name,
+ }
+ return context
diff --git a/main/templates/main/base_template.html b/main/templates/main/base_template.html
index 256ecbe..cb1d442 100644
--- a/main/templates/main/base_template.html
+++ b/main/templates/main/base_template.html
@@ -12,32 +12,43 @@
+
{% block stylesheets %}
{% endblock %}