Skip to content

Commit

Permalink
Tracking pull request to merge release-1.5.0 to main (#205)
Browse files Browse the repository at this point in the history
* update to 1.5.0

* itvr-353 (#206)

* -migration/model for constraints, is_legacy, allow nulls if legacy
-script for import
-excludes is_legacy from serializer
-adds is_legacy to console details

* -adds files that were missed in last commit

* -fixes migration

* itvr-362--schedule-ncda-job (#207)

* Itvr 335 (#208)

* add searchable fields in django admin

* add status field searchable

* adds logout button (#210)

* itvr-337--spouse-login-validation (#211)

* itvr-337--spouse-login-validation

* retry update

* itvr-338--cancel-household-application (#213)

* itvr-360--legacy-applications-console-fix (#214)

* itvr-365--cancel-from-login-page--backend (#215)

* add-run-jobs-env-var (#216)

* snowplow-analytics (#217)

* household-login-error--logout-redirect-change (#218)

* loop db inserts (#219)

* cleanup (#220)

* cancel initiated applications (#221)

* cancel initiated applications

* fix sonar bug

* PR suggestions

* remove change_form

* add migration file (#222)

* -adds user and password arguments for connecting to db (#223)

* reduce duplicate code (#224)

* More cleanup (#226)

* initial commit

* more cleanup

* remove missing import

* add NCDA vars to task-q (#227)

Co-authored-by: Emily <[email protected]>
Co-authored-by: tim738745 <[email protected]>
Co-authored-by: vibhiquartech <[email protected]>
  • Loading branch information
4 people authored Jul 13, 2022
1 parent ab51113 commit 7bcfc26
Show file tree
Hide file tree
Showing 47 changed files with 1,143 additions and 301 deletions.
66 changes: 66 additions & 0 deletions django/api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from .models.go_electric_rebate_application import (
GoElectricRebateApplication,
SubmittedGoElectricRebateApplication,
InitiatedGoElectricRebateApplication,
)
from .models.household_member import HouseholdMember
from .models.go_electric_rebate import GoElectricRebate
Expand Down Expand Up @@ -42,6 +43,7 @@ class GoElectricRebateApplicationAdmin(admin.ModelAdmin):
# by BCeID users.
@admin.register(SubmittedGoElectricRebateApplication)
class SubmittedGoElectricRebateApplicationAdmin(admin.ModelAdmin):
search_fields = ["drivers_licence", "id", "status"]
# disable bulk actions
actions = None
exclude = (
Expand Down Expand Up @@ -70,6 +72,7 @@ class SubmittedGoElectricRebateApplicationAdmin(admin.ModelAdmin):
"doc2_tag",
"consent_personal",
"consent_tax",
"is_legacy",
)

def get_queryset(self, request):
Expand Down Expand Up @@ -114,3 +117,66 @@ def message_user(
@admin.register(GoElectricRebate)
class GoElectricRebateAdmin(admin.ModelAdmin):
pass


@admin.register(InitiatedGoElectricRebateApplication)
class InitiatedGoElectricRebateApplicationAdmin(admin.ModelAdmin):
search_fields = ["drivers_licence", "id", "status"]
# disable bulk actions
actions = None
exclude = (
"sin",
"doc1",
"doc2",
"user",
"spouse_email",
"status",
"address",
"city",
"postal_code",
"application_type",
"doc1_tag",
"doc2_tag",
"consent_personal",
"consent_tax",
)
readonly_fields = (
"id",
"last_name",
"first_name",
"middle_names",
"email",
"user_is_bcsc",
"drivers_licence",
"date_of_birth",
"tax_year",
"is_legacy",
)

def get_queryset(self, request):
return GoElectricRebateApplication.objects.filter(
status=GoElectricRebateApplication.Status.HOUSEHOLD_INITIATED
)

def has_delete_permission(self, request, obj=None):
return False

def response_change(self, request, obj):
ret = super().response_change(request, obj)
if "cancel_application" in request.POST:
obj.status = GoElectricRebateApplication.Status.CANCELLED
obj.save(update_fields=["status"])
return ret

def message_user(
self,
request,
message,
level=messages.INFO,
extra_tags="",
fail_silently=False,
):
revised_level = level
if "cancel_application" in request.POST:
revised_level = messages_custom.NEGATIVE_SUCCESS
super().message_user(request, message, revised_level, extra_tags, fail_silently)
8 changes: 7 additions & 1 deletion django/api/apps.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
from django.apps import AppConfig
from django.contrib.admin.apps import AdminConfig
from . import settings
import sys


class ApiConfig(AppConfig):
name = "api"
verbose_name = "Submitted Rebate Applications"

def ready(self):
import api.signals
import api.signal_receivers
from api.scheduled_jobs import schedule_get_ncda_redeemed_rebates

if settings.RUN_JOBS and "qcluster" in sys.argv:
schedule_get_ncda_redeemed_rebates()


class ITVRAdminConfig(AdminConfig):
Expand Down
4 changes: 2 additions & 2 deletions django/api/authentication/keycloak.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def authenticate_credentials(self, token):
user, created = ITVRUser.objects.get_or_create(
username=token_info.get("sub"),
defaults={
"display_name": token_info.get("display_name"),
"display_name": token_info.get("display_name", ""),
"email": token_info.get("email", ""),
"identity_provider": token_info.get("identity_provider"),
"identity_provider": token_info.get("identity_provider", ""),
},
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Generated by Django 4.0.1 on 2022-06-30 15:56

import api.validators
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import encrypted_fields.fields


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('api', '0002_alter_goelectricrebate_ncda_id'),
]

operations = [
migrations.AddField(
model_name='goelectricrebateapplication',
name='is_legacy',
field=models.BooleanField(default=False, editable=False),
),
migrations.AlterField(
model_name='goelectricrebateapplication',
name='address',
field=models.CharField(max_length=250, null=True),
),
migrations.AlterField(
model_name='goelectricrebateapplication',
name='application_type',
field=models.CharField(max_length=25, null=True),
),
migrations.AlterField(
model_name='goelectricrebateapplication',
name='city',
field=models.CharField(max_length=250, null=True),
),
migrations.AlterField(
model_name='goelectricrebateapplication',
name='consent_personal',
field=models.BooleanField(null=True, validators=[api.validators.validate_consent]),
),
migrations.AlterField(
model_name='goelectricrebateapplication',
name='consent_tax',
field=models.BooleanField(null=True, validators=[api.validators.validate_consent]),
),
migrations.AlterField(
model_name='goelectricrebateapplication',
name='date_of_birth',
field=models.DateField(null=True, validators=[api.validators.validate_driving_age]),
),
migrations.AlterField(
model_name='goelectricrebateapplication',
name='email',
field=models.EmailField(max_length=250, null=True),
),
migrations.AlterField(
model_name='goelectricrebateapplication',
name='first_name',
field=models.CharField(max_length=250, null=True),
),
migrations.AlterField(
model_name='goelectricrebateapplication',
name='last_name',
field=models.CharField(max_length=250, null=True),
),
migrations.AlterField(
model_name='goelectricrebateapplication',
name='sin',
field=encrypted_fields.fields.EncryptedCharField(max_length=9, null=True, validators=[api.validators.validate_sin]),
),
migrations.AlterField(
model_name='goelectricrebateapplication',
name='tax_year',
field=models.IntegerField(null=True),
),
migrations.AlterField(
model_name='goelectricrebateapplication',
name='user',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
),
migrations.AddConstraint(
model_name='goelectricrebateapplication',
constraint=models.CheckConstraint(check=models.Q(('is_legacy__exact', True), ('user__isnull', False), _connector='OR'), name='user_null_constraint'),
),
migrations.AddConstraint(
model_name='goelectricrebateapplication',
constraint=models.CheckConstraint(check=models.Q(('is_legacy__exact', True), ('sin__isnull', False), _connector='OR'), name='sin_null_constraint'),
),
migrations.AddConstraint(
model_name='goelectricrebateapplication',
constraint=models.CheckConstraint(check=models.Q(('is_legacy__exact', True), ('last_name__isnull', False), _connector='OR'), name='last_name_null_constraint'),
),
migrations.AddConstraint(
model_name='goelectricrebateapplication',
constraint=models.CheckConstraint(check=models.Q(('is_legacy__exact', True), ('first_name__isnull', False), _connector='OR'), name='first_name_null_constraint'),
),
migrations.AddConstraint(
model_name='goelectricrebateapplication',
constraint=models.CheckConstraint(check=models.Q(('is_legacy__exact', True), ('email__isnull', False), _connector='OR'), name='email_null_constraint'),
),
migrations.AddConstraint(
model_name='goelectricrebateapplication',
constraint=models.CheckConstraint(check=models.Q(('is_legacy__exact', True), ('address__isnull', False), _connector='OR'), name='address_null_constraint'),
),
migrations.AddConstraint(
model_name='goelectricrebateapplication',
constraint=models.CheckConstraint(check=models.Q(('is_legacy__exact', True), ('city__isnull', False), _connector='OR'), name='city_null_constraint'),
),
migrations.AddConstraint(
model_name='goelectricrebateapplication',
constraint=models.CheckConstraint(check=models.Q(('is_legacy__exact', True), ('date_of_birth__isnull', False), _connector='OR'), name='date_of_birth_null_constraint'),
),
migrations.AddConstraint(
model_name='goelectricrebateapplication',
constraint=models.CheckConstraint(check=models.Q(('is_legacy__exact', True), ('tax_year__isnull', False), _connector='OR'), name='tax_year_null_constraint'),
),
migrations.AddConstraint(
model_name='goelectricrebateapplication',
constraint=models.CheckConstraint(check=models.Q(('is_legacy__exact', True), ('consent_personal__isnull', False), _connector='OR'), name='consent_personal_null_constraint'),
),
migrations.AddConstraint(
model_name='goelectricrebateapplication',
constraint=models.CheckConstraint(check=models.Q(('is_legacy__exact', True), ('consent_tax__isnull', False), _connector='OR'), name='consent_tax_null_constraint'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.1 on 2022-07-06 20:33

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0003_goelectricrebateapplication_is_legacy_and_more'),
]

operations = [
migrations.AlterField(
model_name='goelectricrebateapplication',
name='status',
field=models.CharField(choices=[('household_initiated', 'Household Initiated'), ('submitted', 'Submitted'), ('verified', 'Verified'), ('declined', 'Declined'), ('approved', 'Approved'), ('not_approved', 'Not Approved'), ('redeemed', 'Redeemed'), ('expired', 'Expired'), ('cancelled', 'Cancelled')], max_length=250),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.0.1 on 2022-07-11 18:09

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0004_alter_goelectricrebateapplication_status'),
]

operations = [
migrations.AddConstraint(
model_name='goelectricrebateapplication',
constraint=models.CheckConstraint(check=models.Q(('is_legacy__exact', True), ('application_type__isnull', False), _connector='OR'), name='application_type_null_constraint'),
),
]
24 changes: 24 additions & 0 deletions django/api/migrations/0006_initiatedgoelectricrebateapplication.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.0.1 on 2022-07-12 17:24

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api', '0005_goelectricrebateapplication_application_type_null_constraint'),
]

operations = [
migrations.CreateModel(
name='InitiatedGoElectricRebateApplication',
fields=[
],
options={
'proxy': True,
'indexes': [],
'constraints': [],
},
bases=('api.goelectricrebateapplication',),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Generated by Django 4.0.1 on 2022-07-12 21:56

import api.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0006_initiatedgoelectricrebateapplication'),
]

operations = [
migrations.AlterModelOptions(
name='goelectricrebate',
options={},
),
migrations.AlterField(
model_name='goelectricrebateapplication',
name='doc1',
field=models.ImageField(blank=True, null=True, upload_to='docs', validators=[api.validators.validate_file_size]),
),
migrations.AlterField(
model_name='goelectricrebateapplication',
name='doc2',
field=models.ImageField(blank=True, null=True, upload_to='docs', validators=[api.validators.validate_file_size]),
),
migrations.AlterField(
model_name='householdmember',
name='doc1',
field=models.ImageField(blank=True, null=True, upload_to='docs', validators=[api.validators.validate_file_size]),
),
migrations.AlterField(
model_name='householdmember',
name='doc2',
field=models.ImageField(blank=True, null=True, upload_to='docs', validators=[api.validators.validate_file_size]),
),
migrations.AlterModelTable(
name='goelectricrebate',
table='go_electric_rebate',
),
]
4 changes: 3 additions & 1 deletion django/api/models/go_electric_rebate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
BooleanField,
PROTECT,
ForeignKey,
UUIDField,
)

from django.core.validators import MinLengthValidator
Expand All @@ -31,3 +30,6 @@ class GoElectricRebate(TimeStampedModel):

def __str__(self):
return "DL: " + self.drivers_licence + ", $" + str(self.rebate_max_amount)

class Meta:
db_table = "go_electric_rebate"
Loading

0 comments on commit 7bcfc26

Please sign in to comment.