You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/models/student_graduation_topic.rb

55 lines
1.1 KiB

6 years ago
class StudentGraduationTopic < ApplicationRecord
# status 0待确认 1已同意 2已拒绝
belongs_to :user
belongs_to :course
# belongs_to course_member, optional: true
belongs_to :graduation_topic
belongs_to :course_member
has_many :tidings, as: :container, dependent: :destroy
# 毕设确认数
scope :confirmation_count, ->{ where(:status => [1, 2]).count }
#用户的选题
scope :user_topics_accept, lambda{|user_id| where(user_id:user_id,status:[0,1])}
scope :is_refused, -> {where(status: 2)}
scope :is_accepted, -> {where(status: 1)}
scope :is_accepting, -> {where(status: 0)}
# 学生名称
def name
self.user.real_name
end
# 学生学号
def student_id
self.user.student_id
end
# 学生班级名称
def class_group_name
self.course_member.try(:course_group).try(:name)
end
# 学生选题时间
def selected_time
format_time self.created_at
end
# 学生选题状态名
def status_name
case self.status
when 0
"待确认"
when 1
"已同意"
when 2
"已拒绝"
end
end
end