def view_embed(organization_id: str): if not request.is_xhr: return index(organization_id) api = pillar_api() organization: Organization = Organization.find(organization_id, api=api) om = current_app.org_manager organization_oid = str2id(organization_id) members = om.org_members(organization.members) for member in members: member['avatar'] = gravatar(member.get('email')) member['_id'] = str(member['_id']) admin_user = User.find(organization.admin_uid, api=api) # Make sure it's never None organization.unknown_members = organization.unknown_members or [] can_super_edit = current_user.has_cap('admin') can_edit = can_super_edit or om.user_is_admin(organization_oid) csrf = flask_wtf.csrf.generate_csrf() return render_template('organizations/view_embed.html', organization=organization, admin_user=admin_user, members=members, can_edit=can_edit, can_super_edit=can_super_edit, seats_used=len(members) + len(organization.unknown_members), csrf=csrf)
def allow_link(): """Helper function to cross check if the user is authenticated, and it is has the 'subscriber' role. Also, we check if the node has world GET permissions, which means it's free. """ # Check if node permissions for the world exist (if node is free) if node.permissions and node.permissions.world: return 'GET' in node.permissions.world return current_user.has_cap('subscriber')
def index(organization_id: str = None): api = pillar_api() organizations = Organization.all(api=api) if not organization_id and organizations['_items']: organization_id = organizations['_items'][0]._id can_create_organization = current_user.has_cap('create-organization') return render_template('organizations/index.html', can_create_organization=can_create_organization, organizations=organizations, open_organization_id=organization_id)