Class: Hyrax::DepositorsController

Inherits:
ApplicationController
  • Object
show all
Includes:
DenyAccessOverrideBehavior
Defined in:
app/controllers/hyrax/depositors_controller.rb

Instance Method Summary collapse

Methods included from DenyAccessOverrideBehavior

#deny_access

Instance Method Details

#createObject


17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/hyrax/depositors_controller.rb', line 17

def create
  grantor = authorize_and_return_grantor
  grantee = ::User.from_url_component(params[:grantee_id])

  if grantor == grantee
    render_json_response(response_type: :unprocessable_entity, message: view_context.t('hyrax.dashboard.proxy_add_deny'))
  elsif grantor.can_receive_deposits_from.include?(grantee)
    head :ok
  else
    grantor.can_receive_deposits_from << grantee
    send_proxy_depositor_added_messages(grantor, grantee)
    render json: { name: grantee.name, delete_path: sanitize_route_string(hyrax.user_depositor_path(grantor.user_key, grantee.user_key)) }
  end
end

#destroyObject


32
33
34
35
36
# File 'app/controllers/hyrax/depositors_controller.rb', line 32

def destroy
  grantor = authorize_and_return_grantor
  grantor.can_receive_deposits_from.delete(::User.from_url_component(params[:id]))
  head :ok
end

#indexObject


10
11
12
13
14
15
# File 'app/controllers/hyrax/depositors_controller.rb', line 10

def index
  add_breadcrumb t(:'hyrax.controls.home'), root_path
  add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
  add_breadcrumb t(:'hyrax.dashboard.manage_proxies'), hyrax.depositors_path
  @user = current_user
end