mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-13 17:30:38 -07:00
working on authentication
This commit is contained in:
parent
f3392f685d
commit
a018c42e0f
17 changed files with 154 additions and 80 deletions
|
|
@ -3,4 +3,15 @@ class User < ApplicationRecord
|
|||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
has_many :user_schools
|
||||
|
||||
def schools
|
||||
districts = user_schools.map(&:district).compact.uniq
|
||||
(user_schools.map(&:school) + districts.map(&:schools)).flatten.compact.uniq
|
||||
end
|
||||
|
||||
def admin?(school)
|
||||
schools.index(school).present?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
7
app/models/user_school.rb
Normal file
7
app/models/user_school.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class UserSchool < ApplicationRecord
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :school
|
||||
belongs_to :district
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue