mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 23:26:23 -05:00
add GET /organisation and GET /organisation/id endpoints
This commit is contained in:
@@ -71,6 +71,7 @@ def create_app(app_name=None):
|
||||
from app.events.rest import events as events_blueprint
|
||||
from app.provider_details.rest import provider_details as provider_details_blueprint
|
||||
from app.spec.rest import spec as spec_blueprint
|
||||
from app.organisation.rest import organisation_blueprint
|
||||
|
||||
application.register_blueprint(service_blueprint, url_prefix='/service')
|
||||
application.register_blueprint(user_blueprint, url_prefix='/user')
|
||||
@@ -85,6 +86,7 @@ def create_app(app_name=None):
|
||||
application.register_blueprint(events_blueprint)
|
||||
application.register_blueprint(provider_details_blueprint, url_prefix='/provider-details')
|
||||
application.register_blueprint(spec_blueprint, url_prefix='/spec')
|
||||
application.register_blueprint(organisation_blueprint, url_prefix='/organisation')
|
||||
|
||||
return application
|
||||
|
||||
|
||||
9
app/dao/organisation_dao.py
Normal file
9
app/dao/organisation_dao.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from app.models import Organisation
|
||||
|
||||
|
||||
def dao_get_organisations():
|
||||
return Organisation.query.all()
|
||||
|
||||
|
||||
def dao_get_organisation_by_id(org_id):
|
||||
return Organisation.query.filter_by(id=org_id).one()
|
||||
0
app/organisation/__init__.py
Normal file
0
app/organisation/__init__.py
Normal file
20
app/organisation/rest.py
Normal file
20
app/organisation/rest.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from flask import Blueprint, jsonify
|
||||
|
||||
from app.dao.organisation_dao import dao_get_organisations, dao_get_organisation_by_id
|
||||
from app.schemas import organisation_schema
|
||||
from app.errors import register_errors
|
||||
|
||||
organisation_blueprint = Blueprint('organisation', __name__)
|
||||
register_errors(organisation_blueprint)
|
||||
|
||||
|
||||
@organisation_blueprint.route('', methods=['GET'])
|
||||
def get_organisations():
|
||||
data = organisation_schema.dump(dao_get_organisations(), many=True).data
|
||||
return jsonify(organisations=data)
|
||||
|
||||
|
||||
@organisation_blueprint.route('/<uuid:org_id>', methods=['GET'])
|
||||
def get_organisation_by_id(org_id):
|
||||
data = organisation_schema.dump(dao_get_organisation_by_id(org_id)).data
|
||||
return jsonify(organisation=data)
|
||||
@@ -440,6 +440,12 @@ class EventSchema(BaseSchema):
|
||||
strict = True
|
||||
|
||||
|
||||
class OrganisationSchema(BaseSchema):
|
||||
class Meta:
|
||||
model = models.Organisation
|
||||
strict = True
|
||||
|
||||
|
||||
class FromToDateSchema(ma.Schema):
|
||||
|
||||
class Meta:
|
||||
@@ -533,6 +539,7 @@ service_history_schema = ServiceHistorySchema()
|
||||
api_key_history_schema = ApiKeyHistorySchema()
|
||||
template_history_schema = TemplateHistorySchema()
|
||||
event_schema = EventSchema()
|
||||
organisation_schema = OrganisationSchema()
|
||||
from_to_date_schema = FromToDateSchema()
|
||||
provider_details_schema = ProviderDetailsSchema()
|
||||
week_aggregate_notification_statistics_schema = WeekAggregateNotificationStatisticsSchema()
|
||||
|
||||
Reference in New Issue
Block a user