-
Notifications
You must be signed in to change notification settings - Fork 867
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 #904
base: master
Are you sure you want to change the base?
solution #904
Conversation
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.
Thank you for your hard work on this project! While you've made great progress, there are a few critical issues that need to be addressed before we can approve the pull request:
-
Incorrect Model Usage in Views:
- The
CarUpdateView
andCarDeleteView
are currently set to use theManufacturer
model instead of theCar
model. This is a critical issue as it impacts the core functionality of updating and deleting car instances. Please correct the model to ensure these views work as intended.
- The
-
Template URL Generation:
- In the templates, URLs for update and delete actions are hardcoded. It's recommended to use the
{% url %}
template tag to dynamically generate URLs. This ensures consistency with the URL patterns defined inurls.py
and improves maintainability.
- In the templates, URLs for update and delete actions are hardcoded. It's recommended to use the
-
Template Logic for Form Headings:
- The logic for determining whether a form is for updating or creating an object seems incorrect. Ensure that the context variable
object
is correctly used in the template to reflect the correct action.
- The logic for determining whether a form is for updating or creating an object seems incorrect. Ensure that the context variable
These changes are necessary to ensure the application functions correctly and aligns with best practices. Once these issues are resolved, we can proceed with the approval. Keep up the great work, and don't hesitate to reach out if you need any assistance! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review
button in the Reviewers tab.
taxi/views.py
Outdated
|
||
|
||
class CarUpdateView(LoginRequiredMixin, generic.UpdateView): | ||
model = Manufacturer |
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 CarUpdateView
should use the Car
model instead of the Manufacturer
model. Ensure that the model is correctly specified to update car instances.
|
||
|
||
class CarDeleteView(LoginRequiredMixin, generic.DeleteView): | ||
model = Manufacturer |
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 CarDeleteView
should use the Car
model instead of the Manufacturer
model. Ensure that the model is correctly specified to delete car instances.
{% extends "base.html" %} | ||
{% load crispy_forms_filters %} | ||
{% block content %} | ||
<h1>{{ objects|yesno:"Update,Create" }} car:</h1> |
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 use of objects|yesno:"Update,Create"
seems incorrect. It should likely be object|yesno:"Update,Create"
to determine whether the form is for updating or creating based on the presence of an object instance. Ensure that the context variable object
is correctly passed to the template.
{% extends "base.html" %} | ||
{% load crispy_forms_filters %} | ||
{% block content %} | ||
<h1>{{ objects|yesno:"Update,Create" }} manufacturer:</h1> |
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 use of objects|yesno:"Update,Create"
seems incorrect. It should likely be object|yesno:"Update,Create"
to determine whether the form is for updating or creating based on the presence of an object instance. Ensure that the context variable object
is correctly passed to the template.
@@ -23,11 +25,18 @@ <h1>Manufacturer List | |||
<td> | |||
{{ manufacturer.country }} | |||
</td> | |||
<td> | |||
<a href="{{ manufacturer.id }}/update/" class="btn btn-primary">+</a> |
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 URL for the update link is hardcoded as {{ manufacturer.id }}/update/
. It would be better to use the {% url %}
template tag to generate the URL dynamically, ensuring it aligns with the URL patterns defined in urls.py
. For example: {% url 'taxi:manufacturer-update' pk=manufacturer.id %}
.
<a href="{{ manufacturer.id }}/update/" class="btn btn-primary">+</a> | ||
</td> | ||
<td> | ||
<a href="{{ manufacturer.id }}/delete/" class="btn btn-danger">-</a> |
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 URL for the delete link is hardcoded as {{ manufacturer.id }}/delete/
. It would be better to use the {% url %}
template tag to generate the URL dynamically, ensuring it aligns with the URL patterns defined in urls.py
. For example: {% url 'taxi:manufacturer-delete' pk=manufacturer.id %}
.
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.
Great job on your progress so far! 🎉 While the Pull Request is approved to help you move forward with your learning, there are several critical issues that need attention to ensure your application functions correctly:
-
Incorrect Model Usage in Views:
- The
CarDeleteView
is currently using theManufacturer
model instead of theCar
model. This needs to be corrected to ensure the delete functionality works as intended.
- The
-
Template URL Generation:
- Many templates use relative URLs, which can lead to issues if the URL structure changes. It's recommended to use the
{% url %}
template tag to dynamically generate URLs based on the named URL patterns defined inurls.py
. This applies to links for creating, updating, and deleting both cars and manufacturers.
- Many templates use relative URLs, which can lead to issues if the URL structure changes. It's recommended to use the
-
Template Logic for Form Headings:
- The logic for determining whether a form is for updating or creating an object is incorrect in
car_form.html
andmanufacturer_form.html
. The context variableobject
should be used instead ofobjects
to reflect the correct action.
- The logic for determining whether a form is for updating or creating an object is incorrect in
-
Context Variables in Templates:
- Ensure that the correct context variables are passed to templates. For example,
{{ car }}
and{{ manufacturer }}
should be correctly passed from the views to display the respective information.
- Ensure that the correct context variables are passed to templates. For example,
These changes are crucial for the functionality and maintainability of your code. Please review the comments and make the necessary adjustments to improve your code. Keep up the good work and continue learning from these experiences! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
class CarDeleteView(LoginRequiredMixin, generic.DeleteView): | ||
model = Manufacturer |
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 CarDeleteView
is incorrectly using the Manufacturer
model. It should be using the Car
model to delete car instances. Please change model = Manufacturer
to model = Car
.
{% extends "base.html" %} | ||
{% block content %} | ||
<h1>Delete car:</h1> | ||
<p>Are you sure you want to delete the car: {{ car }}?</p> |
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 template uses {{ car }}
to display the car's information. Ensure that the context variable car
is correctly passed from the view to this template. If the context variable is named differently, update it accordingly.
<a href="./update/" class="btn btn-primary">Update</a> | ||
<a href="./delete/" class="btn btn-primary">Delete</a> |
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.
Using relative URLs like ./update/
and ./delete/
can lead to issues if the URL structure changes. It's recommended to use the {% url %}
template tag to dynamically generate these URLs based on the named URL patterns defined in urls.py
. For example, {% url 'taxi:car-update' car.id %}
for the update link.
{% extends "base.html" %} | ||
{% load crispy_forms_filters %} | ||
{% block content %} | ||
<h1>{{ objects|yesno:"Update,Create" }} car:</h1> |
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 use of {{ objects|yesno:"Update,Create" }}
is incorrect because objects
is not a standard context variable for determining form actions. Typically, you would check if the form instance has an id
or use a context variable like is_update
to decide between 'Update' and 'Create'. Ensure the correct context variable is used here.
@@ -14,4 +14,6 @@ <h1>Car list</h1> | |||
{% else %} | |||
<p>There are no cars in taxi</p> | |||
{% endif %} | |||
<a href="./create/" class="m-md-2 btn btn-primary">Add new car</a> |
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.
Using a relative URL like ./create/
for the 'Add new car' link can lead to issues if the URL structure changes. It's recommended to use the {% url %}
template tag to dynamically generate this URL based on the named URL pattern defined in urls.py
. For example, {% url 'taxi:car-create' %}
.
{% extends "base.html" %} | ||
{% block content %} | ||
<h1>Delete manufacturer:</h1> | ||
<p>Are you sure you want to delete the manufacturer: {{ manufacturer }}?</p> |
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 template uses {{ manufacturer }}
to display the manufacturer's information. Ensure that the context variable manufacturer
is correctly passed from the view to this template. If the context variable is named differently, update it accordingly.
{% extends "base.html" %} | ||
{% load crispy_forms_filters %} | ||
{% block content %} | ||
<h1>{{ objects|yesno:"Update,Create" }} manufacturer:</h1> |
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 use of {{ objects|yesno:"Update,Create" }}
is incorrect because objects
is not a standard context variable for determining form actions. Typically, you would check if the form instance has an id
or use a context variable like is_update
to decide between 'Update' and 'Create'. Ensure the correct context variable is used here.
@@ -23,11 +25,18 @@ <h1>Manufacturer List | |||
<td> | |||
{{ manufacturer.country }} | |||
</td> | |||
<td> | |||
<a href="{{ manufacturer.id }}/update/" class="btn btn-primary">+</a> |
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.
Using a relative URL like {{ manufacturer.id }}/update/
can lead to issues if the URL structure changes. It's recommended to use the {% url %}
template tag to dynamically generate this URL based on the named URL pattern defined in urls.py
. For example, {% url 'taxi:manufacturer-update' manufacturer.id %}
.
<a href="{{ manufacturer.id }}/update/" class="btn btn-primary">+</a> | ||
</td> | ||
<td> | ||
<a href="{{ manufacturer.id }}/delete/" class="btn btn-danger">-</a> |
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.
Using a relative URL like {{ manufacturer.id }}/delete/
can lead to issues if the URL structure changes. It's recommended to use the {% url %}
template tag to dynamically generate this URL based on the named URL pattern defined in urls.py
. For example, {% url 'taxi:manufacturer-delete' manufacturer.id %}
.
</tr> | ||
{% endfor %} | ||
</table> | ||
|
||
{% else %} | ||
<p>There are no manufacturers in the service.</p> | ||
{% endif %} | ||
<a href="./create/" class="m-md-2 btn btn-primary">Add new manufacturer</a> |
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.
Using a relative URL like ./create/
for the 'Add new manufacturer' link can lead to issues if the URL structure changes. It's recommended to use the {% url %}
template tag to dynamically generate this URL based on the named URL pattern defined in urls.py
. For example, {% url 'taxi:manufacturer-create' %}
.
No description provided.