From 03850139051be65f1a7a4d0f4167e8c868820c18 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 15 May 2014 19:16:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=BB=E9=A1=B5=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=20=E5=8E=BB=E9=99=A4=E8=80=81=E5=B8=88=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E9=A1=B9=E7=9B=AE=E5=9E=8B=E4=BD=9C=E4=B8=9A=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 16 ++++++++++++---- app/controllers/bids_controller.rb | 12 ++++++++---- app/helpers/bids_helper.rb | 4 ++++ app/views/bids/_list_projects.html.erb | 4 ++-- 4 files changed, 26 insertions(+), 10 deletions(-) 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 %> - <% if b_project.user.id == User.current.id || User.current.id == b_project.bid.author.id + <% if can_delete_project_homework b_project,User.current %> - <%= link_to image_tag('delete.png'),{ :action => "delete", :binding_project => b_project}, :confirm => "Are you sure?" %> + <%= link_to image_tag('delete.png'),{ :action => "delete", :binding_project => b_project}, :confirm => l(:text_are_you_sure) %> <% end %>