修复主页跳转

去除老师删除项目型作业,优化代码
exceptionHandle
z9hang 11 years ago
parent 09eae52fc1
commit 0385013905

@ -276,10 +276,18 @@ class AccountController < ApplicationController
set_autologin_cookie(user) set_autologin_cookie(user)
end end
call_hook(:controller_account_success_authentication_after, {:user => user }) call_hook(:controller_account_success_authentication_after, {:user => user })
#by young
# redirect_back_or_default my_page_path code = /\d*/
redirect_back_or_default User.current #根据home_url生产正则表达式
# redirect_to User.current 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 end
def set_autologin_cookie(user) def set_autologin_cookie(user)

@ -18,6 +18,8 @@ class BidsController < ApplicationController
helper :attachments helper :attachments
include AttachmentsHelper include AttachmentsHelper
include ApplicationHelper include ApplicationHelper
include BidsHelper
helper :projects helper :projects
helper :words helper :words
helper :welcome helper :welcome
@ -503,10 +505,12 @@ class BidsController < ApplicationController
#删除已提交的项目作业(不删项目) #删除已提交的项目作业(不删项目)
def delete def delete
binding_project = params[:binding_project] binding_project = params[:binding_project]
if BidingProject.delete(binding_project) if can_delete_project_homework(BidingProject.find(binding_project),User.current)
redirect_to project_for_bid_path if BidingProject.delete(binding_project)
else redirect_to project_for_bid_path
redirect_to 403; else
redirect_to 403;
end
end end
end end
## 新建留言 ## 新建留言

@ -151,4 +151,8 @@ module BidsHelper
tmp tmp
end end
def can_delete_project_homework bind_project,current_user
current_user.id == bind_project.user.id || current_user.admin
end
end end

@ -154,9 +154,9 @@
<% end %> <% end %>
</td> </td>
<td align="right"> <td align="right">
<% 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 %> <% end %>
</td> </td>
</tr> </tr>

Loading…
Cancel
Save