diff --git a/app/controllers/api/v0/guidances_controller.rb b/app/controllers/api/v0/guidances_controller.rb deleted file mode 100644 index 2803ea6..0000000 --- a/app/controllers/api/v0/guidances_controller.rb +++ /dev/null @@ -1,59 +0,0 @@ -module Api - module V0 - class GuidancesController < Api::V0::BaseController - before_action :authenticate - - swagger_controller :guidances, 'Guidances' - - swagger_api :show do - summary 'Returns a single guidance item' - notes 'Notes...' - param :path, :id, :integer, :required, "Guidance Id" - param :header, 'Authentication-Token', :string, :required, 'Authentication-Token' - response :ok, "success", :Guidance - response :unauthorized - response :not_found - end - - # TODO: impliment auth on show/index - # for both, first validate that the user has the permission to use this api - # then for show, display iff they have permissions for that resource - # for index, compile the list of all groups they have permissions to view, then return - - def show - # ensure use has auth for guidances api - if has_auth("guidance") - if Guidance.can_view?(@user, params[:id]) - respond_with get_resource - else - render json: I18n.t("api.bad_resource"), status: 401 - end - else - render I18n.t("api.no_auth_for_endpoint"), status: 401 - end - end - - swagger_api :index do - summary 'Returns a list of all viewable guidances' - notes 'Notes...' - param :header, 'Authentication-Token', :string, :required, 'Authentication-Token' - response :unauthorized - end - - def index - if has_auth("guidance") - @all_viewable_guidances = Guidance.all_viewable(@user) - respond_with @all_viewable_guidances - else - render json I18n.t("api.no_auth_for_endpoint"), status: 401 - end - end - - - private - def query_params - params.permit(:id) - end - end - end -end diff --git a/app/views/api/v0/guidances/index.json.jbuilder b/app/views/api/v0/guidances/index.json.jbuilder deleted file mode 100644 index 82edd20..0000000 --- a/app/views/api/v0/guidances/index.json.jbuilder +++ /dev/null @@ -1,29 +0,0 @@ -# builds a json response to api querry for all guidances - -json.prettify! - -json.guidance @all_viewable_guidances do |guidance| - json.id guidance.id - json.text guidance.text - json.updated_at guidance.updated_at - - # each guidance may be associated with many guidance groups - @guidance_groups = guidance.guidance_groups - json.guidance_groups @guidance_groups do |guidance_group| - json.name guidance_group.name - json.id guidance_group.id - - # for each template associated with the guidance group, list the template name - @templates = guidance_group.dmptemplates - # if the template is empty, instead use all avalable templates - if @templates.empty? - @templates = Dmptemplate.all - end - json.templates @templates do |template| - json.title template.title - end - json.optional guidance_group.optional_subset - json.updated guidance_group.updated_at - end - -end diff --git a/app/views/api/v0/guidances/show.json.jbuilder b/app/views/api/v0/guidances/show.json.jbuilder deleted file mode 100644 index be04df7..0000000 --- a/app/views/api/v0/guidances/show.json.jbuilder +++ /dev/null @@ -1,30 +0,0 @@ -# builds a json response to api querry for a specific guidance - -json.prettify! - -json.guidance do - json.id @guidance.id - json.text @guidance.text - json.updated_at @guidance.updated_at - - # each guidance may be associated with many guidance groups - @guidance_groups = @guidance.guidance_groups - unless @guidance_groups.empty? - json.guidance_groups @guidance_groups do |guidance_group| - json.name guidance_group.name - json.id guidance_group.id - - # for each template associated with the guidance group, list the template name - @templates = guidance_group.dmptemplates - # if the template is empty, instead use all avalable templates - if @templates.empty? - @templates = Dmptemplate.all - end - json.templates @templates do |template| - json.title template.title - end - json.optional guidance_group.optional_subset - json.updated guidance_group.updated_at - end - end -end \ No newline at end of file