clubs api endpoint

This commit is contained in:
Daniel Sun 2022-11-13 20:29:02 -05:00 committed by Daniel Sun
parent f9bda2f724
commit 7e699ddda3
2 changed files with 15 additions and 0 deletions

View File

@ -149,3 +149,11 @@ def delete(group_name):
click.confirm(f"Are you sure you want to delete {group_name}?", abort=True)
resp = http_delete(f'/api/groups/{group_name}')
handle_stream_response(resp, DeleteGroupTransaction.operations)
@groups.command(short_help='Search for groups')
@click.argument('group_name')
def search(group_name):
check_if_in_development()
resp = http_get('/api/groups/clubs')
result = handle_sync_response(resp)
print(result)

View File

@ -1,4 +1,5 @@
from flask import Blueprint, request
from flask.json import jsonify
from zope import component
from .utils import authz_restrict_to_syscom, is_truthy, \
@ -31,6 +32,12 @@ def get_group(group_name):
group = ldap_srv.get_group(group_name)
return group.to_dict()
@bp.route('/clubs')
def get_clubs():
ldap_srv = component.getUtility(ILDAPService)
clubs = ldap_srv.get_clubs()
#return jsonify([club.to_dict() for club in clubs])
return jsonify(clubs)
@bp.route('/<group_name>/members/<username>', methods=['POST'])
@authz_restrict_to_syscom