diff --git a/Pipfile b/Pipfile index b5e7bfa3..aee03b5c 100644 --- a/Pipfile +++ b/Pipfile @@ -35,3 +35,6 @@ pytest-django = "*" [requires] python_version = "3.11" + +[scripts] +wipe_database = "chmod +x wipe_database.sh && ./wipe_database.sh" diff --git a/README.md b/README.md index 3d15d8c7..b437223d 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/docker-compose.yml b/docker-compose.yml index 2750fda4..7093a9d4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,8 @@ services: - ./pgdata/:/var/lib/postgresql/data env_file: - .env + environment: + POSTGRES_PASSWORD: password ports: - "15432:5432" healthcheck: @@ -20,4 +22,4 @@ services: volumes: - ./redis_data:/data ports: - - "16379:6379" \ No newline at end of file + - "16379:6379" diff --git a/fixtures.sh b/fixtures.sh new file mode 100755 index 00000000..56b3e96f --- /dev/null +++ b/fixtures.sh @@ -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" diff --git a/local.env.example b/local.env.example index d7cd88de..8f46418a 100644 --- a/local.env.example +++ b/local.env.example @@ -1,16 +1,16 @@ +# DJANGO DJANGO_SECRET_KEY=dummy_key -DATABASE_URL=psql://postgres:password@127.0.0.1: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:password@127.0.0.1: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 diff --git a/report_a_breach/core/forms.py b/report_a_breach/core/forms.py index e4593bae..05b8de7c 100644 --- a/report_a_breach/core/forms.py +++ b/report_a_breach/core/forms.py @@ -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"] @@ -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): diff --git a/report_a_breach/core/models.py b/report_a_breach/core/models.py index a58c2a10..b2bff97d 100644 --- a/report_a_breach/core/models.py +++ b/report_a_breach/core/models.py @@ -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" ) @@ -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): diff --git a/report_a_breach/fixtures/sanctions_regimes.json b/report_a_breach/fixtures/sanctions_regimes.json new file mode 100644 index 00000000..3d88b10d --- /dev/null +++ b/report_a_breach/fixtures/sanctions_regimes.json @@ -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": "" + } + } +] diff --git a/report_a_breach/migrations/0001_initial.py b/report_a_breach/migrations/0001_initial.py index 3d8f8a91..806251e5 100644 --- a/report_a_breach/migrations/0001_initial.py +++ b/report_a_breach/migrations/0001_initial.py @@ -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): @@ -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, @@ -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)), diff --git a/report_a_breach/migrations/0003_historicalbreach_what_were_the_goods_and_more.py b/report_a_breach/migrations/0003_historicalbreach_what_were_the_goods_and_more.py new file mode 100644 index 00000000..2e825e9b --- /dev/null +++ b/report_a_breach/migrations/0003_historicalbreach_what_were_the_goods_and_more.py @@ -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), + ), + ] diff --git a/report_a_breach/templates/summary.html b/report_a_breach/templates/summary.html index 34b865a2..d63122ff 100644 --- a/report_a_breach/templates/summary.html +++ b/report_a_breach/templates/summary.html @@ -48,6 +48,17 @@