Skip to content

Commit

Permalink
Merge pull request #1348 from BLSQ/IA-2996-IA-2949-make-completeness-…
Browse files Browse the repository at this point in the history
…as-module-search-modules-on-french

IA-2996-IA-2949: Make Completeness table for PBF as a module as we can hide it and All search in french on modules
  • Loading branch information
hakifran authored May 31, 2024
2 parents f05fab8 + fb6b37e commit 2f13c2b
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Add the permission to a module from `MODULE_PERMISSIONS`
- If no existing module fits, create one (see exiting modules for inspiration)
- If a new module is created, add it to `MODULES` (in the same file)
- If it's a new module run migration to add it in modules options for the account

## 3. Include the permission in the corresponding group
- Go to `/hat/menupermissions/constants.py`
Expand Down
1 change: 1 addition & 0 deletions hat/assets/js/apps/Iaso/domains/app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@
"iaso.mappings.useInstanceProperty": "Use instance property to fill in this answer",
"iaso.mappings.willNeverMap": "Will never map",
"iaso.matching.title": "Matching",
"iaso.modules.completeness_per_period": "Completeness per Period",
"iaso.modules.data_collection_forms": "Data collection - Forms",
"iaso.modules.default": "Default",
"iaso.modules.dhis2_mapping": "DHIS2 mapping",
Expand Down
1 change: 1 addition & 0 deletions hat/assets/js/apps/Iaso/domains/app/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@
"iaso.mappings.useInstanceProperty": "Utiliser la propriété d'une instance pour remplir cette question",
"iaso.mappings.willNeverMap": "N'aura jamais de correspondance",
"iaso.matching.title": "Correspondances sources",
"iaso.modules.completeness_per_period": "Complétude par période",
"iaso.modules.data_collection_forms": "Collecte de données - Formulaires",
"iaso.modules.default": "Par défaut",
"iaso.modules.dhis2_mapping": "Mappage DHIS2",
Expand Down
4 changes: 4 additions & 0 deletions hat/assets/js/apps/Iaso/domains/modules/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export const MESSAGES = defineMessages({
defaultMessage: 'Payments',
id: 'iaso.modules.payments',
},
completeness_per_period: {
defaultMessage: 'Completeness per Period',
id: 'iaso.modules.completeness_per_period',
},
modulesInformation: {
id: 'iaso.modules.modulesInformation',
defaultMessage:
Expand Down
27 changes: 16 additions & 11 deletions hat/menupermissions/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"iaso_forms",
"iaso_update_submission",
"iaso_submissions",
"iaso_completeness",
"iaso_completeness_stats",
],
"DEFAULT": [
Expand Down Expand Up @@ -48,19 +47,25 @@
],
"REGISTRY": ["iaso_registry_write", "iaso_registry_read", "iaso_org_unit_change_request_review"],
"PAYMENTS": ["iaso_payments"],
"COMPLETENESS_PER_PERIOD": ["iaso_completeness"],
}

MODULES = [
{"name": "Data collection - Forms", "codename": "DATA_COLLECTION_FORMS"},
{"name": "Default", "codename": "DEFAULT"},
{"name": "DHIS2 mapping", "codename": "DHIS2_MAPPING"},
{"name": "Embedded links", "codename": "EMBEDDED_LINKS"},
{"name": "Entities", "codename": "ENTITIES"},
{"name": "External storage", "codename": "EXTERNAL_STORAGE"},
{"name": "Planning", "codename": "PLANNING"},
{"name": "Polio project", "codename": "POLIO_PROJECT"},
{"name": "Registry", "codename": "REGISTRY"},
{"name": "Payments", "codename": "PAYMENTS"},
{
"name": "Data collection - Forms",
"codename": "DATA_COLLECTION_FORMS",
"fr_name": "Collecte de données - Formulaires",
},
{"name": "Default", "codename": "DEFAULT", "fr_name": "Par défaut"},
{"name": "DHIS2 mapping", "codename": "DHIS2_MAPPING", "fr_name": "Mappage DHIS2"},
{"name": "Embedded links", "codename": "EMBEDDED_LINKS", "fr_name": "Liens intégrés"},
{"name": "Entities", "codename": "ENTITIES", "fr_name": "Entités"},
{"name": "External storage", "codename": "EXTERNAL_STORAGE", "fr_name": "Stockage externe"},
{"name": "Planning", "codename": "PLANNING", "fr_name": "Planification"},
{"name": "Polio project", "codename": "POLIO_PROJECT", "fr_name": "Projet Polio"},
{"name": "Registry", "codename": "REGISTRY", "fr_name": "Registre"},
{"name": "Payments", "codename": "PAYMENTS", "fr_name": "Paiements"},
{"name": "Completeness per Period", "codename": "COMPLETENESS_PER_PERIOD", "fr_name": "Complétude par période"},
]

FEATUREFLAGES_TO_EXCLUDE = {
Expand Down
9 changes: 7 additions & 2 deletions iaso/api/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,17 @@ def get_queryset(self):
permissions = MODULE_PERMISSIONS[module["codename"]]
name = module["name"]
codename = module["codename"]
queryset.append({"name": name, "codename": codename, "permissions": permissions})
fr_name = module["fr_name"]
queryset.append({"name": name, "codename": codename, "permissions": permissions, "fr_name": fr_name})
search = self.request.GET.get("search", None)
orders = self.request.GET.get("order", "name").split(",")

if search:
queryset = [module for module in queryset if search.lower() in module["name"].lower()]
queryset = [
module
for module in queryset
if search.lower() in module["name"].lower() or search.lower() in module["fr_name"].lower()
]
if orders:
order_key = ("").join(orders)
if "-" in order_key:
Expand Down
39 changes: 39 additions & 0 deletions iaso/migrations/0281_alter_account_modules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 4.2.13 on 2024-05-31 13:35

from django.db import migrations, models
import iaso.models.base


class Migration(migrations.Migration):
dependencies = [
("iaso", "0280_datasource_tree_config_status_fields"),
]

operations = [
migrations.AlterField(
model_name="account",
name="modules",
field=iaso.models.base.ChoiceArrayField(
base_field=models.CharField(
choices=[
("DATA_COLLECTION_FORMS", "Data collection - Forms"),
("DEFAULT", "Default"),
("DHIS2_MAPPING", "DHIS2 mapping"),
("EMBEDDED_LINKS", "Embedded links"),
("ENTITIES", "Entities"),
("EXTERNAL_STORAGE", "External storage"),
("PLANNING", "Planning"),
("POLIO_PROJECT", "Polio project"),
("REGISTRY", "Registry"),
("PAYMENTS", "Payments"),
("COMPLETENESS_PER_PERIOD", "Completeness per Period"),
],
max_length=100,
),
blank=True,
default=list,
null=True,
size=None,
),
),
]

0 comments on commit 2f13c2b

Please sign in to comment.