Skip to content

Commit 536f97f

Browse files
chg! drop use Program.active (#81)
1 parent 2154aa1 commit 536f97f

File tree

5 files changed

+64
-12
lines changed

5 files changed

+64
-12
lines changed

src/country_workspace/admin/program.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class ProgramAdmin(SyncAdminMixin, BaseModelAdmin):
2222
"name",
2323
"sector",
2424
"status",
25-
"active",
2625
"beneficiary_group",
2726
"beneficiary_validator",
2827
"household_checker",
@@ -32,7 +31,6 @@ class ProgramAdmin(SyncAdminMixin, BaseModelAdmin):
3231
list_filter = (
3332
("country_office", AutoCompleteFilter),
3433
"status",
35-
"active",
3634
"sector",
3735
"beneficiary_group",
3836
"beneficiary_validator",

src/country_workspace/contrib/hope/sync/context_programs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def sync_offices(self) -> None:
4444
SyncConfig(
4545
model=Office,
4646
path="business_areas",
47-
prepare_defaults=lambda r: {f: r.get(f) for f in ("name", "slug", "code", "long_name")},
47+
prepare_defaults=lambda r: {f: r.get(f) for f in ("name", "slug", "code", "long_name", "active")},
4848
should_process=lambda r: r.get("active"),
4949
should_deactivate=lambda r: not r.get("active"),
5050
),
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Generated by Django 5.1.7 on 2025-04-21 14:57
2+
3+
import pgtrigger.compiler
4+
import pgtrigger.migrations
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
dependencies = [
10+
("country_workspace", "0010_householdevent_individualevent_and_more"),
11+
]
12+
13+
operations = [
14+
pgtrigger.migrations.RemoveTrigger(
15+
model_name="household",
16+
name="updates_update",
17+
),
18+
pgtrigger.migrations.RemoveTrigger(
19+
model_name="individual",
20+
name="updates_update",
21+
),
22+
migrations.RemoveField(
23+
model_name="program",
24+
name="active",
25+
),
26+
migrations.AlterField(
27+
model_name="program",
28+
name="individual_columns",
29+
field=models.TextField(default="name\nid", help_text="Columns to display in the Admin table"),
30+
),
31+
pgtrigger.migrations.AddTrigger(
32+
model_name="household",
33+
trigger=pgtrigger.compiler.Trigger(
34+
name="update_update",
35+
sql=pgtrigger.compiler.UpsertTriggerSql(
36+
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"))',
37+
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;',
38+
hash="8ecf3de9db1d0a404013f2d873e0f061d7d00111",
39+
operation="UPDATE",
40+
pgid="pgtrigger_update_update_c2d37",
41+
table="country_workspace_household",
42+
when="AFTER",
43+
),
44+
),
45+
),
46+
pgtrigger.migrations.AddTrigger(
47+
model_name="individual",
48+
trigger=pgtrigger.compiler.Trigger(
49+
name="update_update",
50+
sql=pgtrigger.compiler.UpsertTriggerSql(
51+
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"))',
52+
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;',
53+
hash="75976263954d18b98b4e9bdd634a3e7db04f8c60",
54+
operation="UPDATE",
55+
pgid="pgtrigger_update_update_6a215",
56+
table="country_workspace_individual",
57+
when="AFTER",
58+
),
59+
),
60+
),
61+
]

src/country_workspace/models/program.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ class Program(BaseModel):
5858
code = models.CharField(max_length=255, blank=True, null=True)
5959
status = models.CharField(max_length=10, choices=STATUS_CHOICE, db_index=True)
6060
sector = models.CharField(max_length=50, choices=SECTOR_CHOICE, db_index=True)
61-
active = models.BooleanField(
62-
default=False,
63-
help_text=_("Whether the program is active. Only active program are visible in the UI"),
64-
)
6561

6662
# Local Fields
6763
beneficiary_validator = StrategyField(

src/country_workspace/workspaces/admin/program.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class Meta:
6969
"code",
7070
"status",
7171
"sector",
72-
"active",
7372
"beneficiary_validator",
7473
"household_checker",
7574
"individual_checker",
@@ -87,16 +86,14 @@ class CountryProgramAdmin(WorkspaceModelAdmin):
8786
"name",
8887
"sector",
8988
"status",
90-
"active",
9189
)
9290
search_fields = ("name",)
93-
list_filter = ("status", "active", "sector")
91+
list_filter = ("status", "sector")
9492
exclude = ("country_office",)
9593
default_url_filters = {"status__exact": CountryProgram.ACTIVE}
9694
readonly_fields = (
9795
"individual_columns",
9896
"household_columns",
99-
"active",
10097
"code",
10198
"status",
10299
"sector",
@@ -134,7 +131,7 @@ def get_fieldsets(
134131
{
135132
"fields": (
136133
("name", "code"),
137-
("status", "sector", "active"),
134+
("status", "sector"),
138135
),
139136
},
140137
),

0 commit comments

Comments
 (0)