Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

dev_winse
杨树明 6 years ago
commit 2ade607dc5

@ -20,4 +20,14 @@ class AttachmentHistory < ApplicationRecord
is_public == 1
end
def is_history_pdf?
is_pdf = false
file_content_type = content_type
file_ext_type = File.extname(filename).strip.downcase[1..-1]
if (file_content_type.present? && file_content_type.downcase.include?("pdf")) || (file_ext_type.present? && file_ext_type.include?("pdf"))
is_pdf = true
end
is_pdf
end
end

@ -51,8 +51,10 @@ class Users::UpdateAccountService < ApplicationService
if first_full_reward
RewardGradeService.call(user, container_id: user.id, container_type: 'Account', score: 500)
sms_notify_admin(user.lastname) if user.user_extension.teacher?
if user.user_extension.teacher?
join_course(user.id,1309, 2)
sms_notify_admin(user.lastname)
end
end
user
@ -73,4 +75,11 @@ class Users::UpdateAccountService < ApplicationService
rescue => ex
Util.logger_error(ex)
end
def join_course(user_id, course_id, identity)
course = Course.find_by(id: course_id)
return unless course
attr = {course_id: course_id, role: identity, user_id: user_id}
CourseMember.create!(attr)
end
end

@ -7,4 +7,4 @@ json.quotes attachment.quotes_count
json.downloads_count attachment.downloads_count
json.created_on attachment.created_on
json.url attachment_path(attachment, type: 'history')
json.is_pdf attachment.is_pdf?
json.is_pdf attachment.is_history_pdf?

Loading…
Cancel
Save