Skip to content
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

Solution #414

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
venv/
.pytest_cache/
**__pycache__/
db.sqlite3
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys


def main():
def main() -> None:
"""Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "taxi_service.settings")
try:
Expand Down
5 changes: 5 additions & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"executionEnvironments": {
"root": ["."]
}
}
16 changes: 15 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
django==4.1
asgiref==3.7.2
Django==4.1
django-debug-toolbar==4.2.0
django-extensions==3.2.3
django-stubs==4.2.4
django-stubs-ext==4.2.2
flake8==5.0.4
flake8-quotes==3.3.1
flake8-variables-names==0.0.5
mccabe==0.7.0
mypy==1.5.1
mypy-extensions==1.0.0
pep8-naming==0.13.2
pycodestyle==2.9.1
pyflakes==2.5.0
sqlparse==0.4.4
types-pytz==2023.3.1.1
types-PyYAML==6.0.12.11
typing_extensions==4.8.0
152 changes: 151 additions & 1 deletion static/css/styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,153 @@
html {
--header-height: 60px;
--footer-height: 100px;
}

body {
margin-top: 20px;
margin: 0;
}

h1 {
margin: 0 0 10px;
}

.header {
padding: 0 2%;
display: flex;
justify-content: space-between;
align-items: center;
height: var(--header-height);
background-color: #4772b5;
color: white;
}

.header ul {
margin: 0;
padding: 0;
list-style: none;
}

.header a {
color: #c7dcfc;
text-decoration: none;
}

.header-right {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
gap: 10px;
}

.container {
box-sizing: border-box;
padding: 20px;
min-height: calc(100vh - var(--header-height) - var(--footer-height));
overflow: hidden;
}

.sidebar {
float: left;
max-width: 300px;
min-width: 150px;
width: 20%;
}

.sidebar__link {
display: block;
background-color: #b2cdf7;
color: #000;
padding: 10px 20px;
text-decoration: none;
}

.sidebar__link:hover {
background-color: #89a3cc;
}

.content {
padding: 0 20px;
float: right;
width: 70%;
}

.content a {
text-decoration: none;
color: #2765c4;
}


.content ul {
margin: 0;
padding: 0;
list-style: none;
}

.footer {
display: flex;
justify-content: center;
align-items: center;
height: var(--footer-height);
line-height: var(--footer-height);
background-color: #000;
color: #fff;
}

.card {
border: 1px solid #000;
border-radius: 5px;
max-width: 300px;
margin-bottom: 8px;
padding: 0 10px;
}

.bold {
font-weight: bold;
}

.pagination {
display: inline-flex;
gap: 8px;
align-items: center;
margin-top: 10px;
}

.pagination a {
padding: 8px 13px;
border: 1px solid #000;
border-radius: 5px;
}

.login-form {
width: 350px;
border: 1px solid #ddd;
padding: 2rem;
background: #ffffff;
}

.form-input {
background: #fafafa;
box-sizing: border-box;
border: 1px solid #eeeeee;
padding: 12px;
width: 100%;
}

.form-group {
margin-bottom: 1rem;
}

.form-button {
background: #b2cdf7;
border: 1px solid #ddd;
color: #000;
padding: 10px;
width: 100%;
text-transform: uppercase;
}

.form-button:hover {
background: #89a3cc;
}

4 changes: 2 additions & 2 deletions taxi/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

@admin.register(Driver)
class DriverAdmin(UserAdmin):
list_display = UserAdmin.list_display + ("license_number",)
fieldsets = UserAdmin.fieldsets + (
list_display = UserAdmin.list_display + ("license_number",) # type: ignore
fieldsets = UserAdmin.fieldsets + ( # type: ignore
(("Additional info", {"fields": ("license_number",)}),)
)
add_fieldsets = UserAdmin.add_fieldsets + (
Expand Down
6 changes: 3 additions & 3 deletions taxi/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.0.2 on 2022-03-24 06:38
# Generated by Django 4.0.2 on 2022-06-16 07:34

from django.conf import settings
import django.contrib.auth.models
Expand Down Expand Up @@ -31,7 +31,7 @@ class Migration(migrations.Migration):
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
('license_number', models.CharField(max_length=255)),
('license_number', models.CharField(max_length=255, unique=True)),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
],
Expand All @@ -47,7 +47,7 @@ class Migration(migrations.Migration):
name='Manufacturer',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('name', models.CharField(max_length=255, unique=True)),
('country', models.CharField(max_length=255)),
],
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.0.2 on 2023-09-21 20:13

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('taxi', '0001_initial'),
]

operations = [
migrations.AlterModelOptions(
name='car',
options={'ordering': ['model']},
),
migrations.AlterModelOptions(
name='driver',
options={'ordering': ['first_name'], 'verbose_name': 'driver', 'verbose_name_plural': 'drivers'},
),
migrations.AlterModelOptions(
name='manufacturer',
options={'ordering': ['name']},
),
]
22 changes: 0 additions & 22 deletions taxi/migrations/0002_alter_manufacturer_options_and_more.py

This file was deleted.

18 changes: 0 additions & 18 deletions taxi/migrations/0003_alter_manufacturer_name.py

This file was deleted.

19 changes: 10 additions & 9 deletions taxi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@ class Manufacturer(models.Model):
country = models.CharField(max_length=255)

class Meta:
ordering = ["name"]

def __str__(self):
return f"{self.name} {self.country}"
ordering = [
"name",
]


class Driver(AbstractUser):
license_number = models.CharField(max_length=255, unique=True)

class Meta:
ordering = [
"first_name",
]
verbose_name = "driver"
verbose_name_plural = "drivers"

def __str__(self):
return f"{self.username} ({self.first_name} {self.last_name})"


class Car(models.Model):
model = models.CharField(max_length=255)
manufacturer = models.ForeignKey(Manufacturer, on_delete=models.CASCADE)
drivers = models.ManyToManyField(Driver, related_name="cars")

def __str__(self):
return self.model
class Meta:
ordering = [
"model",
]
10 changes: 6 additions & 4 deletions taxi/urls.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from django.urls import path

from .views import (
index,
CarListView,
CarDetailView,
DriverListView,
CarListView,
DriverDetailView,
DriverListView,
ManufacturerListView,
index,
)

urlpatterns = [
Expand All @@ -20,7 +20,9 @@
path("cars/<int:pk>/", CarDetailView.as_view(), name="car-detail"),
path("drivers/", DriverListView.as_view(), name="driver-list"),
path(
"drivers/<int:pk>/", DriverDetailView.as_view(), name="driver-detail"
"drivers/<int:pk>/",
DriverDetailView.as_view(),
name="driver-detail",
),
]

Expand Down
Loading