Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/country_workspace/admin/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class ProgramAdmin(SyncAdminMixin, BaseModelAdmin):
"name",
"sector",
"status",
"active",
"beneficiary_group",
"beneficiary_validator",
"household_checker",
Expand All @@ -32,7 +31,6 @@ class ProgramAdmin(SyncAdminMixin, BaseModelAdmin):
list_filter = (
("country_office", AutoCompleteFilter),
"status",
"active",
"sector",
"beneficiary_group",
"beneficiary_validator",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def sync_offices(self) -> None:
SyncConfig(
model=Office,
path="business_areas",
prepare_defaults=lambda r: {f: r.get(f) for f in ("name", "slug", "code", "long_name")},
prepare_defaults=lambda r: {f: r.get(f) for f in ("name", "slug", "code", "long_name", "active")},
should_process=lambda r: r.get("active"),
should_deactivate=lambda r: not r.get("active"),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Generated by Django 5.1.7 on 2025-04-21 14:57

import pgtrigger.compiler
import pgtrigger.migrations
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("country_workspace", "0010_householdevent_individualevent_and_more"),
]

operations = [
pgtrigger.migrations.RemoveTrigger(
model_name="household",
name="updates_update",
),
pgtrigger.migrations.RemoveTrigger(
model_name="individual",
name="updates_update",
),
migrations.RemoveField(
model_name="program",
name="active",
),
migrations.AlterField(
model_name="program",
name="individual_columns",
field=models.TextField(default="name\nid", help_text="Columns to display in the Admin table"),
),
pgtrigger.migrations.AddTrigger(
model_name="household",
trigger=pgtrigger.compiler.Trigger(
name="update_update",
sql=pgtrigger.compiler.UpsertTriggerSql(
condition='WHEN (OLD."flex_fields" IS DISTINCT FROM (NEW."flex_fields") OR OLD."flex_files" IS DISTINCT FROM (NEW."flex_files") OR OLD."removed" IS DISTINCT FROM (NEW."removed"))',
func='INSERT INTO "country_workspace_householdevent" ("batch_id", "checksum", "errors", "flex_fields", "flex_files", "id", "last_checked", "last_modified", "name", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "removed", "system_fields", "version") VALUES (NEW."batch_id", NEW."checksum", NEW."errors", NEW."flex_fields", NEW."flex_files", NEW."id", NEW."last_checked", NEW."last_modified", NEW."name", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."removed", NEW."system_fields", NEW."version"); RETURN NULL;',
hash="8ecf3de9db1d0a404013f2d873e0f061d7d00111",
operation="UPDATE",
pgid="pgtrigger_update_update_c2d37",
table="country_workspace_household",
when="AFTER",
),
),
),
pgtrigger.migrations.AddTrigger(
model_name="individual",
trigger=pgtrigger.compiler.Trigger(
name="update_update",
sql=pgtrigger.compiler.UpsertTriggerSql(
condition='WHEN (OLD."flex_fields" IS DISTINCT FROM (NEW."flex_fields") OR OLD."flex_files" IS DISTINCT FROM (NEW."flex_files") OR OLD."removed" IS DISTINCT FROM (NEW."removed"))',
func='INSERT INTO "country_workspace_individualevent" ("batch_id", "checksum", "errors", "flex_fields", "flex_files", "household_id", "id", "last_checked", "last_modified", "name", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "removed", "system_fields", "version") VALUES (NEW."batch_id", NEW."checksum", NEW."errors", NEW."flex_fields", NEW."flex_files", NEW."household_id", NEW."id", NEW."last_checked", NEW."last_modified", NEW."name", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."removed", NEW."system_fields", NEW."version"); RETURN NULL;',
hash="75976263954d18b98b4e9bdd634a3e7db04f8c60",
operation="UPDATE",
pgid="pgtrigger_update_update_6a215",
table="country_workspace_individual",
when="AFTER",
),
),
),
]
4 changes: 0 additions & 4 deletions src/country_workspace/models/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ class Program(BaseModel):
code = models.CharField(max_length=255, blank=True, null=True)
status = models.CharField(max_length=10, choices=STATUS_CHOICE, db_index=True)
sector = models.CharField(max_length=50, choices=SECTOR_CHOICE, db_index=True)
active = models.BooleanField(
default=False,
help_text=_("Whether the program is active. Only active program are visible in the UI"),
)

# Local Fields
beneficiary_validator = StrategyField(
Expand Down
7 changes: 2 additions & 5 deletions src/country_workspace/workspaces/admin/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class Meta:
"code",
"status",
"sector",
"active",
"beneficiary_validator",
"household_checker",
"individual_checker",
Expand All @@ -87,16 +86,14 @@ class CountryProgramAdmin(WorkspaceModelAdmin):
"name",
"sector",
"status",
"active",
)
search_fields = ("name",)
list_filter = ("status", "active", "sector")
list_filter = ("status", "sector")
exclude = ("country_office",)
default_url_filters = {"status__exact": CountryProgram.ACTIVE}
readonly_fields = (
"individual_columns",
"household_columns",
"active",
"code",
"status",
"sector",
Expand Down Expand Up @@ -134,7 +131,7 @@ def get_fieldsets(
{
"fields": (
("name", "code"),
("status", "sector", "active"),
("status", "sector"),
),
},
),
Expand Down
Loading