-
Notifications
You must be signed in to change notification settings - Fork 834
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 #891
base: master
Are you sure you want to change the base?
Solution #891
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,14 @@ | ||
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 | ||
asgiref==3.8.1 | ||
crispy-bootstrap4==2022.1 | ||
Django==4.1 | ||
django-crispy-forms==1.14.0 | ||
django-debug-toolbar==3.2.4 | ||
flake8==5.0.4 | ||
flake8-quotes==3.3.1 | ||
flake8-variables-names==0.0.5 | ||
mccabe==0.7.0 | ||
pep8-naming==0.13.2 | ||
pycodestyle==2.9.1 | ||
pyflakes==2.5.0 | ||
sqlparse==0.5.3 | ||
tzdata==2024.2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,9 @@ | |
<html lang="en"> | ||
|
||
<head> | ||
{% block title %}<title>Taxi Service</title>{% endblock %} | ||
{% block title %} | ||
<title>Taxi Service</title> | ||
{% endblock %} | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" | ||
|
@@ -18,20 +20,24 @@ | |
<div class="container-fluid"> | ||
<div class="row"> | ||
<div class="col-sm-2"> | ||
|
||
{% block sidebar %} | ||
{% include "includes/sidebar.html" %} | ||
{% endblock %} | ||
|
||
</div> | ||
<div class="col-sm-10 "> | ||
|
||
{% block content %}{% endblock %} | ||
<div class="col-sm-10 "> | ||
{% block content %} | ||
<h1>Car Creation</h1> | ||
<form method="POST"> | ||
{% csrf_token %} | ||
{{ form|crispy }} | ||
<button type="submit" class="btn btn-primary">Submit</button> | ||
</form> | ||
{% endblock %} | ||
Comment on lines
+29
to
+36
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 content specific to 'Car Creation' should not be hardcoded in the base template. Move this content to a specific template for car creation to avoid duplication and maintain template reusability. |
||
|
||
{% block pagination %} | ||
{% include "includes/pagination.html" %} | ||
{% endblock %} | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<p>Manufacturer: ({{ car.manufacturer.name }}, {{ car.manufacturer.country }})</p> | ||
<h1>Drivers</h1> | ||
<h2>Manufacturer: ({{ car.manufacturer.name }}, {{ car.manufacturer.country }})</h2> | ||
<p>Drivers: </p> | ||
<hr> | ||
<ul> | ||
{% for driver in car.drivers.all %} | ||
<li>{{ driver.username }} ({{ driver.first_name }} {{ driver.last_name }})</li> | ||
{% endfor %} | ||
</ul> | ||
<form action="{% url 'taxi:car-update' pk=car.id %}" method="post" style="display: inline;"> | ||
{% csrf_token %} | ||
<button type="submit">Update Car</button> | ||
</form> | ||
<form action="{% url 'taxi:car-delete' pk=car.id %}" method="post" style="display: inline;"> | ||
{% csrf_token %} | ||
<input type="hidden" name="_method" value="delete"> | ||
Comment on lines
+16
to
+18
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 delete form uses a hidden input to specify the HTTP method as 'delete', which is not supported by HTML forms. Change the form method to 'post' and handle the delete action in the view logic. |
||
<button type="submit">Delete Car</button> | ||
</form> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
{% extends "base.html" %} | ||
{% load crispy_forms_filters %} | ||
|
||
{% block content %} | ||
<h1>Car list</h1> | ||
{% if car_list %} | ||
<ul> | ||
{% for car in car_list %} | ||
<li> | ||
<a href="{% url "taxi:car-detail" pk=car.id %} ">{{ car.id }}</a> | ||
{{ car.model }} ({{ car.manufacturer.name }}) | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% else %} | ||
<p>There are no cars in taxi</p> | ||
{% endif %} | ||
<h1> | ||
{% if object %} | ||
Update Car | ||
{% else %} | ||
Create Car | ||
{% endif %} | ||
Comment on lines
+6
to
+10
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 logic for determining whether to display 'Update Car' or 'Create Car' is based on the presence of |
||
</h1> | ||
|
||
<form action="" method="post" novalidate> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
<input type="submit" value="Submit"> | ||
</form> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<h1>Delete Manufacturer</h1> | ||
|
||
<p>Are you sure you want to delete this manufacturer?</p> | ||
<p>Name: {{ manufacturer.name }}</p> | ||
<a href="{% url 'taxi:manufacturer-list' %}" class="btn btn-primary">Cancel</a> | ||
<br><br> | ||
<form action="" method="post"> | ||
{% csrf_token %} | ||
<input type="submit" value="Yes, delete" class="btn btn-danger" /> | ||
</form> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,13 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<h1>Manufacturer List | ||
</h1> | ||
|
||
{% if manufacturer_list %} | ||
<table class="table"> | ||
<tr> | ||
<th>ID</th> | ||
<th>Name</th> | ||
<th>Country</th> | ||
</tr> | ||
{% load crispy_forms_filters %} | ||
|
||
{% for manufacturer in manufacturer_list %} | ||
<tr> | ||
<td> | ||
{{ manufacturer.id }} | ||
</td> | ||
<td> | ||
{{ manufacturer.name }} | ||
</td> | ||
<td> | ||
{{ manufacturer.country }} | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
{% block content %} | ||
<h1>{% if object %}Update{% else %}Create{% endif %} Manufacturer</h1> | ||
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 logic for determining whether to display 'Update Manufacturer' or 'Create Manufacturer' is based on the presence of |
||
|
||
{% else %} | ||
<p>There are no manufacturers in the service.</p> | ||
{% endif %} | ||
<form action="" method="post" novalidate> | ||
{% csrf_token %} | ||
{{ form|crispy }} | ||
<input type="submit" value="Submit"> | ||
</form> | ||
{% 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.
The
debug_toolbar
is listed twice in theINSTALLED_APPS
list, once commented and once uncommented. Please remove the commented entry to avoid redundancy.