/
Migration0.8.14To0.90.0.py
54 lines (46 loc) · 1.66 KB
/
Migration0.8.14To0.90.0.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# -*- coding: utf-8 -*-
##
##
## This file is part of Indico.
## Copyright (C) 2002 - 2013 European Organization for Nuclear Research (CERN).
##
## Indico is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 3 of the
## License, or (at your option) any later version.
##
## Indico is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Indico;if not, see <http://www.gnu.org/licenses/>.
from indico.core.db import DBMgr
DBMgr.getInstance().startRequest()
from MaKaC.user import AvatarHolder
ah = AvatarHolder()
#migrate dict to list
for av in ah.getValuesToList():
if not isinstance(av.identities, list):
av.identities = av.identities.values()
from MaKaC.authentication.NiceAuthentication import NiceAuthenticator, NiceIdentity
na = NiceAuthenticator()
from MaKaC.authentication.LocalAuthentication import LocalAuthenticator
la = LocalAuthenticator()
#sync authenticators identities to avatars identity list
for id in la.getValuesToList():
u = id.getUser()
if not id in u.getIdentityList():
try:
u.addIdentity(id)
except:
print u.getId()
for id in na.getValuesToList():
u = id.getUser()
if not id in u.getIdentityList():
try:
u.addIdentity(id)
except:
print u.getId()
DBMgr.getInstance().endRequest()