From 3f8a4b4ba7c23a299e7ac12309905642c852ff32 Mon Sep 17 00:00:00 2001 From: Abdallah Harun Date: Fri, 24 Jan 2025 10:11:25 +0000 Subject: [PATCH 1/2] DST-861 - Adding feedback content changes (#181) --- django_app/feedback/choices.py | 2 +- django_app/feedback/forms.py | 4 +- ...0005_alter_feedbackitem_rating_and_more.py | 39 +++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 django_app/feedback/migrations/0005_alter_feedbackitem_rating_and_more.py diff --git a/django_app/feedback/choices.py b/django_app/feedback/choices.py index 466e98f5..0b425f72 100644 --- a/django_app/feedback/choices.py +++ b/django_app/feedback/choices.py @@ -7,7 +7,7 @@ class RatingChoices(models.IntegerChoices): VERY_SATISFIED = 5, "Very satisfied" SATISFIED = 4, "Satisfied" - NEUTRAL = 3, "Neutral" + NEUTRAL = 3, "Neither satisfied nor dissatisfied" DISSATISFIED = 2, "Dissatisfied" VERY_DISSATISFIED = 1, "Very dissatisfied" diff --git a/django_app/feedback/forms.py b/django_app/feedback/forms.py index 0b863695..69b6d340 100644 --- a/django_app/feedback/forms.py +++ b/django_app/feedback/forms.py @@ -23,8 +23,10 @@ class Meta: model = FeedbackItem fields = ("rating", "did_you_experience_any_issues", "how_we_could_improve_the_service", "user_name", "user_email") labels = { - "how_we_could_improve_the_service": "How could we improve the service?", + "how_we_could_improve_the_service": "How could we improve the service? (optional)", "rating": "Overall, how satisfied did you feel with using this service?", + "user_name": "Your name (optional)", + "user_email": "Your email address (optional)", } widgets = { "rating": forms.RadioSelect, diff --git a/django_app/feedback/migrations/0005_alter_feedbackitem_rating_and_more.py b/django_app/feedback/migrations/0005_alter_feedbackitem_rating_and_more.py new file mode 100644 index 00000000..850a206f --- /dev/null +++ b/django_app/feedback/migrations/0005_alter_feedbackitem_rating_and_more.py @@ -0,0 +1,39 @@ +# Generated by Django 4.2.15 on 2025-01-23 15:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("feedback", "0004_alter_feedbackitem_rating_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="feedbackitem", + name="rating", + field=models.IntegerField( + choices=[ + (5, "Very satisfied"), + (4, "Satisfied"), + (3, "Neither satisfied nor dissatisfied"), + (2, "Dissatisfied"), + (1, "Very dissatisfied"), + ] + ), + ), + migrations.AlterField( + model_name="historicalfeedbackitem", + name="rating", + field=models.IntegerField( + choices=[ + (5, "Very satisfied"), + (4, "Satisfied"), + (3, "Neither satisfied nor dissatisfied"), + (2, "Dissatisfied"), + (1, "Very dissatisfied"), + ] + ), + ), + ] From 34bfced24e7aeaa064315eee28f963f42c9badf8 Mon Sep 17 00:00:00 2001 From: Christopher Pettinga Date: Mon, 27 Jan 2025 09:38:30 +0000 Subject: [PATCH 2/2] DST-943 - Remove test cases from the viewer portals (#183) * DST-943 - Remove test cases from the viewer portals * fixing tests * touching --- .../commands/delete_licence_applications.py | 23 ++++++++++ .../management/commands/drop_all_tables.py | 43 ------------------- .../test_management_commands/__init__.py | 0 .../test_delete_licence_applications.py | 23 ++++++++++ 4 files changed, 46 insertions(+), 43 deletions(-) create mode 100644 django_app/core/management/commands/delete_licence_applications.py delete mode 100644 django_app/core/management/commands/drop_all_tables.py create mode 100644 tests/test_unit/test_core/test_management_commands/__init__.py create mode 100644 tests/test_unit/test_core/test_management_commands/test_delete_licence_applications.py diff --git a/django_app/core/management/commands/delete_licence_applications.py b/django_app/core/management/commands/delete_licence_applications.py new file mode 100644 index 00000000..4717ab30 --- /dev/null +++ b/django_app/core/management/commands/delete_licence_applications.py @@ -0,0 +1,23 @@ +from apply_for_a_licence.models import Licence +from django.core.management.base import BaseCommand + + +class Command(BaseCommand): + help = ( + "Deletes licence applications when given a list of application references." + "Usage: pipenv run django_app/python manage.py delete_licence_applications ..." + ) + + def add_arguments(self, parser): + parser.add_argument("licence_references", nargs="+", type=str) + + def handle(self, *args, **options): + for reference in options["licence_references"]: + try: + licence_object = Licence.objects.get(reference=reference) + licence_object.delete() + except Licence.DoesNotExist: + self.stdout.write(self.style.ERROR(f"Licence {reference} does not exist")) + continue + + self.stdout.write(self.style.SUCCESS(f"Successfully deleted Licence application {reference}")) diff --git a/django_app/core/management/commands/drop_all_tables.py b/django_app/core/management/commands/drop_all_tables.py deleted file mode 100644 index 54c07d42..00000000 --- a/django_app/core/management/commands/drop_all_tables.py +++ /dev/null @@ -1,43 +0,0 @@ -from django.conf import settings -from django.core.management.base import BaseCommand, CommandError -from django.db import connection - - -class Command(BaseCommand): - help = """Drop all tables. Only for use before go live.""" - - def add_arguments(self, parser): - parser.add_argument( - "--confirm-drop-all-tables", - action="store_true", - help="You must specify this to enable the command to run", - ) - - def handle(self, *args, **options): - if not options["confirm_drop_all_tables"]: - raise CommandError("Command line parameter not set!") - - if settings.ENVIRONMENT == "production": - raise CommandError("This command is not allowed in production environment") - - cursor = connection.cursor() - - cursor.execute( - """ - select 'drop table if exists "' || tablename || '" cascade;' - from pg_tables - where - schemaname = 'public' - and tableowner != 'rdsadmin' - order by tablename; - """ - ) - - rows = cursor.fetchall() - - for row in rows: - sql = row[0] - self.stdout.write(f"Executing this SQL: {sql}") - cursor.execute(sql) - - self.stdout.write("Dropped all tables") diff --git a/tests/test_unit/test_core/test_management_commands/__init__.py b/tests/test_unit/test_core/test_management_commands/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_unit/test_core/test_management_commands/test_delete_licence_applications.py b/tests/test_unit/test_core/test_management_commands/test_delete_licence_applications.py new file mode 100644 index 00000000..895087af --- /dev/null +++ b/tests/test_unit/test_core/test_management_commands/test_delete_licence_applications.py @@ -0,0 +1,23 @@ +from apply_for_a_licence.models import Licence +from django.core.management import call_command + +from tests.factories import LicenceFactory + + +def test_successful_delete(db): + LicenceFactory(reference="123") + LicenceFactory(reference="456") + + assert Licence.objects.count() == 2 + + call_command("delete_licence_applications", ["123", "456"]) + assert Licence.objects.count() == 0 + + +def test_doesnt_exist_delete(db): + LicenceFactory(reference="123") + + assert Licence.objects.count() == 1 + + call_command("delete_licence_applications", ["456"]) + assert Licence.objects.count() == 1