Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][PORT] 659 from 16.0 #660

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion users_ldap_groups/models/res_company_ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _get_or_create_user(self, conf, login, ldap_entry):
_logger.debug("deleting all groups from user %d", user_id)
groups.append((5, False, False))
for mapping in this.group_mapping_ids:
operator = getattr(op_obj, mapping.operator)
operator = getattr(op_obj, f"_{mapping.operator}")
_logger.debug("checking mapping %s", mapping)
if operator(ldap_entry, mapping):
_logger.debug(
Expand Down
8 changes: 4 additions & 4 deletions users_ldap_groups/models/res_company_ldap_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ class ResCompanyLdapOperator(models.AbstractModel):

@api.model
def operators(self):
"""Return names of function to call on this model as operator"""
"""Return names (without '_') of function to call on this model as operator"""
return ("contains", "equals", "query")

def contains(self, ldap_entry, mapping):
def _contains(self, ldap_entry, mapping):
return mapping.ldap_attribute in ldap_entry[1] and mapping.value in map(
lambda x: x.decode(), ldap_entry[1][mapping.ldap_attribute]
)

def equals(self, ldap_entry, mapping):
def _equals(self, ldap_entry, mapping):
return mapping.ldap_attribute in ldap_entry[1] and mapping.value == str(
list(map(lambda x: x.decode(), ldap_entry[1][mapping.ldap_attribute]))
)

def query(self, ldap_entry, mapping):
def _query(self, ldap_entry, mapping):
query_string = Template(mapping.value).safe_substitute(
{attr: ldap_entry[1][attr][0].decode() for attr in ldap_entry[1]}
)
Expand Down
Loading