Module: Sufia::DepositorsControllerBehavior

Extended by:
ActiveSupport::Concern
Included in:
DepositorsController
Defined in:
app/controllers/concerns/sufia/depositors_controller_behavior.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/concerns/sufia/depositors_controller_behavior.rb', line 10

def create
  grantor = authorize_and_return_grantor
  grantee = ::User.from_url_component(params[:grantee_id])
  if grantor.can_receive_deposits_from.include?(grantee)
    head :ok
  else
    grantor.can_receive_deposits_from << grantee
    render json: { name: grantee.name, delete_path: sufia.user_depositor_path(grantor.user_key, grantee.user_key) }
  end
end

#destroyObject



21
22
23
24
25
# File 'app/controllers/concerns/sufia/depositors_controller_behavior.rb', line 21

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

#validate_usersObject



27
28
29
30
31
# File 'app/controllers/concerns/sufia/depositors_controller_behavior.rb', line 27

def validate_users
  if params[:user_id] == params[:grantee_id]
    head :ok
  end
end