2013-04-02 02:43:01 -04:00
|
|
|
class Alert < ActiveRecord::Base
|
2013-04-03 19:44:01 -04:00
|
|
|
attr_accessible :alerted, :course, :department, :user_id, :semester
|
2013-04-02 03:07:11 -04:00
|
|
|
|
|
|
|
validates :department, :presence => true,
|
|
|
|
:length => {
|
|
|
|
:minimum => 2,
|
|
|
|
:maximum => 4
|
|
|
|
},
|
|
|
|
:format => {
|
|
|
|
:with => /\A[A-Za-z]+\Z/
|
|
|
|
}
|
|
|
|
validates :course, :presence => true,
|
|
|
|
:length => {
|
|
|
|
:minimum => 3,
|
|
|
|
:maximum => 4
|
|
|
|
},
|
|
|
|
:format => {
|
|
|
|
:with => /\A[0-9]+[A-Za-z]?\Z/
|
|
|
|
}
|
|
|
|
validates :user_id, :presence => true,
|
|
|
|
:numericality => {
|
|
|
|
only_integer: true
|
|
|
|
}
|
2013-04-03 19:44:01 -04:00
|
|
|
validates :semester, :presence => true
|
2013-04-02 03:07:11 -04:00
|
|
|
|
|
|
|
def alerted?
|
|
|
|
@alerted
|
|
|
|
end
|
|
|
|
|
2013-04-03 19:47:38 -04:00
|
|
|
def course_name
|
2013-04-03 19:32:59 -04:00
|
|
|
"#{self.department} #{self.course}"
|
2013-04-02 03:07:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def sections
|
|
|
|
|
|
|
|
end
|
2013-04-02 02:43:01 -04:00
|
|
|
end
|