-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from bento-platform/features/configure-response
Features/configure response
- Loading branch information
Showing
14 changed files
with
309 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
GRANULARITY_BOOLEAN = "boolean" | ||
GRANULARITY_COUNT = "count" | ||
GRANULARITY_RECORD = "record" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,28 @@ | ||
from flask import Blueprint, current_app | ||
from ..authz.middleware import authz_middleware | ||
from ..utils.exceptions import NotImplemented | ||
from ..utils.beacon_response import beacon_response | ||
from ..utils.beacon_response import beacon_collections_response | ||
|
||
cohorts = Blueprint("cohorts", __name__) | ||
|
||
|
||
@cohorts.route("/cohorts", methods=['GET', 'POST']) | ||
@authz_middleware.deco_public_endpoint | ||
def get_cohorts(): | ||
granularity = current_app.config["DEFAULT_GRANULARITY"]["cohorts"] | ||
|
||
cohort = current_app.config["BEACON_COHORT"] | ||
results = {"collections": cohort} | ||
return beacon_response(results, collection_response=True) | ||
cohorts = current_app.config["BEACON_COHORT"] | ||
return beacon_collections_response({"collections": cohorts}) | ||
|
||
|
||
@cohorts.route("/cohorts/<id>", methods=['GET', 'POST']) | ||
@authz_middleware.deco_public_endpoint | ||
def get_cohort_by_id(id): | ||
cohort = current_app.config["BEACON_COHORT"] | ||
response = cohort if id == cohort.get("id") else {} | ||
return beacon_response(response, collection_response=True) | ||
|
||
|
||
@cohorts.route("/cohorts/<id>/individuals", methods=['GET', 'POST']) | ||
def individuals_by_cohort(id): # TODO: authz | ||
raise NotImplemented() | ||
cohorts = current_app.config["BEACON_COHORT"] | ||
cohort_this_id = next((c for c in cohorts if c.get("id") == id), []) | ||
return beacon_collections_response({"collections": cohort_this_id}) | ||
|
||
|
||
@cohorts.route("/cohorts/<id>/filtering_terms", methods=['GET', 'POST']) | ||
def filtering_terms_by_cohort(id): # TODO: authz | ||
raise NotImplemented() | ||
# ------------------------------------------------------- | ||
# endpoints in beacon model not yet implemented: | ||
# | ||
# /cohorts/<id>/individuals | ||
# /cohorts/<id>/filtering_terms | ||
# ------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.