Skip to main content

Forge workflow — statuts et transitions applicatives.

Project description

forge-mvc-workflow

Module workflow pour Forge — statuts et transitions applicatives.

Extrait du core Forge depuis la version 2.6.0 (ADR-004).

Installation

pip install forge-mvc-workflow
# ou en mode developpement
pip install -e packages/forge-mvc-workflow/

Usage

from forge_mvc_workflow import (
    WorkflowStatus,
    WorkflowTransition,
    make_status,
    make_transition,
    validate_statuses,
    validate_transitions,
    can_transition,
    get_available_transitions,
    make_workflow_jinja_helpers,
)

# Definir des statuts
statuses = validate_statuses([
    make_status("brouillon", label="Brouillon", color="gray"),
    make_status("confirme", label="Confirme", color="green"),
    make_status("annule", label="Annule", color="red"),
])

# Definir des transitions autorisees
transitions = validate_transitions([
    make_transition("brouillon", "confirme"),
    make_transition("brouillon", "annule"),
    make_transition("confirme", "annule"),
], statuses=statuses)

# Verifier une transition
if can_transition(transitions, "brouillon", "confirme"):
    ...

# Obtenir les transitions disponibles depuis un statut
available = get_available_transitions(transitions, "brouillon")

Helpers Jinja2

env.globals.update(make_workflow_jinja_helpers())

Dans un template :

{{ workflow_status_badge(reservation.status) }}
{{ workflow_status_label(reservation.status) }}

Cas d'usage

  • Statut d'une reservation (brouillon → confirmee → terminee → annulee)
  • Statut d'un document (redaction → validation → publie)
  • Statut d'une commande (panier → payee → expediee → livree)

API publique

  • WorkflowStatus — dataclass statut (name, label, color)
  • WorkflowTransition — dataclass transition (from_status, to_status)
  • make_status(name, label, color) — constructeur valide
  • make_transition(from_status, to_status) — constructeur valide
  • validate_statuses(list) — valide une liste de statuts
  • validate_transitions(list, statuses) — valide les transitions par rapport aux statuts
  • can_transition(transitions, from_name, to_name) — teste une transition
  • get_available_transitions(transitions, from_name) — liste les transitions disponibles
  • make_workflow_jinja_helpers() — dict de helpers Jinja2

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

forge_mvc_workflow-1.0.0b17.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

forge_mvc_workflow-1.0.0b17-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file forge_mvc_workflow-1.0.0b17.tar.gz.

File metadata

  • Download URL: forge_mvc_workflow-1.0.0b17.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for forge_mvc_workflow-1.0.0b17.tar.gz
Algorithm Hash digest
SHA256 aa46b705ef5aecc5c7b4e51429b094130871c7920ac551c9afeac132137c6be8
MD5 e0db8b03d70e48ce6130f61a497eed7d
BLAKE2b-256 c398e35e3fb41265e962fa0cb22aee904d1f943a11c5e886e91e14aa88fba84d

See more details on using hashes here.

File details

Details for the file forge_mvc_workflow-1.0.0b17-py3-none-any.whl.

File metadata

File hashes

Hashes for forge_mvc_workflow-1.0.0b17-py3-none-any.whl
Algorithm Hash digest
SHA256 893aa48c2baaf5f93915c8bfb4aca75dce6586f2677077be543cd197551a0068
MD5 7d67b2da9f4d4f2bbde3768ef32e224e
BLAKE2b-256 85846a7c2b43fb2e3b43bb958b86579b2d1731d064b989ecdd432722adc2e661

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page