From 13d1c506a0c013ba923bdf9ea249b299292df48c Mon Sep 17 00:00:00 2001 From: Egor Derepovskiy Date: Wed, 11 Sep 2024 09:41:31 +0300 Subject: [PATCH] first --- db.sqlite3 | Bin 0 -> 176128 bytes taxi/views.py | 13 ++++++++----- taxi_service/settings.py | 2 ++ taxi_service/urls.py | 1 + templates/includes/sidebar.html | 12 +++++++++++- templates/registration/logged_out.html | 5 +++++ templates/registration/login.html | 14 ++++++++++++++ templates/taxi/driver_list.html | 3 +++ templates/taxi/index.html | 1 + 9 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 db.sqlite3 create mode 100644 templates/registration/logged_out.html create mode 100644 templates/registration/login.html diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..9448f71c2fb79a1d8f9af666c6a133852fac8263 GIT binary patch literal 176128 zcmeI53ve9Cd6;*0XJ6PygLrU`hr@BOAVltgAol&>)#YvpEXgHaBpxJjiE3+hcK{5y z4{#qKK{-(^kI^}jQ;ua>@*s4^{juJ^ORq5i2Dk>>< zRF+(}q^kVgGrK$c0&uiWKHmLHqG!AN?|=UO`tOafQhCu_z z8D0`agTdg1ziIdzhCdGeV(`bqU*kj5j{0~F7j9iMgOri{fXYsjACez9zCG~cfff4) zZM)VFS-xx8w4C8n{E+c0T-oqh!>9VGw9$D>@4?iwkl=va#gyoqzh89wk2h& zwX$69N*JD7O(xcp;(FrJVp8;U<$J_)9wp}ym10%imdoPu%DT9`vA8H+Urj9~RyW0k z z9wl2<$d#3Sxty+5AlQ@31*K9^O2rDZwol$rkBapXeXKfax+t5BvJH5eRTNi~my@f> z<+RcHbyC*8kROZgo>ZyaE0w`T8-39qh_&^_yi}>C^Cj?K zkC>CHa#bnFtbcl-RodF>HWaD>2R}G|bZ5~Tr+1;{WI)uazIKSCb}3o8 zSdr7kS|LLrG%&Uu(!9YDi*RM4pGUABsyd^;^?k5@V%RE7OmOuA^M_VW>zkw98(JBU z5v=H%uX%O zCvS_Mj@)!V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R033{U5fG@42p2i0+hGQ24@x=U6I1-PA==#5tL=7ZLzDHI_ zf_$3%5&05%oxDmi7VT<2VsnHFrH z3F6(R39dEWVj`wVkZ8_m7+t0bduxtB9sd^$q(J_HyqA<=?Ef|LW%4cZN%C{#x5%%& zrKqDZNB{{S0VIF~kN^@u0!RP}AOR$R1fB!}yvfBmou+ZFaR-`%MYKD+256*l$CRB$ z8aE@^XrytIkClmOx6oKF>)dKGv7Qvy6PFf~qNgk0BcAgpIgh9m ztMay77MEAn#pR8~Me+J-3a$e-#f9XinAlifNiBn>rR4JZdC`+C)r!^ffk)hz%2~Ll z{2cs>kGEMA1d38Y?vpESET?X4B)tG>C>`ev^v?eKmAiSRnh08ijahw)oR(_U5|c=G zS)TTHCE3D$i;$W;R7I|=?91hJfE89F&xL)*EvD{ME#`eCJ!=&vC%IS6t;SHZbjr{5 zXaH5{vC!{HmCC(R8CtBt-XDmyvCm7DYC2!qR*D`mCspODQjl4bLc1uHbfpHj#L}BJ zJz}O*%IjN=rna}7KkRGi)>;nKY$;{f$04F1!^}8bM5YgMv?>w^hgv(+jIByrTiu32 zHNfAY9lNt=jnli}Gcq7*RbTUJYL}9gixoLttQ9g8LIY!)3pbp!K61e-ta-V5oH=1` zS1N9o(iOQ68H=#u?dRqld-1o&-&K#Cw+db__wX$9+Vu{Y~sB;qkumUawV{nc-fALl~SnIxXmoPiYou=Z((n$2xYEGP`oN3LF|u59b+h z3N0BP@6vZipU#Uwi1v5ra$9+6+ap#AQa%r7EU{LsDBIB0n_eW&T}{p{Kohme|D6{^ zpBI$CxvID=rwh=3rENHPbUI)swANXXo)K4*my@f><+M*aW* literal 0 HcmV?d00001 diff --git a/taxi/views.py b/taxi/views.py index 82ad312f..b9fef82a 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -1,9 +1,12 @@ +from django.contrib.auth.decorators import login_required +from django.contrib.auth.mixins import LoginRequiredMixin from django.shortcuts import render from django.views import generic from .models import Driver, Car, Manufacturer +@login_required def index(request): """View function for the home page of the site.""" @@ -20,28 +23,28 @@ def index(request): return render(request, "taxi/index.html", context=context) -class ManufacturerListView(generic.ListView): +class ManufacturerListView(LoginRequiredMixin, generic.ListView): model = Manufacturer context_object_name = "manufacturer_list" template_name = "taxi/manufacturer_list.html" paginate_by = 5 -class CarListView(generic.ListView): +class CarListView(LoginRequiredMixin, generic.ListView): model = Car paginate_by = 5 queryset = Car.objects.select_related("manufacturer") -class CarDetailView(generic.DetailView): +class CarDetailView(LoginRequiredMixin, generic.DetailView): model = Car -class DriverListView(generic.ListView): +class DriverListView(LoginRequiredMixin, generic.ListView): model = Driver paginate_by = 5 -class DriverDetailView(generic.DetailView): +class DriverDetailView(LoginRequiredMixin, generic.DetailView): model = Driver queryset = Driver.objects.prefetch_related("cars__manufacturer") diff --git a/taxi_service/settings.py b/taxi_service/settings.py index b6c0cf19..e8f0543a 100644 --- a/taxi_service/settings.py +++ b/taxi_service/settings.py @@ -133,3 +133,5 @@ # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + +LOGIN_REDIRECT_URL = "/" diff --git a/taxi_service/urls.py b/taxi_service/urls.py index 8b94449f..baf83d1a 100644 --- a/taxi_service/urls.py +++ b/taxi_service/urls.py @@ -22,4 +22,5 @@ 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..42584992 100644 --- a/templates/includes/sidebar.html +++ b/templates/includes/sidebar.html @@ -1,6 +1,16 @@ + \ No newline at end of file diff --git a/templates/registration/logged_out.html b/templates/registration/logged_out.html new file mode 100644 index 00000000..92bf1f23 --- /dev/null +++ b/templates/registration/logged_out.html @@ -0,0 +1,5 @@ +{% extends "base.html" %} +{% block content %} +

logged out

+ Click here to log in again +{% 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..4ef64d72 --- /dev/null +++ b/templates/registration/login.html @@ -0,0 +1,14 @@ +{% 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/driver_list.html b/templates/taxi/driver_list.html index c6c3e823..36ad23a2 100644 --- a/templates/taxi/driver_list.html +++ b/templates/taxi/driver_list.html @@ -8,6 +8,9 @@

Driver list

  • {{ driver.username }} ({{ driver.first_name }} {{ driver.last_name }}) + {% if driver.id == request.user.id %} + (Me) + {% endif %}
  • {% endfor %} diff --git a/templates/taxi/index.html b/templates/taxi/index.html index 13c59aa8..ed6fdfda 100644 --- a/templates/taxi/index.html +++ b/templates/taxi/index.html @@ -10,4 +10,5 @@

    Dynamic content

  • Drivers: {{ num_drivers }}
  • Manufacturers: {{ num_manufacturers }}
  • +

    You have visited this page {{ num_visits }} time{{ num_visits|pluralize}}.

    {% endblock %}