-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74effaf
commit 8d33709
Showing
9 changed files
with
160 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# import re | ||
|
||
from django.contrib.auth.forms import UserCreationForm | ||
# from django.core.exceptions import ValidationError | ||
from django.forms import ModelForm, CheckboxSelectMultiple | ||
|
||
from taxi.models import Driver, Car | ||
|
||
|
||
class DriverCreationForm(UserCreationForm): | ||
class Meta(UserCreationForm.Meta): | ||
model = Driver | ||
fields = UserCreationForm.Meta.fields + ( | ||
"first_name", "last_name", "license_number" | ||
) | ||
|
||
# def clean_license_number(self): | ||
# data = self.cleaned_data["license_number"] | ||
# | ||
# if not re.fullmatch(r"^[A-Z]{3}[0-9]{5}$", data): | ||
# raise ValidationError("The license number is incorrect.") | ||
# | ||
# return data | ||
|
||
|
||
class DriverLicenseUpdateForm(ModelForm): | ||
class Meta: | ||
model = Driver | ||
fields = ("first_name", "last_name", "license_number") | ||
|
||
# def clean_license_number(self): | ||
# data = self.cleaned_data["license_number"] | ||
# | ||
# if not re.fullmatch(r"^[A-Z]{3}[0-9]{5}$", data): | ||
# raise ValidationError("The license number is incorrect.") | ||
# | ||
# return data | ||
|
||
|
||
class CarCreateForm(ModelForm): | ||
class Meta: | ||
model = Car | ||
fields = "__all__" | ||
widgets = {"drivers": CheckboxSelectMultiple} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<h1>Delete driver?</h1> | ||
<form action="" method="post"> | ||
{% csrf_token %} | ||
|
||
<input type="submit" value="Yes" class="btn btn-danger"> | ||
</form> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% extends "base.html" %} | ||
{% load crispy_forms_filters %} | ||
|
||
{% block content %} | ||
<h1>Create driver:</h1> | ||
<form action="" method="post" novalidate> | ||
{% csrf_token %} | ||
{{ form|crispy }} | ||
|
||
<input type="submit" value="Submit" class="btn btn-primary"> | ||
</form> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters