课程资源文件迁移,从项目中分离
This commit is contained in:
parent
6ff26d06ab
commit
cd3c69af94
|
@ -21,6 +21,7 @@ require "fileutils"
|
|||
class Attachment < ActiveRecord::Base
|
||||
belongs_to :container, :polymorphic => true
|
||||
belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'"
|
||||
belongs_to :course, foreign_key: 'container_id', conditions: "attachments.container_type = 'Course'"
|
||||
belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'"
|
||||
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
|
||||
belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id"
|
||||
|
|
|
@ -40,9 +40,9 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 8px"><%= link_to request.host()+"/course", :controller => 'courses', :action => 'course' %></td>
|
||||
<td style="padding-left: 8px"><%= link_to request.host()+"/course", :controller => 'courses', :action => 'index' %></td>
|
||||
<td><p class="top-content-list"><%= link_to "主页", home_path %>
|
||||
> <%= link_to l(:label_course_practice), :controller => 'courses', :action => 'course' %>
|
||||
> <%= link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %>
|
||||
> <%= link_to @course.name, nil %></p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -79,9 +79,6 @@
|
|||
<% end %>
|
||||
<% unless User.current.member_of?(@course) %>
|
||||
<!-- <%= image_tag "/images/fav.png" %> -->
|
||||
<div style="padding-right: 10px">
|
||||
<span class="icon-fav icon"></span><span>
|
||||
<%= watcher_link(@course, User.current) %></span></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
class MigrateCourseAttachments < ActiveRecord::Migration
|
||||
def self.up
|
||||
# 原课程的资源数据迁移成新模式
|
||||
Attachment.all.each do |attach|
|
||||
if attach.container_type == "Project"
|
||||
project = Project.find_by_id(attach.container_id)
|
||||
if project && project.project_type == 1
|
||||
attach.container_type= 'Course'
|
||||
attach.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140605025300) do
|
||||
ActiveRecord::Schema.define(:version => 20140605025302) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
|
Loading…
Reference in New Issue