Allow platform admins and internal users to switch their current study group

This commit is contained in:
Sebastian Serth
2022-09-20 00:12:46 +02:00
committed by Sebastian Serth
parent 2e3480a068
commit ac3dc8d30f
12 changed files with 94 additions and 21 deletions

View File

@ -3,7 +3,7 @@
class StudyGroupsController < ApplicationController
include CommonBehavior
before_action :set_group, only: MEMBER_ACTIONS
before_action :set_group, only: MEMBER_ACTIONS + %w[set_as_current]
def index
@search = policy_scope(StudyGroup).ransack(params[:q])
@ -37,6 +37,12 @@ class StudyGroupsController < ApplicationController
end
private :study_group_params
def set_as_current
session[:study_group_id] = @study_group.id
current_user.store_current_study_group_id(@study_group.id)
redirect_back(fallback_location: root_path, notice: t('study_groups.set_as_current.success'))
end
def set_group
@study_group = StudyGroup.find(params[:id])
authorize!