Orgs: some small fixes, mostly for stability / corner cases

This commit is contained in:
2017-08-23 16:03:54 +02:00
parent e9cb235640
commit 4116357447
4 changed files with 11 additions and 6 deletions

View File

@@ -115,7 +115,7 @@ class OrgManager:
# Compute the new members. # Compute the new members.
members = set(org_doc.get('members') or []) | existing_users members = set(org_doc.get('members') or []) | existing_users
unknown_members = set(org_doc.get('unknown_members')) | unknown_users unknown_members = set(org_doc.get('unknown_members') or []) | unknown_users
# Make sure we don't exceed the current seat count. # Make sure we don't exceed the current seat count.
new_seat_count = len(members) + len(unknown_members) new_seat_count = len(members) + len(unknown_members)
@@ -270,7 +270,7 @@ class OrgManager:
return False return False
org = self._get_org(org_id, projection={'admin_uid': 1}) org = self._get_org(org_id, projection={'admin_uid': 1})
return org['admin_uid'] == uid return org.get('admin_uid') == uid
def unknown_member_roles(self, member_email: str) -> typing.Set[str]: def unknown_member_roles(self, member_email: str) -> typing.Set[str]:
"""Returns the set of organization roles for this user. """Returns the set of organization roles for this user.
@@ -321,6 +321,9 @@ class OrgManager:
""" """
from pillar.api.utils import str2id from pillar.api.utils import str2id
if not member_sting_ids:
return []
member_ids = [str2id(uid) for uid in member_sting_ids] member_ids = [str2id(uid) for uid in member_sting_ids]
users_coll = current_app.db('users') users_coll = current_app.db('users')
users = users_coll.find({'_id': {'$in': member_ids}}, users = users_coll.find({'_id': {'$in': member_ids}},

View File

@@ -55,6 +55,9 @@ def view_embed(organization_id: str):
member['avatar'] = gravatar(member.get('email')) member['avatar'] = gravatar(member.get('email'))
member['_id'] = str(member['_id']) member['_id'] = str(member['_id'])
# Make sure it's never None
organization.unknown_members = organization.unknown_members or []
can_edit = om.user_is_admin(organization_oid) can_edit = om.user_is_admin(organization_oid)
csrf = flask_wtf.csrf.generate_csrf() csrf = flask_wtf.csrf.generate_csrf()

View File

@@ -43,7 +43,7 @@
#item-action-panel #item-action-panel
| {% if can_create_organization %} | {% if can_create_organization %}
button.btn(onclick='createNewOrganization(this)') Create new organization (max {{max_organizations}}) button.btn(onclick='createNewOrganization(this)') Create new organization
#create_organization_result_panel #create_organization_result_panel
| {% endif %} | {% endif %}
@@ -151,7 +151,7 @@ script.
// TODO: create a form to get the initial info from the user. // TODO: create a form to get the initial info from the user.
$.post( $.post(
'{{ url_for('pillar.organizations.create_new') }}', '{{ url_for('pillar.web.organizations.create_new') }}',
{ {
name: 'New Organization', name: 'New Organization',
seat_count: 1, seat_count: 1,

View File

@@ -52,9 +52,8 @@
.table-row.properties-org-roles .table-row.properties-org-roles
.table-cell User roles .table-cell User roles
.table-cell(title='Unable to edit, determined by subscription') .table-cell(title='Unable to edit, determined by subscription')
| {{ organization.org_roles | sort | join(', ') }} | {{ organization.org_roles | hide_none | sort | join(', ') }}
.flamenco-box.manager .flamenco-box.manager
h4 Organization members h4 Organization members
| {% if can_edit %} | {% if can_edit %}