Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineGirard committed Nov 25, 2024
1 parent 12a1162 commit 69f30c7
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Api::Internal::Admin::Agenda::AbsencesController < Api::Internal::BaseController
class Admin::Api::Agenda::AbsencesController < Admin::Api::BaseController
def index
agent = Agent.find(params[:agent_id])
@organisation = Organisation.find(params[:organisation_id])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Api::Internal::Admin::Agenda::PlageOuverturesController < Api::Internal::BaseController
class Admin::Api::Agenda::PlageOuverturesController < Admin::Api::BaseController
def index
@agent = Agent.find(params[:agent_id])
@organisation = Organisation.find(params[:organisation_id])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Api::Internal::Admin::Agenda::RdvsController < Api::Internal::BaseController
class Admin::Api::Agenda::RdvsController < Admin::Api::BaseController
def index
agent = Agent.find(params[:agent_id])
@organisation = Organisation.find(params[:organisation_id])
Expand Down
22 changes: 22 additions & 0 deletions app/controllers/admin/api/base_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Admin::Api::BaseController < ApplicationController
include Admin::AuthenticatedControllerConcern

respond_to :json

private

def time_range_params
start_time = params.require(:start)
end_time = params.require(:end)
Time.zone.parse(start_time)..Time.zone.parse(end_time)
end

def date_range_params
(time_range_params.begin.to_date)..(time_range_params.end.to_date)
end
helper_method :date_range_params

def pundit_user
AgentContext.new(current_agent)
end
end
39 changes: 0 additions & 39 deletions app/controllers/api/internal/base_controller.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/admin/agent_agendas/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
data-selected-event-id="#{@selected_event_id}"
data-organisation-id="#{@organisation.id}"
data-display-saturdays="#{current_agent.display_saturdays}"
data-event-sources-json="#{[api_internal_admin_agenda_rdvs_path(agent_id: @agent, organisation_id: current_organisation.id), api_internal_admin_agenda_absences_path(agent_id: @agent, organisation_id: current_organisation.id), api_internal_admin_agenda_plage_ouvertures_path(agent_id: @agent, organisation_id: current_organisation.id, in_background: true), OffDays.to_full_calendar_array].to_json}"
data-event-sources-json="#{[admin_api_agenda_absences_path(agent_id: @agent, organisation_id: current_organisation.id, format: :json), admin_api_agenda_rdvs_path(agent_id: @agent, organisation_id: current_organisation.id, format: :json), admin_api_agenda_plage_ouvertures_path(agent_id: @agent, organisation_id: current_organisation.id, in_background: true, format: :json), OffDays.to_full_calendar_array].to_json}"
]
.mt-3.flex-grow-1.text-right
.m-2
Expand Down
7 changes: 7 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@

authenticate :agent do
namespace "admin" do
namespace :api, defaults: { format: :json } do
namespace :agenda do
resources :plage_ouvertures, only: [:index]
resources :rdvs, only: [:index]
resources :absences, only: [:index]
end
end
resources :territories, only: %i[edit update show] do
scope module: "territories" do
resources :agent_roles, only: %i[update create destroy]
Expand Down
10 changes: 0 additions & 10 deletions config/routes/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@
end
end

namespace :internal do
namespace :admin do
namespace :agenda do
resources :plage_ouvertures, only: [:index]
resources :rdvs, only: [:index]
resources :absences, only: [:index]
end
end
end

post "/coop-mediation-numerique/accounts", to: "coop_mediation_numerique/accounts#create"
end

Expand Down

0 comments on commit 69f30c7

Please sign in to comment.