Fix datepicker arrows style on hover
[cds-indico.git] / bin / maintenance / fix_utf8_errors.py
blobb7817c6256812c4171274219b6c62c950444f14a
1 # This file is part of Indico.
2 # Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
4 # Indico is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
9 # Indico is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Indico; if not, see <http://www.gnu.org/licenses/>.
17 """
18 Fixes possible encoding errors caused by older DB data
19 """
21 from indico.core.db import DBMgr
22 from MaKaC.conference import ConferenceHolder
23 from indico.util.console import conferenceHolderIterator
26 def fix_prop(c, name):
27 getter = getattr(c, 'get' + name)
28 try:
29 getter().decode('utf-8')
30 except UnicodeDecodeError:
31 print c.getId(), name
32 getattr(c, 'set' + name)(getter().decode('latin1').encode('utf-8'))
35 def fix_everything(dbi):
36 i = 0
37 for level, c in conferenceHolderIterator(ConferenceHolder(), deepness='event'):
38 fix_prop(c, 'Title')
39 fix_prop(c, 'Description')
41 for spk in c.getChairList():
42 fix_prop(spk, 'Affiliation')
43 fix_prop(spk, 'FamilyName')
44 fix_prop(spk, 'FirstName')
46 if i % 999 == 0:
47 dbi.commit()
48 i += 1
51 if __name__ == '__main__':
52 dbi = DBMgr.getInstance()
53 dbi.startRequest()
55 fix_everything(dbi)
57 dbi.endRequest()