diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 795aaa872..b08d5beb8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -23,12 +23,14 @@ class UsersController < ApplicationController menu_item :requirement_focus, :only => :watch_bids menu_item :user_newfeedback, :only => :user_newfeedback menu_item :user_course, :only => :user_courses + menu_item :user_homework, :onlu => :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,:update, :user_courses] + before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks] #edit has been deleted by huang, 2013-9-23 - before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, + before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info] accept_api_auth :index, :show, :create, :update, :destroy,:tag_save @@ -122,6 +124,29 @@ class UsersController < ApplicationController end # end + # added by huang + def user_homeworks + @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 + @bid = @bid.group_by {|bid| bid.courses.first.id} + #add by huang + unless User.current.admin? + if !@user.active? + render_404 + return + end + end + end + # added by fq def user_courses case params[:type] diff --git a/app/views/users/user_courses.html.erb b/app/views/users/user_courses.html.erb index adab06489..46f10d378 100644 --- a/app/views/users/user_courses.html.erb +++ b/app/views/users/user_courses.html.erb @@ -5,4 +5,3 @@ <% else %> <%= render :partial => 'my_joinedcourse' %> <% end %> -