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
|
||||
Populated data
|
||||
- username: ``<clipper>@<entrance year>``
|
||||
- email: from LDAP's *mailRoutingAddress* field, or ``<clipper>@clipper.ens.fr``
|
||||
- first_name, last_name from LDAP's *cn* field
|
||||
- extra_data in SocialAccount instance, containing these field, plus *annee*
|
||||
and *promotion* parsed from LDAP's *homeDirectory* field (available only on
|
||||
first connection)
|
||||
- *username*: ``<clipper>@<entrance year>``
|
||||
- *email*: from LDAP's *mailRoutingAddress* field, or ``<clipper>@clipper.ens.fr``
|
||||
- *first_name*, *last_name* from LDAP's *cn* field
|
||||
- *entrance_year* (as 2-digit string), *department_code*, *department* and *promotion* (department+year) parsed from LDAP's *homeDirectory* field
|
||||
- *extra_data* in SocialAccount instance, containing all these field except *promotion* (and available only on first connection)
|
||||
|
||||
Account deprecation
|
||||
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, '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
|
||||
get_account_adapter().populate_username(request, user)
|
||||
|
||||
|
|
|
@ -49,7 +49,6 @@ def extract_infos_from_ldap(infos):
|
|||
annee = dirs[2]
|
||||
dep = dirs[3]
|
||||
dep_fancy = DEPARTMENTS_LIST.get(dep.lower(), '')
|
||||
promotion = u'%s %s' % (dep, annee)
|
||||
data['entrance_year'] = annee
|
||||
data['department_code'] = dep
|
||||
data['department'] = dep_fancy
|
||||
|
|
Loading…
Reference in a new issue