Ejemplo n.º 1
0
 def _serialize_principal(self, principal):
     if principal.principal_type == PrincipalType.email:
         return principal.fossilize()
     elif principal.principal_type == PrincipalType.user:
         return serialize_user(principal)
     else:
         return serialize_group(principal)
Ejemplo n.º 2
0
 def _value(self):
     if self.serializable:
         data = retrieve_principals(self._get_data(), legacy=False)
     else:
         data = self._get_data()
     data.sort(key=lambda x: x.name.lower())
     return [serialize_user(x) if isinstance(x, User) else serialize_group(x) for x in data]
Ejemplo n.º 3
0
 def _serialize_principal(self, principal):
     if principal.principal_type == PrincipalType.email:
         return principal.fossilize()
     elif principal.principal_type == PrincipalType.user:
         return serialize_user(principal)
     else:
         return serialize_group(principal)
Ejemplo n.º 4
0
 def _value(self):
     if self.serializable:
         data = retrieve_principals(self._get_data(), legacy=False)
     else:
         data = self._get_data()
     data.sort(key=lambda x: x.name.lower())
     return [
         serialize_user(x) if isinstance(x, User) else serialize_group(x)
         for x in data
     ]
Ejemplo n.º 5
0
 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))
Ejemplo n.º 6
0
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))
Ejemplo n.º 7
0
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))
Ejemplo n.º 8
0
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))
Ejemplo n.º 9
0
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})')
Ejemplo n.º 10
0
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 IPNetworkGroupSchema().dump(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.principal_type in (PrincipalType.local_group,
                                      PrincipalType.multipass_group):
        return serialize_group(principal)
    else:
        raise ValueError(
            f'Invalid principal: {principal} ({principal.principal_type})')
Ejemplo n.º 11
0
 def _process(self, name, exact):
     groups = GroupProxy.search(name, exact=exact)
     total = len(groups)
     return jsonify(
         groups=[serialize_group(group) for group in groups[:10]],
         total=total)
Ejemplo n.º 12
0
 def _process(self, name):
     groups = GroupProxy.search(name)
     return jsonify([serialize_group(group) for group in groups])
Ejemplo n.º 13
0
 def _process(self, name, exact):
     groups = GroupProxy.search(name, exact=exact)
     total = len(groups)
     return jsonify(groups=[serialize_group(group) for group in groups[:10]], total=total)