Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide title field by default & add Mx title #4692

Merged
merged 2 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Version 2.3.2

*Unreleased*

Improvements
^^^^^^^^^^^^

- Disable title field by default in new registration forms (:issue:`4688`, :pr:`4692`)
- Add gender-neutral "Mx" title (:issue:`4688`, :pr:`4692`)

Bugfixes
^^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""Allow mx user title

Revision ID: 8d614ef75968
Revises: f37d509e221c
Create Date: 2020-11-03 14:31:44.639447
"""

from alembic import op


# revision identifiers, used by Alembic.
revision = '8d614ef75968'
down_revision = 'f37d509e221c'
branch_labels = None
depends_on = None


def upgrade():
op.execute('''
ALTER TABLE "event_abstracts"."abstract_person_links" DROP CONSTRAINT "ck_abstract_person_links_valid_enum_title";
ALTER TABLE "events"."contribution_person_links" DROP CONSTRAINT "ck_contribution_person_links_valid_enum_title";
ALTER TABLE "events"."event_person_links" DROP CONSTRAINT "ck_event_person_links_valid_enum_title";
ALTER TABLE "events"."persons" DROP CONSTRAINT "ck_persons_valid_enum_title";
ALTER TABLE "events"."session_block_person_links" DROP CONSTRAINT "ck_session_block_person_links_valid_enum_title";
ALTER TABLE "events"."subcontribution_person_links" DROP CONSTRAINT "ck_subcontribution_person_links_valid_enum_title";
ALTER TABLE "users"."users" DROP CONSTRAINT "ck_users_valid_enum_title";
ALTER TABLE "event_abstracts"."abstract_person_links" ADD CONSTRAINT "ck_abstract_person_links_valid_enum_title" CHECK ((title = ANY (ARRAY[0, 1, 2, 3, 4, 5, 6])));
ALTER TABLE "events"."contribution_person_links" ADD CONSTRAINT "ck_contribution_person_links_valid_enum_title" CHECK ((title = ANY (ARRAY[0, 1, 2, 3, 4, 5, 6])));
ALTER TABLE "events"."event_person_links" ADD CONSTRAINT "ck_event_person_links_valid_enum_title" CHECK ((title = ANY (ARRAY[0, 1, 2, 3, 4, 5, 6])));
ALTER TABLE "events"."persons" ADD CONSTRAINT "ck_persons_valid_enum_title" CHECK ((title = ANY (ARRAY[0, 1, 2, 3, 4, 5, 6])));
ALTER TABLE "events"."session_block_person_links" ADD CONSTRAINT "ck_session_block_person_links_valid_enum_title" CHECK ((title = ANY (ARRAY[0, 1, 2, 3, 4, 5, 6])));
ALTER TABLE "events"."subcontribution_person_links" ADD CONSTRAINT "ck_subcontribution_person_links_valid_enum_title" CHECK ((title = ANY (ARRAY[0, 1, 2, 3, 4, 5, 6])));
ALTER TABLE "users"."users" ADD CONSTRAINT "ck_users_valid_enum_title" CHECK ((title = ANY (ARRAY[0, 1, 2, 3, 4, 5, 6])));
''')


def downgrade():
op.execute('''
UPDATE "event_abstracts"."abstract_person_links" SET title = 0 WHERE title = 6;
UPDATE "events"."contribution_person_links" SET title = 0 WHERE title = 6;
UPDATE "events"."event_person_links" SET title = 0 WHERE title = 6;
UPDATE "events"."persons" SET title = 0 WHERE title = 6;
UPDATE "events"."session_block_person_links" SET title = 0 WHERE title = 6;
UPDATE "events"."subcontribution_person_links" SET title = 0 WHERE title = 6;
UPDATE "users"."users" SET title = 0 WHERE title = 6;
''')
op.execute('''
ALTER TABLE "event_abstracts"."abstract_person_links" DROP CONSTRAINT "ck_abstract_person_links_valid_enum_title";
ALTER TABLE "events"."contribution_person_links" DROP CONSTRAINT "ck_contribution_person_links_valid_enum_title";
ALTER TABLE "events"."event_person_links" DROP CONSTRAINT "ck_event_person_links_valid_enum_title";
ALTER TABLE "events"."persons" DROP CONSTRAINT "ck_persons_valid_enum_title";
ALTER TABLE "events"."session_block_person_links" DROP CONSTRAINT "ck_session_block_person_links_valid_enum_title";
ALTER TABLE "events"."subcontribution_person_links" DROP CONSTRAINT "ck_subcontribution_person_links_valid_enum_title";
ALTER TABLE "users"."users" DROP CONSTRAINT "ck_users_valid_enum_title";
ALTER TABLE "event_abstracts"."abstract_person_links" ADD CONSTRAINT "ck_abstract_person_links_valid_enum_title" CHECK ((title = ANY (ARRAY[0, 1, 2, 3, 4, 5])));
ALTER TABLE "events"."contribution_person_links" ADD CONSTRAINT "ck_contribution_person_links_valid_enum_title" CHECK ((title = ANY (ARRAY[0, 1, 2, 3, 4, 5])));
ALTER TABLE "events"."event_person_links" ADD CONSTRAINT "ck_event_person_links_valid_enum_title" CHECK ((title = ANY (ARRAY[0, 1, 2, 3, 4, 5])));
ALTER TABLE "events"."persons" ADD CONSTRAINT "ck_persons_valid_enum_title" CHECK ((title = ANY (ARRAY[0, 1, 2, 3, 4, 5])));
ALTER TABLE "events"."session_block_person_links" ADD CONSTRAINT "ck_session_block_person_links_valid_enum_title" CHECK ((title = ANY (ARRAY[0, 1, 2, 3, 4, 5])));
ALTER TABLE "events"."subcontribution_person_links" ADD CONSTRAINT "ck_subcontribution_person_links_valid_enum_title" CHECK ((title = ANY (ARRAY[0, 1, 2, 3, 4, 5])));
ALTER TABLE "users"."users" ADD CONSTRAINT "ck_users_valid_enum_title" CHECK ((title = ANY (ARRAY[0, 1, 2, 3, 4, 5])));
''')
2 changes: 1 addition & 1 deletion indico/modules/events/persons/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def is_submitted(self):


class EventPersonForm(IndicoForm):
title = IndicoEnumSelectField(_('Title'), enum=UserTitle)
title = IndicoEnumSelectField(_('Title'), enum=UserTitle, sorted=True)
first_name = StringField(_('First name'), [DataRequired()])
last_name = StringField(_('Family name'), [DataRequired()])
affiliation = StringField(_('Affiliation'))
Expand Down
22 changes: 12 additions & 10 deletions indico/modules/events/registration/models/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,6 @@ def FIELD_DATA(cls):
'places_limit': 0,
'is_enabled': True}
return [
(cls.title, {
'title': cls.title.get_title(),
'input_type': 'single_choice',
'data': {
'item_type': 'dropdown',
'with_extra_slots': False,
'choices': [dict(title_item, id=unicode(uuid4()), caption=orig_string(t.title))
for t in UserTitle if t]
}
}),
(cls.first_name, {
'title': cls.first_name.get_title(),
'input_type': 'text'
Expand Down Expand Up @@ -121,6 +111,18 @@ def FIELD_DATA(cls):
'is_enabled': False,
'position': 1003
}),
(cls.title, {
'title': cls.title.get_title(),
'input_type': 'single_choice',
'is_enabled': False,
'position': 1004,
'data': {
'item_type': 'dropdown',
'with_extra_slots': False,
'choices': [dict(title_item, id=unicode(uuid4()), caption=orig_string(t.title))
for t in UserTitle if t]
}
}),
]

@property
Expand Down
2 changes: 1 addition & 1 deletion indico/modules/users/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


class UserDetailsForm(SyncedInputsMixin, IndicoForm):
title = IndicoEnumSelectField(_('Title'), enum=UserTitle)
title = IndicoEnumSelectField(_('Title'), enum=UserTitle, sorted=True)
first_name = StringField(_('First name'), [used_if_not_synced, DataRequired()], widget=SyncedInputWidget())
last_name = StringField(_('Family name'), [used_if_not_synced, DataRequired()], widget=SyncedInputWidget())
affiliation = StringField(_('Affiliation'), widget=SyncedInputWidget())
Expand Down
3 changes: 2 additions & 1 deletion indico/modules/users/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@


class UserTitle(RichIntEnum):
__titles__ = ('', _('Mr'), _('Ms'), _('Mrs'), _('Dr'), _('Prof.'))
__titles__ = ('', _('Mr'), _('Ms'), _('Mrs'), _('Dr'), _('Prof.'), _('Mx'))
none = 0
mr = 1
ms = 2
mrs = 3
dr = 4
prof = 5
mx = 6
ThiefMaster marked this conversation as resolved.
Show resolved Hide resolved


class NameFormat(RichIntEnum):
Expand Down