首页增加加入课程按钮,用户可以输入课程ID以及课程密码加入对应的课程,已过期课程会给出对应提示

This commit is contained in:
sw 2014-10-16 10:56:13 +08:00
parent 7729a2739f
commit 4c41c10e0d
7 changed files with 81 additions and 4 deletions

View File

@ -14,7 +14,7 @@ class CoursesController < ApplicationController
menu_item l(:label_sort_by_influence), :only => :index menu_item l(:label_sort_by_influence), :only => :index
before_filter :can_show_course, :except => [] 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, :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 :authorize_course_global, :only => [:view_homework_attaches, :new,:create]
before_filter :require_admin, :only => [:copy, :archive, :unarchive, :destroy, :calendar] before_filter :require_admin, :only => [:copy, :archive, :unarchive, :destroy, :calendar]
@ -60,6 +60,14 @@ class CoursesController < ApplicationController
end end
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 def update
@course.safe_attributes = params[:course] @course.safe_attributes = params[:course]

View File

@ -0,0 +1,59 @@
<!-- added by fq -->
<style>
input[type="submit"].bid_btn {
vertical-align: middle;
width: 60px;/*modified by ming*/
height: 25px;
line-height: 19px;
font-size: 14px;
color: rgb(0, 0, 0);
background: buttonface;/*url("/images/button/bg103.jpg") no-repeat scroll left top transparent;*/
padding: 0px 0px 4px 0px;
border-radius: 2px;
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
/*margin-top: -10px;*/
/*margin-right: -4px;*/
}
input[type="button"].bid_btn {
width: 60px;/*modified by ming*/
height: 25px;
line-height: 19px;
font-size: 14px;
color: rgb(0, 0, 0);
background: buttonface;/*url("/images/button/bg103.jpg") no-repeat scroll left top transparent;*/
padding: 0px 0px 4px 0px;
border-radius: 2px;
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
/*margin-top: -10px;*/
margin-right: -2px;
}
textarea:focus {
border: #d5dee9 1px solid;
}
</style>
<h3 class="title">请输入课程密码</h3>
<%= form_tag({:controller => 'courses',
:action => 'join'},
:remote => true,
:method => :post,
:id => 'new-watcher-form') do %>
<div>
<span>课程ID</span>
<%= text_field_tag 'object_id', nil, :style=>'width:80%'%>
</div>
<div>
<span>密码:</span>
<%= text_field_tag 'course_password', nil, :style=>'width:80%'%>
</div>
<p class="buttons" style="padding-top: 10px; padding-bottom: 1px; margin-bottom: 1px">
<%= 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' %>
</p>
<% end %>

View File

@ -0,0 +1,3 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'join_private_course') %>');
showModal('ajax-modal', '400px');
$('#ajax-modal').addClass('new-watcher');

View File

@ -80,9 +80,9 @@
<% else %> <% else %>
<%= join_in_course(@course, User.current) %> <%= join_in_course(@course, User.current) %>
<% end %> <% end %>
<% unless User.current.member_of_course?(@course) %> <%# unless User.current.member_of_course?(@course) %>
<!-- <%#= image_tag "/images/fav.png" %> --> <!-- <%#= image_tag "/images/fav.png" %> -->
<% end %> <%# end %>
<% end %> <% end %>
</div> </div>
</td> </td>

View File

@ -56,6 +56,7 @@
<p class="buttons" style="padding-top: 10px; padding-bottom: 1px; margin-bottom: 1px"> <p class="buttons" style="padding-top: 10px; padding-bottom: 1px; margin-bottom: 1px">
<%= submit_tag l(:label_new_join), :name => nil, :class => "bid_btn", :onclick => "hideModal(this);" %> <%= 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' %> <%= submit_tag l(:button_cancel), :name => nil, :class => "bid_btn", :onclick => "hideModal(this);", :type => 'button' %>
</p>
</td> </td>
</tr></table> </tr></table>
<% end %> <% end %>

View File

@ -127,6 +127,8 @@
<strong><%= l(:label_issue_feedback_activities)%></strong> <strong><%= l(:label_issue_feedback_activities)%></strong>
<%= link_to l(:label_my_question), newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE"} %> <%= 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 l(:label_my_feedback), suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE"} %>
<!-- 加入课程按钮 -->
<%#= link_to "加入私有课程", join_private_courses_courses_path ,:remote => true %>
</h3> </h3>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", forums_path %></span> <span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", forums_path %></span>

View File

@ -31,7 +31,6 @@ RedmineApp::Application.routes.draw do
#match '/contests/:id/contestnotifications', :controller => 'contestnotifications', :action => 'index' #match '/contests/:id/contestnotifications', :controller => 'contestnotifications', :action => 'index'
resources :homework_users resources :homework_users
resources :no_uses resources :no_uses
delete 'no_uses', :to => 'no_uses#delete' delete 'no_uses', :to => 'no_uses#delete'
@ -626,7 +625,12 @@ RedmineApp::Application.routes.draw do
get 'member', :controller => 'courses', :action => 'member', :as => 'member' get 'member', :controller => 'courses', :action => 'member', :as => 'member'
post 'finishcourse' post 'finishcourse'
post 'restartcourse' post 'restartcourse'
end end
collection do
match 'join_private_courses', :via => [:get, :post]
end
match '/member', :to => 'courses#member', :as => 'member', :via => :get match '/member', :to => 'courses#member', :as => 'member', :via => :get
resources :boards resources :boards
resources :files, :only => [:index, :new, :create] do resources :files, :only => [:index, :new, :create] do