Allow assignment of study groups for internal users
This commit is contained in:

committed by
Sebastian Serth

parent
998a12e6bc
commit
4d2fe22daf
@@ -11,6 +11,8 @@ class InternalUser < User
|
||||
validates :password, confirmation: true, if: -> { password_void? && validate_password? }, on: :update, presence: true
|
||||
validate :password_strength, if: -> { password_void? && validate_password? }, on: :update
|
||||
|
||||
accepts_nested_attributes_for :study_group_memberships
|
||||
|
||||
def activated?
|
||||
activation_state == 'active'
|
||||
end
|
||||
|
@@ -1,9 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class StudyGroupMembership < ApplicationRecord
|
||||
ROLES = %w[learner teacher].freeze
|
||||
|
||||
belongs_to :user, polymorphic: true
|
||||
belongs_to :study_group
|
||||
|
||||
before_save :destroy_if_empty_study_group_or_user
|
||||
|
||||
def destroy_if_empty_study_group_or_user
|
||||
destroy if study_group.blank? || user.blank?
|
||||
end
|
||||
|
||||
enum role: {
|
||||
learner: 0,
|
||||
teacher: 1,
|
||||
|
Reference in New Issue
Block a user