拷贝课程图标
This commit is contained in:
parent
724ff31751
commit
71778ba948
|
@ -442,10 +442,14 @@ class CoursesController < ApplicationController
|
|||
@course = cs.create_course(params,User.current)[:course]
|
||||
if params[:copy_course]
|
||||
copy_course = Course.find params[:copy_course].to_i
|
||||
@course.is_copy = 1
|
||||
@course.is_copy = params[:copy_course].to_i
|
||||
@course.open_student = copy_course.open_student
|
||||
@course.publish_resource = copy_course.publish_resource
|
||||
@course.save
|
||||
|
||||
#copy avatar
|
||||
copy_avatar(@course, copy_course)
|
||||
|
||||
if params[:checkAll]
|
||||
attachments = copy_course.attachments
|
||||
attachments.each do |attachment|
|
||||
|
|
|
@ -1,9 +1,24 @@
|
|||
module AvatarHelper
|
||||
|
||||
AVATAR_SIZE="50x50"
|
||||
|
||||
def copy_avatar(des, src)
|
||||
src_file = disk_filename(src.class,src.id)
|
||||
des_file = disk_filename(des.class,des.id)
|
||||
|
||||
FileUtils.cp(src_file, des_file) if File.exist?(src_file)
|
||||
end
|
||||
|
||||
def avatar_image(source)
|
||||
File.join(relative_path, avatar_directory(source.class), source.id.to_s)
|
||||
def avatar_image(source, copyed=false)
|
||||
source_type = source.class
|
||||
source_id = source.id
|
||||
|
||||
course = Course.find(source_id) rescue nil
|
||||
if course && copyed
|
||||
source_id = course.is_copy
|
||||
end
|
||||
|
||||
File.join(relative_path, avatar_directory(source_type), source_id.to_s)
|
||||
end
|
||||
|
||||
def relative_path
|
||||
|
@ -23,7 +38,18 @@ module AvatarHelper
|
|||
end
|
||||
|
||||
def disk_filename(source_type,source_id,image_file=nil)
|
||||
File.join(storage_path,avatar_directory(source_type),avatar_filename(source_id,image_file))
|
||||
File.join(storage_path,avatar_directory(source_type),avatar_filename(source_id,image_file))
|
||||
end
|
||||
|
||||
def copy_course?(source_type, source_id)
|
||||
file= disk_filename(source_type, source_id)
|
||||
if source_type == Course && !File.exist?(file)
|
||||
course = Course.find(source_id) rescue nil
|
||||
if course && course.is_copy>0
|
||||
return true
|
||||
end
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
def file_extension(filename=nil)
|
||||
|
@ -35,7 +61,9 @@ module AvatarHelper
|
|||
return File.join(relative_path,'AnonymousUser','0')
|
||||
end
|
||||
if source.class && source.id && File.exist?(disk_filename(source.class,source.id))
|
||||
avatar_image(source)
|
||||
avatar_image(source, false)
|
||||
elsif copy_course?(source.class, source.id)
|
||||
avatar_image(source, true)
|
||||
else
|
||||
File.join(relative_path,avatar_directory(source.class),'0')
|
||||
end
|
||||
|
|
|
@ -72,7 +72,7 @@ class CourseActivity < ActiveRecord::Base
|
|||
# message的status状态为0为正常,为1表示创建课程时发送的message
|
||||
message = Message.create(:subject => name, :content => content, :board_id => self.course.boards.first.id, :author_id => self.course.tea_id , :sticky => true, :status => true )
|
||||
# 更新的目的是为了排序,因为该条动态的时间可能与课程创建的动态创建时间一直
|
||||
message.course_acts.first.update_attribute(:updated_at, message.course_acts.first.updated_at + 1)
|
||||
message.course_acts.first.update_attribute(:updated_at, message.course_acts.first.updated_at + 1) if message.course_acts.first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,12 +39,13 @@
|
|||
<input name="copy_course" value="<%=@course.id %>" style="display: none"/>
|
||||
<li class="ml45 mb10">
|
||||
<a href="javascript:void(0)" class="upimg fl">
|
||||
<%= image_tag(url_to_avatar(@new_course), id: "avatar_image", :width =>"60", :height =>"60",:alt=>"上传图片")%>
|
||||
<%= image_tag(url_to_avatar(@course), id: "avatar_image", :width =>"60", :height =>"60",:alt=>"上传图片")%>
|
||||
</a> <!--<a href="javascript:void(0)" class="upbtn fl ml30" onclick="$('#upload_course_logo').click();">上传图片</a>-->
|
||||
<!--</span>-->
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li class="ml45">
|
||||
|
||||
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
|
||||
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
|
||||
<label><span class="c_red">*</span> <%= l(:label_tags_course_name)%> :</label>
|
||||
|
|
Loading…
Reference in New Issue