Browse Source

Otimiza geração de grupos com base no LDAP

pull/159/head
Sesostris Vieira 2 years ago
parent
commit
ed92ab4d95
  1. 9
      sigi/apps/servidores/models.py

9
sigi/apps/servidores/models.py

@ -137,9 +137,12 @@ def ajusta_nome_usuario(sender, instance, *args, **kwargs):
def user_staff_and_group(user, ldap_user, **kwargs): def user_staff_and_group(user, ldap_user, **kwargs):
dep = ldap_user.attrs.get("department", [""])[0] dep = ldap_user.attrs.get("department", [""])[0]
title = ldap_user.attrs.get("title", [""])[0] title = ldap_user.attrs.get("title", [""])[0]
group_names = [dep.split("-")[-1], title] deps = dep.split("-")
group_names.extend(title.split("-", 1)) titles = [s.strip().upper() for s in title.split("-", 1)]
group_names = [s.strip().upper() for s in group_names] group_names = [f"{d}-{t}" for d in deps for t in titles]
group_names.extend(deps)
group_names.extend(titles)
group_names.extend([dep, title.upper()])
user.is_staff = "ILB" in dep user.is_staff = "ILB" in dep
user.save() user.save()
user.groups.clear() user.groups.clear()

Loading…
Cancel
Save