Skip to content

Commit

Permalink
login requaired add to index func and main page
Browse files Browse the repository at this point in the history
  • Loading branch information
musakovskiy committed Nov 2, 2023
1 parent fb3d609 commit f28cb85
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions taxi/views.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
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."""

num_drivers = Driver.objects.count()
num_cars = Car.objects.count()
num_manufacturers = Manufacturer.objects.count()
num_vizits = request.session.get("num_vizits", 0)
request.session["num_vizits"] = num_vizits + 1
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_vizits": num_vizits + 1,
"num_visits": num_visits + 1,
}

return render(request, "taxi/index.html", context=context)
Expand Down

0 comments on commit f28cb85

Please sign in to comment.