Class: GroupsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- GroupsController
- Defined in:
- app/controllers/groups_controller.rb
Instance Method Summary collapse
-
#add_admin ⇒ Object
This is a JSON only endpoint.
-
#add_submitter ⇒ Object
This is a JSON only endpoint.
-
#delete_user_from_group ⇒ Object
This is a JSON only endpoint.
- #edit ⇒ Object
- #index ⇒ Object
- #show ⇒ Object
-
#update ⇒ Object
rubocop:disable Metrics/MethodLength.
Methods inherited from ApplicationController
Instance Method Details
#add_admin ⇒ Object
This is a JSON only endpoint
42 43 44 45 46 |
# File 'app/controllers/groups_controller.rb', line 42 def add_admin @group = Group.find(params[:id]) @group.add_administrator(current_user, User.new_for_uid(params[:uid])) check_and_render end |
#add_submitter ⇒ Object
This is a JSON only endpoint
49 50 51 52 53 54 |
# File 'app/controllers/groups_controller.rb', line 49 def add_submitter @group = Group.find(params[:id]) user = @group.default_user(params[:uid]) @group.add_submitter(current_user, user) check_and_render end |
#delete_user_from_group ⇒ Object
This is a JSON only endpoint
57 58 59 60 61 |
# File 'app/controllers/groups_controller.rb', line 57 def delete_user_from_group @group = Group.find(params[:id]) @group.(current_user, User.find_by(uid: params[:uid])) check_and_render end |
#edit ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/groups_controller.rb', line 10 def edit @group = Group.find(params[:id]) if can_edit? render "edit" else Rails.logger.warn("Unauthorized to edit group #{@group.id} (current user: #{current_user.id})") redirect_to groups_path end end |
#index ⇒ Object
3 |
# File 'app/controllers/groups_controller.rb', line 3 def index; end |
#show ⇒ Object
5 6 7 8 |
# File 'app/controllers/groups_controller.rb', line 5 def show @group = Group.find(params[:id]) @can_edit = can_edit? end |
#update ⇒ Object
rubocop:disable Metrics/MethodLength
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/groups_controller.rb', line 21 def update @group = Group.find(params[:id]) if can_edit? respond_to do |format| if @group.update(group_params) format.html { redirect_to group_url(@group), notice: "Group was successfully updated." } format.json { render :show, status: :ok, location: @group } else # return 200 so the loadbalancer doesn't capture the error format.html { render :edit } format.json { render json: @group.errors } end end else Rails.logger.warn("Unauthorized to update group #{@group.id} (current user: #{current_user.id})") redirect_to groups_path end end |