started implementing teams

This commit is contained in:
Hauke Klement
2015-01-28 12:28:09 +01:00
parent cf346e2271
commit dd624b26c8
25 changed files with 355 additions and 3 deletions

View File

@@ -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)') }

View File

@@ -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
View 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