Skip to content

Commit

Permalink
merging with main
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-pettinga committed Feb 21, 2024
1 parent bd91d93 commit 509e6de
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 30 deletions.
3 changes: 3 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ pytest-django = "*"

[requires]
python_version = "3.11"

[scripts]
wipe_database = "chmod +x wipe_database.sh && ./wipe_database.sh"
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ To add a new dependency to the project, use the following command:\
## Standards
### Linting and Formatting
We use:
- [black](https://github.com/psf/black) to ensure consistent formatting across the project.\
- [flake8](https://flake8.pycqa.org/en/latest/) to lint the project and flag any common code smells.\
- [isort](https://pycqa.github.io/isort/) to ensure imports are ordered correctly.\
- [djhtml](https://pypi.org/project/djhtml/) to format and indent our HTML, CSS, and JS files\
- [black](https://github.com/psf/black) to ensure consistent formatting across the project.
- [flake8](https://flake8.pycqa.org/en/latest/) to lint the project and flag any common code smells.
- [isort](https://pycqa.github.io/isort/) to ensure imports are ordered correctly.
- [djhtml](https://pypi.org/project/djhtml/) to format and indent our HTML, CSS, and JS files

We use [pre-commit](https://pre-commit.com/) to run all of the above before every commit.

Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ services:
- ./pgdata/:/var/lib/postgresql/data
env_file:
- .env
environment:
POSTGRES_PASSWORD: password
ports:
- "15432:5432"
healthcheck:
Expand All @@ -20,4 +22,4 @@ services:
volumes:
- ./redis_data:/data
ports:
- "16379:6379"
- "16379:6379"
8 changes: 8 additions & 0 deletions fixtures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Load all fixtures in one go

echo "Loading all fixture data"

python manage.py loaddata report_a_breach/fixtures/*.json

echo "Fixtures loaded"
20 changes: 10 additions & 10 deletions local.env.example
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# DJANGO
DJANGO_SECRET_KEY=dummy_key
DATABASE_URL=psql://postgres:[email protected]:15432/postgres
GOV_NOTIFY_API_KEY=ask team members
GOVUK_NOTIFY_TEMPLATE_EMAIL_VERIFICATION=ask team members
DJANGO_DEBUG=True
SENTRY_DSN=ask team members
SENTRY_ENVIRONMENT=local
DATABASE_URL=psql://postgres:[email protected]:15432/postgres

# AWS
S3_STORAGE_KEY=Ask a Colleague
S3_STORAGE_SECRET=Ask a Colleague
S3_BUCKET_NAME=Ask a Colleague
AWS_REGION=Ask a Colleague
# GOV NOTIFY
GOV_NOTIFY_API_KEY=Ask a Colleague
GOVUK_NOTIFY_TEMPLATE_EMAIL_VERIFICATION=Ask a Colleague


# SENTRY
SENTRY_DSN=Ask a Colleague
SENTRY_ENVIRONMENT=local

# ClamAV
CLAM_AV_USERNAME=Ask a Colleague
Expand Down
9 changes: 4 additions & 5 deletions report_a_breach/core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ def clean_reporter_verify_email(self):


class NameForm(BaseModelForm):
reporter_full_name = forms.CharField(
label=content.FULL_NAME["text"],
widget=forms.TextInput(attrs={"id": "full_user_name"}),
)

class Meta:
model = Breach
fields = ["reporter_full_name"]
Expand Down Expand Up @@ -144,6 +139,10 @@ class Meta:
model = Breach
fields = ["what_were_the_goods"]

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["what_were_the_goods"].widget.attrs = {"rows": 5}


class SummaryForm(BaseForm):
def __init__(self, *args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions report_a_breach/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Breach(BaseModel):
verbose_name=RELATIONSHIP["text"],
)
reporter_email_address = models.EmailField(verbose_name=EMAIL["text"])
reporter_full_name = models.TextField(verbose_name=FULL_NAME["text"])
reporter_full_name = models.CharField(verbose_name=FULL_NAME["text"], max_length=255)
sanctions_regimes = models.ManyToManyField(
"SanctionsRegime", through="SanctionsRegimeBreachThrough"
)
Expand Down Expand Up @@ -93,7 +93,7 @@ class SanctionsRegimeBreachThrough(BaseModel):
class SanctionsRegime(BaseModel):
short_name = models.TextField()
full_name = models.TextField()
date_range = DateRangeField
date_range = DateRangeField(blank=True, null=True)


class UploadedDocument(BaseModel):
Expand Down
56 changes: 56 additions & 0 deletions report_a_breach/fixtures/sanctions_regimes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[
{
"model": "report_a_breach.SanctionsRegime",
"pk": "cf6b54c5-a46b-4b7d-a40d-9f2ed750eb6d",
"fields": {
"short_name": "The Afghanistan",
"full_name": "The Afghanistan (Sanctions) (EU Exit) Regulations 2020",
"date_range": ""
}
},
{
"model": "report_a_breach.SanctionsRegime",
"pk": "708e45bf-838b-4efc-b302-6d31d5684e7b",
"fields": {
"short_name": "The Republic of Belarus",
"full_name": "The Republic of Belarus (Sanctions) (EU Exit) Regulations 2019",
"date_range": ""
}
},
{
"model": "report_a_breach.SanctionsRegime",
"pk": "10cb44e9-fcdf-4fe5-89e8-798b5192b766",
"fields": {
"short_name": "The Burma",
"full_name": "The Burma (Sanctions) (EU Exit) Regulations 2019",
"date_range": ""
}
},
{
"model": "report_a_breach.SanctionsRegime",
"pk": "1f7f89b3-b574-4fd9-9904-d7701865c5a1",
"fields": {
"short_name": "The Democratic People’s Republic of Korea",
"full_name": "The Democratic People’s Republic of Korea (Sanctions) (EU Exit) Regulations 2019",
"date_range": ""
}
},
{
"model": "report_a_breach.SanctionsRegime",
"pk": "fef50ac9-ecbc-454b-915f-d5aa4953a2f8",
"fields": {
"short_name": "The Iran",
"full_name": "The Iran Human Rights (Sanctions) (EU Exit) Regulations 2019",
"date_range": ""
}
},
{
"model": "report_a_breach.SanctionsRegime",
"pk": "0f3d1e25-638c-41b7-89df-4e569b45297f",
"fields": {
"short_name": "The Russia",
"full_name": "The Russia (Sanctions) (EU Exit) Regulations 2019",
"date_range": ""
}
}
]
31 changes: 24 additions & 7 deletions report_a_breach/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Generated by Django 4.2.10 on 2024-02-16 10:24

import uuid
# Generated by Django 4.2.10 on 2024-02-19 15:52

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django_countries.fields
import simple_history.models
from django.conf import settings
from django.db import migrations, models
import uuid


class Migration(migrations.Migration):
Expand Down Expand Up @@ -56,11 +55,20 @@ class Migration(migrations.Migration):
"reporter_email_address",
models.EmailField(max_length=254, verbose_name="What is your email address?"),
),
("reporter_full_name", models.TextField(verbose_name="What is your full name?")),
(
"reporter_full_name",
models.CharField(max_length=255, verbose_name="What is your full name?"),
),
(
"additional_information",
models.TextField(verbose_name="Tell us about the suspected breach"),
),
(
"what_were_the_goods",
models.TextField(
verbose_name="What were the goods or services, or what was the technological assistance or technology?"
),
),
],
options={
"abstract": False,
Expand Down Expand Up @@ -423,11 +431,20 @@ class Migration(migrations.Migration):
"reporter_email_address",
models.EmailField(max_length=254, verbose_name="What is your email address?"),
),
("reporter_full_name", models.TextField(verbose_name="What is your full name?")),
(
"reporter_full_name",
models.CharField(max_length=255, verbose_name="What is your full name?"),
),
(
"additional_information",
models.TextField(verbose_name="Tell us about the suspected breach"),
),
(
"what_were_the_goods",
models.TextField(
verbose_name="What were the goods or services, or what was the technological assistance or technology?"
),
),
("history_id", models.AutoField(primary_key=True, serialize=False)),
("history_date", models.DateTimeField(db_index=True)),
("history_change_reason", models.CharField(max_length=100, null=True)),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.2.10 on 2024-02-20 16:37

import django.contrib.postgres.fields.ranges
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("report_a_breach", "0002_breach_what_were_the_goods_and_more"),
]

operations = [
migrations.AddField(
model_name="historicalbreach",
name="what_were_the_goods",
field=models.TextField(
default="",
verbose_name="What were the goods or services, or what was the technological assistance or technology?",
),
preserve_default=False,
),
migrations.AddField(
model_name="historicalsanctionsregime",
name="date_range",
field=django.contrib.postgres.fields.ranges.DateRangeField(blank=True, null=True),
),
migrations.AddField(
model_name="sanctionsregime",
name="date_range",
field=django.contrib.postgres.fields.ranges.DateRangeField(blank=True, null=True),
),
]
12 changes: 11 additions & 1 deletion report_a_breach/templates/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ <h2 class="govuk-summary-card__title">Your details</h2>
<a class="govuk-link" href="/start">Change<span class="govuk-visually-hidden"> professional relationship with the organisation (Your details)</span></a>
</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
What were the goods
</dt>
<dd class="govuk-summary-list__value">
{{ what_were_the_goods }}
</dd>
<dd class="govuk-summary-list__actions">
<a class="govuk-link" href="/name/{{ pk }}">Change<span class="govuk-visually-hidden"> what were the goods</span></a>
</dd>
</div>
</dl>
</div>
</div>
Expand All @@ -60,6 +71,5 @@ <h2 class="govuk-summary-card__title">Your details</h2>
{% else %}
{% crispy wizard.form %}
{% endif %}
<!-- <input type="submit" name="continue" value="Submit" class="govuk-button btn-primary" id="save-button">-->
</form>
{% endblock column_content %}
6 changes: 6 additions & 0 deletions wipe_database.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

docker-compose down
rm -r pgdata
docker-compose up -d
pipenv run python manage.py migrate

0 comments on commit 509e6de

Please sign in to comment.