-
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.
wip Fix #1281 As a shop owner I can assign managers to plan(s)
- Loading branch information
1 parent
b27ffc0
commit a16a621
Showing
5 changed files
with
172 additions
and
1 deletion.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
migrations/versions/d80effffd83d_add_association_table_plan_to_users.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 @@ | ||
"""add association_table_plan_to_users | ||
Revision ID: d80effffd83d | ||
Revises: 48074e6225c6 | ||
Create Date: 2024-02-12 12:24:44.482877 | ||
Why? | ||
Some shop owners want/need to assign managers (users) to | ||
plans. For example large clubs or membership organisations which | ||
assign a 'manager' to one or more plans. | ||
The plan_user_associations table begins to make possible the | ||
assignment of Users to Plans. Recall that Users (see class User | ||
in models.py) is a shop owner (admin) which may login to the | ||
Subscribie application. | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "d80effffd83d" | ||
down_revision = "48074e6225c6" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
"plan_user_associations", | ||
sa.Column("plan_uuid", sa.String(), nullable=True), | ||
sa.Column("user_id", sa.String(), nullable=True), | ||
sa.ForeignKeyConstraint( | ||
["plan_uuid"], | ||
["plan.uuid"], | ||
), | ||
sa.ForeignKeyConstraint( | ||
["user_id"], | ||
["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
84 changes: 84 additions & 0 deletions
84
subscribie/blueprints/admin/templates/admin/assign_managers_to_plan.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,84 @@ | ||
{% extends "admin/layout.html" %} | ||
{% block title %} {{ title }} {% endblock %} | ||
|
||
{% block body %} | ||
|
||
<h2 class="text-center text-dark mb-3">Assign manager(s) to plans</h2> | ||
|
||
<div class="container"> | ||
<ul class="breadcrumb"> | ||
<li class="breadcrumb-item"><a href="/">Shop</a></li> | ||
<li class="breadcrumb-item"><a href="{{ url_for('admin.dashboard') }}">Manage My Shop</a></li> | ||
<li class="breadcrumb-item"><a href="{{ url_for('admin.list_choice_groups') }}">Choice Groups</a></li> | ||
<li class="breadcrumb-item active" aria-current="page"> Add / Edit / Delete Choice Group</li> | ||
</ul> | ||
</div> | ||
|
||
<main> | ||
<div class="section"> | ||
<div class="container"> | ||
<h3>Allow managers to quickly see plans they're responsible for</h3> | ||
<div class="col-md-7"> | ||
<p>Some larger organisations like to assign people to 'manage' Subscribers who are subscribed to specific plans.<br /> | ||
For example, if you're a sports club or large membership organisation you can assign specific staff to | ||
become 'managers' of specific plans. This helps them see only the Subscribers they are responsible for.</p> | ||
|
||
<p> | ||
Once you do so, when they login to their account, the visibility of the Subscribers they see | ||
will be highlighted, and by default any Subscribers they are <em>not</em> a manager of given less Precedence, based | ||
on the Plans they are assigned to as a manager.</p> | ||
<br /> | ||
<p> | ||
Please note this is <em>not</em> a security feature- it does <em>not</em> stop managers being able to access | ||
all plans, it simply makes it easier for a manager of specific plans to quickly see the Subscribers | ||
who are subscribed to the plans they manage. | ||
</p> | ||
|
||
<p>Select a user to assign plan(s) to them.</p> | ||
|
||
</div> | ||
|
||
{% if confirm is sameas false %} | ||
<div class="card mx-auto my-3 py-3 col-md-7"> | ||
<h3 class="card-title mx-auto">Are you sure?</h3> | ||
<div class="mx-auto"> | ||
<a href="{{ url_for('admin.delete_choice_group', id=choice_group.id) }}" | ||
class="btn btn-danger mx-3 px-5" role="button"> | ||
Yes | ||
</a> | ||
<a href="{{ url_for('admin.list_choice_groups', cancel=1) }}" | ||
class="btn btn-success mx-3 px-5" role="button"> | ||
No | ||
</a> | ||
</div> | ||
</div> | ||
{% else %} | ||
<table class="table table-hover table-scroll"> | ||
<thead> | ||
<th>Title</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</thead> | ||
{% for user in users %} | ||
<tr> | ||
<td> | ||
{{ user.email}} | ||
</td> | ||
<td> | ||
<a href="{# url_for('admin.choice_group_assign_plan', choice_group_id=choice_group.id) #}" | ||
class="btn btn-success btn-block" style="display: inline-block" role="button"> | ||
Assign Plan(s) | ||
</a> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
{% endif %} | ||
|
||
</div><!--end container--> | ||
</div><!--end section--> | ||
</main> | ||
|
||
{% endblock body %} |
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