diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 8011b238b..8d5ef1a67 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1,4 +1,4 @@ -class CourseController < ApplicationController +class CoursesController < ApplicationController before_filter :require_login, :only => [:join, :unjoin] diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 5908c5940..2769b4736 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -355,7 +355,7 @@ class ProjectsController < ApplicationController redirect_to new_project_path(:course => '1') #Ended by young else - redirect_to settings_project_path(@project, :course => @course_tag) + redirect_to settings_project_path(@project) end } format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) } @@ -430,7 +430,8 @@ class ProjectsController < ApplicationController "show_issues" => true, "show_files" => true, "show_documents" => true, - "show_messages" => true + "show_messages" => true, + "show_bids" => true } @date_to ||= Date.today + 1 @date_from = @date_to - @days @@ -483,7 +484,7 @@ class ProjectsController < ApplicationController #Added by young # @course_tag = params[:course] # if @course_tag == '1' - if @project.project_type + if @project.project_type == 1 render :layout => 'base_courses' end #Ended by young diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index fa8879921..20246bc45 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -22,11 +22,12 @@ class UsersController < ApplicationController menu_item :user_project, :only => :user_projects menu_item :requirement_focus, :only => :watch_bids menu_item :user_newfeedback, :only => :user_newfeedback + menu_item :user_course, :only => :user_courses #Ended by young - before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist,:edit,:update] - before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, + before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist,:edit,:update, :user_courses] + before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info] accept_api_auth :index, :show, :create, :update, :destroy,:tag_save @@ -117,6 +118,56 @@ class UsersController < ApplicationController end end # end + + # added by fq + def user_courses + case params[:type] + when "1" + @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current)) + + @memberships = [] + @membership.each do |membership| + if membership.project.project_type == 1 + @memberships << membership + end + end + @bid = [] + @memberships.each do |membership| + @bid += membership.project.homeworks + end + @state = 1 + else + @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current)) + + @memberships = [] + @membership.each do |membership| + if membership.project.project_type == 1 + @memberships << membership + end + end + @state = 0 + end + + # events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20) + # @events_by_day = events.group_by(&:event_date) + + # @state = 0 + + #add by huang + unless User.current.admin? + if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?) + render_404 + return + end + end + #end + + # respond_to do |format| + # format.html + # format.api + # end + end + # end # modified by fq def user_newfeedback diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 32c4b6142..3e4700cff 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -90,6 +90,22 @@ module UsersHelper end content_tag('div', content, :class => "pagination") end + + def user_course(state) + content = ''.html_safe + case state + when 0 + s = content_tag('span', '我的课程', :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) + when 1 + s = content_tag('span', '我的作业', :class => "current-page") + content << content_tag('li', link_to('我的课程', {:controller => 'users', :action => 'user_courses'})) + content << content_tag('li', s, :class => "current-page") + end + content_tag('div', content, :class => "pagination") + + end # added by huang def sort_user(state) diff --git a/app/models/bid.rb b/app/models/bid.rb index c79f8fd10..a017cb48b 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -48,7 +48,7 @@ class Bid < ActiveRecord::Base :author => :author, :url => Proc.new {|o| {:controller => 'bids', :action => 'show', :id => o.id}} - acts_as_activity_provider :find_options => {:include => [:author]}, + acts_as_activity_provider :find_options => {:include => [:project, :author]}, :author_key => :author_id diff --git a/app/models/project.rb b/app/models/project.rb index 4e0e4549c..dfdca8a03 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -54,7 +54,7 @@ class Project < ActiveRecord::Base # added by fq has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :homework_for_courses, :dependent => :destroy - has_many :homeworks, :through => :homework_for_courses, :source => :bid + has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy has_many :students_for_courses, :dependent => :destroy has_many :student, :through => :students_for_courses, :source => :user diff --git a/app/views/courses/_set_join.js.erb b/app/views/courses/_set_join.js.erb new file mode 100644 index 000000000..cd6ca1b59 --- /dev/null +++ b/app/views/courses/_set_join.js.erb @@ -0,0 +1,3 @@ + + +$('#join').html('<%= escape_javascript join_in_course(course, user) %>'); diff --git a/app/views/projects/_new_join.html.erb b/app/views/projects/_new_join.html.erb index 244bb95cb..b96ce346c 100644 --- a/app/views/projects/_new_join.html.erb +++ b/app/views/projects/_new_join.html.erb @@ -1,6 +1,6 @@

请输入课程密码

-<%= form_tag({:controller => 'watchers', +<%= form_tag({:controller => 'courses', :action => 'join', :object_id => course.id}, :remote => true, diff --git a/app/views/projects/settings.html.erb b/app/views/projects/settings.html.erb index 02a2388c1..6682ced76 100644 --- a/app/views/projects/settings.html.erb +++ b/app/views/projects/settings.html.erb @@ -1,5 +1,5 @@

<%=l(:label_settings)%>

-<% if @project.project_type %> +<% if @project.project_type == 1 %> <%= render_tabs course_settings_tabs %> <% else %> <%= render_tabs project_settings_tabs %> diff --git a/app/views/users/_my_course.html.erb b/app/views/users/_my_course.html.erb new file mode 100644 index 000000000..c735859bb --- /dev/null +++ b/app/views/users/_my_course.html.erb @@ -0,0 +1,42 @@ +
+<% unless @memberships.empty? %> + +<% else %> +<% if @user != User.current %> +

<%= l(:label_project_un) %>

+<% else %> +

<%= l(:label_project_unadd) %><%= link_to"#{l(:label_new)}",:controller=>'projects',:action=>'new'%>

+<% end %> + +<% end %> +<%= call_hook :view_account_left_bottom, :user => @user %> +
diff --git a/app/views/users/_my_homework.html.erb b/app/views/users/_my_homework.html.erb new file mode 100644 index 000000000..3be7e0e2a --- /dev/null +++ b/app/views/users/_my_homework.html.erb @@ -0,0 +1,56 @@ + +<% if @bid.size > 0%> + +<% for bid in @bid%> + + + + + + +
<%= link_to image_tag(url_to_avatar(bid.author), :class => 'avatar'),user_path(bid.author), :class => "avatar" %> + + + + + + + + + + + +
<%= link_to(bid.author, user_path(bid.author), :class => 'bid_user') %>: <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %>
+ + + + + +
+ <% if bid.reward_type.nil? or bid.reward_type == 1%> + <%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %><%= bid.budget%> + <% elsif bid.reward_type == 2%> + <%= l(:label_bids_reward_method) %><%= bid.budget%> + <% else %> + <%= l(:label_bids_reward_method) %><%= l(:label_bids_credit) %> <%= bid.budget%> <%= l(:label_bids_credit_number) %> + <% end %> + + +
+ <%= l(:label_biding_project) %>(<%=link_to bid.biding_projects.count, project_for_bid_path(bid) %>) + <%= l(:label_responses) %>(<%=link_to bid.commit, respond_path(bid) %>) + <%= l(:label_followers) %>(<%=link_to bid.watcher_users.count, respond_path(bid) %>) +
<%= format_time bid.created_on %>
+
+ + + + +
<%= bid.description%>
+
+ +<% end %> + +<% else %> +

暂无任何作业

+<% end %> \ No newline at end of file diff --git a/app/views/users/user_courses.html.erb b/app/views/users/user_courses.html.erb new file mode 100644 index 000000000..8124468da --- /dev/null +++ b/app/views/users/user_courses.html.erb @@ -0,0 +1,10 @@ + + +<%= user_course @state%> + +<% if @state == 0%> +<%= render :partial => 'my_course' %> +<% else %> +<%= render :partial => 'my_homework' %> +<% end %> + diff --git a/config/routes.rb b/config/routes.rb index 282a36ddc..b79a490db 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -89,6 +89,7 @@ RedmineApp::Application.routes.draw do match 'info', :to => 'users#info', :via => [:get , :post], :as => 'user_info' match 'user_watchlist', :to => 'users#user_watchlist', :via => :get, :as => "user_watchlist" #add by huang match 'user_fanslist', :to => 'users#user_fanslist', :via => :get, :as => "user_fanslist" #add by huang + match 'user_courses', :to => 'users#user_courses', :via => :get end end match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback" diff --git a/lib/redmine.rb b/lib/redmine.rb index 59c6e6d94..1f6cacd2d 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -279,6 +279,7 @@ end Redmine::MenuManager.map :user_menu do |menu| menu.push :activity, {:controller => 'users', :action => 'show' } menu.push :user_project, {:controller => 'users', :action => 'user_projects'} + menu.push :user_course, {:controller => 'users', :action => 'user_courses'} menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'} menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback'}