From 82f16f436173d655df13ed66bae8b428805b842f Mon Sep 17 00:00:00 2001 From: Soloveyk1n Date: Mon, 16 Oct 2023 14:34:18 +0300 Subject: [PATCH 1/6] check error --- taxi/urls.py | 2 +- taxi/views.py | 5 +++++ taxi_service/settings.py | 2 ++ taxi_service/urls.py | 2 ++ templates/includes/sidebar.html | 18 ++++++++++++++---- templates/registration/logged_out.html | 8 ++++++++ templates/registration/login.html | 15 +++++++++++++++ templates/taxi/car_list.html | 2 +- templates/taxi/driver_list.html | 2 +- templates/taxi/index.html | 1 + 10 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 templates/registration/logged_out.html create mode 100644 templates/registration/login.html diff --git a/taxi/urls.py b/taxi/urls.py index c663d6e2..28cb8941 100644 --- a/taxi/urls.py +++ b/taxi/urls.py @@ -1,6 +1,6 @@ from django.urls import path -from .views import ( +from taxi.views import ( index, CarListView, CarDetailView, diff --git a/taxi/views.py b/taxi/views.py index 82ad312f..5c5df367 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -1,3 +1,4 @@ +from django.contrib.auth.mixins import LoginRequiredMixin from django.shortcuts import render from django.views import generic @@ -10,11 +11,15 @@ def index(request): num_drivers = Driver.objects.count() num_cars = Car.objects.count() num_manufacturers = Manufacturer.objects.count() + num_visits = request.session.get("num_visits", 0) + request.session["num_visits"] = num_visits + 1 + context = { "num_drivers": num_drivers, "num_cars": num_cars, "num_manufacturers": num_manufacturers, + "num_visits": num_visits + 1 } return render(request, "taxi/index.html", context=context) diff --git a/taxi_service/settings.py b/taxi_service/settings.py index b6c0cf19..bfdba372 100644 --- a/taxi_service/settings.py +++ b/taxi_service/settings.py @@ -108,6 +108,8 @@ AUTH_USER_MODEL = "taxi.Driver" +LOGIN_REDIRECT_URL = "/taxi/" + # Internationalization # https://docs.djangoproject.com/en/4.0/topics/i18n/ diff --git a/taxi_service/urls.py b/taxi_service/urls.py index 8b94449f..263195fd 100644 --- a/taxi_service/urls.py +++ b/taxi_service/urls.py @@ -22,4 +22,6 @@ urlpatterns = [ path("admin/", admin.site.urls), path("", include("taxi.urls", namespace="taxi")), + path("accounts/", include("django.contrib.auth.urls")), + ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/templates/includes/sidebar.html b/templates/includes/sidebar.html index b7cd72dc..09affeab 100644 --- a/templates/includes/sidebar.html +++ b/templates/includes/sidebar.html @@ -1,6 +1,16 @@ diff --git a/templates/registration/logged_out.html b/templates/registration/logged_out.html new file mode 100644 index 00000000..a5b29aa4 --- /dev/null +++ b/templates/registration/logged_out.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} + +{% block content %} +

Logged out!

+ + Click here + +{% endblock %} \ No newline at end of file diff --git a/templates/registration/login.html b/templates/registration/login.html new file mode 100644 index 00000000..b0326131 --- /dev/null +++ b/templates/registration/login.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} + +{% block content %} +

Login

+ + {% if form.errors %} +

Invalid credentials

+ {% endif %} + +
+ {% csrf_token %} + {{ form.as_p }} + +
+{% endblock %} \ No newline at end of file diff --git a/templates/taxi/car_list.html b/templates/taxi/car_list.html index e107b579..90067b92 100644 --- a/templates/taxi/car_list.html +++ b/templates/taxi/car_list.html @@ -6,7 +6,7 @@

Car list