diff --git a/.flake8 b/.flake8 index e8114cc1c..653f0e27a 100644 --- a/.flake8 +++ b/.flake8 @@ -6,5 +6,5 @@ max-complexity = 18 select = B,C,E,F,W,T4,B9,Q0,N8,VNE exclude = **migrations - venv + .venv tests diff --git a/manage.py b/manage.py index 3d09a6ce4..1fb041d75 100755 --- a/manage.py +++ b/manage.py @@ -1,5 +1,6 @@ #!/usr/bin/env python """Django's command-line utility for administrative tasks.""" + import os import sys diff --git a/static/css/styles.css b/static/css/styles.css new file mode 100644 index 000000000..cf49aa7f5 --- /dev/null +++ b/static/css/styles.css @@ -0,0 +1,25 @@ +body { + padding: 20px; +} + +a { + text-decoration: none; +} + +.visits { + font-weight: normal; +} + +.nav-content { + list-style-type: none; + padding: 0; + margin: 0; +} + +.nav-content>li{ + padding: 10px; +} + +a:hover { + text-decoration: underline; +} diff --git a/taxi/urls.py b/taxi/urls.py new file mode 100644 index 000000000..1e41ad95b --- /dev/null +++ b/taxi/urls.py @@ -0,0 +1,9 @@ +from django.urls import path + +from taxi.views import index + +app_name = "taxi" + +urlpatterns = [ + path("", index, name="index"), +] diff --git a/taxi/views.py b/taxi/views.py index 91ea44a21..fc1f665eb 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -1,3 +1,17 @@ +from django.http import HttpRequest, HttpResponse from django.shortcuts import render -# Create your views here. +from taxi.models import Driver, Manufacturer, Car + + +def index(request: HttpRequest) -> HttpResponse: + num_drivers = Driver.objects.count() + num_manufacturers = Manufacturer.objects.count() + num_cars = Car.objects.count() + context = { + "num_drivers": num_drivers, + "num_manufacturers": num_manufacturers, + "num_cars": num_cars, + } + + return render(request, template_name="taxi/index.html", context=context) diff --git a/taxi_service/settings.py b/taxi_service/settings.py index 00329f55f..cd6f803db 100644 --- a/taxi_service/settings.py +++ b/taxi_service/settings.py @@ -20,8 +20,7 @@ # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = "django-insecure-8ovil3xu6=eaoqd#" \ - "-#&ricv159p0pypoh5_lgm*)-dfcjqe=yc" +SECRET_KEY = "django-insecure-8ovil3xu6=eaoqd#-#&ricv159p0pypoh5_lgm*)-dfcjqe=yc" # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -56,7 +55,7 @@ TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [], + "DIRS": [BASE_DIR / "templates"], "APP_DIRS": True, "OPTIONS": { "context_processors": [ @@ -89,7 +88,7 @@ AUTH_PASSWORD_VALIDATORS = [ { "NAME": "django.contrib.auth.password_validation" - ".UserAttributeSimilarityValidator", + ".UserAttributeSimilarityValidator", }, { "NAME": "django.contrib.auth.password_validation" @@ -124,6 +123,10 @@ STATIC_URL = "static/" +STATICFILES_DIRS = [ + BASE_DIR / "static", +] + # Default primary key field type # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field diff --git a/taxi_service/urls.py b/taxi_service/urls.py index 57c939e7f..417df5904 100644 --- a/taxi_service/urls.py +++ b/taxi_service/urls.py @@ -13,9 +13,11 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ + from django.contrib import admin -from django.urls import path +from django.urls import path, include urlpatterns = [ path("admin/", admin.site.urls), + path("", include("taxi.urls", namespace="taxi")), ] diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 000000000..bf148d934 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,19 @@ + + +
+ + {% block title %} +