Wire up selector for updating a workspace user's role
This commit is contained in:
16
atst/forms/update_member.py
Normal file
16
atst/forms/update_member.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from flask_wtf import Form
|
||||||
|
from wtforms.fields import StringField
|
||||||
|
from wtforms.fields.html5 import EmailField
|
||||||
|
from wtforms.validators import Required, Email, Length
|
||||||
|
|
||||||
|
from atst.forms.validators import IsNumber
|
||||||
|
from atst.forms.fields import SelectField
|
||||||
|
|
||||||
|
from .data import WORKSPACE_ROLES
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateMemberForm(Form):
|
||||||
|
|
||||||
|
workspace_role = SelectField(
|
||||||
|
"Workspace Role", choices=WORKSPACE_ROLES, validators=[Required()], default=""
|
||||||
|
)
|
@@ -5,6 +5,7 @@ from atst.models import Base
|
|||||||
from atst.models.types import Id
|
from atst.models.types import Id
|
||||||
from atst.models.mixins import TimestampsMixin
|
from atst.models.mixins import TimestampsMixin
|
||||||
from atst.utils import first_or_none
|
from atst.utils import first_or_none
|
||||||
|
from atst.models.workspace_user import WorkspaceUser
|
||||||
|
|
||||||
|
|
||||||
MOCK_MEMBERS = [
|
MOCK_MEMBERS = [
|
||||||
@@ -68,4 +69,4 @@ class Workspace(Base, TimestampsMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def members(self):
|
def members(self):
|
||||||
return MOCK_MEMBERS
|
return [ WorkspaceUser(role.user, role) for role in self.roles]
|
||||||
|
@@ -16,3 +16,20 @@ class WorkspaceUser(object):
|
|||||||
|
|
||||||
def workspace_id(self):
|
def workspace_id(self):
|
||||||
return self.workspace_role.workspace_id
|
return self.workspace_role.workspace_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def user_id(self):
|
||||||
|
return self.user.id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def user_name(self):
|
||||||
|
return self.user.full_name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def role(self):
|
||||||
|
return self.workspace_role.role.name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def status(self):
|
||||||
|
return "radical"
|
||||||
|
|
||||||
|
@@ -9,9 +9,12 @@ from flask import (
|
|||||||
|
|
||||||
from atst.domain.exceptions import UnauthorizedError
|
from atst.domain.exceptions import UnauthorizedError
|
||||||
from atst.domain.workspaces import Workspaces
|
from atst.domain.workspaces import Workspaces
|
||||||
|
from atst.domain.workspace_users import WorkspaceUsers
|
||||||
from atst.domain.projects import Projects
|
from atst.domain.projects import Projects
|
||||||
from atst.forms.new_project import NewProjectForm
|
from atst.forms.new_project import NewProjectForm
|
||||||
from atst.forms.new_member import NewMemberForm
|
from atst.forms.new_member import NewMemberForm
|
||||||
|
from atst.forms.update_member import UpdateMemberForm
|
||||||
|
from atst.forms.forms import ValidatedForm
|
||||||
from atst.domain.authz import Authorization
|
from atst.domain.authz import Authorization
|
||||||
from atst.models.permissions import Permissions
|
from atst.models.permissions import Permissions
|
||||||
|
|
||||||
@@ -119,3 +122,29 @@ def create_member(workspace_id):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return render_template("member_new.html", workspace=workspace, form=form)
|
return render_template("member_new.html", workspace=workspace, form=form)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/workspaces/<workspace_id>/members/<member_id>/member_edit")
|
||||||
|
def view_member(workspace_id, member_id):
|
||||||
|
workspace = Workspaces.get(g.current_user, workspace_id)
|
||||||
|
member = WorkspaceUsers.get(workspace_id, member_id)
|
||||||
|
form = NewMemberForm(http_request.form)
|
||||||
|
|
||||||
|
return render_template("member_edit.html", form=form, workspace=workspace, member=member)
|
||||||
|
|
||||||
|
@bp.route("/workspaces/<workspace_id>/members/<member_id>/member_edit", methods=['POST'])
|
||||||
|
def update_member(workspace_id, member_id):
|
||||||
|
workspace = Workspaces.get(g.current_user, workspace_id)
|
||||||
|
member = WorkspaceUsers.get(workspace_id, member_id)
|
||||||
|
form = UpdateMemberForm(http_request.form)
|
||||||
|
|
||||||
|
if form.validate():
|
||||||
|
return redirect(
|
||||||
|
url_for(
|
||||||
|
"workspaces.workspace_members",
|
||||||
|
workspace_id=workspace.id,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return render_template("member_edit.html", form=form, workspace=workspace, member=member)
|
||||||
|
|
||||||
|
@@ -2,48 +2,44 @@
|
|||||||
|
|
||||||
{% from "components/icon.html" import Icon %}
|
{% from "components/icon.html" import Icon %}
|
||||||
{% from "components/modal.html" import Modal %}
|
{% from "components/modal.html" import Modal %}
|
||||||
|
{% from "components/selector.html" import Selector %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div class='panel member-card'>
|
<form method="POST" action="{{ url_for('workspaces.update_member', workspace_id=workspace.id, member_id=member.user_id) }}" autocomplete="false">
|
||||||
<div class='member-card__header'>
|
{{ form.csrf_token }}
|
||||||
<h1 class='member-card__heading'>Danny Knight</h1>
|
|
||||||
|
<div class='panel member-card'>
|
||||||
|
<div class='member-card__header'>
|
||||||
|
<h1 class='member-card__heading'>Danny Knight</h1>
|
||||||
|
|
||||||
|
<div class="usa-input member-card__input">
|
||||||
|
<label for="filter-status">Workspace Role</label>
|
||||||
|
{{ Selector(form.workspace_role) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="usa-input member-card__input">
|
|
||||||
<label for="filter-status">Workspace Role</label>
|
|
||||||
<select id="filter-status" name="filter-status">
|
|
||||||
<option value="Admin">Admin</option>
|
|
||||||
<option value="Billing Auditor" selected="selected">Billing Auditor</option>
|
|
||||||
<option value="CCPO">CCPO</option>
|
|
||||||
<option value="Developer">Developer</option>
|
|
||||||
<option value="Owner">Owner</option>
|
|
||||||
<option value="Security Auditor">Security Auditor</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class='member-card__details'>
|
||||||
|
<dl>
|
||||||
|
<div>
|
||||||
|
<dt>DOD ID:</dt>
|
||||||
|
<dd>789</dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt>Email:</dt>
|
||||||
|
<dd>knight@mil.gov</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
<a href='#' class='icon-link'>edit account details</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class='member-card__details'>
|
|
||||||
<dl>
|
|
||||||
<div>
|
|
||||||
<dt>DOD ID:</dt>
|
|
||||||
<dd>789</dd>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<dt>Email:</dt>
|
|
||||||
<dd>knight@mil.gov</dd>
|
|
||||||
</div>
|
|
||||||
</dl>
|
|
||||||
<a href='#' class='icon-link'>edit account details</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div class="panel__heading panel__heading--tight">
|
<div class="panel__heading panel__heading--tight">
|
||||||
<h2 class="h3">Manage Access <div class="subtitle">Grant access to an environment</div></h2>
|
<h2 class="h3">Manage Access <div class="subtitle">Grant access to an environment</div></h2>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<form class='search-bar'>
|
|
||||||
<div class='usa-input search-input'>
|
<div class='usa-input search-input'>
|
||||||
<label for='project-search'>Search by project name</label>
|
<label for='project-search'>Search by project name</label>
|
||||||
<input type='search' id='project-search' name='project-search' placeholder="Search by project name"/>
|
<input type='search' id='project-search' name='project-search' placeholder="Search by project name"/>
|
||||||
@@ -51,174 +47,96 @@
|
|||||||
<span class="hide">Search</span>
|
<span class="hide">Search</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
|
||||||
|
|
||||||
{% call Modal(name='rolesModal', dismissable=False) %}
|
<div is='toggler' default-visible class='block-list project-list-item'>
|
||||||
<div class="block-list">
|
<template slot-scope='{ isVisible, toggle }'>
|
||||||
<header class="block-list__header">
|
<header class='block-list__header'>
|
||||||
<h2 class="block-list__title">
|
<button v-on:click='toggle' class='icon-link icon-link--large icon-link--default spend-table__project__toggler'>
|
||||||
Environment access for Danny Knight
|
<template v-if='isVisible'>{{ Icon('caret_down') }}</template>
|
||||||
<div class='subtitle'>Project Name - Environment Name</div>
|
<template v-else>{{ Icon('caret_right') }}</template>
|
||||||
</h2>
|
<h3 class="block-list__title">Code.mil</h3>
|
||||||
</header>
|
</button>
|
||||||
|
<span><a href="#" class="icon-link icon-link--danger">revoke all access</a></span>
|
||||||
<form method="post" action="">
|
</header>
|
||||||
<ul>
|
<ul v-show='isVisible'>
|
||||||
<li class='block-list__item block-list__item--selectable'>
|
<li class='block-list__item project-list-item__environment'>
|
||||||
<input type='radio' name='radio' id='radio-1' />
|
<span class='project-list-item__environment'>
|
||||||
<label for='radio-1'>
|
Development
|
||||||
<dl>
|
</span>
|
||||||
<dt>CCPO</dt>
|
<div class='project-list-item__environment__actions'>
|
||||||
<dd>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat dicta voluptate vitae quasi, cumque rem dolores, quae quas cum in recusandae? Libero deleniti minus ab accusantium vel necessitatibus placeat, rerum?</dd>
|
<span class="label">no access </span><button v-on:click="openModal('rolesModal')" type="button" class="icon-link">set role</button>
|
||||||
</dl>
|
</div>
|
||||||
</label>
|
|
||||||
</li>
|
</li>
|
||||||
<li class='block-list__item block-list__item--selectable'>
|
<li class='block-list__item project-list-item__environment'>
|
||||||
<input type='radio' name='radio' id='radio-2' />
|
<span class='project-list-item__environment'>
|
||||||
<label for='radio-2'>
|
Sandbox
|
||||||
<dl>
|
</span>
|
||||||
<dt>Security</dt>
|
<div class='project-list-item__environment__actions'>
|
||||||
<dd>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quaerat vel ea, eaque, odio sint explicabo officia, debitis dolore, et repudiandae possimus deserunt eveniet laborum. Sunt blanditiis deleniti minus. Et, mollitia.</dd>
|
<span class="label">no access</span><button v-on:click="openModal('rolesModal')" type="button" class="icon-link">set role</button>
|
||||||
</dl>
|
</div>
|
||||||
</label>
|
|
||||||
</li>
|
</li>
|
||||||
<li class='block-list__item block-list__item--selectable'>
|
<li class='block-list__item project-list-item__environment'>
|
||||||
<input type='radio' name='radio' id='radio-3' />
|
<span class='project-list-item__environment'>
|
||||||
<label for='radio-3'>
|
Production
|
||||||
<dl>
|
</span>
|
||||||
<dt>Audit</dt>
|
<div class='project-list-item__environment__actions'>
|
||||||
<dd>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Autem itaque reprehenderit dolorum nobis voluptatibus quae, facilis voluptatum necessitatibus alias laboriosam, esse blanditiis culpa possimus tempore consectetur recusandae. Nihil, vel, dolorem!</dd>
|
<span class="label label--success">Billing</span><button v-on:click="openModal('rolesModal')" type="button" class="icon-link">set role</button>
|
||||||
</dl>
|
</div>
|
||||||
</label>
|
|
||||||
</li>
|
|
||||||
<li class='block-list__item block-list__item--selectable'>
|
|
||||||
<input type='radio' name='radio' id='radio-4' />
|
|
||||||
<label for='radio-4'>
|
|
||||||
<dl>
|
|
||||||
<dt>Application Developer</dt>
|
|
||||||
<dd>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea esse ab consequuntur aliquam. Porro ea mollitia sapiente blanditiis quaerat quam beatae vitae adipisci quisquam dolore reiciendis tenetur, eius nemo quibusdam!</dd>
|
|
||||||
</dl>
|
|
||||||
</label>
|
|
||||||
</li>
|
|
||||||
<li class='block-list__item block-list__item--selectable'>
|
|
||||||
<input type='radio' name='radio' id='radio-5' />
|
|
||||||
<label for='radio-5'>
|
|
||||||
<dl>
|
|
||||||
<dt>Dev Ops</dt>
|
|
||||||
<dd>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore incidunt obcaecati, quidem ullam sint iusto. Natus ex distinctio eveniet cumque laudantium veritatis nemo asperiores, esse hic quis perspiciatis, quia impedit.</dd>
|
|
||||||
</dl>
|
|
||||||
</label>
|
|
||||||
</li>
|
|
||||||
<li class='block-list__item block-list__item--selectable'>
|
|
||||||
<input type='radio' name='radio' id='radio-6' />
|
|
||||||
<label for='radio-6'>
|
|
||||||
<dl>
|
|
||||||
<dt>Billing</dt>
|
|
||||||
<dd>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quidem delectus at, voluptatibus dolores, nobis temporibus. Ipsum dignissimos corrupti qui nisi et alias totam commodi maiores hic possimus ipsam error, ullam.</dd>
|
|
||||||
</dl>
|
|
||||||
</label>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
</template>
|
||||||
<div class='block-list__footer'>
|
|
||||||
<div class='action-group'>
|
|
||||||
<a v-on:click="closeModal('rolesModal')" class='action-group__action usa-button'>Select Access Role</a>
|
|
||||||
<a class='action-group__action icon-link icon-link--danger' v-on:click="closeModal('rolesModal')">No Access</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endcall %}
|
<div is="toggler" class='block-list project-list-item'>
|
||||||
|
<template slot-scope='{ isVisible, toggle }'>
|
||||||
|
<header class='block-list__header'>
|
||||||
|
<button v-on:click='toggle' class='icon-link icon-link--large icon-link--default spend-table__project__toggler'>
|
||||||
|
<template v-if='isVisible'>{{ Icon('caret_down') }}</template>
|
||||||
|
<template v-else>{{ Icon('caret_right') }}</template>
|
||||||
|
<h3 class="block-list__title">Digital Dojo</h3>
|
||||||
|
</button>
|
||||||
|
<span class="label">no access</span>
|
||||||
|
</header>
|
||||||
|
<ul v-show='isVisible'>
|
||||||
|
<li class='block-list__item project-list-item__environment'>
|
||||||
|
<span class='project-list-item__environment'>
|
||||||
|
Development
|
||||||
|
</span>
|
||||||
|
<div class='project-list-item__environment__actions'>
|
||||||
|
<span class="label">no access </span><button v-on:click="openModal('rolesModal')" type="button" class="icon-link">set role</button>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class='block-list__item project-list-item__environment'>
|
||||||
|
<span class='project-list-item__environment'>
|
||||||
|
Sandbox
|
||||||
|
</span>
|
||||||
|
<div class='project-list-item__environment__actions'>
|
||||||
|
<span class="label">no access</span><button v-on:click="openModal('rolesModal')" type="button" class="icon-link">set role</button>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class='block-list__item project-list-item__environment'>
|
||||||
|
<span class='project-list-item__environment'>
|
||||||
|
Production
|
||||||
|
</span>
|
||||||
|
<div class='project-list-item__environment__actions'>
|
||||||
|
<span class="label">no access</span><button v-on:click="openModal('rolesModal')" type="button" class="icon-link">set role</button>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div is='toggler' default-visible class='block-list project-list-item'>
|
<div class='action-group'>
|
||||||
<template slot-scope='{ isVisible, toggle }'>
|
<button class='action-group__action usa-button usa-button-big'>
|
||||||
<header class='block-list__header'>
|
{% if is_new_member %}Create{% else %}Save{% endif %}
|
||||||
<button v-on:click='toggle' class='icon-link icon-link--large icon-link--default spend-table__project__toggler'>
|
</button>
|
||||||
<template v-if='isVisible'>{{ Icon('caret_down') }}</template>
|
<a href='#' class='action-group__action icon-link'>
|
||||||
<template v-else>{{ Icon('caret_right') }}</template>
|
{{ Icon('x') }}
|
||||||
<h3 class="block-list__title">Code.mil</h3>
|
<span>Cancel</span>
|
||||||
</button>
|
</a>
|
||||||
<span><a href="#" class="icon-link icon-link--danger">revoke all access</a></span>
|
</div>
|
||||||
</header>
|
|
||||||
<ul v-show='isVisible'>
|
|
||||||
<li class='block-list__item project-list-item__environment'>
|
|
||||||
<span class='project-list-item__environment'>
|
|
||||||
Development
|
|
||||||
</span>
|
|
||||||
<div class='project-list-item__environment__actions'>
|
|
||||||
<span class="label">no access </span><button v-on:click="openModal('rolesModal')" type="button" class="icon-link">set role</button>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<li class='block-list__item project-list-item__environment'>
|
|
||||||
<span class='project-list-item__environment'>
|
|
||||||
Sandbox
|
|
||||||
</span>
|
|
||||||
<div class='project-list-item__environment__actions'>
|
|
||||||
<span class="label">no access</span><button v-on:click="openModal('rolesModal')" type="button" class="icon-link">set role</button>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<li class='block-list__item project-list-item__environment'>
|
|
||||||
<span class='project-list-item__environment'>
|
|
||||||
Production
|
|
||||||
</span>
|
|
||||||
<div class='project-list-item__environment__actions'>
|
|
||||||
<span class="label label--success">Billing</span><button v-on:click="openModal('rolesModal')" type="button" class="icon-link">set role</button>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div is="toggler" class='block-list project-list-item'>
|
</form>
|
||||||
<template slot-scope='{ isVisible, toggle }'>
|
|
||||||
<header class='block-list__header'>
|
|
||||||
<button v-on:click='toggle' class='icon-link icon-link--large icon-link--default spend-table__project__toggler'>
|
|
||||||
<template v-if='isVisible'>{{ Icon('caret_down') }}</template>
|
|
||||||
<template v-else>{{ Icon('caret_right') }}</template>
|
|
||||||
<h3 class="block-list__title">Digital Dojo</h3>
|
|
||||||
</button>
|
|
||||||
<span class="label">no access</span>
|
|
||||||
</header>
|
|
||||||
<ul v-show='isVisible'>
|
|
||||||
<li class='block-list__item project-list-item__environment'>
|
|
||||||
<span class='project-list-item__environment'>
|
|
||||||
Development
|
|
||||||
</span>
|
|
||||||
<div class='project-list-item__environment__actions'>
|
|
||||||
<span class="label">no access </span><button v-on:click="openModal('rolesModal')" type="button" class="icon-link">set role</button>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<li class='block-list__item project-list-item__environment'>
|
|
||||||
<span class='project-list-item__environment'>
|
|
||||||
Sandbox
|
|
||||||
</span>
|
|
||||||
<div class='project-list-item__environment__actions'>
|
|
||||||
<span class="label">no access</span><button v-on:click="openModal('rolesModal')" type="button" class="icon-link">set role</button>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<li class='block-list__item project-list-item__environment'>
|
|
||||||
<span class='project-list-item__environment'>
|
|
||||||
Production
|
|
||||||
</span>
|
|
||||||
<div class='project-list-item__environment__actions'>
|
|
||||||
<span class="label">no access</span><button v-on:click="openModal('rolesModal')" type="button" class="icon-link">set role</button>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class='action-group'>
|
|
||||||
<a href='#' class='action-group__action usa-button usa-button-big'>
|
|
||||||
{% if is_new_member %}Create{% else %}Save{% endif %}
|
|
||||||
</a>
|
|
||||||
<a href='#' class='action-group__action icon-link'>
|
|
||||||
{{ Icon('x') }}
|
|
||||||
<span>Cancel</span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -77,10 +77,10 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for m in workspace.members %}
|
{% for m in workspace.members %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="/member_edit" class="icon-link icon-link--large">{{ m['first_name'] }} {{ m['last_name'] }}</a></td>
|
<td><a href="{{ url_for('workspaces.update_member', workspace_id=workspace.id, member_id=m.user_id) }}" class="icon-link icon-link--large">{{ m.user_name }}</a></td>
|
||||||
<td class='table-cell--shrink'>{% if m['num_projects'] == '0' %} <span class="label label--info">No Project Access</span> {% endif %}</td>
|
<td class='table-cell--shrink'>{% if m['num_projects'] == '0' %} <span class="label label--info">No Project Access</span> {% endif %}</td>
|
||||||
<td>{{ m['status'] }}</a></td>
|
<td>{{ m.status }}</a></td>
|
||||||
<td>{{ m['workspace_role'] }}</a></td>
|
<td>{{ m.role }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
Reference in New Issue
Block a user