Skip to content

Commit e814c1d

Browse files
committed
update user save field
1 parent 525de42 commit e814c1d

File tree

4 files changed

+59
-16
lines changed

4 files changed

+59
-16
lines changed

tax/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def tax_calculate(self):
8080
sgst = 0
8181
tax_rate = 0
8282
income = float(self.income)
83-
if self.tax_payer.indian_state == '':
83+
if self.tax_payer.state == '':
8484
self.tax_amount = 0
8585
return None
8686
if self.tax_payer is not None:
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-09 08:25
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('user', '0002_auto_20210809_1351'),
10+
]
11+
12+
operations = [
13+
migrations.RemoveField(
14+
model_name='user',
15+
name='indian_state',
16+
),
17+
migrations.AddField(
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, verbose_name='State'),
21+
),
22+
]
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-09 08:33
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('user', '0003_auto_20210809_1355'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='user',
15+
name='state',
16+
field=models.CharField(blank=True, 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, null=True, verbose_name='State'),
17+
),
18+
]

user/models.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,13 @@ class User(AbstractBaseUser, PermissionsMixin):
9797
('Jammu and Kashmir', 'Jammu and Kashmir'),
9898
('Puducherry', 'Puducherry')
9999
)
100-
indian_state = models.CharField(
100+
state = models.CharField(
101101
max_length=100,
102102
choices=state_choice,
103103
default='',
104-
verbose_name='Indian State'
104+
verbose_name='State',
105+
blank=True,
106+
null=True
105107
)
106108
union_territories = models.BooleanField(default=False)
107109

@@ -127,17 +129,18 @@ def __str__(self):
127129
return str(self.username)
128130

129131
def save(self, *args, **kwargs):
130-
if self.state in [
131-
'Andaman and Nicobar Island',
132-
'Chandigarh',
133-
'Dadra and Nagar Haveli and Daman and Diu',
134-
'Delhi',
135-
'Ladakh',
136-
'Lakshadweep',
137-
'Jammu and Kashmir',
138-
'Puducherry'
139-
]:
140-
self.union_territories = True
141-
else:
142-
self.union_territories = False
132+
if self.state:
133+
if self.state in [
134+
'Andaman and Nicobar Island',
135+
'Chandigarh',
136+
'Dadra and Nagar Haveli and Daman and Diu',
137+
'Delhi',
138+
'Ladakh',
139+
'Lakshadweep',
140+
'Jammu and Kashmir',
141+
'Puducherry'
142+
]:
143+
self.union_territories = True
144+
else:
145+
self.union_territories = False
143146
super(User, self).save(*args, **kwargs)

0 commit comments

Comments
 (0)