Allow internal user to be part of an study group
This commit is contained in:
@ -202,7 +202,7 @@ module Lti
|
|||||||
else
|
else
|
||||||
StudyGroup.find_or_create_by(external_id: @provider.resource_link_id, consumer: @consumer)
|
StudyGroup.find_or_create_by(external_id: @provider.resource_link_id, consumer: @consumer)
|
||||||
end
|
end
|
||||||
group.users << @current_user unless group.users.include? @current_user
|
group.external_users << @current_user unless group.external_users.include? @current_user
|
||||||
group.save
|
group.save
|
||||||
session[:study_group_id] = group.id
|
session[:study_group_id] = group.id
|
||||||
end
|
end
|
||||||
|
@ -10,11 +10,11 @@ class StudyGroupsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@search = @study_group.users.ransack(params[:q])
|
@search = @study_group.external_users.ransack(params[:q])
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@search = @study_group.users.ransack(params[:q])
|
@search = @study_group.external_users.ransack(params[:q])
|
||||||
@members = StudyGroupMembership.where(user: @search.result, study_group: @study_group)
|
@members = StudyGroupMembership.where(user: @search.result, study_group: @study_group)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2,13 +2,15 @@
|
|||||||
|
|
||||||
class StudyGroup < ApplicationRecord
|
class StudyGroup < ApplicationRecord
|
||||||
has_many :study_group_memberships, dependent: :destroy
|
has_many :study_group_memberships, dependent: :destroy
|
||||||
# Use `ExternalUser` as `source_type` for now.
|
has_many :external_users, through: :study_group_memberships, source_type: 'ExternalUser', source: :user
|
||||||
# Using `User` will lead ActiveRecord to access the inexistent table `users`.
|
has_many :internal_users, through: :study_group_memberships, source_type: 'InternalUser', source: :user
|
||||||
# Issue created: https://github.com/rails/rails/issues/34531
|
|
||||||
has_many :users, through: :study_group_memberships, source_type: 'ExternalUser'
|
|
||||||
has_many :submissions, dependent: :nullify
|
has_many :submissions, dependent: :nullify
|
||||||
belongs_to :consumer
|
belongs_to :consumer
|
||||||
|
|
||||||
|
def users
|
||||||
|
external_users + internal_users
|
||||||
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
if name.blank?
|
if name.blank?
|
||||||
"StudyGroup " + id.to_s
|
"StudyGroup " + id.to_s
|
||||||
|
Reference in New Issue
Block a user