Skip to content

Commit

Permalink
Merge pull request #2288 from uktrade/dev
Browse files Browse the repository at this point in the history
UAT release
  • Loading branch information
markj0hnst0n authored Nov 18, 2024
2 parents 9fbbbc8 + fc93b83 commit 4bfbbc2
Show file tree
Hide file tree
Showing 49 changed files with 1,519 additions and 227 deletions.
13 changes: 13 additions & 0 deletions .InstallPackages
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
libpq-dev
build-essential
libcairo2
libpango-1.0-0
libpangocairo-1.0-0
libgdk-pixbuf2.0-0
libffi-dev
shared-mime-info
swig
imagemagick
poppler-utils
libsqlite3-dev
postgresql-client-14
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ jobs:
- git_checkout
- attach_workspace:
at: ~/lite-api/tmp
- run: pip install coverage diff_cover
- run: pip install coverage==7.6.4 diff_cover
- run: coverage combine tmp
- run: coverage xml
- run: coverage html
Expand Down
6 changes: 6 additions & 0 deletions .copilot/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repository: lite/lite-backend
builder:
name: paketobuildpacks/builder-jammy-full
version: 0.3.339
packs:
- acodeninja/install
3 changes: 3 additions & 0 deletions .copilot/image_build_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

set -e
3 changes: 3 additions & 0 deletions .copilot/phases/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

set -e
3 changes: 3 additions & 0 deletions .copilot/phases/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

set -e
3 changes: 3 additions & 0 deletions .copilot/phases/post_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

set -e
25 changes: 25 additions & 0 deletions .copilot/phases/pre_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# Exit early if something goes wrong
set -e

git_clone_base_url="https://codestar-connections.eu-west-2.amazonaws.com/git-http/$AWS_ACCOUNT_ID/eu-west-2/$CODESTAR_CONNECTION_ID/uktrade"

git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true

cat <<EOF > ./.gitmodules
[submodule "lite-content"]
path = lite_content
url = $git_clone_base_url/lite-content.git
branch = master
[submodule "lite_routing"]
path = lite_routing
url = $git_clone_base_url/lite-routing.git
branch = main
[submodule "django_db_anonymiser"]
path = django_db_anonymiser
url = $git_clone_base_url/django-db-anonymiser.git
EOF

git submodule update --init --recursive
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ omit =
./*/migrations/*
./api/conf/schema_generator_urls.py
./api/conf/settings.py
./api/conf/gconfig-dbt-platform.py
./api/conf/wsgi.py
./static/management/*
*test*
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ bank-holidays.csv
/test_helpers/test_endpoints/results/*.csv
*.p12

.python-version

# pii file
.pii-secret-hook
Expand Down
266 changes: 266 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
web: SWIG_LIB=/home/vcap/deps/0/apt/usr/share/swig4.0 CFLAGS=-I/home/vcap/deps/1/python/include/python3.9.18m pip3 install endesive==1.5.9 && python manage.py migrate && gunicorn --worker-class gevent -c api/conf/gconfig.py -b 0.0.0.0:$PORT api.conf.wsgi
web-dbt-platform: python manage.py migrate && gunicorn -c api/conf/gconfig-dbt-platform.py -b 0.0.0.0:$PORT api.conf.wsgi
dump-and-anonymise: python manage.py dump_and_anonymise
celeryworker: celery -A api.conf worker -l info
celeryscheduler: celery -A api.conf beat
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Gegenerate diagrams
## Running tests

- `pipenv run pytest`
- `pipenv run pytest --reuse-db` to speed up tests

## Running code coverage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def handle(self, *args, **kwargs):
for row in reader:
party_id = row["party_id"]
address = row["address"].replace("\\r\\n", "\r\n")
new_address = row["new_address"]
new_address = row["new_address"].replace("\\r\\n", "\r\n")
additional_text = row["additional_text"]

self.update_field_on_party(party_id, address, new_address, additional_text, audit_log)
Expand Down
2 changes: 1 addition & 1 deletion api/applications/management/commands/update_party_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def handle(self, *args, **kwargs):
for row in reader:
party_id = row["party_id"]
name = row["name"].replace("\\r\\n", "\r\n")
new_name = row["new_name"]
new_name = row["new_name"].replace("\\r\\n", "\r\n")
additional_text = row["additional_text"]

self.update_field_on_party(party_id, name, new_name, additional_text)
Expand Down
7 changes: 4 additions & 3 deletions api/applications/tests/test_update_parties_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ def setUp(self):

def test_update_field_on_party_from_csv(self):

new_address = "56 Heathwood Road Broadstairs Kent"
new_address = "56 Heathwood Road\\r\\n Broadstairs Kent"
old_address = self.standard_application.end_user.party.address
result = "56 Heathwood Road\r\n Broadstairs Kent"
party_id = self.standard_application.end_user.party.id

with NamedTemporaryFile(suffix=".csv", delete=True) as tmp_file:
Expand All @@ -28,7 +29,7 @@ def test_update_field_on_party_from_csv(self):

call_command("update_party_address", tmp_file.name)
self.standard_application.refresh_from_db()
self.assertEqual(self.standard_application.end_user.party.address, new_address)
self.assertEqual(self.standard_application.end_user.party.address, result)

audit = Audit.objects.get()

Expand All @@ -38,7 +39,7 @@ def test_update_field_on_party_from_csv(self):
self.assertEqual(
audit.payload,
{
"address": {"new": new_address, "old": old_address},
"address": {"new": result, "old": old_address},
"additional_text": "added by John Smith as per LTD-XXX",
},
)
Expand Down
7 changes: 4 additions & 3 deletions api/applications/tests/test_update_party_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ def setUp(self):

def test_update_field_on_party_from_csv(self):

new_name = "Bangarang 3000"
new_name = "Bangarang 3000\\r\\n Skrilly"
old_name = self.standard_application.end_user.party.name
party_id = self.standard_application.end_user.party.id
result = "Bangarang 3000\r\n Skrilly"

with NamedTemporaryFile(suffix=".csv", delete=True) as tmp_file:
rows = [
Expand All @@ -28,7 +29,7 @@ def test_update_field_on_party_from_csv(self):

call_command("update_party_name", tmp_file.name)
self.standard_application.refresh_from_db()
self.assertEqual(self.standard_application.end_user.party.name, new_name)
self.assertEqual(self.standard_application.end_user.party.name, result)

audit = Audit.objects.get()

Expand All @@ -38,7 +39,7 @@ def test_update_field_on_party_from_csv(self):
self.assertEqual(
audit.payload,
{
"name": {"new": new_name, "old": old_name},
"name": {"new": result, "old": old_name},
"additional_text": "added by John Smith as per LTD-XXX",
},
)
Expand Down
36 changes: 36 additions & 0 deletions api/cases/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

from lite_content.lite_api import strings

SIEL_LICENCE_TEMPLATE_ID = "d159b195-9256-4a00-9bc8-1eb2cebfa1d2"
SIEL_REFUSAL_TEMPLATE_ID = "074d8a54-ee10-4dca-82ba-650460650342"


class CaseTypeReferenceEnum:
OIEL = "oiel"
Expand Down Expand Up @@ -408,3 +411,36 @@ class EnforcementXMLEntityTypes:
(SITE, "site"),
(ORGANISATION, "organisation"),
]


class LicenceDecisionType:
ISSUED = "issued"
REFUSED = "refused"
REVOKED = "revoked"

choices = [
(ISSUED, "issued"),
(REFUSED, "refused"),
(REVOKED, "revoked"),
]

decision_map = {
AdviceType.APPROVE: ISSUED,
AdviceType.REFUSE: REFUSED,
}

@classmethod
def decisions(cls):
return [d[0] for d in cls.choices]

@classmethod
def templates(cls):
return {
cls.ISSUED: SIEL_LICENCE_TEMPLATE_ID,
cls.REFUSED: SIEL_REFUSAL_TEMPLATE_ID,
cls.REVOKED: None,
}

@classmethod
def advice_type_to_decision(cls, advice_type):
return cls.decision_map[advice_type]
9 changes: 9 additions & 0 deletions api/cases/generated_documents/tests/factories.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import factory

from api.cases.enums import AdviceType
from api.cases.generated_documents.models import GeneratedCaseDocument
from api.cases.tests.factories import CaseSIELFactory
from api.letter_templates.tests.factories import SIELLicenceTemplateFactory


class GeneratedCaseDocumentFactory(factory.django.DjangoModelFactory):
Expand All @@ -13,3 +15,10 @@ class GeneratedCaseDocumentFactory(factory.django.DjangoModelFactory):

class Meta:
model = GeneratedCaseDocument


class SIELLicenceDocumentFactory(GeneratedCaseDocumentFactory):
text = factory.Faker("sentence")
template = factory.SubFactory(SIELLicenceTemplateFactory)
licence = None
advice_type = AdviceType.APPROVE
4 changes: 2 additions & 2 deletions api/cases/libraries/finalise.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from api.audit_trail.models import Audit
from api.applications.models import GoodOnApplication
from api.cases.enums import AdviceType, CaseTypeSubTypeEnum, AdviceLevel
from api.cases.models import Advice, GoodCountryDecision
from api.applications.models import GoodOnApplication
from api.flags.models import Flag
from api.audit_trail.models import Audit


def get_required_decision_document_types(case):
Expand Down
63 changes: 63 additions & 0 deletions api/cases/migrations/0067_licencedecision.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Generated by Django 4.2.16 on 2024-11-01 11:48

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import model_utils.fields
import uuid


class Migration(migrations.Migration):

dependencies = [
("licences", "0019_auto_20210506_0340"),
("cases", "0066_delete_casereviewdate"),
]

operations = [
migrations.CreateModel(
name="LicenceDecision",
fields=[
(
"created_at",
model_utils.fields.AutoCreatedField(
default=django.utils.timezone.now, editable=False, verbose_name="created_at"
),
),
(
"updated_at",
model_utils.fields.AutoLastModifiedField(
default=django.utils.timezone.now, editable=False, verbose_name="updated_at"
),
),
("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
(
"decision",
models.CharField(
choices=[("issued", "issued"), ("refused", "refused"), ("revoked", "revoked")], max_length=50
),
),
(
"case",
models.ForeignKey(
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="licence_decisions",
to="cases.case",
),
),
(
"licence",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="licence_decisions",
to="licences.licence",
),
),
],
options={
"abstract": False,
},
),
]
Loading

0 comments on commit 4bfbbc2

Please sign in to comment.