forked from bcgov/cthub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-adds new model for household member applications (bcgov#68)
-updates go_electric_rebate_applications to accept spouse email and application type, updates serializer -migration
- Loading branch information
Showing
6 changed files
with
130 additions
and
17 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
django/api/migrations/0002_goelectricrebateapplication_application_type_and_more.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,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', | ||
}, | ||
), | ||
] |
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
Model Initializer | ||
""" | ||
from . import go_electric_rebate_application | ||
from . import household_member |
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,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' |
This file was deleted.
Oops, something went wrong.
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