Skip to content

Commit

Permalink
-adds new model for household member applications (bcgov#68)
Browse files Browse the repository at this point in the history
-updates go_electric_rebate_applications to accept spouse email and application type, updates serializer
-migration
  • Loading branch information
emi-hi authored Apr 12, 2022
1 parent 1e1ade9 commit 07000ef
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Generated by Django 4.0.1 on 2022-04-12 22:18

from django.db import migrations, models
import django.db.models.deletion
import encrypted_fields.fields


class Migration(migrations.Migration):

dependencies = [
('api', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='goelectricrebateapplication',
name='application_type',
field=models.CharField(default='individual', max_length=25),
preserve_default=False,
),
migrations.AddField(
model_name='goelectricrebateapplication',
name='spouse_email',
field=models.EmailField(blank=True, max_length=250, null=True),
),
migrations.CreateModel(
name='HouseholdMember',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('create_timestamp', models.DateTimeField(auto_now_add=True, null=True)),
('create_user', models.CharField(default='SYSTEM', max_length=130)),
('update_timestamp', models.DateTimeField(auto_now=True, null=True)),
('update_user', models.CharField(max_length=130, null=True)),
('sin', encrypted_fields.fields.EncryptedCharField(max_length=9)),
('last_name', models.CharField(max_length=250)),
('first_name', models.CharField(max_length=250)),
('middle_names', models.CharField(blank=True, max_length=250, null=True)),
('email', models.EmailField(max_length=250)),
('date_of_birth', models.DateField()),
('doc1', models.ImageField(upload_to='docs')),
('doc2', models.ImageField(upload_to='docs')),
('verified', models.BooleanField()),
('application', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='api.goelectricrebateapplication')),
],
options={
'db_table': 'household_member',
},
),
]
1 change: 1 addition & 0 deletions django/api/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
Model Initializer
"""
from . import go_electric_rebate_application
from . import household_member
12 changes: 12 additions & 0 deletions django/api/models/go_electric_rebate_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ def doc2_tag(self):

verified = BooleanField()

spouse_email = EmailField(
max_length=250,
unique=False,
null=True,
blank=True
)

application_type = CharField(
max_length=25,
unique=False,
)

def __str__(self):
return self.last_name + ', ' + self.first_name

Expand Down
66 changes: 66 additions & 0 deletions django/api/models/household_member.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import uuid
from django.db.models import CharField, IntegerField, ImageField, \
DateField, EmailField, BooleanField, UUIDField, PROTECT, ForeignKey
from encrypted_fields.fields import EncryptedCharField
from auditable.models import Auditable
from django.utils.html import mark_safe
from django.core.files.storage import get_storage_class

media_storage = get_storage_class()()


class HouseholdMember(Auditable):
application = ForeignKey(
'GoElectricRebateApplication',
on_delete=PROTECT,
)
sin = EncryptedCharField(
max_length=9,
unique=False
)
last_name = CharField(
max_length=250,
unique=False
)
first_name = CharField(
max_length=250,
unique=False
)
middle_names = CharField(
max_length=250,
unique=False,
blank=True,
null=True
)
email = EmailField(
max_length=250,
unique=False
)
date_of_birth = DateField()
doc1 = ImageField(upload_to='docs')

def doc1_tag(self):
return mark_safe(
'<img src="%s" width="800" />'
% (media_storage.url(name=self.doc1.file.name))
)

doc1_tag.short_description = 'First Uploaded Document'

doc2 = ImageField(upload_to='docs')

def doc2_tag(self):
return mark_safe(
'<img src="%s" width="800" />'
% (media_storage.url(name=self.doc2.file.name))
)

doc2_tag.short_description = 'Second Uploaded Document'

verified = BooleanField()

def __str__(self):
return self.last_name + ', ' + self.first_name

class Meta:
db_table = 'household_member'
17 changes: 0 additions & 17 deletions django/api/models/income_verification2.py

This file was deleted.

2 changes: 2 additions & 0 deletions django/api/serializers/application_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def create(self, validated_data):
doc2=validated_data['doc2'],
tax_year=2021,
verified=False,
application_type=validated_data['application_type'],
spouse_email=validated_data['spouse_email']
)
return obj

Expand Down

0 comments on commit 07000ef

Please sign in to comment.