diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index cf39898fe..af8487868 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -276,10 +276,18 @@ class AccountController < ApplicationController set_autologin_cookie(user) end call_hook(:controller_account_success_authentication_after, {:user => user }) - #by young -# redirect_back_or_default my_page_path - redirect_back_or_default User.current -# redirect_to User.current + + code = /\d*/ + #根据home_url生产正则表达式 + eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/") + if code=~params[:back_url] + redirect_to user_activities_path(user) + else + #by young + #redirect_back_or_default my_page_path + redirect_back_or_default User.current + #redirect_to User.current + end end def set_autologin_cookie(user) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 206421e5d..1ae04fa08 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -18,6 +18,8 @@ class BidsController < ApplicationController helper :attachments include AttachmentsHelper include ApplicationHelper + include BidsHelper + helper :projects helper :words helper :welcome @@ -503,10 +505,12 @@ class BidsController < ApplicationController #删除已提交的项目作业(不删项目) def delete binding_project = params[:binding_project] - if BidingProject.delete(binding_project) - redirect_to project_for_bid_path - else - redirect_to 403; + if can_delete_project_homework(BidingProject.find(binding_project),User.current) + if BidingProject.delete(binding_project) + redirect_to project_for_bid_path + else + redirect_to 403; + end end end ## 新建留言 diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb index bd39d6c28..38b32e692 100644 --- a/app/helpers/bids_helper.rb +++ b/app/helpers/bids_helper.rb @@ -151,4 +151,8 @@ module BidsHelper tmp end + def can_delete_project_homework bind_project,current_user + current_user.id == bind_project.user.id || current_user.admin + end + end \ No newline at end of file diff --git a/app/views/bids/_list_projects.html.erb b/app/views/bids/_list_projects.html.erb index e51314c48..ce24a4457 100644 --- a/app/views/bids/_list_projects.html.erb +++ b/app/views/bids/_list_projects.html.erb @@ -154,9 +154,9 @@ <% end %>