1.创建组织课程关联表,建立相应模型及控制器;

2.在课程设置中,添加加入组中功能;
3.解决添加项目后,组织列表的上一页和下一页链接问题。
This commit is contained in:
ouyangxuhua 2015-11-17 17:34:50 +08:00
parent 8aeae831b8
commit 71bf80c7a5
23 changed files with 611 additions and 68 deletions

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the org_courses controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -29,6 +29,29 @@ class CoursesController < ApplicationController
before_filter :require_login, :only => [:join, :unjoin]
#before_filter :allow_join, :only => [:join]
#查找组织
def search_public_orgs_not_in_course
condition = '%%'
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
course_org_ids = OrgCourse.find_by_sql("select distinct organization_id from org_courses where course_id = #{params[:id]}").map(&:organization_id)
if course_org_ids.empty?
@orgs_not_in_course = Organization.where("(is_public or creator_id =?) and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(10)
@org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count
else
course_org_ids = "(" + course_org_ids.join(',') + ")"
@orgs_not_in_course = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(10)
@org_count = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count
end
# @course_count = Project.course_entities.visible.like(params[:name]).page(params[:page]).count
@orgs_page = Paginator.new @org_count, 10,params[:page]
#render :json => {:orgs => @orgs_not_in_course, :count => @org_count}.to_json
respond_to do |format|
format.js
end
end
def join
if User.current.logged?
cs = CoursesService.new

View File

@ -0,0 +1,48 @@
class OrgCoursesController < ApplicationController
def create
org_ids = params[:orgNames]
@course = Course.find(params[:course_id])
org_ids.each do |org_id|
OrgCourse.create(:organization_id => org_id.to_i, :course_id => params[:course_id].to_i, :created_at => Time.now)
end
condition = '%%'
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
course_org_ids = OrgCourse.find_by_sql("select distinct organization_id from org_courses where course_id = #{params[:course_id]}").map(&:organization_id)
if course_org_ids.empty?
@orgs_not_in_course = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(10)
@org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count
else
course_org_ids = "(" + course_org_ids.join(',') + ")"
@orgs_not_in_course = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(10)
@org_count = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count
end
# @course_count = Course.course_entities.visible.like(params[:name]).page(params[:page]).count
@orgs_page = Paginator.new @org_count, 10,params[:page]
#render :json => {:orgs => @orgs_not_in_course, :count => @org_count}.to_json
respond_to do |format|
format.js
end
end
def destroy
@course = Course.find(params[:course_id])
@org_course = OrgCourse.find(params[:id])
@org_course.destroy
condition = '%%'
course_org_ids = OrgCourse.find_by_sql("select distinct organization_id from org_courses where course_id = #{params[:course_id]}").map(&:organization_id)
if course_org_ids.empty?
@orgs_not_in_course = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page( 1).per(10)
@org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count
else
course_org_ids = "(" + course_org_ids.join(',') + ")"
@orgs_not_in_course = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page( 1).per(10)
@org_count = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count
end
# @course_count = Course.course_entities.visible.like(params[:name]).page(params[:page]).count
@orgs_page = Paginator.new @org_count, 10,1
end
end

View File

@ -0,0 +1,2 @@
module OrgCoursesHelper
end

View File

@ -18,6 +18,8 @@ class Course < ActiveRecord::Base
:conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})"
has_many :principals, :through => :member_principals, :source => :principal
has_many :users, :through => :members
has_many :org_courses
has_many :organizations, :through => :org_courses
# has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
# has_many :homework_for_courses, :dependent => :destroy

5
app/models/org_course.rb Normal file
View File

@ -0,0 +1,5 @@
class OrgCourse < ActiveRecord::Base
#attr_accessible :organization, :course, :created_at
belongs_to :organization
belongs_to :course
end

View File

@ -3,7 +3,9 @@ class Organization < ActiveRecord::Base
has_many :org_members, :dependent => :destroy
has_many :org_projects ,:dependent => :destroy
has_many :projects,:through => :org_projects
has_many :courses, :through => :org_courses
has_many :org_document_comments, :dependent => :destroy
has_many :org_courses
has_many :users, :through => :org_members
validates_uniqueness_of :name
after_create :save_as_org_activity

View File

@ -0,0 +1,13 @@
$("#search_orgs_result_list").html("");
$("#search_orgs_result_list").append('<ul class="ml20">');
<% @orgs_not_in_course.each do |org|%>
link = "<li><label><input type='checkbox'class='mr5 fl mt3' name='orgNames[]' value='<%=org.id%>'/><span class='relateOrgName fl'> <%=org.name %> </span></label></li><div class='cl mt5'></div>";
$("#search_orgs_result_list").append(link );
<%end %>
$("#search_orgs_result_list").append('</ul>')
<% if @org_count > 10 %>
$("#paginator").html(' <%= pagination_links_full @orgs_page, @org_count ,:per_page_links => true,:remote =>true,:flag=>true%>');
$("#paginator").css("display", "block");
<% else %>
$("#paginator").css("display", "none");
<% end %>

View File

@ -10,6 +10,9 @@
<li id="tb_2" class="hwork_normaltab" onclick="course_setting(2);">
成员
</li>
<li id="tb_3" class="hwork_normaltab" onclick="course_setting(3);">
组织
</li>
</ul>
</div>
<div class="hwork_dis" id="tbc_01" style="padding-top: 10px;">
@ -91,6 +94,10 @@
<%= render :partial => "course_members" %>
</div>
</div><!---成员结束-->
<div class="hwork_undis" id="tbc_03">
<%= render :partial => 'courses/settings/join_org' %>
</div>
</div><!--talknew end-->
<div class="cl"></div>
<script type="text/javascript">

View File

@ -0,0 +1,9 @@
<ul>
<li><span class="relatedListName fb fl">名称</span><span class="relatedListOption fb fl">操作</span></li>
<% orgs.each do |org| %>
<li><a href="<%= organization_path(org) %>" class="relatedListName linkBlue fl"><%= org.name %></a>
<%= link_to "取消关联", org_course_path(:id => OrgCourse.where(:organization_id => org.id, :course_id => course_id).first.id, :course_id => course_id),
:method => 'delete',:remote => true, :class => "relatedListOption fl linkGrey3" %>
</li>
<% end %>
</ul>

View File

@ -0,0 +1,74 @@
<!--<div class="members_left">-->
<!--<input type="text" id="orgs_not_course_member_search" name="orgAddSearch" placeholder="支持姓名、邮箱、昵称搜索" class="orgAddSearch mb20" />-->
<!--<%#= javascript_tag "observeSearchfield('orgs_not_course_member_search', null, '#{ escape_javascript autocomplete_search_organizations_path(:course_id=> @course.id, :format => 'js') }')" %>-->
<!--<div id="new_orgs_for_course">-->
<!--</div>-->
<!--</div>-->
<%= stylesheet_link_tag 'org' %>
<div>
<div class="relateOrg fl">
<span class="pic_add fl mr5 mt3"></span><span class="f14 fontBlue fl">关联组织</span>
<div class="cl mb5"></div>
<%= form_tag url_for(:controller => 'org_courses', :action => 'create', :course_id => @course.id), :id => 'join_orgs_for_course', :remote => true do %>
<input type="text" name="orgs" class="searchOrg mb5 ml20" placeholder="请输入组织名称" />
<div id="search_orgs_result_list" class="ml20"></div>
<ul id="paginator" class="wlist ml20" style="float:none;"></ul>
<a href="javascript:void(0);" class="saveBtn db fl ml20 mr15 mb5" onclick="$('#join_orgs_for_course').submit();">关联</a>
<a href="javascript:void(0);" class="cancelBtn db fl" onclick="cancel_join_orgs();">取消</a>
<% end %>
</div>
<div class="relatedList fr">
<div class="fr mr15">
<span class="f14 fontBlue">已关联组织</span>
<div id="added_orgs">
<%= render :partial => 'courses/settings/added_orgs', :locals => {:orgs => @course.organizations, :course_id => params[:id]} %>
</div>
<div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var lastSearchCondition = '';
var page = 1;
var count = 0;
var maxPage = 0;
function search_orgs(e){
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
{
return;
}
lastSearchCondition = $(e.target).val().trim();
page = 1;
$.ajax({
url: '<%= url_for(:controller => 'courses', :action => 'search_public_orgs_not_in_course') %>'+'?name='+ e.target.value+'&page='+page,
type:'get'
});
}
function throttle(method,context,e){
clearTimeout(method.tId);
method.tId=setTimeout(function(){
method.call(context,e);
},500);
}
//查询组织
$("input[name='orgs']").on('input', function (e) {
throttle(search_orgs,window,e);
});
$(document).ready(function(){
$.ajax({
url: '<%= url_for(:controller => 'courses', :action => 'search_public_orgs_not_in_course') %>'+'?page=1',
type:'get'
});
});
function cancel_join_orgs() {
$("#search_orgs_result_list").html("");
$("#paginator").css("display", "none")
}
</script>

View File

@ -112,6 +112,11 @@
<div class="cl"></div>
<%= render :partial => 'layouts/footer' %>
<div class="cl"></div>
<div id="ajax-modal" style="display:none;"></div>
<div id="ajax-indicator" style="display:none;">
<span><%= l(:label_loading) %></span>
</div>
</body>
</html>

View File

@ -0,0 +1,13 @@
$("#search_orgs_result_list").html("");
$("#search_orgs_result_list").append('<ul class="ml20">');
<% @orgs_not_in_course.each do |org|%>
link = "<li><label><input type='checkbox'class='mr5 fl mt3' name='orgNames[]' value='<%=org.id%>'/><span class='relateOrgName fl'> <%=org.name %> </span></label></li><div class='cl mt5'></div>";
$("#search_orgs_result_list").append(link );
<% end %>
$("#search_orgs_result_list").append('</ul>')
<% if @org_count > 10 %>
$("#paginator").html(' <%= pagination_links_full @orgs_page, @org_count ,:per_page_links => true,:remote =>true,:flag=>true %>');
<% end %>
$("#added_orgs").html("");
$("#added_orgs").html('<%= escape_javascript(render :partial => "courses/settings/added_orgs", :locals => {:orgs => @course.organizations, :course_id => @course.id}) %>')

View File

@ -0,0 +1,17 @@
$("#added_orgs").html("");
$("#added_orgs").html('<%= escape_javascript(render :partial => "courses/settings/added_orgs", :locals => {:orgs => @course.organizations, :course_id => @course.id}) %>')
$("#search_orgs_result_list").html("");
$("#search_orgs_result_list").append('<ul class="ml20">');
<% @orgs_not_in_course.each do |org|%>
link = "<li><label><input type='checkbox'class='mr5 fl mt3' name='orgNames[]' value='<%=org.id%>'/><span class='relateOrgName fl'> <%=org.name %> </span></label></li><div class='cl mt5'></div>";
$("#search_orgs_result_list").append(link );
<%end %>
$("#search_orgs_result_list").append('</ul>')
<% if @org_count > 10 %>
$("#paginator").html(' <%= pagination_links_full @orgs_page, @org_count ,:per_page_links => true,:remote =>true,:flag=>true%>');
$("#paginator").css("display", "block");
<% else %>
$("#paginator").css("display", "none");
<% end %>

View File

@ -2,7 +2,8 @@
<li><span class="relatedListName fb fl">名称</span><span class="relatedListOption fb fl">操作</span></li>
<% orgs.each do |org| %>
<li><a href="<%= organization_path(org) %>" class="relatedListName linkBlue fl"><%= org.name %></a>
<%= link_to "取消关联", org_project_path(:id => OrgProject.where(:organization_id => org.id, :project_id => project_id).first.id, :project_id => project_id),
<a href = "javascript:void(0);" onclick = "cancel_relation('<%= OrgProject.where(:organization_id => org.id, :project_id => project_id).first.id %>','<%=project_id %>')" class="relatedListOption fl linkGrey3" >取消关联</a>
<%#= link_to "取消关联", org_project_path(:id => OrgProject.where(:organization_id => org.id, :project_id => project_id).first.id, :project_id => project_id),
:method => 'delete',:remote => true, :class => "relatedListOption fl linkGrey3" %>
</li>
<% end %>

View File

@ -7,11 +7,6 @@
<!--</div>-->
<%= stylesheet_link_tag 'org' %>
<ul class="mb10">
<li class="orgSettingOp orgOpActive" id="orgSetting_1">组织</li>
<li class="orgBorder" style="width:625px;"></li>
<div class="cl"></div>
</ul>
<div>
<div class="relateOrg fl">
<span class="pic_add fl mr5 mt3"></span><span class="f14 fontBlue fl">关联组织</span>
@ -50,21 +45,6 @@
$.ajax({
url: '<%= url_for(:controller => 'projects', :action => 'search_public_orgs_not_in_project') %>'+'?name='+ e.target.value+'&page='+page,
type:'get'
// success: function(data){
// orgs = data.orgs;
// count = data.count;
// maxPage = Math.ceil(count/10);
// $("#search_orgs_result_list").next().html("");
// if(orgs.length != undefined && orgs.length != 0){
// var i = 0;
// for(; i<orgs.length; i++){
// link = "<li><label><input type='checkbox'class='mr5 fl mt3' name='orgNames[]' value='"+ orgs[i].organization.id + "'/><span class='relateOrgName fl'>" + orgs[i].organization.name + "</span></label></li><div class='cl mt5'></div>";
// console.log(link)
// $("#search_orgs_result_list").next().append(link );
// }
//
// }
// }
});
}
@ -84,24 +64,11 @@
$.ajax({
url: '<%= url_for(:controller => 'projects', :action => 'search_public_orgs_not_in_project') %>'+'?page=1',
type:'get'
// success: function(data){
// orgs = data.orgs;
// count = data.count;
// maxPage = Math.ceil(count/10);
// $("#search_orgs_result_list").next().html("");
// if(orgs.length != undefined && orgs.length != 0){
// var i = 0;
// for(; i<orgs.length; i++){
// link = "<li><label><input type='checkbox'class='mr5 fl mt3' name='orgNames[]' value='"+ orgs[i].organization.id + "'/><span class='relateOrgName fl'>" + orgs[i].organization.name + "</span></label></li><div class='cl mt5'></div>";
// console.log(link)
// $("#search_orgs_result_list").next().append(link );
// }
//
// }
// }
});
});
function cancel_join_orgs() {
$("#search_orgs_result_list").html("");
$("#paginator").html("");
$("#paginator").css("display", "none");
}
</script>

View File

@ -79,6 +79,15 @@ RedmineApp::Application.routes.draw do
end
end
resources :org_courses do
member do
end
collection do
end
end
#match '/organizations/:organization_id/org_document_comments/new', :to => 'org_document_comments#new', :as => 'new_org_documents', :via => [:get, :post]
#match '/organizations/:organization_id/org_document_comments/create', :to => 'org_document_comments#create', :as => 'create_org_documents', :via => [:post]
resources :homework_users
@ -850,6 +859,7 @@ RedmineApp::Application.routes.draw do
post 'search_course_outline'
post 'set_course_outline'
get 'syllabus'
get 'search_public_orgs_not_in_course'
end
collection do
match 'join_private_courses', :via => [:get, :post]

View File

@ -0,0 +1,12 @@
class CreateOrgCourses < ActiveRecord::Migration
def up
create_table :org_courses do |t|
t.integer :organization_id
t.integer :course_id
t.timestamp :created_at
end
end
def down
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20151110011003) do
ActiveRecord::Schema.define(:version => 20151117033430) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -293,6 +293,16 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
t.boolean "diff_all"
end
create_table "columns_priv", :id => false, :force => true do |t|
t.string "Host", :limit => 60, :default => "", :null => false
t.string "Db", :limit => 64, :default => "", :null => false
t.string "User", :limit => 16, :default => "", :null => false
t.string "Table_name", :limit => 64, :default => "", :null => false
t.string "Column_name", :limit => 64, :default => "", :null => false
t.timestamp "Timestamp", :null => false
t.string "Column_priv", :limit => 0, :default => "", :null => false
end
create_table "comments", :force => true do |t|
t.string "commented_type", :limit => 30, :default => "", :null => false
t.integer "commented_id", :default => 0, :null => false
@ -491,6 +501,33 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id"
add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized"
create_table "db", :id => false, :force => true do |t|
t.string "Host", :limit => 60, :default => "", :null => false
t.string "Db", :limit => 64, :default => "", :null => false
t.string "User", :limit => 16, :default => "", :null => false
t.string "Select_priv", :limit => 1, :default => "N", :null => false
t.string "Insert_priv", :limit => 1, :default => "N", :null => false
t.string "Update_priv", :limit => 1, :default => "N", :null => false
t.string "Delete_priv", :limit => 1, :default => "N", :null => false
t.string "Create_priv", :limit => 1, :default => "N", :null => false
t.string "Drop_priv", :limit => 1, :default => "N", :null => false
t.string "Grant_priv", :limit => 1, :default => "N", :null => false
t.string "References_priv", :limit => 1, :default => "N", :null => false
t.string "Index_priv", :limit => 1, :default => "N", :null => false
t.string "Alter_priv", :limit => 1, :default => "N", :null => false
t.string "Create_tmp_table_priv", :limit => 1, :default => "N", :null => false
t.string "Lock_tables_priv", :limit => 1, :default => "N", :null => false
t.string "Create_view_priv", :limit => 1, :default => "N", :null => false
t.string "Show_view_priv", :limit => 1, :default => "N", :null => false
t.string "Create_routine_priv", :limit => 1, :default => "N", :null => false
t.string "Alter_routine_priv", :limit => 1, :default => "N", :null => false
t.string "Execute_priv", :limit => 1, :default => "N", :null => false
t.string "Event_priv", :limit => 1, :default => "N", :null => false
t.string "Trigger_priv", :limit => 1, :default => "N", :null => false
end
add_index "db", ["User"], :name => "User"
create_table "delayed_jobs", :force => true do |t|
t.integer "priority", :default => 0, :null => false
t.integer "attempts", :default => 0, :null => false
@ -528,23 +565,26 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
add_index "documents", ["created_on"], :name => "index_documents_on_created_on"
add_index "documents", ["project_id"], :name => "documents_project_id"
create_table "dts", :force => true do |t|
t.string "IPLineCode"
t.string "Description"
t.string "Num"
t.string "Variable"
t.string "TraceInfo"
t.string "Method"
create_table "dts", :primary_key => "Num", :force => true do |t|
t.string "Defect", :limit => 50
t.string "Category", :limit => 50
t.string "File"
t.string "IPLine"
t.string "Review"
t.string "Category"
t.string "Defect"
t.string "PreConditions"
t.string "StartLine"
t.string "Method"
t.string "Module", :limit => 20
t.string "Variable", :limit => 50
t.integer "StartLine"
t.integer "IPLine"
t.string "IPLineCode", :limit => 200
t.string "Judge", :limit => 15
t.integer "Review", :limit => 1
t.string "Description"
t.text "PreConditions", :limit => 2147483647
t.text "TraceInfo", :limit => 2147483647
t.text "Code", :limit => 2147483647
t.integer "project_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "id", :null => false
end
create_table "enabled_modules", :force => true do |t|
@ -569,6 +609,31 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type"
add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id"
create_table "event", :id => false, :force => true do |t|
t.string "db", :limit => 64, :default => "", :null => false
t.string "name", :limit => 64, :default => "", :null => false
t.binary "body", :limit => 2147483647, :null => false
t.string "definer", :limit => 77, :default => "", :null => false
t.datetime "execute_at"
t.integer "interval_value"
t.string "interval_field", :limit => 18
t.timestamp "created", :null => false
t.timestamp "modified", :null => false
t.datetime "last_executed"
t.datetime "starts"
t.datetime "ends"
t.string "status", :limit => 18, :default => "ENABLED", :null => false
t.string "on_completion", :limit => 8, :default => "DROP", :null => false
t.string "sql_mode", :limit => 0, :default => "", :null => false
t.string "comment", :limit => 64, :default => "", :null => false
t.integer "originator", :null => false
t.string "time_zone", :limit => 64, :default => "SYSTEM", :null => false
t.string "character_set_client", :limit => 32
t.string "collation_connection", :limit => 32
t.string "db_collation", :limit => 32
t.binary "body_utf8", :limit => 2147483647
end
create_table "first_pages", :force => true do |t|
t.string "web_title"
t.string "title"
@ -620,6 +685,21 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
t.integer "locked"
end
create_table "func", :primary_key => "name", :force => true do |t|
t.boolean "ret", :default => false, :null => false
t.string "dl", :limit => 128, :default => "", :null => false
t.string "type", :limit => 9, :null => false
end
create_table "general_log", :id => false, :force => true do |t|
t.timestamp "event_time", :null => false
t.text "user_host", :limit => 16777215, :null => false
t.integer "thread_id", :null => false
t.integer "server_id", :null => false
t.string "command_type", :limit => 64, :null => false
t.text "argument", :limit => 16777215, :null => false
end
create_table "groups_users", :id => false, :force => true do |t|
t.integer "group_id", :null => false
t.integer "user_id", :null => false
@ -627,6 +707,35 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true
create_table "help_category", :primary_key => "help_category_id", :force => true do |t|
t.string "name", :limit => 64, :null => false
t.integer "parent_category_id", :limit => 2
t.text "url", :null => false
end
add_index "help_category", ["name"], :name => "name", :unique => true
create_table "help_keyword", :primary_key => "help_keyword_id", :force => true do |t|
t.string "name", :limit => 64, :null => false
end
add_index "help_keyword", ["name"], :name => "name", :unique => true
create_table "help_relation", :id => false, :force => true do |t|
t.integer "help_topic_id", :null => false
t.integer "help_keyword_id", :null => false
end
create_table "help_topic", :primary_key => "help_topic_id", :force => true do |t|
t.string "name", :limit => 64, :null => false
t.integer "help_category_id", :limit => 2, :null => false
t.text "description", :null => false
t.text "example", :null => false
t.text "url", :null => false
end
add_index "help_topic", ["name"], :name => "name", :unique => true
create_table "homework_attaches", :force => true do |t|
t.integer "bid_id"
t.integer "user_id"
@ -712,6 +821,29 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
t.datetime "updated_at", :null => false
end
create_table "host", :id => false, :force => true do |t|
t.string "Host", :limit => 60, :default => "", :null => false
t.string "Db", :limit => 64, :default => "", :null => false
t.string "Select_priv", :limit => 1, :default => "N", :null => false
t.string "Insert_priv", :limit => 1, :default => "N", :null => false
t.string "Update_priv", :limit => 1, :default => "N", :null => false
t.string "Delete_priv", :limit => 1, :default => "N", :null => false
t.string "Create_priv", :limit => 1, :default => "N", :null => false
t.string "Drop_priv", :limit => 1, :default => "N", :null => false
t.string "Grant_priv", :limit => 1, :default => "N", :null => false
t.string "References_priv", :limit => 1, :default => "N", :null => false
t.string "Index_priv", :limit => 1, :default => "N", :null => false
t.string "Alter_priv", :limit => 1, :default => "N", :null => false
t.string "Create_tmp_table_priv", :limit => 1, :default => "N", :null => false
t.string "Lock_tables_priv", :limit => 1, :default => "N", :null => false
t.string "Create_view_priv", :limit => 1, :default => "N", :null => false
t.string "Show_view_priv", :limit => 1, :default => "N", :null => false
t.string "Create_routine_priv", :limit => 1, :default => "N", :null => false
t.string "Alter_routine_priv", :limit => 1, :default => "N", :null => false
t.string "Execute_priv", :limit => 1, :default => "N", :null => false
t.string "Trigger_priv", :limit => 1, :default => "N", :null => false
end
create_table "invite_lists", :force => true do |t|
t.integer "project_id"
t.integer "user_id"
@ -814,16 +946,6 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_details_copy", :force => true do |t|
t.integer "journal_id", :default => 0, :null => false
t.string "property", :limit => 30, :default => "", :null => false
t.string "prop_key", :limit => 30, :default => "", :null => false
t.text "old_value"
t.text "value"
end
add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id"
t.integer "user_id"
@ -951,6 +1073,15 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id"
add_index "messages", ["parent_id"], :name => "messages_parent_id"
create_table "ndb_binlog_index", :primary_key => "epoch", :force => true do |t|
t.integer "Position", :limit => 8, :null => false
t.string "File", :null => false
t.integer "inserts", :limit => 8, :null => false
t.integer "updates", :limit => 8, :null => false
t.integer "deletes", :limit => 8, :null => false
t.integer "schemaops", :limit => 8, :null => false
end
create_table "news", :force => true do |t|
t.integer "project_id"
t.string "title", :limit => 60, :default => "", :null => false
@ -960,6 +1091,7 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
t.datetime "created_on"
t.integer "comments_count", :default => 0, :null => false
t.integer "course_id"
t.integer "sticky", :default => 0
end
add_index "news", ["author_id"], :name => "index_news_on_author_id"
@ -1055,6 +1187,12 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
t.datetime "updated_at", :null => false
end
create_table "org_courses", :force => true do |t|
t.integer "organization_id"
t.integer "course_id"
t.datetime "created_at"
end
create_table "org_document_comments", :force => true do |t|
t.string "title"
t.text "content"
@ -1076,8 +1214,7 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
create_table "org_members", :force => true do |t|
t.integer "user_id"
t.integer "organization_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
end
create_table "org_projects", :force => true do |t|
@ -1104,6 +1241,10 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
t.datetime "updated_at", :null => false
end
create_table "plugin", :primary_key => "name", :force => true do |t|
t.string "dl", :limit => 128, :default => "", :null => false
end
create_table "poll_answers", :force => true do |t|
t.integer "poll_question_id"
t.text "answer_text"
@ -1179,6 +1320,42 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
t.datetime "updated_at", :null => false
end
create_table "proc", :id => false, :force => true do |t|
t.string "db", :limit => 64, :default => "", :null => false
t.string "name", :limit => 64, :default => "", :null => false
t.string "type", :limit => 9, :null => false
t.string "specific_name", :limit => 64, :default => "", :null => false
t.string "language", :limit => 3, :default => "SQL", :null => false
t.string "sql_data_access", :limit => 17, :default => "CONTAINS_SQL", :null => false
t.string "is_deterministic", :limit => 3, :default => "NO", :null => false
t.string "security_type", :limit => 7, :default => "DEFINER", :null => false
t.binary "param_list", :null => false
t.binary "returns", :limit => 2147483647, :null => false
t.binary "body", :limit => 2147483647, :null => false
t.string "definer", :limit => 77, :default => "", :null => false
t.timestamp "created", :null => false
t.timestamp "modified", :null => false
t.string "sql_mode", :limit => 0, :default => "", :null => false
t.text "comment", :null => false
t.string "character_set_client", :limit => 32
t.string "collation_connection", :limit => 32
t.string "db_collation", :limit => 32
t.binary "body_utf8", :limit => 2147483647
end
create_table "procs_priv", :id => false, :force => true do |t|
t.string "Host", :limit => 60, :default => "", :null => false
t.string "Db", :limit => 64, :default => "", :null => false
t.string "User", :limit => 16, :default => "", :null => false
t.string "Routine_name", :limit => 64, :default => "", :null => false
t.string "Routine_type", :limit => 9, :null => false
t.string "Grantor", :limit => 77, :default => "", :null => false
t.string "Proc_priv", :limit => 0, :default => "", :null => false
t.timestamp "Timestamp", :null => false
end
add_index "procs_priv", ["Grantor"], :name => "Grantor"
create_table "project_infos", :force => true do |t|
t.integer "project_id"
t.integer "user_id"
@ -1253,6 +1430,18 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true
add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id"
create_table "proxies_priv", :id => false, :force => true do |t|
t.string "Host", :limit => 60, :default => "", :null => false
t.string "User", :limit => 16, :default => "", :null => false
t.string "Proxied_host", :limit => 60, :default => "", :null => false
t.string "Proxied_user", :limit => 16, :default => "", :null => false
t.boolean "With_grant", :default => false, :null => false
t.string "Grantor", :limit => 77, :default => "", :null => false
t.timestamp "Timestamp", :null => false
end
add_index "proxies_priv", ["Grantor"], :name => "Grantor"
create_table "queries", :force => true do |t|
t.integer "project_id"
t.string "name", :default => "", :null => false
@ -1366,6 +1555,17 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
t.integer "is_teacher_score", :default => 0
end
create_table "servers", :primary_key => "Server_name", :force => true do |t|
t.string "Host", :limit => 64, :default => "", :null => false
t.string "Db", :limit => 64, :default => "", :null => false
t.string "Username", :limit => 64, :default => "", :null => false
t.string "Password", :limit => 64, :default => "", :null => false
t.integer "Port", :default => 0, :null => false
t.string "Socket", :limit => 64, :default => "", :null => false
t.string "Wrapper", :limit => 64, :default => "", :null => false
t.string "Owner", :limit => 64, :default => "", :null => false
end
create_table "settings", :force => true do |t|
t.string "name", :default => "", :null => false
t.text "value"
@ -1386,6 +1586,20 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
t.string "description"
end
create_table "slow_log", :id => false, :force => true do |t|
t.timestamp "start_time", :null => false
t.text "user_host", :limit => 16777215, :null => false
t.time "query_time", :null => false
t.time "lock_time", :null => false
t.integer "rows_sent", :null => false
t.integer "rows_examined", :null => false
t.string "db", :limit => 512, :null => false
t.integer "last_insert_id", :null => false
t.integer "insert_id", :null => false
t.integer "server_id", :null => false
t.text "sql_text", :limit => 16777215, :null => false
end
create_table "softapplications", :force => true do |t|
t.string "name"
t.text "description"
@ -1467,6 +1681,19 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
t.string "subject"
end
create_table "tables_priv", :id => false, :force => true do |t|
t.string "Host", :limit => 60, :default => "", :null => false
t.string "Db", :limit => 64, :default => "", :null => false
t.string "User", :limit => 16, :default => "", :null => false
t.string "Table_name", :limit => 64, :default => "", :null => false
t.string "Grantor", :limit => 77, :default => "", :null => false
t.timestamp "Timestamp", :null => false
t.string "Table_priv", :limit => 0, :default => "", :null => false
t.string "Column_priv", :limit => 0, :default => "", :null => false
end
add_index "tables_priv", ["Grantor"], :name => "Grantor"
create_table "taggings", :force => true do |t|
t.integer "tag_id"
t.integer "taggable_id"
@ -1516,6 +1743,32 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
add_index "time_entries", ["project_id"], :name => "time_entries_project_id"
add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id"
create_table "time_zone", :primary_key => "Time_zone_id", :force => true do |t|
t.string "Use_leap_seconds", :limit => 1, :default => "N", :null => false
end
create_table "time_zone_leap_second", :primary_key => "Transition_time", :force => true do |t|
t.integer "Correction", :null => false
end
create_table "time_zone_name", :primary_key => "Name", :force => true do |t|
t.integer "Time_zone_id", :null => false
end
create_table "time_zone_transition", :id => false, :force => true do |t|
t.integer "Time_zone_id", :null => false
t.integer "Transition_time", :limit => 8, :null => false
t.integer "Transition_type_id", :null => false
end
create_table "time_zone_transition_type", :id => false, :force => true do |t|
t.integer "Time_zone_id", :null => false
t.integer "Transition_type_id", :null => false
t.integer "Offset", :default => 0, :null => false
t.integer "Is_DST", :limit => 1, :default => 0, :null => false
t.string "Abbreviation", :limit => 8, :default => "", :null => false
end
create_table "tokens", :force => true do |t|
t.integer "user_id", :default => 0, :null => false
t.string "action", :limit => 30, :default => "", :null => false
@ -1534,6 +1787,51 @@ ActiveRecord::Schema.define(:version => 20151110011003) do
t.integer "fields_bits", :default => 0
end
create_table "user", :id => false, :force => true do |t|
t.string "Host", :limit => 60, :default => "", :null => false
t.string "User", :limit => 16, :default => "", :null => false
t.string "Password", :limit => 41, :default => "", :null => false
t.string "Select_priv", :limit => 1, :default => "N", :null => false
t.string "Insert_priv", :limit => 1, :default => "N", :null => false
t.string "Update_priv", :limit => 1, :default => "N", :null => false
t.string "Delete_priv", :limit => 1, :default => "N", :null => false
t.string "Create_priv", :limit => 1, :default => "N", :null => false
t.string "Drop_priv", :limit => 1, :default => "N", :null => false
t.string "Reload_priv", :limit => 1, :default => "N", :null => false
t.string "Shutdown_priv", :limit => 1, :default => "N", :null => false
t.string "Process_priv", :limit => 1, :default => "N", :null => false
t.string "File_priv", :limit => 1, :default => "N", :null => false
t.string "Grant_priv", :limit => 1, :default => "N", :null => false
t.string "References_priv", :limit => 1, :default => "N", :null => false
t.string "Index_priv", :limit => 1, :default => "N", :null => false
t.string "Alter_priv", :limit => 1, :default => "N", :null => false
t.string "Show_db_priv", :limit => 1, :default => "N", :null => false
t.string "Super_priv", :limit => 1, :default => "N", :null => false
t.string "Create_tmp_table_priv", :limit => 1, :default => "N", :null => false
t.string "Lock_tables_priv", :limit => 1, :default => "N", :null => false
t.string "Execute_priv", :limit => 1, :default => "N", :null => false
t.string "Repl_slave_priv", :limit => 1, :default => "N", :null => false
t.string "Repl_client_priv", :limit => 1, :default => "N", :null => false
t.string "Create_view_priv", :limit => 1, :default => "N", :null => false
t.string "Show_view_priv", :limit => 1, :default => "N", :null => false
t.string "Create_routine_priv", :limit => 1, :default => "N", :null => false
t.string "Alter_routine_priv", :limit => 1, :default => "N", :null => false
t.string "Create_user_priv", :limit => 1, :default => "N", :null => false
t.string "Event_priv", :limit => 1, :default => "N", :null => false
t.string "Trigger_priv", :limit => 1, :default => "N", :null => false
t.string "Create_tablespace_priv", :limit => 1, :default => "N", :null => false
t.string "ssl_type", :limit => 9, :default => "", :null => false
t.binary "ssl_cipher", :null => false
t.binary "x509_issuer", :null => false
t.binary "x509_subject", :null => false
t.integer "max_questions", :default => 0, :null => false
t.integer "max_updates", :default => 0, :null => false
t.integer "max_connections", :default => 0, :null => false
t.integer "max_user_connections", :default => 0, :null => false
t.string "plugin", :limit => 64, :default => ""
t.text "authentication_string"
end
create_table "user_activities", :force => true do |t|
t.string "act_type"
t.integer "act_id"

View File

@ -2,10 +2,20 @@
function course_setting(id)
{
//alert(id);
$('#tb_'+id).removeClass().addClass("hwork_hovertab");
$('#tbc_0'+id).removeClass().addClass("dis");
$('#tb_'+(3-id)).removeClass().addClass("hwork_normaltab");
$('#tbc_0'+(3-id)).removeClass().addClass("undis");
//$('#tb_'+id).removeClass().addClass("hwork_hovertab");
//$('#tbc_0'+id).removeClass().addClass("dis");
//$('#tb_'+(3-id)).removeClass().addClass("hwork_normaltab");
//$('#tbc_0'+(3-id)).removeClass().addClass("undis");
for (var i = 1; i < 4; i++) {
if (i == id) {
$("#tb_" + i).removeClass().addClass("hwork_hovertab");
$("#tbc_0" + i).removeClass().addClass("dis");
}
else {
$("#tb_" + i).removeClass().addClass("hwork_normaltab");
$("#tbc_0" + i).removeClass().addClass("undis");
}
}
}
$(function(){

View File

@ -526,4 +526,18 @@ function jsCopy2(id){
function zip(){
alert("该功能正在紧张的开发中,我们会争取在最短时间内上线,如若对您工作造成不便敬请谅解!")
}
//取消关联
function cancel_relation(orgId,projectId){
$.ajax({
url:'/org_projects/'+orgId+"?project_id="+projectId,
type:'DELETE',
success:function(data) {
$.ajax({
url: ' /projects/'+projectId+'/search_public_orgs_not_in_project',
type:'get'
});
}
});
}

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe OrgCoursesController, :type => :controller do
end