diff --git a/extras/csv-examples/participants-demo_de.csv b/extras/csv-examples/participants-demo_de.csv index 5a21169a1..f90ec012a 100644 --- a/extras/csv-examples/participants-demo_de.csv +++ b/extras/csv-examples/participants-demo_de.csv @@ -1,12 +1,15 @@ -"Vorname";"Nachname";"Geschlecht";"Gliederungsebene";"Typ";"Amt";"Kommentar" -"Angramain";"Aranea";"female";;"delegate";; -"Bastian";"Bux";"male";;"observer";"2. Vorsitzender"; -"Emma";"Dampf";"female";"Ortsverband Berlin-Mitte";"delegate";"AG Frauen"; -"David";"Delegierter";"male";"Ortsverband Berlin-Mitte";"delegate";"Haushaltsausschuss";"Demo-Account" -"Marta";"Grankvist";"female";"Ortsverband Köln";"delegate";"1. Vorsitzende"; -"Atréju";"Grün";"male";"Ortsverband Freiburg";"staff";"Versammlungsleitung"; -"Li Si";"Mandala";"female";;"staff";; -"Malin";"Melchersson";"male";"Gastredner e.V.";"guest";; -"Molly";"Tender";"female";"Ortsverband Berlin-Mitte";"delegate";; -"Dr. Karl";"Tur Tur";"male";;"observer";; -"Volker";"Versammlungsleitung";"male";"Ortsverband Hamburg";"delegate";"Versammlungsleitung";"Demo-Account" +"Titel";"Vorname";"Nachname";"Geschlecht";"E-Mail";"Gruppen-ID";"Gliederungsebene";"Amt";"Über mich";"Kommentar";"Aktiviert" +;"Angramain";"Aranea";"female";;;;;;;1 +;"Bastian";"Bux";"male";;;;"2. Vorsitzender";;;1 +;"Emma";"Dampf";"female";;3;"Ortsverband Berlin-Mitte";"AG Frauen";;;0 +"Dr.";"David";"Delegierter";"male";"david@example.com";3;"Ortsverband Berlin-Mitte";"Haushaltsausschuss";"Zu meiner Person: +A +B +C";"Demo-Account";1 +;"Marta";"Grankvist";"female";;3,4;"Ortsverband Köln";"1. Vorsitzende";;;0 +"Prof. Dr.";"Atréju";"Grün";"male";;4;"Ortsverband Freiburg";"Versammlungsleitung";;;1 +;"Li Si";"Mandala";"female";;4;;;;;1 +;"Malin";"Melchersson";"male";;;"Gastredner e.V.";;;;1 +;"Molly";"Tender";"female";;3;"Ortsverband Berlin-Mitte";;;;1 +"Dr. med.";"Karl";"Tur Tur";"male";;;;;;;1 +"Dipl.-Ing.";"Volker";"Versammlungsleitung";"male";"volker@example.com";3,4;"Ortsverband Hamburg";"Versammlungsleitung";;"Demo-Account";1 diff --git a/extras/csv-examples/participants-demo_en.csv b/extras/csv-examples/participants-demo_en.csv index 5c357b2ab..971eeaebd 100644 --- a/extras/csv-examples/participants-demo_en.csv +++ b/extras/csv-examples/participants-demo_en.csv @@ -1,12 +1,15 @@ -"First Name";"Last Name";"Gender";"Structure Level";"Type";"Committee";"Comment" -"Angramain";"Aranea";"female";;"delegate";; -"Bastian";"Bux";"male";;"observer";"2. Vorsitzender"; -"Emma";"Dampf";"female";"Ortsverband Berlin-Mitte";"delegate";"AG Frauen"; -"David";"Delegierter";"male";"Ortsverband Berlin-Mitte";"delegate";"Haushaltsausschuss";"Demo-Account" -"Marta";"Grankvist";"female";"Ortsverband Köln";"delegate";"1. Vorsitzende"; -"Atréju";"Grün";"male";"Ortsverband Freiburg";"staff";"Versammlungsleitung"; -"Li Si";"Mandala";"female";;"staff";; -"Malin";"Melchersson";"male";"Gastredner e.V.";"guest";; -"Molly";"Tender";"female";"Ortsverband Berlin-Mitte";"delegate";; -"Dr. Karl";"Tur Tur";"male";;"observer";; -"Volker";"Versammlungsleitung";"male";"Ortsverband Hamburg";"delegate";"Versammlungsleitung";"Demo-Account" +"First Name";"Last Name";"Gender";"Email";"Group id";"Structure Level";"Committee";"About me";"Comment";"Is active" +"Angramain";"Aranea";"female";;;;;;;1 +"Bastian";"Bux";"male";;;;"2. Vorsitzender";;;1 +"Emma";"Dampf";"female";;3;"Ortsverband Berlin-Mitte";"AG Frauen";;;0 +"David";"Delegierter";"male";"david@example.com";3;"Ortsverband Berlin-Mitte";"Haushaltsausschuss";"Zu meiner Person: +A +B +C";"Demo-Account";1 +"Marta";"Grankvist";"female";;3,4;"Ortsverband Köln";"1. Vorsitzende";;;0 +"Atréju";"Grün";"male";;4;"Ortsverband Freiburg";"Versammlungsleitung";;;1 +"Li Si";"Mandala";"female";;4;;;;;1 +"Malin";"Melchersson";"male";;;"Gastredner e.V.";;;;1 +"Molly";"Tender";"female";;3;"Ortsverband Berlin-Mitte";;;;1 +"Karl";"Tur Tur";"male";;;;;;;1 +"Volker";"Versammlungsleitung";"male";"volker@example.com";3,4;"Ortsverband Hamburg";"Versammlungsleitung";;"Demo-Account";1 diff --git a/openslides/participant/api.py b/openslides/participant/api.py index bf4310ca8..433dc2fc3 100644 --- a/openslides/participant/api.py +++ b/openslides/participant/api.py @@ -67,21 +67,38 @@ def import_users(csv_file): dialect=dialect)): if line_no: try: - (first_name, last_name, gender, structure_level, type, committee, comment) = line[:7] + (title, first_name, last_name, gender, email, groups, + structure_level, committee, about_me, comment, is_active) = line[:11] except ValueError: error_messages.append(_('Ignoring malformed line %d in import file.') % (line_no + 1)) continue user = User() + user.title = title user.last_name = last_name user.first_name = first_name user.username = gen_username(first_name, last_name) user.gender = gender + user.email = email user.structure_level = structure_level - user.type = type user.committee = committee + user.about_me = about_me user.comment = comment + if is_active == '1': + user.is_active = True + else: + user.is_active = False user.default_password = gen_password() user.save() + for groupid in groups: + try: + if 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 %s does not exists (line %d).') % (groupid, line_no + 1)) + continue user.reset_password() count_success += 1 except csv.Error: diff --git a/openslides/participant/forms.py b/openslides/participant/forms.py index 64a4f2b83..bab9ba92c 100644 --- a/openslides/participant/forms.py +++ b/openslides/participant/forms.py @@ -36,16 +36,17 @@ class UserCreateForm(forms.ModelForm, CssClassMixin): class Meta: model = User - fields = ('first_name', 'last_name', 'is_active', 'groups', 'structure_level', - 'gender', 'type', 'committee', 'about_me', 'comment', 'default_password') + fields = ('title', 'first_name', 'last_name', 'gender', 'email', + 'groups', 'structure_level', 'committee', 'about_me', 'comment', + 'is_active', 'default_password') class UserUpdateForm(UserCreateForm): class Meta: model = User - fields = ('username', 'first_name', 'last_name', 'is_active', 'groups', - 'structure_level', 'gender', 'type', 'committee', 'about_me', 'comment', - 'default_password') + fields = ('username', 'title', 'first_name', 'last_name', 'gender', 'email', + 'groups', 'structure_level', 'committee', 'about_me', 'comment', + 'is_active', 'default_password') class GroupForm(forms.ModelForm, CssClassMixin): @@ -106,7 +107,8 @@ class UsersettingsForm(forms.ModelForm, CssClassMixin): class Meta: model = User - fields = ('username', 'first_name', 'last_name', 'gender', 'email', 'committee', 'about_me') + fields = ('username', 'title', 'first_name', 'last_name', 'gender', 'email', + 'committee', 'about_me') class UserImportForm(forms.Form, CssClassMixin): diff --git a/openslides/participant/models.py b/openslides/participant/models.py index bbb889329..37aa13c9d 100644 --- a/openslides/participant/models.py +++ b/openslides/participant/models.py @@ -30,25 +30,19 @@ class User(PersonMixin, Person, SlideMixin, DjangoUser): ('male', _('Male')), ('female', _('Female')), ) - TYPE_CHOICES = ( - ('delegate', _('Delegate')), - ('observer', _('Observer')), - ('staff', _('Staff')), - ('guest', _('Guest')), - ) django_user = models.OneToOneField(DjangoUser, editable=False, parent_link=True) structure_level = models.CharField( - max_length=100, blank=True, default='', verbose_name=_("Structure level"), + max_length=255, blank=True, default='', verbose_name=_("Structure level"), help_text=_('Will be shown after the name.')) + title = models.CharField( + max_length=50, blank=True, default='', verbose_name=_("Titel"), + help_text=_('Will be shown before the name.')) gender = models.CharField( max_length=50, choices=GENDER_CHOICES, blank=True, verbose_name=_("Gender"), help_text=_('Only for filtering the participant list.')) - type = models.CharField( - max_length=100, choices=TYPE_CHOICES, blank=True, - verbose_name=_("Typ"), help_text=_('Only for filtering the participant list.')) committee = models.CharField( - max_length=100, blank=True, default='', verbose_name=_("Committee"), + max_length=255, blank=True, default='', verbose_name=_("Committee"), help_text=_('Only for filtering the participant list.')) about_me = models.TextField( blank=True, default='', verbose_name=_('About me'), @@ -62,7 +56,11 @@ class User(PersonMixin, Person, SlideMixin, DjangoUser): @property def clean_name(self): - return self.get_full_name() or self.username + if self.title: + name = "%s %s" % (self.title, self.get_full_name()) + else: + name = self.get_full_name() + return name or self.username def get_name_suffix(self): return self.structure_level diff --git a/openslides/participant/templates/participant/import.html b/openslides/participant/templates/participant/import.html index e5c8ce024..2d754b401 100644 --- a/openslides/participant/templates/participant/import.html +++ b/openslides/participant/templates/participant/import.html @@ -13,15 +13,21 @@
{% trans 'Select a CSV file to import participants!' %}
- -{% trans 'Required comma separated values' %}:
- ({% trans 'first_name, last_name, gender, structure level, type, committee, comment' %})
-
- {% trans 'Required CSV file encoding: UTF-8 (Unicode).' %}
-
{% trans 'A CSV example file is available in OpenSlides Wiki.' %} -
+ +{% trans 'Please note' %}:
+({% trans 'title, first name, last name, gender, email, group id, structure level, committee, about me, comment, is active' %})
+ 1
), {% trans 'Registered' %} (2
),
+ {% trans 'Delegate' %} (3
), {% trans 'Staff' %} (4
)
+