Populate user model with promotion infos
As requested by Erkan et Martin
This commit is contained in:
parent
4cf633ed81
commit
08a47150db
3 changed files with 15 additions and 7 deletions
11
README.rst
11
README.rst
|
@ -181,12 +181,11 @@ Configuration
|
||||||
|
|
||||||
Auto-signup
|
Auto-signup
|
||||||
Populated data
|
Populated data
|
||||||
- username: ``<clipper>@<entrance year>``
|
- *username*: ``<clipper>@<entrance year>``
|
||||||
- email: from LDAP's *mailRoutingAddress* field, or ``<clipper>@clipper.ens.fr``
|
- *email*: from LDAP's *mailRoutingAddress* field, or ``<clipper>@clipper.ens.fr``
|
||||||
- first_name, last_name from LDAP's *cn* field
|
- *first_name*, *last_name* from LDAP's *cn* field
|
||||||
- extra_data in SocialAccount instance, containing these field, plus *annee*
|
- *entrance_year* (as 2-digit string), *department_code*, *department* and *promotion* (department+year) parsed from LDAP's *homeDirectory* field
|
||||||
and *promotion* parsed from LDAP's *homeDirectory* field (available only on
|
- *extra_data* in SocialAccount instance, containing all these field except *promotion* (and available only on first connection)
|
||||||
first connection)
|
|
||||||
|
|
||||||
Account deprecation
|
Account deprecation
|
||||||
At the beginning of each year (i.e. early November), to prevent clipper
|
At the beginning of each year (i.e. early November), to prevent clipper
|
||||||
|
|
|
@ -100,6 +100,16 @@ class LongTermClipperAccountAdapter(DefaultSocialAccountAdapter):
|
||||||
user_field(user, 'first_name', name_parts[0])
|
user_field(user, 'first_name', name_parts[0])
|
||||||
user_field(user, 'last_name', ' '.join(name_parts[1:]))
|
user_field(user, 'last_name', ' '.join(name_parts[1:]))
|
||||||
|
|
||||||
|
# Entrance year and department, if the user has these fields
|
||||||
|
entrance_year = ldap_data.get('entrance_year', '')
|
||||||
|
dep_code = ldap_data.get('department_code', '')
|
||||||
|
dep_fancy = ldap_data.get('department', '')
|
||||||
|
promotion = u'%s %s' % (dep_fancy, entrance_year)
|
||||||
|
user_field(user, 'entrance_year', entrance_year)
|
||||||
|
user_field(user, 'department_code', dep_code)
|
||||||
|
user_field(user, 'department', dep_fancy)
|
||||||
|
user_field(user, 'promotion', promotion)
|
||||||
|
|
||||||
# Ignore form
|
# Ignore form
|
||||||
get_account_adapter().populate_username(request, user)
|
get_account_adapter().populate_username(request, user)
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ def extract_infos_from_ldap(infos):
|
||||||
annee = dirs[2]
|
annee = dirs[2]
|
||||||
dep = dirs[3]
|
dep = dirs[3]
|
||||||
dep_fancy = DEPARTMENTS_LIST.get(dep.lower(), '')
|
dep_fancy = DEPARTMENTS_LIST.get(dep.lower(), '')
|
||||||
promotion = u'%s %s' % (dep, annee)
|
|
||||||
data['entrance_year'] = annee
|
data['entrance_year'] = annee
|
||||||
data['department_code'] = dep
|
data['department_code'] = dep
|
||||||
data['department'] = dep_fancy
|
data['department'] = dep_fancy
|
||||||
|
|
Loading…
Reference in a new issue