-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP #1281 As shop owner I can assign users to plans
- Loading branch information
1 parent
cbe30c1
commit 73b2169
Showing
8 changed files
with
248 additions
and
75 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
migrations/versions/ac23e0d75b27_primary_keys_association_table_plan_to_.py
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,47 @@ | ||
"""primary keys association_table_plan_to_users | ||
Revision ID: ac23e0d75b27 | ||
Revises: ba57f5aeba5f | ||
Create Date: 2024-02-24 16:15:56.898449 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy import MetaData, Table, Column, Integer, String | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "ac23e0d75b27" | ||
down_revision = "ba57f5aeba5f" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
meta = MetaData() | ||
some_table = Table( | ||
"plan_user_associations", | ||
meta, | ||
Column("plan_uuid", String, nullable=False), | ||
Column("user_id", Integer, nullable=False), | ||
sa.ForeignKeyConstraint( | ||
["plan_uuid"], | ||
["plan.uuid"], | ||
), | ||
sa.ForeignKeyConstraint( | ||
["user_id"], | ||
["user.id"], | ||
), | ||
sa.PrimaryKeyConstraint("plan_uuid", "user_id"), | ||
) | ||
|
||
with op.batch_alter_table( | ||
"plan_user_associations", copy_from=some_table | ||
) as batch_op: | ||
batch_op.create_primary_key( | ||
"pk_plan_user_association", ["plan_uuid", "user_id"] | ||
) | ||
|
||
|
||
def downgrade(): | ||
pass |
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 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
19 changes: 19 additions & 0 deletions
19
subscribie/blueprints/admin/templates/macros/plan_assign_managers_form.html
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,19 @@ | ||
{% macro plan_assign_managers_form(plan, users) -%} | ||
|
||
<form action="{{ url_for("admin.assign_manager_to_plan") }}" method="POST"> | ||
{% for user in users %} | ||
<div class="form-check"> | ||
<input type="checkbox" class="form-check-input" name="user_id" id="{{ user.id }}" value="{{ user.id }}" | ||
{% if user in plan.users %} | ||
checked | ||
{% endif %} /> | ||
<label for="{{ user.id }}" class="form-check-label">{{ user.email }}</label> | ||
</div> | ||
{% endfor %} | ||
<input type="hidden" name="plan_uuid" value="{{ plan.uuid }}" /> | ||
<div class="form-group row mt-4"> | ||
<input type="submit" value="Update" class="btn btn-primary" /> | ||
</div> | ||
</form> | ||
|
||
{%- endmacro %} |
Oops, something went wrong.