generated from hackforla/.github-hackforla-base-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/npm_and_yarn/app/express-4.19.2
- Loading branch information
Showing
135 changed files
with
11,617 additions
and
39,909 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
name: Post an open role | ||
about: Recruit volunteers for specific open roles template | ||
title: 'HUU: Open Role for: [Replace with NAME OF ROLE]' | ||
labels: 'Complexity: Small, feature: recruitment, role: missing' | ||
assignees: '' | ||
|
||
--- | ||
|
||
<img src="https://user-images.githubusercontent.com/26660349/114799694-38cb3a80-9d66-11eb-8b08-78bdc1b653b3.png" /> | ||
|
||
[INSERT DRAFT FROM THE Recruit volunteers for team open roles issue] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
"""Add user types | ||
Revision ID: e4c8bb426528 | ||
Revises: ec8b1c17739a | ||
Create Date: 2024-03-10 21:47:13.942845 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy import text | ||
from openapi_server.models.user_roles import UserRole | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'e4c8bb426528' | ||
down_revision = 'ec8b1c17739a' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
def upgrade() -> None: | ||
''' | ||
1. Add one table: | ||
1. role - Store available application user roles | ||
2. Prepopulate the role table with four role types: Admin, Host, Guest, Coordinator | ||
3. Update the user table to add the first, middle, last name, and role_id columns. | ||
* All existing users will be given the first, last name "UNKNOWN" | ||
* Assign all existing users to the Guest role. | ||
4. Drop the host table. | ||
* There is no way to map host users back to the user table. We would need a user id foreign | ||
key, or at least an email address. | ||
''' | ||
role_table = op.create_table('role', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('name', sa.String(), nullable=False), | ||
sa.PrimaryKeyConstraint('id'), | ||
sa.UniqueConstraint('name') | ||
) | ||
op.bulk_insert(role_table, | ||
[{'name': UserRole.ADMIN.value}, | ||
{'name': UserRole.HOST.value}, | ||
{'name': UserRole.GUEST.value}, | ||
{'name': UserRole.COORDINATOR.value}]) | ||
op.create_index(op.f('ix_role_id'), 'role', ['id']) | ||
|
||
conn = op.get_bind() | ||
guest_role_id = conn.execute(text("SELECT id FROM role WHERE name = 'Guest'")).fetchone()[0] | ||
|
||
with op.batch_alter_table('user', schema=None) as batch_op: | ||
# Each existing user will get the first and last names "Unknown" by default | ||
# and they will be assigned to the "Guest" user role. | ||
batch_op.add_column(sa.Column('firstName', sa.String(length=255), nullable=False, server_default='Unknown')) | ||
batch_op.add_column(sa.Column('middleName', sa.String(length=255), nullable=True)) | ||
batch_op.add_column(sa.Column('lastName', sa.String(length=255), nullable=True)) | ||
batch_op.add_column(sa.Column('role_id', sa.Integer, nullable=False, server_default=str(guest_role_id))) | ||
batch_op.create_foreign_key('fk_user_role_id', 'role', ['role_id'], ['id']) | ||
|
||
op.drop_table('host') | ||
|
||
def downgrade() -> None: | ||
with op.batch_alter_table('user', schema=None) as batch_op: | ||
batch_op.drop_constraint('fk_user_role_id', type_='foreignkey') | ||
batch_op.drop_column('lastName') | ||
batch_op.drop_column('middleName') | ||
batch_op.drop_column('firstName') | ||
|
||
op.drop_index(op.f('ix_role_id'), table_name='role') | ||
op.drop_table('role') | ||
op.create_table('host', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('name', sa.String(), nullable=False), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
op.create_index(op.f('ix_host_id'), 'host', ['id']) |
Oops, something went wrong.