diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 01945358d..ef9204f04 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -14,7 +14,7 @@ class CoursesController < ApplicationController menu_item l(:label_sort_by_influence), :only => :index before_filter :can_show_course, :except => [] - before_filter :find_course, :except => [ :index, :search,:list, :new,:join,:unjoin, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches] + before_filter :find_course, :except => [ :index, :search,:list, :new,:join,:unjoin, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_private_courses] before_filter :authorize_course, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course] before_filter :authorize_course_global, :only => [:view_homework_attaches, :new,:create] before_filter :require_admin, :only => [:copy, :archive, :unarchive, :destroy, :calendar] @@ -60,6 +60,14 @@ class CoursesController < ApplicationController end end + def join_private_courses + + respond_to do |format| + # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} + format.js + end + end + #更新课程信息 def update @course.safe_attributes = params[:course] diff --git a/app/views/courses/_join_private_course.html.erb b/app/views/courses/_join_private_course.html.erb new file mode 100644 index 000000000..2c616027e --- /dev/null +++ b/app/views/courses/_join_private_course.html.erb @@ -0,0 +1,59 @@ + + + +

请输入课程密码

+ +<%= form_tag({:controller => 'courses', + :action => 'join'}, + :remote => true, + :method => :post, + :id => 'new-watcher-form') do %> +
+ 课程ID: + <%= text_field_tag 'object_id', nil, :style=>'width:80%'%> +
+
+ 密码: + <%= text_field_tag 'course_password', nil, :style=>'width:80%'%> +
+ +

+ <%= submit_tag l(:label_new_join), :name => nil, :class => "bid_btn", :onclick => "hideModal(this);" %> + <%= submit_tag l(:button_cancel), :name => nil, :class => "bid_btn", :onclick => "hideModal(this);", :type => 'button' %> +

+<% end %> diff --git a/app/views/courses/join_private_courses.js.erb b/app/views/courses/join_private_courses.js.erb new file mode 100644 index 000000000..71c7e62b7 --- /dev/null +++ b/app/views/courses/join_private_courses.js.erb @@ -0,0 +1,3 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'join_private_course') %>'); +showModal('ajax-modal', '400px'); +$('#ajax-modal').addClass('new-watcher'); \ No newline at end of file diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 91ab68fdf..305e09abe 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -80,9 +80,9 @@ <% else %> <%= join_in_course(@course, User.current) %> <% end %> - <% unless User.current.member_of_course?(@course) %> + <%# unless User.current.member_of_course?(@course) %> - <% end %> + <%# end %> <% end %> diff --git a/app/views/projects/_new_join.html.erb b/app/views/projects/_new_join.html.erb index cc83ac80d..e74ddeba0 100644 --- a/app/views/projects/_new_join.html.erb +++ b/app/views/projects/_new_join.html.erb @@ -56,6 +56,7 @@

<%= submit_tag l(:label_new_join), :name => nil, :class => "bid_btn", :onclick => "hideModal(this);" %> <%= submit_tag l(:button_cancel), :name => nil, :class => "bid_btn", :onclick => "hideModal(this);", :type => 'button' %> +

<% end %> diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index ea8963f7e..b3c1341a4 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -127,6 +127,8 @@ <%= l(:label_issue_feedback_activities)%> <%= link_to l(:label_my_question), newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE"} %> <%= link_to l(:label_my_feedback), suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE"} %> + + <%#= link_to "加入私有课程", join_private_courses_courses_path ,:remote => true %> <%= link_to "更多>>", forums_path %> diff --git a/config/routes.rb b/config/routes.rb index dedf15dfe..f67e63419 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -31,7 +31,6 @@ RedmineApp::Application.routes.draw do #match '/contests/:id/contestnotifications', :controller => 'contestnotifications', :action => 'index' resources :homework_users - resources :no_uses delete 'no_uses', :to => 'no_uses#delete' @@ -626,7 +625,12 @@ RedmineApp::Application.routes.draw do get 'member', :controller => 'courses', :action => 'member', :as => 'member' post 'finishcourse' post 'restartcourse' + end + collection do + match 'join_private_courses', :via => [:get, :post] + end + match '/member', :to => 'courses#member', :as => 'member', :via => :get resources :boards resources :files, :only => [:index, :new, :create] do