Changeset a3227e7 in flexoentity


Ignore:
Timestamp:
10/27/25 10:56:45 (3 months ago)
Author:
Enrico Schwass <ennoausberlin@…>
Branches:
master
Children:
52ccac6
Parents:
3bad43e
Message:

helper method apply_state_change added to call appropriate actions for a given new state

File:
1 edited

Legend:

Unmodified
Added
Removed
  • flexoentity/flexo_entity.py

    r3bad43e ra3227e7  
    307307    def publish(self):
    308308        """
    309     Move    from APPROVED or APPROVED_AND_SIGNED to PUBLISHED.
     309        Move from APPROVED or APPROVED_AND_SIGNED to PUBLISHED.
    310310       
    311311        Uses allowed_transitions() to verify legality,
     
    375375            case _:
    376376                return []
     377
     378    def apply_state_change(self, new_state):
     379        """
     380        High-level dispatcher used by GUI actions.
     381        Safely applies the requested state transition by invoking
     382        the corresponding FlexoEntity method if available.
     383        """
     384
     385        if self.state == new_state:
     386            return
     387        if new_state == EntityState.APPROVED:
     388            self.approve()
     389        elif new_state == EntityState.SIGNED:
     390            self.sign()
     391        elif new_state == EntityState.PUBLISHED:
     392            self.publish()
     393        elif new_state == EntityState.OBSOLETE:
     394            self.obsolete()
     395        else:
     396            raise RuntimeError(f"No handler for state transition to {new_state.name}")
Note: See TracChangeset for help on using the changeset viewer.