From 7f092277031c7b892b0be47b9d005aa49deed514 Mon Sep 17 00:00:00 2001 From: Domenico DiNicola Date: Wed, 15 Jan 2025 08:53:11 -0600 Subject: [PATCH] add migrations --- .../apps/account/migrations/0003_migration.py | 17 +++++++++++ .../migrations/0005_migration.py | 29 +++++++++++++++++++ src/hct_mis_api/apps/activity_log/admin.py | 3 +- .../apps/core/migrations/0004_migration.py | 21 ++++++++++++++ .../apps/geo/migrations/0002_migration.py | 17 +++++++++++ .../apps/household/admin/xlsupdate.py | 3 +- src/hct_mis_api/apps/household/forms.py | 6 ++-- .../household/migrations/0008_migration.py | 17 +++++++++++ .../apps/payment/models/verification.py | 2 +- .../apps/periodic_data_update/admin.py | 5 ++-- .../migrations/0002_migration.py | 17 +++++++++++ .../reporting/migrations/0002_migration.py | 18 ++++++++++++ src/hct_mis_api/apps/sanction_list/admin.py | 3 +- .../migrations/0002_migration.py | 17 +++++++++++ .../steficon/migrations/0002_migration.py | 17 +++++++++++ src/hct_mis_api/apps/utils/admin.py | 4 --- .../aurora/migrations/0004_migration.py | 17 +++++++++++ tests/selenium/targeting/test_targeting.py | 2 +- 18 files changed, 201 insertions(+), 14 deletions(-) create mode 100644 src/hct_mis_api/apps/account/migrations/0003_migration.py create mode 100644 src/hct_mis_api/apps/accountability/migrations/0005_migration.py create mode 100644 src/hct_mis_api/apps/core/migrations/0004_migration.py create mode 100644 src/hct_mis_api/apps/geo/migrations/0002_migration.py create mode 100644 src/hct_mis_api/apps/household/migrations/0008_migration.py create mode 100644 src/hct_mis_api/apps/registration_data/migrations/0002_migration.py create mode 100644 src/hct_mis_api/apps/reporting/migrations/0002_migration.py create mode 100644 src/hct_mis_api/apps/sanction_list/migrations/0002_migration.py create mode 100644 src/hct_mis_api/apps/steficon/migrations/0002_migration.py create mode 100644 src/hct_mis_api/contrib/aurora/migrations/0004_migration.py diff --git a/src/hct_mis_api/apps/account/migrations/0003_migration.py b/src/hct_mis_api/apps/account/migrations/0003_migration.py new file mode 100644 index 0000000000..3ba57c7214 --- /dev/null +++ b/src/hct_mis_api/apps/account/migrations/0003_migration.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.25 on 2025-01-15 14:51 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('account', '0002_migration'), + ] + + operations = [ + migrations.AlterModelOptions( + name='user', + options={'permissions': (('can_load_from_ad', 'Can load users from ActiveDirectory'), ('can_sync_with_ad', 'Can synchronise user with ActiveDirectory'), ('can_create_kobo_user', 'Can create users in Kobo'), ('can_import_from_kobo', 'Can import and sync users from Kobo'), ('can_upload_to_kobo', 'Can upload CSV file to Kobo'), ('can_debug', 'Can access debug information'), ('can_inspect', 'Can inspect objects'), ('quick_links', 'Can see quick links in admin'), ('restrict_help_desk', 'Limit fields to be editable for help desk'), ('can_reindex_programs', 'Can reindex programs'), ('can_add_business_area_to_partner', 'Can add business area to partner'), ('can_import_fixture', 'Can import fixture'))}, + ), + ] diff --git a/src/hct_mis_api/apps/accountability/migrations/0005_migration.py b/src/hct_mis_api/apps/accountability/migrations/0005_migration.py new file mode 100644 index 0000000000..384b7ae3c0 --- /dev/null +++ b/src/hct_mis_api/apps/accountability/migrations/0005_migration.py @@ -0,0 +1,29 @@ +# Generated by Django 3.2.25 on 2025-01-15 14:51 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('accountability', '0004_migration'), + ] + + operations = [ + migrations.RemoveField( + model_name='feedback', + name='is_migration_handled', + ), + migrations.RemoveField( + model_name='feedback', + name='migrated_at', + ), + migrations.RemoveField( + model_name='message', + name='is_migration_handled', + ), + migrations.RemoveField( + model_name='message', + name='migrated_at', + ), + ] diff --git a/src/hct_mis_api/apps/activity_log/admin.py b/src/hct_mis_api/apps/activity_log/admin.py index 0ece397e54..49c5329ee7 100644 --- a/src/hct_mis_api/apps/activity_log/admin.py +++ b/src/hct_mis_api/apps/activity_log/admin.py @@ -1,6 +1,7 @@ from typing import Any, Optional from django.contrib import admin +from django.db.models.query import QuerySet from django.http import HttpRequest from adminfilters.autocomplete import AutoCompleteFilter @@ -41,5 +42,5 @@ def has_add_permission(self, request: HttpRequest) -> bool: def has_delete_permission(self, request: HttpRequest, obj: Optional[Any] = None) -> bool: return False - def get_queryset(self, request: HttpRequest) -> "QuerySet": + def get_queryset(self, request: HttpRequest) -> QuerySet: return super().get_queryset(request).select_related("content_type", "user", "business_area") diff --git a/src/hct_mis_api/apps/core/migrations/0004_migration.py b/src/hct_mis_api/apps/core/migrations/0004_migration.py new file mode 100644 index 0000000000..c6d649e433 --- /dev/null +++ b/src/hct_mis_api/apps/core/migrations/0004_migration.py @@ -0,0 +1,21 @@ +# Generated by Django 3.2.25 on 2025-01-15 14:51 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0003_migration'), + ] + + operations = [ + migrations.AlterModelOptions( + name='businessarea', + options={'ordering': ['name'], 'permissions': (('can_split', 'Can split BusinessArea'), ('can_send_doap', 'Can send DOAP matrix'), ('can_reset_doap', 'Can force sync DOAP matrix'), ('can_export_doap', 'Can export DOAP matrix'), ('ping_rapidpro', 'Can test RapidPRO connection'))}, + ), + migrations.AlterModelOptions( + name='xlsxkobotemplate', + options={'ordering': ('-created_at',), 'permissions': (('download_last_valid_file', 'Can download the last valid KOBO template'), ('rerun_kobo_import', 'Can rerun a KOBO import'))}, + ), + ] diff --git a/src/hct_mis_api/apps/geo/migrations/0002_migration.py b/src/hct_mis_api/apps/geo/migrations/0002_migration.py new file mode 100644 index 0000000000..1d62a67041 --- /dev/null +++ b/src/hct_mis_api/apps/geo/migrations/0002_migration.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.25 on 2025-01-15 14:51 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('geo', '0001_migration'), + ] + + operations = [ + migrations.AlterModelOptions( + name='area', + options={'ordering': ('name',), 'permissions': (('import_areas', 'Can import areas'),), 'verbose_name_plural': 'Areas'}, + ), + ] diff --git a/src/hct_mis_api/apps/household/admin/xlsupdate.py b/src/hct_mis_api/apps/household/admin/xlsupdate.py index 9ab403fc43..df4c4ff8a5 100644 --- a/src/hct_mis_api/apps/household/admin/xlsupdate.py +++ b/src/hct_mis_api/apps/household/admin/xlsupdate.py @@ -3,6 +3,7 @@ from django import forms from django.contrib import admin, messages from django.db import transaction +from django.db.models.query import QuerySet from django.forms import Form from django.http import HttpRequest, HttpResponseRedirect from django.template.response import TemplateResponse @@ -41,7 +42,7 @@ class XlsxUpdateFileAdmin(HOPEModelAdminBase): ) search_fields = ("file",) - def get_queryset(self, request): + def get_queryset(self, request: HttpRequest) -> QuerySet: return super().get_queryset(request).select_related("business_area", "rdi", "program", "uploaded_by") def xlsx_update_stage2(self, request: HttpRequest, old_form: Form) -> TemplateResponse: diff --git a/src/hct_mis_api/apps/household/forms.py b/src/hct_mis_api/apps/household/forms.py index c2a5e94416..d7265a9103 100644 --- a/src/hct_mis_api/apps/household/forms.py +++ b/src/hct_mis_api/apps/household/forms.py @@ -45,17 +45,17 @@ class UpdateByXlsxStage1Form(forms.Form): business_area = forms.ModelChoiceField( queryset=BusinessArea.objects.all().order_by("name"), required=True, - widget=AutocompleteWidget(BusinessArea, None), + widget=AutocompleteWidget(BusinessArea, ""), ) program = forms.ModelChoiceField( queryset=Program.objects.filter(status=Program.ACTIVE).order_by("name"), required=True, - widget=AutocompleteWidget(Program, None), + widget=AutocompleteWidget(Program, ""), ) registration_data_import = forms.ModelChoiceField( queryset=RegistrationDataImport.objects.all().order_by("name"), required=True, - widget=AutocompleteWidget(RegistrationDataImport, None), + widget=AutocompleteWidget(RegistrationDataImport, ""), ) file = forms.FileField(required=True, help_text="Select XLSX file") diff --git a/src/hct_mis_api/apps/household/migrations/0008_migration.py b/src/hct_mis_api/apps/household/migrations/0008_migration.py new file mode 100644 index 0000000000..7fe4748c65 --- /dev/null +++ b/src/hct_mis_api/apps/household/migrations/0008_migration.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.25 on 2025-01-15 14:51 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('household', '0007_migration'), + ] + + operations = [ + migrations.AlterModelOptions( + name='individual', + options={'permissions': (('update_individual_iban', 'Can update individual IBAN'),), 'verbose_name': 'Individual'}, + ), + ] diff --git a/src/hct_mis_api/apps/payment/models/verification.py b/src/hct_mis_api/apps/payment/models/verification.py index b7ad320d2b..64aa5537e9 100644 --- a/src/hct_mis_api/apps/payment/models/verification.py +++ b/src/hct_mis_api/apps/payment/models/verification.py @@ -81,7 +81,7 @@ class PaymentVerificationPlan(TimeStampedUUIDModel, ConcurrencyModel, UnicefIden status = models.CharField(max_length=50, choices=STATUS_CHOICES, default=STATUS_PENDING, db_index=True) payment_plan = models.ForeignKey( - "payment.PaymentPlan", on_delete=models.CASCADE, related_name="payment_verification_plans" + "payment.PaymentPlan", on_delete=models.CASCADE, related_name="payment_verification_plans", null=True ) sampling = models.CharField(max_length=50, choices=SAMPLING_CHOICES) diff --git a/src/hct_mis_api/apps/periodic_data_update/admin.py b/src/hct_mis_api/apps/periodic_data_update/admin.py index b51ee0effe..5a49615333 100644 --- a/src/hct_mis_api/apps/periodic_data_update/admin.py +++ b/src/hct_mis_api/apps/periodic_data_update/admin.py @@ -1,6 +1,7 @@ from typing import Optional from django.contrib import admin +from django.db.models.query import QuerySet from django.http import HttpRequest from adminfilters.autocomplete import AutoCompleteFilter, LinkedAutoCompleteFilter @@ -37,7 +38,7 @@ class PeriodicDataUpdateTemplateAdmin(HOPEModelAdminBase): raw_id_fields = ("file", "program", "business_area", "created_by") inlines = [PeriodicDataUpdateUploadInline] - def get_queryset(self, request: HttpRequest) -> "QuerySet": + def get_queryset(self, request: HttpRequest) -> QuerySet: return super().get_queryset(request).select_related("created_by", "program", "business_area") @@ -49,7 +50,7 @@ class PeriodicDataUpdateUploadAdmin(HOPEModelAdminBase): ("created_by", AutoCompleteFilter), ) - def get_queryset(self, request: HttpRequest) -> "QuerySet": + def get_queryset(self, request: HttpRequest) -> QuerySet: return ( super() .get_queryset(request) diff --git a/src/hct_mis_api/apps/registration_data/migrations/0002_migration.py b/src/hct_mis_api/apps/registration_data/migrations/0002_migration.py new file mode 100644 index 0000000000..35f6b26a5e --- /dev/null +++ b/src/hct_mis_api/apps/registration_data/migrations/0002_migration.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.25 on 2025-01-15 14:51 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('registration_data', '0001_migration'), + ] + + operations = [ + migrations.AlterModelOptions( + name='registrationdataimport', + options={'permissions': (('rerun_rdi', 'Can Rerun RDI'),), 'verbose_name': 'Registration data import'}, + ), + ] diff --git a/src/hct_mis_api/apps/reporting/migrations/0002_migration.py b/src/hct_mis_api/apps/reporting/migrations/0002_migration.py new file mode 100644 index 0000000000..ca6e64e6f9 --- /dev/null +++ b/src/hct_mis_api/apps/reporting/migrations/0002_migration.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.25 on 2025-01-15 14:51 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('reporting', '0001_migration'), + ] + + operations = [ + migrations.AlterField( + model_name='dashboardreport', + name='year', + field=models.PositiveSmallIntegerField(default=2025), + ), + ] diff --git a/src/hct_mis_api/apps/sanction_list/admin.py b/src/hct_mis_api/apps/sanction_list/admin.py index ca81132022..f7280bb9e1 100644 --- a/src/hct_mis_api/apps/sanction_list/admin.py +++ b/src/hct_mis_api/apps/sanction_list/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin +from django.db.models.query import QuerySet from django.http.request import HttpRequest from adminfilters.autocomplete import AutoCompleteFilter @@ -40,5 +41,5 @@ class SanctionListIndividualDocumentAdmin(HOPEModelAdminBase): list_filter = (("issuing_country", AutoCompleteFilter), "type_of_document") search_fields = ("document_number",) - def get_queryset(self, request: HttpRequest) -> "QuerySet": + def get_queryset(self, request: HttpRequest) -> QuerySet: return super().get_queryset(request).select_related("individual", "issuing_country") diff --git a/src/hct_mis_api/apps/sanction_list/migrations/0002_migration.py b/src/hct_mis_api/apps/sanction_list/migrations/0002_migration.py new file mode 100644 index 0000000000..b2ff42ae8e --- /dev/null +++ b/src/hct_mis_api/apps/sanction_list/migrations/0002_migration.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.25 on 2025-01-15 14:51 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('sanction_list', '0001_migration'), + ] + + operations = [ + migrations.AlterModelOptions( + name='sanctionlistindividual', + options={'ordering': ['-listed_on']}, + ), + ] diff --git a/src/hct_mis_api/apps/steficon/migrations/0002_migration.py b/src/hct_mis_api/apps/steficon/migrations/0002_migration.py new file mode 100644 index 0000000000..a802676554 --- /dev/null +++ b/src/hct_mis_api/apps/steficon/migrations/0002_migration.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.25 on 2025-01-15 14:51 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('steficon', '0001_migration'), + ] + + operations = [ + migrations.AlterModelOptions( + name='rule', + options={'permissions': (('process_file', 'Can Process File'), ('check_diff', 'Can Check Diff'), ('changelog', 'Can Check Changelog'), ('rerun_rule', 'Can Rerun Rule'))}, + ), + ] diff --git a/src/hct_mis_api/apps/utils/admin.py b/src/hct_mis_api/apps/utils/admin.py index ca58bfd8ac..21cf8f6967 100644 --- a/src/hct_mis_api/apps/utils/admin.py +++ b/src/hct_mis_api/apps/utils/admin.py @@ -252,7 +252,6 @@ def restart_preparing_payment_plan(self, request: HttpRequest, pk: str) -> Optio @button( visible=lambda btn: is_exporting_xlsx_file(btn) and is_locked_payment_plan(btn), enabled=lambda btn: is_enabled(btn), - permission=is_root, ) def restart_exporting_template_for_entitlement(self, request: HttpRequest, pk: str) -> Optional[HttpResponse]: """Exporting template for entitlement""" @@ -288,7 +287,6 @@ def restart_exporting_template_for_entitlement(self, request: HttpRequest, pk: s @button( visible=lambda btn: is_importing_entitlements_xlsx_file(btn) and is_locked_payment_plan(btn), enabled=lambda btn: is_enabled(btn), - permission=is_root, ) def restart_importing_entitlements_xlsx_file(self, request: HttpRequest, pk: str) -> Optional[HttpResponse]: """Importing entitlement file""" @@ -322,7 +320,6 @@ def restart_importing_entitlements_xlsx_file(self, request: HttpRequest, pk: str @button( visible=lambda btn: is_exporting_xlsx_file(btn) and is_accepted_payment_plan(btn), enabled=lambda btn: is_enabled(btn), - permission=is_root, ) def restart_exporting_payment_plan_list(self, request: HttpRequest, pk: str) -> Optional[HttpResponse]: """Exporting payment plan list""" @@ -356,7 +353,6 @@ def restart_exporting_payment_plan_list(self, request: HttpRequest, pk: str) -> @button( visible=lambda btn: is_importing_reconciliation_xlsx_file(btn) and is_accepted_payment_plan(btn), enabled=lambda btn: is_enabled(btn), - permission=is_root, ) def restart_importing_reconciliation_xlsx_file(self, request: HttpRequest, pk: str) -> Optional[HttpResponse]: """Importing payment plan list (from xlsx)""" diff --git a/src/hct_mis_api/contrib/aurora/migrations/0004_migration.py b/src/hct_mis_api/contrib/aurora/migrations/0004_migration.py new file mode 100644 index 0000000000..2ff0d124df --- /dev/null +++ b/src/hct_mis_api/contrib/aurora/migrations/0004_migration.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.25 on 2025-01-15 14:51 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('aurora', '0003_migration'), + ] + + operations = [ + migrations.AlterModelOptions( + name='record', + options={'permissions': (('can_fetch_data', 'Can fetch data from aurora'), ('can_add_records', 'Can add records'))}, + ), + ] diff --git a/tests/selenium/targeting/test_targeting.py b/tests/selenium/targeting/test_targeting.py index 6998c51efd..45ef828b44 100644 --- a/tests/selenium/targeting/test_targeting.py +++ b/tests/selenium/targeting/test_targeting.py @@ -751,7 +751,7 @@ def test_create_targeting_with_pdu_decimal_criteria( pageTargetingDetails.getButtonIconEdit().click() pageTargetingCreate.getInputIndividualsFiltersBlocksValueTo().send_keys(Keys.BACKSPACE) pageTargetingCreate.getInputIndividualsFiltersBlocksValueTo().send_keys("5") - bool_no_expected_criteria_text = "Test Decimal Attribute: 2 - 5\nRound 1 (Test Round Decimal 1)" + bool_no_expected_criteria_text = "Test Decimal Attribute: 2 - 4\nRound 1 (Test Round Decimal 1)" pageTargetingCreate.get_elements(pageTargetingCreate.targetingCriteriaAddDialogSaveButton)[1].click()