from core.models.Result import Result, ResultError from core.controllers.SyncController import new_sync # from gui.v2.actions.payment_actions import stop_payment_timer ENUM_MAP = { ResultError.UNKNOWN: None, ResultError.NEED_SYNC: (new_sync), ResultError.INVALID_API_REPLY: None, ResultError.ENCRYPTION: None, # ResultError.ACTIVE_BILLING: (stop_payment_timer), } def register_action(error_code): def wrapper(func): ENUM_MAP[error_code] = (func) return func return wrapper # Add later potentially: # ResultError.NO_TICKET: (start_billing), # ResultError.NO_PROFILE: (go_to_new_profile_page), # ResultError.ALREADY_EXISTS: (get_invoice), # bypass_existing: True # ResultError.BILLING_CODE_EXISTS: (get_invoice) # bypass_existing: True # Potential future upgrade to multiple error codes per function: # def register_action(*error_codes): # def wrapper(func): # for code in error_codes: # ACTION_REGISTRY[code] = func # return func # return wrapper