-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Develop #1359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Develop #1359
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,5 +6,5 @@ max-complexity = 18 | |
| select = B,C,E,F,W,T4,B9,Q0,N8,VNE | ||
| exclude = | ||
| **migrations | ||
| venv | ||
| .venv | ||
| tests | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| #!/usr/bin/env python | ||
| """Django's command-line utility for administrative tasks.""" | ||
|
|
||
| import os | ||
| import sys | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| from django.urls import path | ||
|
|
||
| from taxi.views import index | ||
|
|
||
| app_name = "taxi" | ||
|
|
||
| urlpatterns = [ | ||
| path("", index, name="index"), | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,21 @@ | ||
| from django.http import HttpRequest, HttpResponse | ||
| from django.shortcuts import render | ||
| from django.utils.translation.trans_real import catalog | ||
|
||
|
|
||
| # Create your views here. | ||
| from taxi.models import Driver, Manufacturer, Car | ||
|
|
||
|
|
||
| def index(request: HttpRequest) -> HttpResponse: | ||
| visits = request.session.get("visits", 0) | ||
| request.session["visits"] = visits + 1 | ||
|
||
| num_drivers = Driver.objects.count() | ||
| num_manufacturers = Manufacturer.objects.count() | ||
| num_cars = Car.objects.count() | ||
| context = { | ||
| "visits": request.session["visits"], | ||
| "num_drivers": num_drivers, | ||
| "num_manufacturers": num_manufacturers, | ||
| "num_cars": num_cars, | ||
| } | ||
|
|
||
| return render(request, template_name="taxi/index.html", context=context) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates checklist item #1: 'Ensure each file ends with a single blank line.' Please add a newline at the end of the file. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +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#" \ | ||
| SECRET_KEY = "django-insecure-8ovil3xu6=eaoqd#"\ | ||
|
||
| "-#&ricv159p0pypoh5_lgm*)-dfcjqe=yc" | ||
|
|
||
| # SECURITY WARNING: don't run with debug turned on in production! | ||
|
|
@@ -39,6 +39,7 @@ | |
| "django.contrib.messages", | ||
| "django.contrib.staticfiles", | ||
| "taxi", | ||
| "django_extensions", | ||
|
||
| ] | ||
|
|
||
| MIDDLEWARE = [ | ||
|
|
@@ -56,7 +57,7 @@ | |
| TEMPLATES = [ | ||
| { | ||
| "BACKEND": "django.template.backends.django.DjangoTemplates", | ||
| "DIRS": [], | ||
| "DIRS": [BASE_DIR / "templates"], | ||
| "APP_DIRS": True, | ||
| "OPTIONS": { | ||
| "context_processors": [ | ||
|
|
@@ -89,7 +90,7 @@ | |
| AUTH_PASSWORD_VALIDATORS = [ | ||
| { | ||
| "NAME": "django.contrib.auth.password_validation" | ||
| ".UserAttributeSimilarityValidator", | ||
| ".UserAttributeSimilarityValidator", | ||
| }, | ||
| { | ||
| "NAME": "django.contrib.auth.password_validation" | ||
|
|
@@ -124,6 +125,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 | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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("taxi/", include("taxi.urls", namespace="taxi")), | ||
|
||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>Taxi Service</title> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The task requires creating a |
||
| {% load static %} | ||
| <link rel="stylesheet" href="{% static "css/styles.css" %}"> | ||
| </head> | ||
| <body> | ||
| {% block sidebar %} | ||
| {% include "includes/sidebar.html" %} | ||
| {% endblock %} | ||
|
|
||
| {% block content %} | ||
| {% endblock %} | ||
| </body> | ||
| </html> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates checklist item #1: 'Ensure each file ends with a single blank line.' Please add a blank line at the end of this file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The task requirements state that each HTML file should end with an empty line. Please add a blank line at the end of this file to adhere to the coding standards for this project. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <h1>Library Home</h1> | ||
| <h3>Welcome to the Greatest Library</h3> | ||
|
||
| <ul class="nav-content"> | ||
| <li> | ||
| <a href="#">Home page</a> | ||
| </li> | ||
| <li> | ||
| <a href="#">Manufacturers</a> | ||
| </li> | ||
| <li> | ||
| <a href="#">Cars</a> | ||
| </li> | ||
| <li> | ||
| <a href="#">Drivers</a> | ||
| </li> | ||
| </ul> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| {% extends "base.html" %} | ||
|
|
||
| {% block content %} | ||
| <h1>Library content</h1> | ||
|
||
| <ul> | ||
| <li>Number of cars: {{ num_cars }}</li> | ||
| <li>Number of drivers: {{ num_drivers }}</li> | ||
| <li>Number of manufacturers: {{ num_manufacturers }}</li> | ||
| </ul> | ||
|
|
||
| <h4 class="visits">You have visited this page {{ visits }} times</h4> | ||
|
||
| {% endblock %} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates checklist item #1: 'Ensure each file ends with a single blank line.' Please add a blank line at the end of the file. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,9 @@ | |
|
|
||
| from taxi.models import Car, Manufacturer | ||
|
|
||
| TestCase.fixtures = ["taxi_service_db_data.json", ] | ||
| TestCase.fixtures = [ | ||
| "taxi_service_db_data.json", | ||
| ] | ||
|
|
||
|
|
||
| class HomePageTests(TestCase): | ||
|
|
@@ -21,14 +23,11 @@ def test_index_count_content_correctly(self): | |
| self.assertTemplateUsed(response, "taxi/index.html") | ||
| self.assertEqual(response.context["num_drivers"], num_drivers) | ||
| self.assertEqual(response.context["num_cars"], num_cars) | ||
| self.assertEqual( | ||
| response.context["num_manufacturers"], | ||
| num_manufacturers | ||
| ) | ||
| self.assertEqual(response.context["num_manufacturers"], num_manufacturers) | ||
|
|
||
|
|
||
| class IsStylesCSSExistTests(TestCase): | ||
| def test_styles_exist(self): | ||
| file_exists = os.path.exists('static/css/styles.css') | ||
| file_exists = os.path.exists("static/css/styles.css") | ||
|
|
||
| self.assertTrue(file_exists) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates checklist item #1: 'Ensure each file ends with a single blank line.' Please add a blank line at the end of the file. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This violates checklist item #1: 'Ensure each file ends with a single blank line.' Please add a blank line at the end of the file.