Skip to content

Commit 2f5b00c

Browse files
committed
added state to users
1 parent 39ab2ad commit 2f5b00c

19 files changed

+272
-2
lines changed

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ gunicorn = "*"
1111
drf-yasg = "*"
1212
whitenoise = "*"
1313
coreapi = "*"
14-
psycopg2-binary = "*"
14+
# psycopg2-binary = "*"
1515

1616
[dev-packages]
1717
django_linter = "*"

tax/__init__.py

Whitespace-only changes.

tax/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

tax/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class TaxConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'tax'

tax/migrations/__init__.py

Whitespace-only changes.

tax/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.db import models
2+
3+
# Create your models here.

tax/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

tax/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.shortcuts import render
2+
3+
# Create your views here.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 3.2.6 on 2021-08-07 16:01
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('user', '0001_initial'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='user',
15+
name='state',
16+
field=models.CharField(choices=[('Andhra Pradesh', 'Andhra Pradesh'), ('Arunachal Pradesh', 'Arunachal Pradesh'), ('Assam', 'Assam'), ('Bihar', 'Bihar'), ('Chhattisgarh', 'Chhattisgarh'), ('Goa', 'Goa'), ('Gujarat', 'Gujarat'), ('Haryana', 'Haryana'), ('Himachal Pradesh', 'Himachal Pradesh'), ('Jharkhand', 'Jharkhand'), ('Karnataka', 'Karnataka'), ('Kerala', 'Kerala'), ('Madhya Pradesh', 'Madhya Pradesh'), ('Maharashtra', 'Maharashtra'), ('Manipur', 'Manipur'), ('Meghalaya', 'Meghalaya'), ('Mizora', 'Mizora'), ('Nagaland', 'Nagaland'), ('Odisha', 'Odisha'), ('Punjab', 'Punjab'), ('Rajasthan', 'Rajasthan'), ('Sikkim', 'Sikkim'), ('Tamil Nadu', 'Tamil Nadu'), ('Telangana', 'Telangana'), ('Tripura', 'Tripura'), ('Uttar Pradesh', 'Uttar Pradesh'), ('Uttarakhand', 'Uttarakhand'), ('West Bengal', 'West Bengal'), ('Andaman and Nicobar Island', 'Andaman and Nicobar Island'), ('Chandigarh', 'Chandigarh'), ('Dadra and Nagar Haveli and Daman and Diu', 'Dadra and Nagar Haveli and Daman and Diu'), ('Delhi', 'Delhi'), ('Ladakh', 'Ladakh'), ('Lakshadweep', 'Lakshadweep'), ('Jammu and Kashmir', 'Jammu and Kashmir'), ('Puducherry', 'Puducherry')], default='', max_length=100),
17+
),
18+
migrations.AddField(
19+
model_name='user',
20+
name='union_territories',
21+
field=models.BooleanField(default=False),
22+
),
23+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.2.6 on 2021-08-07 16:03
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('user', '0002_auto_20210807_2131'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='user',
15+
name='state',
16+
field=models.CharField(choices=[('Andhra Pradesh', 'Andhra Pradesh'), ('Arunachal Pradesh', 'Arunachal Pradesh'), ('Assam', 'Assam'), ('Bihar', 'Bihar'), ('Chhattisgarh', 'Chhattisgarh'), ('Goa', 'Goa'), ('Gujarat', 'Gujarat'), ('Haryana', 'Haryana'), ('Himachal Pradesh', 'Himachal Pradesh'), ('Jharkhand', 'Jharkhand'), ('Karnataka', 'Karnataka'), ('Kerala', 'Kerala'), ('Madhya Pradesh', 'Madhya Pradesh'), ('Maharashtra', 'Maharashtra'), ('Manipur', 'Manipur'), ('Meghalaya', 'Meghalaya'), ('Mizora', 'Mizora'), ('Nagaland', 'Nagaland'), ('Odisha', 'Odisha'), ('Punjab', 'Punjab'), ('Rajasthan', 'Rajasthan'), ('Sikkim', 'Sikkim'), ('Tamil Nadu', 'Tamil Nadu'), ('Telangana', 'Telangana'), ('Tripura', 'Tripura'), ('Uttar Pradesh', 'Uttar Pradesh'), ('Uttarakhand', 'Uttarakhand'), ('West Bengal', 'West Bengal'), ('Andaman and Nicobar Island', 'Andaman and Nicobar Island'), ('Chandigarh', 'Chandigarh'), ('Dadra and Nagar Haveli and Daman and Diu', 'Dadra and Nagar Haveli and Daman and Diu'), ('Delhi', 'Delhi'), ('Ladakh', 'Ladakh'), ('Lakshadweep', 'Lakshadweep'), ('Jammu and Kashmir', 'Jammu and Kashmir'), ('Puducherry', 'Puducherry')], default='', max_length=200),
17+
),
18+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.2.6 on 2021-08-07 16:05
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('user', '0003_alter_user_state'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='user',
15+
name='state',
16+
field=models.CharField(choices=[('Andhra Pradesh', 'Andhra Pradesh'), ('Arunachal Pradesh', 'Arunachal Pradesh'), ('Assam', 'Assam'), ('Bihar', 'Bihar'), ('Chhattisgarh', 'Chhattisgarh'), ('Goa', 'Goa'), ('Gujarat', 'Gujarat'), ('Haryana', 'Haryana'), ('Himachal Pradesh', 'Himachal Pradesh'), ('Jharkhand', 'Jharkhand'), ('Karnataka', 'Karnataka'), ('Kerala', 'Kerala'), ('Madhya Pradesh', 'Madhya Pradesh'), ('Maharashtra', 'Maharashtra'), ('Manipur', 'Manipur'), ('Meghalaya', 'Meghalaya'), ('Mizora', 'Mizora'), ('Nagaland', 'Nagaland'), ('Odisha', 'Odisha'), ('Punjab', 'Punjab'), ('Rajasthan', 'Rajasthan'), ('Sikkim', 'Sikkim'), ('Tamil Nadu', 'Tamil Nadu'), ('Telangana', 'Telangana'), ('Tripura', 'Tripura'), ('Uttar Pradesh', 'Uttar Pradesh'), ('Uttarakhand', 'Uttarakhand'), ('West Bengal', 'West Bengal'), ('Andaman and Nicobar Island', 'Andaman and Nicobar Island'), ('Chandigarh', 'Chandigarh'), ('Dadra and Nagar Haveli and Daman and Diu', 'Dadra and Nagar Haveli and Daman and Diu'), ('Delhi', 'Delhi'), ('Ladakh', 'Ladakh'), ('Lakshadweep', 'Lakshadweep'), ('Jammu and Kashmir', 'Jammu and Kashmir'), ('Puducherry', 'Puducherry')], default='West Bengal', max_length=200),
17+
),
18+
]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generated by Django 3.2.6 on 2021-08-07 16:13
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('user', '0004_alter_user_state'),
10+
]
11+
12+
operations = [
13+
migrations.RemoveField(
14+
model_name='user',
15+
name='union_territories',
16+
),
17+
migrations.AlterField(
18+
model_name='user',
19+
name='state',
20+
field=models.CharField(choices=[('Andhra Pradesh', 'Andhra Pradesh'), ('Arunachal Pradesh', 'Arunachal Pradesh'), ('Assam', 'Assam'), ('Bihar', 'Bihar'), ('Chhattisgarh', 'Chhattisgarh'), ('Goa', 'Goa'), ('Gujarat', 'Gujarat'), ('Haryana', 'Haryana'), ('Himachal Pradesh', 'Himachal Pradesh'), ('Jharkhand', 'Jharkhand'), ('Karnataka', 'Karnataka'), ('Kerala', 'Kerala'), ('Madhya Pradesh', 'Madhya Pradesh'), ('Maharashtra', 'Maharashtra'), ('Manipur', 'Manipur'), ('Meghalaya', 'Meghalaya'), ('Mizora', 'Mizora'), ('Nagaland', 'Nagaland'), ('Odisha', 'Odisha'), ('Punjab', 'Punjab'), ('Rajasthan', 'Rajasthan'), ('Sikkim', 'Sikkim'), ('Tamil Nadu', 'Tamil Nadu'), ('Telangana', 'Telangana'), ('Tripura', 'Tripura'), ('Uttar Pradesh', 'Uttar Pradesh'), ('Uttarakhand', 'Uttarakhand'), ('West Bengal', 'West Bengal'), ('Andaman and Nicobar Island', 'Andaman and Nicobar Island'), ('Chandigarh', 'Chandigarh'), ('Dadra and Nagar Haveli and Daman and Diu', 'Dadra and Nagar Haveli and Daman and Diu'), ('Delhi', 'Delhi'), ('Ladakh', 'Ladakh'), ('Lakshadweep', 'Lakshadweep'), ('Jammu and Kashmir', 'Jammu and Kashmir'), ('Puducherry', 'Puducherry')], default='', max_length=100),
21+
),
22+
]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 3.2.6 on 2021-08-07 16:14
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('user', '0005_auto_20210807_2143'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='user',
15+
name='union_territories',
16+
field=models.BooleanField(default=False),
17+
),
18+
migrations.AlterField(
19+
model_name='user',
20+
name='state',
21+
field=models.CharField(choices=[('Andhra Pradesh', 'Andhra Pradesh'), ('Arunachal Pradesh', 'Arunachal Pradesh'), ('Assam', 'Assam'), ('Bihar', 'Bihar'), ('Chhattisgarh', 'Chhattisgarh'), ('Goa', 'Goa'), ('Gujarat', 'Gujarat'), ('Haryana', 'Haryana'), ('Himachal Pradesh', 'Himachal Pradesh'), ('Jharkhand', 'Jharkhand'), ('Karnataka', 'Karnataka'), ('Kerala', 'Kerala'), ('Madhya Pradesh', 'Madhya Pradesh'), ('Maharashtra', 'Maharashtra'), ('Manipur', 'Manipur'), ('Meghalaya', 'Meghalaya'), ('Mizora', 'Mizora'), ('Nagaland', 'Nagaland'), ('Odisha', 'Odisha'), ('Punjab', 'Punjab'), ('Rajasthan', 'Rajasthan'), ('Sikkim', 'Sikkim'), ('Tamil Nadu', 'Tamil Nadu'), ('Telangana', 'Telangana'), ('Tripura', 'Tripura'), ('Uttar Pradesh', 'Uttar Pradesh'), ('Uttarakhand', 'Uttarakhand'), ('West Bengal', 'West Bengal'), ('Andaman and Nicobar Island', 'Andaman and Nicobar Island'), ('Chandigarh', 'Chandigarh'), ('Dadra and Nagar Haveli and Daman and Diu', 'Dadra and Nagar Haveli and Daman and Diu'), ('Delhi', 'Delhi'), ('Ladakh', 'Ladakh'), ('Lakshadweep', 'Lakshadweep'), ('Jammu and Kashmir', 'Jammu and Kashmir'), ('Puducherry', 'Puducherry')], default='', max_length=150),
22+
),
23+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.2.6 on 2021-08-07 16:15
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('user', '0006_auto_20210807_2144'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='user',
15+
name='state',
16+
field=models.CharField(choices=[('Andhra Pradesh', 'Andhra Pradesh'), ('Arunachal Pradesh', 'Arunachal Pradesh')], default='', max_length=150),
17+
),
18+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.2.6 on 2021-08-07 16:16
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('user', '0007_alter_user_state'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='user',
15+
name='state',
16+
field=models.CharField(choices=[('Andhra Pradesh', 'Andhra Pradesh'), ('Arunachal Pradesh', 'Arunachal Pradesh'), ('Assam', 'Assam'), ('Bihar', 'Bihar'), ('Chhattisgarh', 'Chhattisgarh'), ('Goa', 'Goa'), ('Gujarat', 'Gujarat'), ('Haryana', 'Haryana'), ('Himachal Pradesh', 'Himachal Pradesh'), ('Jharkhand', 'Jharkhand'), ('Karnataka', 'Karnataka'), ('Kerala', 'Kerala'), ('Madhya Pradesh', 'Madhya Pradesh'), ('Maharashtra', 'Maharashtra'), ('Manipur', 'Manipur'), ('Meghalaya', 'Meghalaya'), ('Mizora', 'Mizora'), ('Nagaland', 'Nagaland'), ('Odisha', 'Odisha'), ('Punjab', 'Punjab'), ('Rajasthan', 'Rajasthan'), ('Sikkim', 'Sikkim'), ('Tamil Nadu', 'Tamil Nadu'), ('Telangana', 'Telangana'), ('Tripura', 'Tripura'), ('Uttar Pradesh', 'Uttar Pradesh'), ('Uttarakhand', 'Uttarakhand'), ('West Bengal', 'West Bengal'), ('Andaman and Nicobar Island', 'Andaman and Nicobar Island'), ('Chandigarh', 'Chandigarh'), ('Dadra and Nagar Haveli and Daman and Diu', 'Dadra and Nagar Haveli and Daman and Diu'), ('Delhi', 'Delhi'), ('Ladakh', 'Ladakh'), ('Lakshadweep', 'Lakshadweep'), ('Jammu and Kashmir', 'Jammu and Kashmir'), ('Puducherry', 'Puducherry')], default='', max_length=100),
17+
),
18+
]

user/models.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,53 @@ class User(AbstractBaseUser, PermissionsMixin):
5757
default='admin'
5858
)
5959

60+
state_choice = (
61+
('Andhra Pradesh', 'Andhra Pradesh'),
62+
('Arunachal Pradesh', 'Arunachal Pradesh'),
63+
('Assam', 'Assam'),
64+
('Bihar', 'Bihar'),
65+
('Chhattisgarh', 'Chhattisgarh'),
66+
('Goa', 'Goa'),
67+
('Gujarat', 'Gujarat'),
68+
('Haryana', 'Haryana'),
69+
('Himachal Pradesh', 'Himachal Pradesh'),
70+
('Jharkhand', 'Jharkhand'),
71+
('Karnataka', 'Karnataka'),
72+
('Kerala', 'Kerala'),
73+
('Madhya Pradesh', 'Madhya Pradesh'),
74+
('Maharashtra', 'Maharashtra'),
75+
('Manipur', 'Manipur'),
76+
('Meghalaya', 'Meghalaya'),
77+
('Mizora', 'Mizora'),
78+
('Nagaland', 'Nagaland'),
79+
('Odisha', 'Odisha'),
80+
('Punjab', 'Punjab'),
81+
('Rajasthan', 'Rajasthan'),
82+
('Sikkim', 'Sikkim'),
83+
('Tamil Nadu', 'Tamil Nadu'),
84+
('Telangana', 'Telangana'),
85+
('Tripura', 'Tripura'),
86+
('Uttar Pradesh', 'Uttar Pradesh'),
87+
('Uttarakhand', 'Uttarakhand'),
88+
('West Bengal', 'West Bengal'),
89+
('Andaman and Nicobar Island',
90+
'Andaman and Nicobar Island'),
91+
('Chandigarh', 'Chandigarh'),
92+
('Dadra and Nagar Haveli and Daman and Diu',
93+
'Dadra and Nagar Haveli and Daman and Diu'),
94+
('Delhi', 'Delhi'),
95+
('Ladakh', 'Ladakh'),
96+
('Lakshadweep', 'Lakshadweep'),
97+
('Jammu and Kashmir', 'Jammu and Kashmir'),
98+
('Puducherry', 'Puducherry')
99+
)
100+
state = models.CharField(
101+
max_length=100,
102+
choices=state_choice,
103+
default=''
104+
)
105+
union_territories = models.BooleanField(default=False)
106+
60107
objects = UserManager()
61108
adminmanager = AdminManager()
62109
taxpayermanager = TaxPayerManager()
@@ -77,3 +124,19 @@ def get_username(self):
77124

78125
def __str__(self):
79126
return str(self.username)
127+
128+
def save(self, *args, **kwargs):
129+
if self.state in [
130+
'Andaman and Nicobar Island',
131+
'Chandigarh',
132+
'Dadra and Nagar Haveli and Daman and Diu',
133+
'Delhi',
134+
'Ladakh',
135+
'Lakshadweep',
136+
'Jammu and Kashmir',
137+
'Puducherry'
138+
]:
139+
self.union_territories = True
140+
else:
141+
self.union_territories = False
142+
super(User, self).save(*args, **kwargs)

user/serializers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Meta:
1414
'first_name',
1515
'last_name',
1616
'user_type',
17+
'state',
1718
'date_joined'
1819
)
1920
extra_kwargs = {
@@ -31,6 +32,7 @@ class Meta:
3132
'email',
3233
'username',
3334
'user_type',
35+
'state',
3436
'date_joined',
3537
'token'
3638
)

user/urls.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
get_user_list,
77
get_user_view,
88
registerTaxAccountant,
9-
registerTaxPayer
9+
registerTaxPayer,
10+
state_list
1011
)
1112

1213
app_name = "user"
@@ -19,4 +20,5 @@
1920
path('list/', get_user_list, name="user_list"),
2021
path('<uuid:id>/', get_user_view, name="user_view"),
2122
path('<uuid:id>/edit/', get_user_edit, name="user_edit"),
23+
path('state_list/', state_list, name="state_list"),
2224
]

user/views.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,48 @@ def get_user_edit(request, id, *args, **kwargs):
145145
status=HTTP_304_NOT_MODIFIED
146146
)
147147
return Response(serializer.data, status=HTTP_200_OK)
148+
149+
150+
@swagger_auto_schema(method='get')
151+
@api_view(['GET'])
152+
@permission_classes([AllowAny])
153+
def state_list(request, *args, **kwargs):
154+
state = (
155+
'Andhra Pradesh',
156+
'Arunachal Pradesh',
157+
'Assam',
158+
'Bihar',
159+
'Chhattisgarh',
160+
'Goa',
161+
'Gujarat',
162+
'Haryana',
163+
'Himachal Pradesh',
164+
'Jharkhand',
165+
'Karnataka',
166+
'Kerala',
167+
'Madhya Pradesh',
168+
'Maharashtra',
169+
'Manipur',
170+
'Meghalaya',
171+
'Mizora',
172+
'Nagaland',
173+
'Odisha',
174+
'Punjab',
175+
'Rajasthan',
176+
'Sikkim',
177+
'Tamil Nadu',
178+
'Telangana',
179+
'Tripura',
180+
'Uttar Pradesh',
181+
'Uttarakhand',
182+
'West Bengal',
183+
'Andaman and Nicobar Island',
184+
'Chandigarh',
185+
'Dadra and Nagar Haveli and Daman and Diu',
186+
'Delhi',
187+
'Ladakh',
188+
'Lakshadweep',
189+
'Jammu and Kashmir',
190+
'Puducherry'
191+
)
192+
return Response(state, status=HTTP_200_OK)

0 commit comments

Comments
 (0)