def get_public_groups(): if current_token is not None and current_token.user_uuid is not None: user_uuid = current_token.user_uuid group_info = groupService.get_public_groups(user_uuid) groups = group_info['groups'] subscribed_groups = group_info['subscribed'] # core.logger.debug("subscribed_groups=" + str(subscribed_groups)) group_list = [] for g in groups: d = GroupSchema().dump(g) d['subscribed'] = False for s in subscribed_groups: if g.group_id == s.group_id: d['subscribed'] = True break group_list.append(d) # core.logger.debug("d=" + str(d)) resp = apiUtils.generate_response_wrapper(group_list) return jsonify(resp) else: abort(403)
def get_groups(): groups = groupService.get_groups() group_list = [] for g in groups: group_list.append(GroupSchema().dump(g)) resp = apiUtils.generate_response_wrapper(group_list) return jsonify(resp)
def add_public_group(): group_name = request.form["group_name"] group_de = request.form["group_de"] new_group = groupService.add_group(group_name, group_de) data = GroupSchema().dump(new_group) resp = apiUtils.generate_response_wrapper(data) resp = apiUtils.add_global_success_msg(resp, "New group has been added") return jsonify(resp), 201
def get_group_by_uuid(group_uuid): current_group = groupService.get_group_by_uuid(group_uuid) if current_group: data = GroupSchema().dump(current_group) resp = apiUtils.generate_response_wrapper(data) return jsonify(resp) else: # # In case we did not find the candidate by id # we send HTTP 404 - Not Found error to the client # abort(404)
def get_my_public_groups(): if current_token is not None and current_token.user_uuid is not None: user_uuid = current_token.user_uuid groups = groupService.get_groups_by_user_uuid(user_uuid) group_list = [] for g in groups: group_list.append(GroupSchema().dump(g)) resp = apiUtils.generate_response_wrapper(group_list) return jsonify(resp) abort(403)
def serialize_group_detail(group_details, user_info=None): group = GroupSchema().dump(group_details.group) active_members = [] for m in group_details.active_members: user = None if user_info: for u in user_info: # print("u=" + str(u)) if u['user_uuid'] == str(m.person.user_uuid): user = u break if user is not None: active_members.append({ "user_uuid": str(m.person.user_uuid), "alias": user['alias'] }) else: active_members.append(PersonSchema().dump(m.person)) active_managers = [] for m in group_details.active_managers: user = None if user_info: for u in user_info: if u['user_uuid'] == str(m.person.user_uuid): user = u break if user is not None: active_managers.append({ "user_uuid": str(m.person.user_uuid), "alias": user['alias'] }) else: active_managers.append(PersonSchema().dump(m.person)) return { "group": group, "active_members": active_members, "active_managers": active_managers }