Module: Sufia::DepositorsControllerBehavior
- Extended by:
- ActiveSupport::Concern
- Included in:
- DepositorsController
- Defined in:
- app/controllers/concerns/sufia/depositors_controller_behavior.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#deny_access(exception) ⇒ Object
Overriding the default behavior from Hydra::Core::ContorllerBehavior.
- #destroy ⇒ Object
- #validate_users ⇒ Object
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/concerns/sufia/depositors_controller_behavior.rb', line 21 def create 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 |
#deny_access(exception) ⇒ Object
Overriding the default behavior from Hydra::Core::ContorllerBehavior
12 13 14 15 16 17 18 19 |
# File 'app/controllers/concerns/sufia/depositors_controller_behavior.rb', line 12 def deny_access(exception) if current_user and current_user.persisted? redirect_to root_path, alert: exception. else session['user_return_to'.freeze] = request.url redirect_to new_user_session_path, alert: exception. end end |
#destroy ⇒ Object
32 33 34 35 36 |
# File 'app/controllers/concerns/sufia/depositors_controller_behavior.rb', line 32 def destroy grantor = grantor.can_receive_deposits_from.delete(::User.from_url_component(params[:id])) head :ok end |
#validate_users ⇒ Object
38 39 40 41 42 |
# File 'app/controllers/concerns/sufia/depositors_controller_behavior.rb', line 38 def validate_users if params[:user_id] == params[:grantee_id] head :ok end end |