Commit 3304837c by Dudás Ádám

common: reverse for operations

parent ff7dcb4f
from inspect import getargspec
from logging import getLogger
from .models import activity_context
from .models import activity_context, activity_code_separator
from django.core.exceptions import PermissionDenied
......@@ -170,6 +170,15 @@ class OperatedMixin(object):
else:
yield op
def get_operation_from_activity_code(self, activity_code):
sep = activity_code_separator
ops = getattr(self, operation_registry_name, {}).values()
for op in ops:
if activity_code.endswith(sep + op.activity_code_suffix):
return op
else:
return None
def register_operation(op_cls, op_id=None, target_cls=None):
"""Register the specified operation with the target class.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment