Fixed participant csv import for group id

- Allowed to add multiple groups in csv group id field (e.g. "3,4")
- Fixed bug that group ids > 9 can not be imported.
- Updated error message if group id does not exists.
This commit is contained in:
Emanuel Schuetze 2014-06-19 14:13:06 +02:00 committed by Norman Jäckel
parent 648d5a6ad7
commit 587a3766d2
3 changed files with 12 additions and 8 deletions

View File

@ -8,6 +8,12 @@ Version 1.6.1 (unreleased)
==========================
[https://github.com/OpenSlides/OpenSlides/issues?milestone=16]
Participants:
- Fixed participant csv import for group id:
* Allowed to add multiple groups in csv group id field, e.g. "3,4".
* Fixed bug that group ids > 9 can not be imported.
* Updated error message if group id does not exists.
Other:
- Fixed CKEditor stuff (added insertpre plugin and removed unused code)

View File

@ -13,7 +13,7 @@ Teilnehmer/innen-Namen aus http://de.wikipedia.org/wiki/Otto_Normalverbraucher";
;"Tädi";"Maali";"female";;3;"Estland";;;;1
;"Maija";"Maikäläinen";"female";;3;"Finnland";;;;1
;"Jean";"Dupont";"male";;3;"Frankreich";;;;1
;"Paul";"Martin";"female";;4;"Frankreich";"Versammlungsleitung";;;1
;"Paul";"Martin";"male";;"3,4";"Frankreich";"Versammlungsleitung";;;1
;"Fred";"Bloggs";"male";;3;"Großbritanien";;;;0
;"John";"Smith";"male";;4;"Großbritanien";"Versammlungsleitung";;;1
;"Ashok";"Kumar";"male";;3;"Indien";;;;1

1 Titel Vorname Nachname Geschlecht E-Mail Gruppen-ID Gliederungsebene Amt Über mich Kommentar Aktiviert
13 Paul Martin female male 4 3,4 Frankreich Versammlungsleitung 1
14 Fred Bloggs male 3 Großbritanien 0
15 John Smith male 4 Großbritanien Versammlungsleitung 1
16 Ashok Kumar male 3 Indien 1
17 Si Polan male Indonesien 1
18 Seán Citizen male 3 Irland 1
19 Jóna Jónsson female 3 Island 1

View File

@ -54,15 +54,13 @@ def import_users(csvfile):
user.is_active = False
user.default_password = gen_password()
user.save()
for groupid in groups:
for groupid in groups.split(','):
try:
if groupid != ",":
if groupid and int(groupid):
Group.objects.get(pk=groupid).user_set.add(user)
except ValueError:
error_messages.append(_('Ignoring malformed group id in line %d.') % (line_no + 1))
continue
except Group.DoesNotExist:
error_messages.append(_('Group id %(id)s does not exists (line %(line)d).') % {'id': groupid, 'line': line_no + 1})
except (Group.DoesNotExist, ValueError):
error_messages.append(_('Ignoring group id "%(id)s" in line %(line)d which does not exist.') %
{'id': groupid, 'line': line_no + 1})
continue
user.reset_password()
count_success += 1