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

Taxi Service User Form and Validation #830

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MarianaTykha
Copy link

image

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

Something went wrong while processing the review.
[CODE: 3]

If the issue is within your control, please address it.
The next review attempt will automatically launch in 1 hour.
If you believe this is an error or need assistance, please contact the support team.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Hello! 😊 You've done a great job setting up the forms, models, and views, and most of your code is well-structured and functional. However, there are a few critical issues that need to be addressed before we can approve the pull request:

  1. License Number Validation: The DriverLicenseUpdateForm should validate that the license consists of 8 characters, with the first 3 being uppercase letters and the last 5 being digits. This validation logic is currently missing and is essential for ensuring data integrity.

  2. Driver Creation Form: The DriverCreationForm should extend UserCreationForm as per the task requirements. This is crucial for maintaining consistency with user creation standards in Django.

  3. Unnecessary Assignment in Model: The assignment objects = None in the Car model is unnecessary and could lead to confusion or errors. Django provides a default manager, so this line should be removed.

These issues are important to resolve to ensure the functionality and integrity of your application. Once these are addressed, your code will be in great shape! Keep up the good work, and feel free to reach out if you have any questions or need further 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/models.py Outdated
@@ -29,6 +29,7 @@ def get_absolute_url(self):


class Car(models.Model):
objects = None

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assignment objects = None in the Car model is unnecessary and should be removed. Django automatically provides a default manager for models, and this line could lead to confusion or errors.

@@ -2,11 +2,11 @@
{% load crispy_forms_filters %}

{% block content %}
<h1>{{ object|yesno:"Update,Create" }} car</h1>
<h1>Create driver</h1>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The heading 'Create driver' appears to be incorrect for this template, which is intended for a car form. Consider changing it to 'Create Car' or a similar title that reflects the purpose of the form.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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 submission! 🎉 While your code is mostly well-structured and functional, there are a few critical areas that need attention to fully meet the task requirements:

  1. License Number Validation: The DriverLicenseUpdateForm needs to validate the license number format to ensure it consists of 8 characters, with the first 3 being uppercase letters and the last 5 being digits. The current implementation only checks for length, so consider adding a custom validator to enforce this rule.

  2. Driver Creation Form: Ensure that the DriverCreationForm extends UserCreationForm instead of forms.ModelForm. This change is crucial for maintaining consistency with Django's user creation standards.

  3. Descriptive Path Naming: Consider renaming the path for DriverLicenseUpdateView to something more descriptive, like driver-license-update, to clearly indicate its purpose.

These improvements are essential for the functionality and integrity of your application. Addressing these issues will not only enhance your code but also align it with best practices. Keep up the great work, and use this opportunity to learn and grow! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

from .models import Driver, Car


class DriverCreationForm(forms.ModelForm):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DriverCreationForm should extend UserCreationForm instead of forms.ModelForm. This is important to ensure consistency with Django's user creation standards and is a requirement in the task checklist .

fields = ["username", "first_name", "last_name", "license_number"]


class DriverLicenseUpdateForm(forms.ModelForm):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DriverLicenseUpdateForm is missing validation for the license_number field. According to the task requirements, the license number should consist of 8 characters, with the first 3 being uppercase letters and the last 5 being digits .

Comment on lines +60 to +63
path(
"drivers/<int:pk>/driver-update/",
DriverLicenseUpdateView.as_view(),
name="driver-update"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming the path for DriverLicenseUpdateView to something more descriptive, such as driver-license-update, to clearly indicate that this view is specifically for updating the driver's license.

Comment on lines +93 to +95
class DriverCreateView(LoginRequiredMixin, generic.CreateView):
model = Driver
form_class = DriverCreationForm

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the DriverCreationForm used here extends UserCreationForm instead of forms.ModelForm. This is crucial for maintaining consistency with user creation standards in Django as per the task requirements.

Comment on lines +103 to +105
class DriverLicenseUpdateView(LoginRequiredMixin, generic.UpdateView):
model = Driver
form_class = DriverLicenseUpdateForm

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure that the DriverLicenseUpdateForm includes validation for the license_number field. The license number should consist of 8 characters, with the first 3 being uppercase letters and the last 5 being digits, as specified in the task requirements.

Comment on lines +10 to +14
class LicenseNumberValidatorMixin:
license_number = forms.CharField(
required=True,
validators=[MinLengthValidator(8), MaxLengthValidator(8)]
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LicenseNumberValidatorMixin currently only checks the length of the license number. According to the task requirements, you need to validate that the license number consists of 8 characters, with the first 3 being uppercase letters and the last 5 being digits. Consider implementing a custom validator to enforce this rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants