started implementing teams
This commit is contained in:
@@ -7,6 +7,7 @@ class Exercise < ActiveRecord::Base
|
||||
|
||||
belongs_to :execution_environment
|
||||
has_many :submissions
|
||||
belongs_to :team
|
||||
has_many :users, source_type: ExternalUser, through: :submissions
|
||||
|
||||
scope :with_submissions, -> { where('id IN (SELECT exercise_id FROM submissions)') }
|
||||
|
@@ -3,6 +3,8 @@ class InternalUser < ActiveRecord::Base
|
||||
|
||||
authenticates_with_sorcery!
|
||||
|
||||
has_and_belongs_to_many :teams
|
||||
|
||||
validates :email, presence: true, uniqueness: true
|
||||
validates :password, confirmation: true, on: :update, presence: true, unless: :activated?
|
||||
validates :role, inclusion: {in: ROLES}
|
||||
|
10
app/models/team.rb
Normal file
10
app/models/team.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class Team < ActiveRecord::Base
|
||||
has_and_belongs_to_many :internal_users
|
||||
alias_method :members, :internal_users
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user