mirror of
https://github.com/viewflow/viewflow.git
synced 2026-03-13 10:32:34 +08:00
Changes sync
This commit is contained in:
@@ -10,6 +10,8 @@ Changelog
|
||||
- Fix jsonstore.DecimalField serialization
|
||||
- Add missing 'index' view for celery.Task node
|
||||
- Allow to revive flow.Subprocess and flow.NSubprocess nodes from error state
|
||||
- Fix invalid typing for fsm conditions
|
||||
- Allow explictily set permission=None for fsm @transtion decorator, to explicitly bypass permissions check
|
||||
|
||||
2.2.7 2024-08-16
|
||||
----------------
|
||||
|
||||
1
tox.ini
1
tox.ini
@@ -30,6 +30,7 @@ deps =
|
||||
django-redis==5.4.0
|
||||
django-reversion==5.0.12
|
||||
django-simple-history==3.4.0
|
||||
django-money==3.5.3
|
||||
|
||||
# development
|
||||
ansible==6.7.0
|
||||
|
||||
@@ -12,7 +12,7 @@ from __future__ import annotations
|
||||
import inspect
|
||||
from typing import Any, Dict, Mapping, Iterable, List, Type, Optional
|
||||
from viewflow.this_object import ThisObject
|
||||
from viewflow.utils import MARKER
|
||||
from viewflow.utils import DEFAULT, MARKER
|
||||
from .typing import (
|
||||
UserModel,
|
||||
Condition,
|
||||
@@ -39,7 +39,7 @@ class Transition:
|
||||
target: Optional[StateValue],
|
||||
label: Optional[str] = None,
|
||||
conditions: Optional[List[Condition]] = None,
|
||||
permission: Optional[Permission] = None,
|
||||
permission: Optional[Permission] = DEFAULT,
|
||||
custom: Optional[Dict] = None,
|
||||
): # noqa D102
|
||||
self.func = func
|
||||
@@ -86,8 +86,10 @@ class Transition:
|
||||
|
||||
def has_perm(self, instance: object, user: UserModel) -> bool:
|
||||
"""Checks if the given user has permission to perform this transition."""
|
||||
if self.permission is DEFAULT:
|
||||
return False # Protected by default
|
||||
if self.permission is None:
|
||||
return False # No permission required
|
||||
return True # Explicitly allowed to any
|
||||
elif callable(self.permission):
|
||||
return self.permission(instance, user)
|
||||
elif isinstance(self.permission, ThisObject):
|
||||
@@ -410,7 +412,7 @@ class State:
|
||||
target: Optional[StateValue] = None,
|
||||
label: Optional[str] = None,
|
||||
conditions: Optional[List[Condition]] = None,
|
||||
permission: Optional[Permission] = None,
|
||||
permission: Optional[Permission] = DEFAULT,
|
||||
custom: Optional[Dict] = None,
|
||||
) -> Any:
|
||||
"""Decorator to mark a method as a state transition."""
|
||||
|
||||
Reference in New Issue
Block a user