-
Notifications
You must be signed in to change notification settings - Fork 26
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
2170 introduce gender model #2485
2170 introduce gender model #2485
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments in migration code.
With help of the openslides-datastore-service pull request 368 it will be easier to write the migration.
openslides_backend/migrations/migrations/0054_introduce_flexible_gender_model.py
Outdated
Show resolved
Hide resolved
openslides_backend/migrations/migrations/0054_introduce_flexible_gender_model.py
Outdated
Show resolved
Hide resolved
openslides_backend/migrations/migrations/0054_introduce_flexible_gender_model.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change the permission from can_manage_organization
to can_manage_accounts
to edit/delete or update a gender
I will use |
openslides_backend/migrations/migrations/0054_introduce_flexible_gender_model.py
Outdated
Show resolved
Hide resolved
openslides_backend/migrations/migrations/0054_introduce_flexible_gender_model.py
Outdated
Show resolved
Hide resolved
openslides_backend/migrations/migrations/0054_introduce_flexible_gender_model.py
Outdated
Show resolved
Hide resolved
"gender/1": {"name": "male"}, | ||
"gender/2": {"name": "female"}, | ||
"gender/3": {"name": "diverse"}, | ||
"gender/4": {"name": "non-binary"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amend an existing test: explicit test for the field gender being empty after importing a new user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used test_all_migrations for this.
) -> dict[str, int] | None: | ||
"""returns gender as a dict of "name" and "id" if it exists, otherwise raises ActionException""" | ||
if gender_id := instance.get("gender_id"): | ||
gender_dict = datastore.get_all("gender", ["id", "name"], lock_result=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a simple self.datastore.get("gender", gender_id,...)
to read the gender instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use the fqid to get the gender now.
) | ||
def check_gender_exists( | ||
datastore: DatastoreService, instance: dict[str, Any] | ||
) -> dict[str, int] | None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't return anything, it is never used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -29,7 +29,7 @@ def setUp(self) -> None: | |||
"first_name": "firstName", | |||
"last_name": "lastName", | |||
"email": "email", | |||
"gender": "gender", | |||
"gender_id": "gender_id", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert to gender:gender
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -12,7 +12,7 @@ class OrganizationUpdateActionTest(BaseActionTestCase): | |||
"first_name": "firstName", | |||
"last_name": "lastName", | |||
"email": "email", | |||
"gender": "gender", | |||
"gender_id": "gender_id", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert to gender:gender
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just 2 little things in documentation.
I'll try to solve the user update problem.
docs/actions/gender.delete.md
Outdated
``` | ||
|
||
## Action | ||
Deletes the gender. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some text like The first 4 gender names are fixed and cannot be changed or delete
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
docs/actions/gender.update.md
Outdated
``` | ||
|
||
## Action | ||
Updates the gender if a gender with that name doesn't exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add some text like The first 4 gender names are fixed and cannot be changed or delete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…e import without any new genders would result in exception.
Thank you. That was really helpful. I didn't think of adding it to the org like this. |
Notice: Needs to be updated, to work with my pr in client. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No changes anymore by merging main
* draft create update delete + tests + testupdates + migration * update meta rep * general error removal and improvement for draft * remove meeting import error * update meeting import so that checker removes gender_id * general code improvements delete gender checks for back relation in organiziation * md documentation + pleasing mypy * use defaultdict * use new in memory flag of datastore * fix mypy error by upping datastore version * change the permission from can_manage_organization to can_manage_users * improve documentation * lock result false + no orga check * add test for gender import * make name and org id required * Use gender string for saml and meeting import. Refine gender actions and mixin. General code improvements. * cleanup and documentation improvement * beautify code * add test update gender on user merge. * update docs test for meeting import and saml account (+ new test) create gender for saml accounts * updated meta * meeting import create user with gender. export gender strings. improve tests. * Separate test for gender on meeting import. General code improvements in saml, export, import and migration plus additional test for empty string. * extend test for gender import, plus fixes. docs update * improve user and gender updates/creation * Gender will not be created without being used anymore. Fix error where import without any new genders would result in exception. * Improve gender action documentation * fixed typo in migration gender female * update meta --------- Co-authored-by: Ralf Peschke <ralf.peschke@intevation.de> Co-authored-by: rrenkert <raimund@renkert.org>
Closes #2170
Themes to check:
gender
-field may change nothing, agender
-field with an empty string should be interpreted as "no gender value wanted" and the user's gender_id should be set to NULL. @rrenkert @Elblinator hope you agree