-
Notifications
You must be signed in to change notification settings - Fork 986
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
Request organization account #11184
Request organization account #11184
Conversation
On second thought, we probably don't want localization for admin emails.
docker-compose run web python -m warehouse db revision --autogenerate --message "Create Organization models" make reformat Forced to regenerate migrations due to recent database changes (pypi#11157).
- Organization account name - Organization name - Organization URL - Organization description - Organization type
Found the droids that we're looking for.
This is a placeholder so we can reference `admin.organization.approve` as a route in the admin-new-organization-requested email.
- `ManageOrganizationsViews.default_response` - `ManageOrganizationsViews.manage_organizations()`
make translations
- `ManageOrganizationsViews.create_organization()`
Co-Authored-By: sterbo <matt.sterba@gmail.com>
Co-Authored-By: sterbo <matt.sterba@gmail.com>
@ewdurbin I think this PR is ready for review again — and ready for merge too if everything looks good. Please let us know if there are other issues or questions we should address. Thank you! The next PR for approving the organization account (#11208) is ready for review too as soon as this PR is merged. |
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 would like to see us store references to users in the OrganizationEvents as User.id rather than sticking with the status quo, so that is a blocker on merge for me.
As far as the Enum questions go, I believe that can be a migration if we decide down the line, so it's more of a preference.
Otherwise this is 👍🏼 for me.
) | ||
self.organization_service.add_organization_role( | ||
"Owner", self.request.user.id, organization.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.
For the purposes of traceability we should use User IDs and reconstitute the user on display.
We should also do this elsewhere, since username changes are something that we want to support in the future, but that's not on you :)
) | ||
|
||
|
||
class OrganizationInvitationStatus(enum.Enum): |
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 should have done some research up front rather than ask the question, but SQLAlchemy has support for proper postgres enums, I think the biggest advantage is that if we utilize that we get actual types in the DB and it becomes possible to inspect them as well as ensure that columns don't contain references to out of date values since when using a naive enum.Enum we get a varchar/int field that isn't validated.
- `make translations` for warehouse/locale/messages.pot - Update migration parent for 614a7fcb40ed_create_organization_models.py
- Remove `OrganizationEvents` class - Add `HasEvents` mixing to `Organization` - Update references {OrganizationEvents => Organization.Events} - Update database migration {organization_id => source_id}
`Organization.Event` with tag: - organization:create - organization:catalog_entry:add - organization:organization_role:invite - organization:organization_role:accepted `User.Event` with tag: - account:organization_role:accepted
If there is a validation error, return the existing invalid form instead of a new blank form so user can actually see that validation error.
- {created_by_id => created_by_user_id} - {submitted_by_id => submitted_by_user_id} Discussed with @ewdurbin. Using `*_user_id` seems more clear.
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'm really happy with where this is at.
If there are no objections, I plan to merge.
Note about PostgreSQL enums for future reference: SQLAlchemy supports PostgreSQL enums as @ewdurbin mentioned, but it looks like there have been issues with Alembic supporting PostgreSQL enums (sqlalchemy/alembic#278). |
* admin-new-organization-requested email template * new-orgnization-requested email template * Test admin-new-organization-requested email * Test new-organization-requested email * Translate *-organization-requested consistently * `make translations` for *-organization-requested * Remove translations from admin-* emails On second thought, we probably don't want localization for admin emails. * Initial cut at db model architecture * Ran code thru make reformat and lint (pypa#11070) * Added tests for new db models (pypa#11070) * Numerous tweaks to db models * Require value for is_active and ran reformat. * Regenerate migrations for Organization models docker-compose run web python -m warehouse db revision --autogenerate --message "Create Organization models" make reformat Forced to regenerate migrations due to recent database changes (pypi#11157). * Numerous tweaks to alembic scripts * Initial implementation of organization service. * Implementing organization events functionality. * Added tests for organization services. * Added OrganizationFactory class for model. * Blank /manage/organizations/ page * Create organization form on /manage/organizations/ - Organization account name - Organization name - Organization URL - Organization description - Organization type * Register DatabaseOrganizationService Found the droids that we're looking for. * POST /manage/organizations/ database updates * Add .get_admins method to user service * POST /manage/organizations/ email notifications * Blank /admin/organizations/approve/ page This is a placeholder so we can reference `admin.organization.approve` as a route in the admin-new-organization-requested email. * Test GET /manage/organizations/ - `ManageOrganizationsViews.default_response` - `ManageOrganizationsViews.manage_organizations()` * Translations for /manage/organizations/ make translations * Fixed OrganizationType enum. * Test POST /manage/organizations/ - `ManageOrganizationsViews.create_organization()` * Test CreateOrganizationForm * Placeholder to test /admin/organizations/approve/ Provides code coverage for the blank page added in 2c70616. * Test `DatabaseUserService.get_admins()` * NFC: Add comments about intentionally blank page * Record events for POST /manage/organizations/ Co-Authored-By: sterbo <matt.sterba@gmail.com> * Test record events for POST /manage/organizations/ * Functional test for POST /manage/organizations/ * Comment out `OrganizationFactory` for future use Co-Authored-By: sterbo <matt.sterba@gmail.com> * NFC: Fix camel case for class names * Converted OrganizationRoleType to SQLAlchemy Enum * Add disable-organizations global admin flag * Add `AdminFlagValue.DISABLE_ORGANIZATIONS` * Modified org name catalog to store normalized name * {OrganizationEvents => Organization.Events} - Remove `OrganizationEvents` class - Add `HasEvents` mixing to `Organization` - Update references {OrganizationEvents => Organization.Events} - Update database migration {organization_id => source_id} * Store id instead of username in new events `Organization.Event` with tag: - organization:create - organization:catalog_entry:add - organization:organization_role:invite - organization:organization_role:accepted `User.Event` with tag: - account:organization_role:accepted * Display CreateOrganizationForm errors If there is a validation error, return the existing invalid form instead of a new blank form so user can actually see that validation error. * Tweak naming in events data {*_id => *_user_id} - {created_by_id => created_by_user_id} - {submitted_by_id => submitted_by_user_id} Discussed with @ewdurbin. Using `*_user_id` seems more clear. Co-authored-by: sterbo <matt.sterba@gmail.com>
/manage/organizations/
page.Testing Setup
make serve
to run locally.make initdb
to initialize the database.disable-organizations
admin flag at http://localhost/admin/flags/.Testing Steps
Expected Behavior
warehouse.organizations
database table withis_active IS FALSE
andis_approved IS NULL
.