Organization¶
Enums: OrganizationStatus and OrganizationOrigin in app/core/models/organizations.py
States¶
graph LR
PROSPECT --> LIVE
LIVE --> CHURNED
CHURNED --> DISABLED
CHURNED --> LIVE
DISABLED --> LIVE
classDef starting fill:#96d0ff;
classDef ending fill:#ffd6d6;
classDef static fill:#dccbff;
classDef paused fill:#fff2a8;
class PROSPECT starting;
class DISABLED ending;
class CHURNED paused;
PROSPECT¶
No campaigns yet. Excluded from reporting and mail.
LIVE¶
Has active/completed campaigns. Full functionality.
CHURNED¶
Manually marked. Continues order/attribution processing but blocks new mail.
DISABLED¶
Manually marked. Blocks all new processing. In-flight prints complete.
Origins¶
| Origin | Meaning |
|---|---|
| MANUAL | Created manually via API. |
| SHOPIFY_APP_STORE | Auto-created from Shopify App Store install. |
Behavior matrix¶
| Operation | PROSPECT | LIVE | CHURNED | DISABLED |
|---|---|---|---|---|
| Send mail | No | Yes | No | No |
| Sync orders | No | Yes | Yes | No |
| Weekly reporting | No | Yes | Yes | No |
| Recipient syncing | No | Yes | No | No |
Transitions¶
| From | To | Trigger | File |
|---|---|---|---|
| PROSPECT | LIVE | First active/completed campaign (auto, every 10min) | celery/organization_status_sync.py |
| Any | Any | Admin PATCH /v1/organizations/<id>/status |
routes/organization_routes.py |
| CHURNED | DISABLED | After 180 days (auto) + Slack notification | celery/organization_status_sync.py |
Side effects on manual transitions:
- -> CHURNED: All Active campaigns -> Completed, Draft/Paused -> Archived, sets
churned_date - -> LIVE (from CHURNED/DISABLED): Clears
churned_date - All transitions send Slack notification
Key files¶
- Model:
core/models/organizations.py - Methods:
methods/organizations.py(update_organization_status_with_side_effects()) - Background:
celery/organization_status_sync.py - Routes:
routes/organization_routes.py