-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from jamedadi/feature_address_mohammad
merge Feature address mohammad
- Loading branch information
Showing
20 changed files
with
540 additions
and
20 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
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,28 @@ | ||
from django import forms | ||
|
||
from address.models import CustomerAddress, ServiceAddress | ||
|
||
base_fields = ('state', 'city', 'area', 'street', 'alley', 'floor', 'plaque') | ||
base_widgets = { | ||
'state': forms.Select(attrs={'class': 'form-control'}), | ||
'city': forms.Select(attrs={'class': 'form-control'}), | ||
'area': forms.Select(attrs={'class': 'form-control'}), | ||
'street': forms.TextInput(attrs={'class': 'form-control'}), | ||
'alley': forms.TextInput(attrs={'class': 'form-control'}), | ||
'floor': forms.NumberInput(attrs={'class': 'form-control'}), | ||
'plaque': forms.NumberInput(attrs={'class': 'form-control'}), | ||
} | ||
|
||
|
||
class CustomerAddressCreateUpdateForm(forms.ModelForm): | ||
class Meta: | ||
model = CustomerAddress | ||
fields = base_fields | ||
widgets = base_widgets | ||
|
||
|
||
class ServiceAddressCreateUpdateForm(forms.ModelForm): | ||
class Meta: | ||
model = ServiceAddress | ||
fields = base_fields | ||
widgets = base_widgets |
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,55 @@ | ||
# Generated by Django 3.2 on 2021-08-30 08:35 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('address', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='CustomerAddress', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_time', models.DateTimeField(auto_now_add=True, verbose_name='created time')), | ||
('modified_time', models.DateTimeField(auto_now=True, verbose_name='modified time')), | ||
('floor', models.SmallIntegerField(verbose_name='floor')), | ||
('plaque', models.SmallIntegerField(verbose_name='plaque')), | ||
], | ||
options={ | ||
'verbose_name': 'CustomerAddress', | ||
'verbose_name_plural': 'CustomerAddresses', | ||
'db_table': 'customer_address', | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='ServiceAddress', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_time', models.DateTimeField(auto_now_add=True, verbose_name='created time')), | ||
('modified_time', models.DateTimeField(auto_now=True, verbose_name='modified time')), | ||
('floor', models.SmallIntegerField(verbose_name='floor')), | ||
('plaque', models.SmallIntegerField(verbose_name='plaque')), | ||
], | ||
options={ | ||
'verbose_name': 'ServiceAddress', | ||
'verbose_name_plural': 'ServiceAddresses', | ||
'db_table': 'service_address', | ||
}, | ||
), | ||
migrations.RemoveField( | ||
model_name='address', | ||
name='area', | ||
), | ||
migrations.RemoveField( | ||
model_name='address', | ||
name='city', | ||
), | ||
migrations.RemoveField( | ||
model_name='address', | ||
name='state', | ||
), | ||
] |
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,55 @@ | ||
# Generated by Django 3.2 on 2021-08-30 08:35 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('service', '0002_alter_service_address'), | ||
('address', '0002_auto_20210830_1305'), | ||
('accounts', '0001_initial'), | ||
('payment', '0002_alter_invoice_address'), | ||
] | ||
|
||
operations = [ | ||
migrations.DeleteModel( | ||
name='Address', | ||
), | ||
migrations.AddField( | ||
model_name='serviceaddress', | ||
name='area', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='s_addresses', to='address.area', verbose_name='area'), | ||
), | ||
migrations.AddField( | ||
model_name='serviceaddress', | ||
name='city', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='s_addresses', to='address.city', verbose_name='city'), | ||
), | ||
migrations.AddField( | ||
model_name='serviceaddress', | ||
name='state', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='s_addresses', to='address.state', verbose_name='state'), | ||
), | ||
migrations.AddField( | ||
model_name='customeraddress', | ||
name='area', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='c_addresses', to='address.area', verbose_name='area'), | ||
), | ||
migrations.AddField( | ||
model_name='customeraddress', | ||
name='city', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='c_addresses', to='address.city', verbose_name='city'), | ||
), | ||
migrations.AddField( | ||
model_name='customeraddress', | ||
name='state', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='c_addresses', to='address.state', verbose_name='state'), | ||
), | ||
migrations.AddField( | ||
model_name='customeraddress', | ||
name='user', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='c_addresses', to='accounts.customer', verbose_name='customer'), | ||
), | ||
] |
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,33 @@ | ||
# Generated by Django 3.2 on 2021-08-30 08:57 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('address', '0003_auto_20210830_1305'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='customeraddress', | ||
name='alley', | ||
field=models.TextField(blank=True), | ||
), | ||
migrations.AddField( | ||
model_name='customeraddress', | ||
name='street', | ||
field=models.TextField(blank=True), | ||
), | ||
migrations.AddField( | ||
model_name='serviceaddress', | ||
name='alley', | ||
field=models.TextField(blank=True), | ||
), | ||
migrations.AddField( | ||
model_name='serviceaddress', | ||
name='street', | ||
field=models.TextField(blank=True), | ||
), | ||
] |
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,33 @@ | ||
# Generated by Django 3.2 on 2021-08-30 08:59 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('address', '0004_auto_20210830_1327'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='customeraddress', | ||
name='alley', | ||
field=models.CharField(max_length=30), | ||
), | ||
migrations.AlterField( | ||
model_name='customeraddress', | ||
name='street', | ||
field=models.CharField(max_length=50), | ||
), | ||
migrations.AlterField( | ||
model_name='serviceaddress', | ||
name='alley', | ||
field=models.CharField(max_length=30), | ||
), | ||
migrations.AlterField( | ||
model_name='serviceaddress', | ||
name='street', | ||
field=models.CharField(max_length=50), | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
address/migrations/0006_rename_user_customeraddress_customer_user.py
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,18 @@ | ||
# Generated by Django 3.2 on 2021-08-31 10:06 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('address', '0005_auto_20210830_1329'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='customeraddress', | ||
old_name='user', | ||
new_name='customer_user', | ||
), | ||
] |
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,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<!-- Bootstrap --> | ||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" | ||
integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous"> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" | ||
crossorigin="anonymous"></script> | ||
|
||
<title>{% block title %} {% endblock %}</title> | ||
</head> | ||
<body> | ||
<div class="container pt-3"> | ||
{% block content %} | ||
{% endblock %} | ||
</div> | ||
|
||
</body> | ||
</html> |
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,8 @@ | ||
{% extends 'address/base.html' %} | ||
{% block content %} | ||
<form method="POST"> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
<input type="submit" value="submit" class="btn btn-warning"> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% extends 'address/base.html' %} | ||
{% block content %} | ||
<div> | ||
<form method="POST"> | ||
{% csrf_token %} | ||
<p>Are you sure to delete address ({{ object.state }} | {{ object.area }})?</p> | ||
<input type="submit" value="delete" class="btn btn-danger"> | ||
</form> | ||
<a href="{% url 'address:customer-address-update' object.id %}" class="btn btn-warning" style="margin-top: 20px">cancel</a> | ||
</div> | ||
{% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from django.urls import path | ||
|
||
from .views import CustomerAddressCreateView, CustomerAddressUpdateView, CustomerAddressDeleteView, \ | ||
ServiceAddressCreateView, ServiceAddressUpdateView | ||
|
||
app_name = 'address' | ||
|
||
urlpatterns = [ | ||
path('customer/create/', CustomerAddressCreateView.as_view(), name='customer-address-create'), | ||
path('service/create/<int:service_pk>/', ServiceAddressCreateView.as_view(), name='service-address-create'), | ||
|
||
path('customer/update/<int:pk>/', CustomerAddressUpdateView.as_view(), name='customer-address-update'), | ||
path('service/update/<int:pk>/', ServiceAddressUpdateView.as_view(), name='service-address-update'), | ||
|
||
path('customer/delete/<int:pk>/', CustomerAddressDeleteView.as_view(), name='customer-address-delete'), | ||
] |
Oops, something went wrong.