Lifecycle & Status

This page explains how Operations move across statuses and what you can change at each step.

Keep in mind

  • Author in DRAFT. Publish to ACTIVE when ready. Deactivate to INACTIVE.
  • Buyers can only use Operations that are ACTIVE and within the [startDate, endDate] window.
  • Automatic rule: when endDate passes, an ACTIVE Operation becomes INACTIVE.

🧭 State model at a glance

stateDiagram-v2
  [*] --> DRAFT
  DRAFT --> ACTIVE: Publish (manual)
  ACTIVE --> INACTIVE: Deactivate (manual)
  ACTIVE --> INACTIVE: endDate passed (auto)

  INACTIVE --> ACTIVE: Re-activate (manual)<br>(ensure now < endDate)

  note right of DRAFT: Editable (metadata, lines, accounts, dates)<br>Type PUBLIC/PRIVATE is immutable once set.
  note right of ACTIVE: Buyer-visible only when now ∈ [startDate, endDate].<br>Most fields locked to protect existing orders.
  note right of INACTIVE: Hidden from buyers, may be re-activated after adjusting dates.

🛠️ What you can do in each status

Action / FieldDRAFTACTIVEINACTIVE
Edit name/description/locales🔒
Edit external ID🔒
Set type (PUBLIC/PRIVATE)(initial choice)🔒 (immutable)🔒 (immutable)
Set startDate / endDate🔒
Manage lines (add/update/remove)🔒 (locked; avoid breaking orders)(prepare reactivation)
Attach/detach Accounts (PRIVATE)🔒
Publish (→ ACTIVE)
Deactivate (→ INACTIVE)(manual)
Re-activate (→ ACTIVE)(ensurenow < endDate)
Duplicate(new copy is DRAFT)(copy current snapshot)
Delete(if no orders linked)
🔒

Locked = strongly discouraged/blocked to avoid inconsistencies with existing orders. Your admin UI should prevent these changes in ACTIVE.


📅 Dates & buyer visibility

  • An Operation becomes buyer-visible when: status = ACTIVE AND now ∈ [startDate, endDate] AND the Account/Store/Locale rules are satisfied.
  • If you set ACTIVE while now < startDate, the Operation is scheduled: it will appear to buyers starting at startDate (no auto-activation step is needed).
  • When endDate passes, the platform automatically sets status to INACTIVE (if it was ACTIVE).
💡

Practical scheduling Set up everything in DRAFT, then publish (ACTIVE). If the campaign starts later, use a future startDate — the system will gate buyer visibility until that date.


👮 Ownership & permissions (recap)

  • Only the creator/owner can modify an Operation.
  • Operator users can see any Operation and can set PUBLIC type.
  • Customer Users (admin) require a specific right to create/manage Operations and can only attach Accounts they are attached to.
  • Standard Djust headers are required on all calls (e.g., dj-client, dj-api-key, optional dj-store, dj-store-view).

🤖 Automation rules

  • Auto-deactivation: if status=ACTIVE and now > endDate, status becomes INACTIVE automatically.
  • No auto-activation from DRAFT: activation is manual (publish). Use startDate to gate visibility after activation.
  • Background processing should be idempotent; re-running checks must not flip states incorrectly.
flowchart TD
    A[Publish request<br>status=ACTIVE] --> B{Valid dates?}
    B -->|startDate <= endDate| C[Set status=ACTIVE]
    B -->|invalid| E[Reject & explain]
    C --> D{now >= startDate?}
    D -->|yes| V[Buyer-visible]
    D -->|no| S[Scheduled: hidden until startDate]

    subgraph Periodic auto job
        J[now > endDate AND status=ACTIVE?] -->|yes| K[Set status=INACTIVE]
        J -->|no| L[No change]
    end

🧪 Common scenarios

Schedule a future campaign

  1. Create in DRAFT → add lines/accounts → set startDate in the future → set endDate.
  2. Publish (→ ACTIVE).
  3. Buyers will see it starting at startDate.

Pause early

  1. Set status to INACTIVE before endDate.
  2. Optionally adjust dates and re-activate later.

Re-run a past campaign

  1. Duplicate the finished Operation (new copy in DRAFT).
  2. Update dates/lines/accounts as needed → publish.

Cannot delete?

  • Ensure no cart or order is linked to the Operation. Otherwise, deletion is blocked by design.

🔗 API quicklinks

Status change

Dates & metadata

Read / verify

Deletion (end-of-life)

Shop (for visibility checks)

  • 🔜 GET /shop/operations — Returns only ACTIVE Operations within the current date window.
  • 🔜 GET /shop/operations/(id) — Returns 404 if not ACTIVE or outside the window.