Skip to content

Commit

Permalink
Merge PR #661 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by thomaspaulb
  • Loading branch information
OCA-git-bot committed Jun 6, 2024
2 parents d1469a0 + 555e2e4 commit bc1bd34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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

0 comments on commit bc1bd34

Please sign in to comment.