black
This commit is contained in:
parent
28223d12b6
commit
b33d30fe40
|
@ -11,82 +11,95 @@ import flaschengeist
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = 'e70508bd8cb4'
|
revision = "e70508bd8cb4"
|
||||||
down_revision = None
|
down_revision = None
|
||||||
branch_labels = ('events',)
|
branch_labels = ("events",)
|
||||||
depends_on = "flaschengeist"
|
depends_on = "flaschengeist"
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
op.create_table('events_event_type',
|
op.create_table(
|
||||||
sa.Column('id', flaschengeist.database.types.Serial(), nullable=False),
|
"events_event_type",
|
||||||
sa.Column('name', sa.String(length=30), nullable=False),
|
sa.Column("id", flaschengeist.database.types.Serial(), nullable=False),
|
||||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_events_event_type')),
|
sa.Column("name", sa.String(length=30), nullable=False),
|
||||||
sa.UniqueConstraint('name', name=op.f('uq_events_event_type_name'))
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_events_event_type")),
|
||||||
|
sa.UniqueConstraint("name", name=op.f("uq_events_event_type_name")),
|
||||||
)
|
)
|
||||||
op.create_table('events_job_type',
|
op.create_table(
|
||||||
sa.Column('id', flaschengeist.database.types.Serial(), nullable=False),
|
"events_job_type",
|
||||||
sa.Column('name', sa.String(length=30), nullable=False),
|
sa.Column("id", flaschengeist.database.types.Serial(), nullable=False),
|
||||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_events_job_type')),
|
sa.Column("name", sa.String(length=30), nullable=False),
|
||||||
sa.UniqueConstraint('name', name=op.f('uq_events_job_type_name'))
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_events_job_type")),
|
||||||
|
sa.UniqueConstraint("name", name=op.f("uq_events_job_type_name")),
|
||||||
)
|
)
|
||||||
op.create_table('events_event',
|
op.create_table(
|
||||||
sa.Column('id', flaschengeist.database.types.Serial(), nullable=False),
|
"events_event",
|
||||||
sa.Column('start', flaschengeist.database.types.UtcDateTime(), nullable=False),
|
sa.Column("id", flaschengeist.database.types.Serial(), nullable=False),
|
||||||
sa.Column('end', flaschengeist.database.types.UtcDateTime(), nullable=True),
|
sa.Column("start", flaschengeist.database.types.UtcDateTime(), nullable=False),
|
||||||
sa.Column('name', sa.String(length=255), nullable=True),
|
sa.Column("end", flaschengeist.database.types.UtcDateTime(), nullable=True),
|
||||||
sa.Column('description', sa.String(length=512), nullable=True),
|
sa.Column("name", sa.String(length=255), nullable=True),
|
||||||
sa.Column('is_template', sa.Boolean(), nullable=True),
|
sa.Column("description", sa.String(length=512), nullable=True),
|
||||||
sa.Column('type_id', flaschengeist.database.types.Serial(), nullable=False),
|
sa.Column("is_template", sa.Boolean(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['type_id'], ['events_event_type.id'], name=op.f('fk_events_event_type_id_events_event_type'), ondelete='CASCADE'),
|
sa.Column("type_id", flaschengeist.database.types.Serial(), nullable=False),
|
||||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_events_event'))
|
sa.ForeignKeyConstraint(
|
||||||
|
["type_id"],
|
||||||
|
["events_event_type.id"],
|
||||||
|
name=op.f("fk_events_event_type_id_events_event_type"),
|
||||||
|
ondelete="CASCADE",
|
||||||
|
),
|
||||||
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_events_event")),
|
||||||
)
|
)
|
||||||
op.create_table('events_job',
|
op.create_table(
|
||||||
sa.Column('id', flaschengeist.database.types.Serial(), nullable=False),
|
"events_job",
|
||||||
sa.Column('start', flaschengeist.database.types.UtcDateTime(), nullable=False),
|
sa.Column("id", flaschengeist.database.types.Serial(), nullable=False),
|
||||||
sa.Column('end', flaschengeist.database.types.UtcDateTime(), nullable=True),
|
sa.Column("start", flaschengeist.database.types.UtcDateTime(), nullable=False),
|
||||||
sa.Column('comment', sa.String(length=256), nullable=True),
|
sa.Column("end", flaschengeist.database.types.UtcDateTime(), nullable=True),
|
||||||
sa.Column('type_id', flaschengeist.database.types.Serial(), nullable=False),
|
sa.Column("comment", sa.String(length=256), nullable=True),
|
||||||
sa.Column('locked', sa.Boolean(), nullable=False),
|
sa.Column("type_id", flaschengeist.database.types.Serial(), nullable=False),
|
||||||
sa.Column('required_services', sa.Numeric(precision=4, scale=2, asdecimal=False), nullable=False),
|
sa.Column("locked", sa.Boolean(), nullable=False),
|
||||||
sa.Column('event_id', flaschengeist.database.types.Serial(), nullable=False),
|
sa.Column("required_services", sa.Numeric(precision=4, scale=2, asdecimal=False), nullable=False),
|
||||||
sa.ForeignKeyConstraint(['event_id'], ['events_event.id'], name=op.f('fk_events_job_event_id_events_event')),
|
sa.Column("event_id", flaschengeist.database.types.Serial(), nullable=False),
|
||||||
sa.ForeignKeyConstraint(['type_id'], ['events_job_type.id'], name=op.f('fk_events_job_type_id_events_job_type')),
|
sa.ForeignKeyConstraint(["event_id"], ["events_event.id"], name=op.f("fk_events_job_event_id_events_event")),
|
||||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_events_job')),
|
sa.ForeignKeyConstraint(
|
||||||
sa.UniqueConstraint('type_id', 'start', 'event_id', name='_type_start_uc')
|
["type_id"], ["events_job_type.id"], name=op.f("fk_events_job_type_id_events_job_type")
|
||||||
|
),
|
||||||
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_events_job")),
|
||||||
|
sa.UniqueConstraint("type_id", "start", "event_id", name="_type_start_uc"),
|
||||||
)
|
)
|
||||||
op.create_table('events_invitation',
|
op.create_table(
|
||||||
sa.Column('id', flaschengeist.database.types.Serial(), nullable=False),
|
"events_invitation",
|
||||||
sa.Column('time', flaschengeist.database.types.UtcDateTime(), nullable=False),
|
sa.Column("id", flaschengeist.database.types.Serial(), nullable=False),
|
||||||
sa.Column('job_id', flaschengeist.database.types.Serial(), nullable=False),
|
sa.Column("time", flaschengeist.database.types.UtcDateTime(), nullable=False),
|
||||||
sa.Column('invitee_id', flaschengeist.database.types.Serial(), nullable=False),
|
sa.Column("job_id", flaschengeist.database.types.Serial(), nullable=False),
|
||||||
sa.Column('inviter_id', flaschengeist.database.types.Serial(), nullable=False),
|
sa.Column("invitee_id", flaschengeist.database.types.Serial(), nullable=False),
|
||||||
sa.Column('transferee_id', flaschengeist.database.types.Serial(), nullable=True),
|
sa.Column("inviter_id", flaschengeist.database.types.Serial(), nullable=False),
|
||||||
sa.ForeignKeyConstraint(['invitee_id'], ['user.id'], name=op.f('fk_events_invitation_invitee_id_user')),
|
sa.Column("transferee_id", flaschengeist.database.types.Serial(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['inviter_id'], ['user.id'], name=op.f('fk_events_invitation_inviter_id_user')),
|
sa.ForeignKeyConstraint(["invitee_id"], ["user.id"], name=op.f("fk_events_invitation_invitee_id_user")),
|
||||||
sa.ForeignKeyConstraint(['job_id'], ['events_job.id'], name=op.f('fk_events_invitation_job_id_events_job')),
|
sa.ForeignKeyConstraint(["inviter_id"], ["user.id"], name=op.f("fk_events_invitation_inviter_id_user")),
|
||||||
sa.ForeignKeyConstraint(['transferee_id'], ['user.id'], name=op.f('fk_events_invitation_transferee_id_user')),
|
sa.ForeignKeyConstraint(["job_id"], ["events_job.id"], name=op.f("fk_events_invitation_job_id_events_job")),
|
||||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_events_invitation'))
|
sa.ForeignKeyConstraint(["transferee_id"], ["user.id"], name=op.f("fk_events_invitation_transferee_id_user")),
|
||||||
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_events_invitation")),
|
||||||
)
|
)
|
||||||
op.create_table('events_service',
|
op.create_table(
|
||||||
sa.Column('is_backup', sa.Boolean(), nullable=True),
|
"events_service",
|
||||||
sa.Column('value', sa.Numeric(precision=3, scale=2, asdecimal=False), nullable=False),
|
sa.Column("is_backup", sa.Boolean(), nullable=True),
|
||||||
sa.Column('job_id', flaschengeist.database.types.Serial(), nullable=False),
|
sa.Column("value", sa.Numeric(precision=3, scale=2, asdecimal=False), nullable=False),
|
||||||
sa.Column('user_id', flaschengeist.database.types.Serial(), nullable=False),
|
sa.Column("job_id", flaschengeist.database.types.Serial(), nullable=False),
|
||||||
sa.ForeignKeyConstraint(['job_id'], ['events_job.id'], name=op.f('fk_events_service_job_id_events_job')),
|
sa.Column("user_id", flaschengeist.database.types.Serial(), nullable=False),
|
||||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_events_service_user_id_user')),
|
sa.ForeignKeyConstraint(["job_id"], ["events_job.id"], name=op.f("fk_events_service_job_id_events_job")),
|
||||||
sa.PrimaryKeyConstraint('job_id', 'user_id', name=op.f('pk_events_service'))
|
sa.ForeignKeyConstraint(["user_id"], ["user.id"], name=op.f("fk_events_service_user_id_user")),
|
||||||
|
sa.PrimaryKeyConstraint("job_id", "user_id", name=op.f("pk_events_service")),
|
||||||
)
|
)
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
op.drop_table('events_service')
|
op.drop_table("events_service")
|
||||||
op.drop_table('events_invitation')
|
op.drop_table("events_invitation")
|
||||||
op.drop_table('events_job')
|
op.drop_table("events_job")
|
||||||
op.drop_table('events_event')
|
op.drop_table("events_event")
|
||||||
op.drop_table('events_job_type')
|
op.drop_table("events_job_type")
|
||||||
op.drop_table('events_event_type')
|
op.drop_table("events_event_type")
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
|
@ -26,7 +26,7 @@ def dict_get(self, key, default=None, type=None):
|
||||||
rv = type(rv)
|
rv = type(rv)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
rv = default
|
rv = default
|
||||||
|
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
|
|
||||||
|
@ -458,7 +458,9 @@ def assign_job(job_id, current_session: Session):
|
||||||
):
|
):
|
||||||
raise Forbidden
|
raise Forbidden
|
||||||
if value > 0:
|
if value > 0:
|
||||||
event_controller.assign_job(job, user, value, data.get("is_backup", False))
|
event_controller.assign_job(
|
||||||
|
job, user, value, data.get("is_backup", False), notify=user != current_session.user_
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
event_controller.unassign_job(job, user, notify=user != current_session.user_)
|
event_controller.unassign_job(job, user, notify=user != current_session.user_)
|
||||||
except (TypeError, KeyError, ValueError):
|
except (TypeError, KeyError, ValueError):
|
||||||
|
|
Loading…
Reference in New Issue