def _serialize_principal(self, principal): if principal.principal_type == PrincipalType.email: return principal.fossilize() elif principal.principal_type == PrincipalType.network: return serialize_ip_network_group(principal) elif principal.principal_type == PrincipalType.user: return serialize_user(principal) elif principal.is_group: return serialize_group(principal) else: raise ValueError('Invalid principal: {} ({})'.format(principal, principal.principal_type))
def serialize_principal(principal): if principal.principal_type == PrincipalType.email: return serialize_email_principal(principal) elif principal.principal_type == PrincipalType.network: return serialize_ip_network_group(principal) elif principal.principal_type == PrincipalType.user: return serialize_user(principal) elif principal.principal_type == PrincipalType.event_role: return serialize_role(principal) elif principal.is_group: return serialize_group(principal) else: raise ValueError('Invalid principal: {} ({})'.format(principal, principal.principal_type))
def serialize_principal(principal): if principal.principal_type == PrincipalType.email: return serialize_email_principal(principal) elif principal.principal_type == PrincipalType.network: return serialize_ip_network_group(principal) elif principal.principal_type == PrincipalType.user: return serialize_user(principal) elif principal.principal_type == PrincipalType.event_role: return serialize_role(principal) elif principal.is_group: return serialize_group(principal) else: raise ValueError('Invalid principal: {} ({})'.format(principal, principal.principal_type))
def serialize_principal(principal): from indico.modules.categories.util import serialize_category_role if principal.principal_type == PrincipalType.email: return serialize_email_principal(principal) elif principal.principal_type == PrincipalType.network: return serialize_ip_network_group(principal) elif principal.principal_type == PrincipalType.user: return serialize_user(principal) elif principal.principal_type == PrincipalType.event_role: return serialize_event_role(principal) elif principal.principal_type == PrincipalType.category_role: return serialize_category_role(principal) elif principal.is_group: return serialize_group(principal) else: raise ValueError('Invalid principal: {} ({})'.format(principal, principal.principal_type))
def serialize_principal(principal): from indico.modules.categories.util import serialize_category_role if principal.principal_type == PrincipalType.email: return serialize_email_principal(principal) elif principal.principal_type == PrincipalType.network: return serialize_ip_network_group(principal) elif principal.principal_type == PrincipalType.user: return serialize_user(principal) elif principal.principal_type == PrincipalType.event_role: return serialize_event_role(principal) elif principal.principal_type == PrincipalType.category_role: return serialize_category_role(principal) elif principal.principal_type == PrincipalType.registration_form: return serialize_registration_form(principal) elif principal.is_group: return serialize_group(principal) else: raise ValueError(f'Invalid principal: {principal} ({principal.principal_type})')