parent
cd3c69af94
commit
d22ffa84b4
|
@ -5,6 +5,7 @@ class TagsController < ApplicationController
|
||||||
|
|
||||||
before_filter :require_admin,:only => :show
|
before_filter :require_admin,:only => :show
|
||||||
|
|
||||||
|
include CoursesHelper
|
||||||
include ProjectsHelper
|
include ProjectsHelper
|
||||||
include IssuesHelper
|
include IssuesHelper
|
||||||
include UsersHelper
|
include UsersHelper
|
||||||
|
@ -64,6 +65,7 @@ class TagsController < ApplicationController
|
||||||
# 获取搜索结果
|
# 获取搜索结果
|
||||||
@obj,@obj_pages,@results_count,@users_results,
|
@obj,@obj_pages,@results_count,@users_results,
|
||||||
@projects_results,
|
@projects_results,
|
||||||
|
@@courses_results,
|
||||||
@issues_results,
|
@issues_results,
|
||||||
@bids_results,
|
@bids_results,
|
||||||
@forums_results,
|
@forums_results,
|
||||||
|
@ -96,6 +98,7 @@ class TagsController < ApplicationController
|
||||||
# 获取搜索结果
|
# 获取搜索结果
|
||||||
@obj,@obj_pages,@results_count,@users_results,
|
@obj,@obj_pages,@results_count,@users_results,
|
||||||
@projects_results,
|
@projects_results,
|
||||||
|
@@courses_results,
|
||||||
@issues_results,
|
@issues_results,
|
||||||
@bids_results,
|
@bids_results,
|
||||||
@forums_results,
|
@forums_results,
|
||||||
|
@ -114,6 +117,7 @@ class TagsController < ApplicationController
|
||||||
# 获取搜索结果
|
# 获取搜索结果
|
||||||
@obj,@obj_pages,@results_count,@users_results,
|
@obj,@obj_pages,@results_count,@users_results,
|
||||||
@projects_results,
|
@projects_results,
|
||||||
|
@@courses_results,
|
||||||
@issues_results,
|
@issues_results,
|
||||||
@bids_results,
|
@bids_results,
|
||||||
@forums_results,
|
@forums_results,
|
||||||
|
@ -188,6 +192,7 @@ class TagsController < ApplicationController
|
||||||
@obj_pages = nil
|
@obj_pages = nil
|
||||||
@obj = nil
|
@obj = nil
|
||||||
@result = nil
|
@result = nil
|
||||||
|
@courses_results = nil
|
||||||
|
|
||||||
# 这里为了提高系统的响应速度 把搜索结果放到case中去了
|
# 这里为了提高系统的响应速度 把搜索结果放到case中去了
|
||||||
case obj_flag
|
case obj_flag
|
||||||
|
@ -219,6 +224,9 @@ class TagsController < ApplicationController
|
||||||
when '8'
|
when '8'
|
||||||
@obj = OpenSourceProject.find_by_id(obj_id)
|
@obj = OpenSourceProject.find_by_id(obj_id)
|
||||||
@obj_pages, @open_source_projects_results, @results_count = for_pagination(get_open_source_projects_by_tag(selected_tags))
|
@obj_pages, @open_source_projects_results, @results_count = for_pagination(get_open_source_projects_by_tag(selected_tags))
|
||||||
|
when '9' then
|
||||||
|
@obj = Course.find_by_id(obj_id)
|
||||||
|
@obj_pages, @courses_results, @results_count = for_pagination(get_courses_by_tag(selected_tags))
|
||||||
else
|
else
|
||||||
@obj = nil
|
@obj = nil
|
||||||
end
|
end
|
||||||
|
@ -232,6 +240,7 @@ class TagsController < ApplicationController
|
||||||
@forums_results,
|
@forums_results,
|
||||||
attachments_results,
|
attachments_results,
|
||||||
@contests_results,
|
@contests_results,
|
||||||
|
@courses_results,
|
||||||
@open_source_projects_results]
|
@open_source_projects_results]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -279,6 +288,8 @@ class TagsController < ApplicationController
|
||||||
return 'Contest'
|
return 'Contest'
|
||||||
when '8'
|
when '8'
|
||||||
return 'OpenSourceProject'
|
return 'OpenSourceProject'
|
||||||
|
when '9'
|
||||||
|
return 'Course'
|
||||||
else
|
else
|
||||||
render_error :message => e.message
|
render_error :message => e.message
|
||||||
return
|
return
|
||||||
|
|
|
@ -23,8 +23,10 @@ class Course < ActiveRecord::Base
|
||||||
has_many :student, :through => :students_for_courses, :source => :user
|
has_many :student, :through => :students_for_courses, :source => :user
|
||||||
has_many :course_infos, :dependent => :destroy
|
has_many :course_infos, :dependent => :destroy
|
||||||
|
|
||||||
|
acts_as_taggable
|
||||||
acts_as_nested_set :order => 'name', :dependent => :destroy
|
acts_as_nested_set :order => 'name', :dependent => :destroy
|
||||||
|
acts_as_attachable :view_permission => :view_files,
|
||||||
|
:delete_permission => :manage_files
|
||||||
|
|
||||||
validates_presence_of :password, :term
|
validates_presence_of :password, :term
|
||||||
validates_format_of :class_period, :message => "class period can only digital!", :with =>/^[1-9]\d*$/
|
validates_format_of :class_period, :message => "class period can only digital!", :with =>/^[1-9]\d*$/
|
||||||
|
|
|
@ -96,9 +96,6 @@
|
||||||
<table width="240" border="0">
|
<table width="240" border="0">
|
||||||
<tr align="center" width="80px">
|
<tr align="center" width="80px">
|
||||||
<% files_count = @course.attachments.count %>
|
<% files_count = @course.attachments.count %>
|
||||||
<% @course.versions.each do |version| %>
|
|
||||||
<% files_count += version.attachments.count %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<td class="font_index">
|
<td class="font_index">
|
||||||
<!-- 1 教师; 2 学生;0 全部-->
|
<!-- 1 教师; 2 学生;0 全部-->
|
||||||
|
@ -188,7 +185,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="padding-bottom: 8px">
|
<div style="padding-bottom: 8px">
|
||||||
<% if @course.description.size>0 %>
|
<% if @course.description && @course.description.size>0 %>
|
||||||
<div class="font_lighter_sidebar">
|
<div class="font_lighter_sidebar">
|
||||||
|
|
||||||
<%= textilizable @course.description %>
|
<%= textilizable @course.description %>
|
||||||
|
@ -199,7 +196,7 @@
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="created_on_course">
|
<div class="created_on_course">
|
||||||
<strong style="color: #068d9c"><%= l(:label_create_time) %>:</strong><%= format_time(@course.created_on) %>
|
<strong style="color: #068d9c"><%= l(:label_create_time) %>:</strong><%= format_time(@course.created_at) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="user_underline"></div>
|
<div class="user_underline"></div>
|
||||||
|
@ -210,7 +207,7 @@
|
||||||
<!-- added by william -for tag -->
|
<!-- added by william -for tag -->
|
||||||
<div class="user_tags">
|
<div class="user_tags">
|
||||||
<div id="tags">
|
<div id="tags">
|
||||||
<%= render :partial => 'tags/tag', :locals => {:obj => @course, :object_flag => "2"} %>
|
<%= render :partial => 'tags/tag', :locals => {:obj => @course, :object_flag => "5"} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
// });
|
// });
|
||||||
// })
|
// })
|
||||||
</script>
|
</script>
|
||||||
<!-- 1代表是user类型 2代表是project类型 3代表是issue类型 4代表需求-->
|
<!-- 1代表是user类型 2代表是project类型 3代表是issue类型 4代表需求 9代表课程-->
|
||||||
<% @tags = obj.reload.tag_list %>
|
<% @tags = obj.reload.tag_list %>
|
||||||
|
|
||||||
<% if non_list_all and (@tags.size > 0) %>
|
<% if non_list_all and (@tags.size > 0) %>
|
||||||
|
@ -70,6 +70,7 @@
|
||||||
:taggable_id => obj.id, :taggable_type => object_flag %> </span>
|
:taggable_id => obj.id, :taggable_type => object_flag %> </span>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% when '6' %>
|
<% when '6' %>
|
||||||
<% if (User.current.logged? &&
|
<% if (User.current.logged? &&
|
||||||
User.current.admin?
|
User.current.admin?
|
||||||
|
@ -86,6 +87,12 @@
|
||||||
:taggable_id => obj.id, :taggable_type => object_flag %> </span>
|
:taggable_id => obj.id, :taggable_type => object_flag %> </span>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% when '9' %>
|
||||||
|
|
||||||
|
<% if (CourseInfo.find_by_course_id(obj.id)).try(:user_id) == User.current.id %>
|
||||||
|
<span class='del'> <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag,
|
||||||
|
:taggable_id => obj.id, :taggable_type => object_flag %> </span>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
|
|
@ -550,9 +550,16 @@ RedmineApp::Application.routes.draw do
|
||||||
get 'settings(/:tab)', :action => 'settings', :as => 'settings'
|
get 'settings(/:tab)', :action => 'settings', :as => 'settings'
|
||||||
get 'homework', :action => 'homework', :as => 'homework'
|
get 'homework', :action => 'homework', :as => 'homework'
|
||||||
get 'new_homework', :action => 'new_homework', :as => 'new_homework'
|
get 'new_homework', :action => 'new_homework', :as => 'new_homework'
|
||||||
|
get 'file', :action => 'file', :as => 'file'
|
||||||
post 'finishcourse'
|
post 'finishcourse'
|
||||||
post 'restartcourse'
|
post 'restartcourse'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :files, :only => [:index, :new, :create] do
|
||||||
|
collection do
|
||||||
|
match "getattachtype" , via: [:get, :post]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
match '/courses/search', :controller => 'courses', :action => 'search', :via => [:get, :post]
|
match '/courses/search', :controller => 'courses', :action => 'search', :via => [:get, :post]
|
||||||
#match 'project/enterprise_course', :to => 'projects#enterprise_course'
|
#match 'project/enterprise_course', :to => 'projects#enterprise_course'
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
class MigrateCourseTags < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
# 原课程的标签数据迁移成新模式
|
||||||
|
taggings = ActsAsTaggableOn::Tagging.find_all_by_taggable_type('Project')
|
||||||
|
taggings.each do |tagging|
|
||||||
|
project = Project.find_by_id(tagging.taggable_id)
|
||||||
|
if project && project.project_type == 1
|
||||||
|
tagging.taggable_type= 'Course'
|
||||||
|
tagging.save
|
||||||
|
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.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20140605025302) do
|
ActiveRecord::Schema.define(:version => 20140605025303) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
|
Loading…
Reference in New Issue