-
Notifications
You must be signed in to change notification settings - Fork 886
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 #905
base: master
Are you sure you want to change the base?
Solution #905
Changes from all 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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
django==4.1 | ||
flake8==5.0.4 | ||
flake8-quotes==3.3.1 | ||
flake8-variables-names==0.0.5 | ||
pep8-naming==0.13.2 | ||
django-debug-toolbar==3.2.4 | ||
django-crispy-forms==1.14.0 | ||
django==5.1.4 | ||
flake8==5.0.4 | ||
flake8-quotes==3.3.1 | ||
flake8-variables-names==0.0.5 | ||
pep8-naming==0.13.2 | ||
django-debug-toolbar==3.2.4 | ||
django-crispy-forms==1.14.0 | ||
crispy-bootstrap4==2022.1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from django.contrib.auth.decorators import login_required | ||
from django.shortcuts import render | ||
from django.urls import reverse_lazy | ||
from django.views import generic | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
|
||
|
@@ -34,6 +35,26 @@ class ManufacturerListView(LoginRequiredMixin, generic.ListView): | |
paginate_by = 5 | ||
|
||
|
||
class ManufacturerCreateView(LoginRequiredMixin, generic.CreateView): | ||
model = Manufacturer | ||
fields = "__all__" | ||
success_url = reverse_lazy("taxi:manufacturer-list") | ||
template_name = "taxi/manufacturer_form.html" | ||
|
||
|
||
class ManufacturerUpdateView(LoginRequiredMixin, generic.UpdateView): | ||
model = Manufacturer | ||
fields = "__all__" | ||
success_url = reverse_lazy("taxi:manufacturer-list") | ||
template_name = "taxi/manufacturer_form.html" | ||
|
||
|
||
class ManufacturerDeleteView(LoginRequiredMixin, generic.DeleteView): | ||
model = Manufacturer | ||
success_url = reverse_lazy("taxi:manufacturer-list") | ||
template_name = "taxi/manufacturer_confirm_delete.html" | ||
|
||
Comment on lines
+38
to
+56
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. Consider adding a |
||
|
||
class CarListView(LoginRequiredMixin, generic.ListView): | ||
model = Car | ||
paginate_by = 5 | ||
|
@@ -44,6 +65,26 @@ class CarDetailView(LoginRequiredMixin, generic.DetailView): | |
model = Car | ||
|
||
|
||
class CarCreateView(LoginRequiredMixin, generic.CreateView): | ||
model = Car | ||
fields = "__all__" | ||
success_url = reverse_lazy("taxi:car-list") | ||
template_name = "taxi/car_form.html" | ||
|
||
|
||
class CarUpdateView(LoginRequiredMixin, generic.UpdateView): | ||
model = Car | ||
fields = "__all__" | ||
success_url = reverse_lazy("taxi:car-list") | ||
template_name = "taxi/car_form.html" | ||
|
||
|
||
class CarDeleteView(LoginRequiredMixin, generic.DeleteView): | ||
model = Car | ||
success_url = reverse_lazy("taxi:car-list") | ||
template_name = "taxi/car_confirm_delete.html" | ||
|
||
|
||
class DriverListView(LoginRequiredMixin, generic.ListView): | ||
model = Driver | ||
paginate_by = 5 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% extends "base.html" %} | ||
{% block content %} | ||
<h1>Delete Car</h1> | ||
<p>Are you sure you want to delete this car: {{ car.model }}?</p> | ||
<form method="post" action=""> | ||
{% csrf_token %} | ||
<input type="submit" value="Yes, I'm sure" class="btn btn-danger"> | ||
</form> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% extends "base.html" %} | ||
{% load crispy_forms_filters %} | ||
{% block content %} | ||
<h1>{{ object|yesno:"Update,Create" }} Car</h1> | ||
<form method="post" action="" novalidate> | ||
{% csrf_token %} | ||
{{ form|crispy }} | ||
<input class="btn btn-primary" type="submit" value="Submit"> | ||
</form> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% extends "base.html" %} | ||
{% block content %} | ||
<h1>Delete Manufacturer</h1> | ||
|
||
<p>Are you sure you want to delete this manufacturer: {{ manufacturer.name }}?</p> | ||
<p><i>All Cars with this manufacturer will be also delete</i></p> | ||
<form method="post" action=""> | ||
{% csrf_token %} | ||
<input type="submit" value="Yes, I'm sure" class="btn btn-danger"> | ||
</form> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% extends "base.html" %} | ||
{% load crispy_forms_filters %} | ||
{% block content %} | ||
<h1>{{ object|yesno:"Update,Create" }} Manufacturer</h1> | ||
<form method="post" action="" novalidate> | ||
{% csrf_token %} | ||
{{ form|crispy }} | ||
<input class="btn btn-primary" type="submit" value="Submit"> | ||
</form> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,27 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<h1>Manufacturer List | ||
</h1> | ||
|
||
{% if manufacturer_list %} | ||
<table class="table"> | ||
<h1>Manufacturer List <a style="float: right" href="{% url "taxi:manufacturer-create" %}">+</a></h1> | ||
{% if manufacturer_list %} | ||
<table class="table"> | ||
<tr> | ||
<th>ID</th> | ||
<th>Name</th> | ||
<th>Country</th> | ||
<th>Update</th> | ||
<th>Delete</th> | ||
</tr> | ||
{% for manufacturer in manufacturer_list %} | ||
<tr> | ||
<th>ID</th> | ||
<th>Name</th> | ||
<th>Country</th> | ||
</tr> | ||
|
||
{% for manufacturer in manufacturer_list %} | ||
<tr> | ||
<td> | ||
{{ manufacturer.id }} | ||
</td> | ||
<td> | ||
{{ manufacturer.name }} | ||
</td> | ||
<td> | ||
{{ manufacturer.country }} | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
|
||
{% else %} | ||
<p>There are no manufacturers in the service.</p> | ||
{% endif %} | ||
<td><a href="{% url "taxi:car-detail" pk=manufacturer.id %} ">{{ manufacturer.id }}</a></td> | ||
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 URL 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 URL for the manufacturer's detail view is incorrect. It currently uses |
||
<td>{{ manufacturer.name }}</td> | ||
<td>{{ manufacturer.country }}</td> | ||
<td><a href="{% url "taxi:manufacturer-update" pk=manufacturer.id %}">Update</a></td> | ||
<td><a href="{% url "taxi:manufacturer-delete" pk=manufacturer.id %}">Delete</a></td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
{% else %} | ||
<p>There are no manufacturers in the service.</p> | ||
{% endif %} | ||
{% endblock %} |
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.
There is no URL pattern for the manufacturer's detail view. Consider adding a path similar to the car detail view to ensure users can navigate to a specific manufacturer's detail page.