From 47e3e93a2f65b81ca9dccd1431089cf9f71d8111 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 27 May 2015 19:37:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?cookies=20=E5=88=A0=E9=99=A4=E4=B9=9F?= =?UTF-8?q?=E9=9C=80=E8=A6=81domain?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 2 +- app/controllers/application_controller.rb | 2 +- config/configuration.yml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 75be302cd..dc1cceb87 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -336,7 +336,7 @@ class AccountController < ApplicationController :expires => 1.month.from_now, :path => (Redmine::Configuration['autologin_cookie_path'] || '/'), :secure => (Redmine::Configuration['autologin_cookie_secure'] ? true : false), - :domain => '.trustie.net', + :domain => Redmine::Configuration['cookie_domain'], :httponly => true } cookies[autologin_cookie_name] = cookie_options diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0dc86fb01..02b2f0d1d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -199,7 +199,7 @@ class ApplicationController < ActionController::Base # Logs out current user def logout_user if User.current.logged? - cookies.delete(autologin_cookie_name) + cookies.delete(autologin_cookie_name, domain: Redmine::Configuration['cookie_domain']) # Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin']) self.logged_user = nil end diff --git a/config/configuration.yml b/config/configuration.yml index 87a54a976..45e307157 100644 --- a/config/configuration.yml +++ b/config/configuration.yml @@ -90,6 +90,7 @@ default: user_name: "huang.jingquan@163.com" password: 'xinhu1ji2qu366' + cookie_domain: ".trustie.net" # Absolute path to the directory where attachments are stored. # The default is the 'files' directory in your Redmine instance. # Your Redmine instance needs to have write permission on this From 1fe49c8cb14030fb74c8648e6a3a8c2e4bb9b4d3 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 27 May 2015 19:38:19 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 5 ++- app/views/courses/homework.html.erb | 5 ++- app/views/users/user_homeworks.html.erb | 2 +- config/locales/en.yml | 1 + config/locales/zh.yml | 1 + config/routes.rb | 2 +- spec/requests/homework_request_spec.rb | 52 +++++++++++++++++++++++++ 7 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 spec/requests/homework_request_spec.rb diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index c98df27d3..35236414f 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -675,11 +675,12 @@ class BidsController < ApplicationController #删除作业 #by xianbo def homework_destroy - @bid_to_destroy = Bid.find params[:course_id] + @bid_to_destroy = Bid.find params[:id] + course_url = course_homework_path(@bid_to_destroy.courses.first) (render_403; return false) unless User.current.admin?||User.current.id==@bid_to_destroy.author_id @bid_to_destroy.destroy respond_to do |format| - format.html { redirect_to :back } + format.html { redirect_to course_url } format.js #format.api { render_api_ok } end diff --git a/app/views/courses/homework.html.erb b/app/views/courses/homework.html.erb index f7cf2a360..7b74351cd 100644 --- a/app/views/courses/homework.html.erb +++ b/app/views/courses/homework.html.erb @@ -21,6 +21,9 @@
<%= l(:lebel_homework_commit)%> ( <%= link_to bid.homeworks.count, course_for_bid_path(bid.id), :class => 'c_red'%> )
<% if @is_teacher%> <%= bid_anonymous_comment(bid)%> + <% if bid.homeworks.empty? %> + <%= link_to(l(:button_delete),bids_homework_path(:id => bid.id), :method => :delete, :confirm => l(:label_delete_confirm), :class => "fr mr10 work_edit") %> + <% end %> <%= link_to(l(:button_edit),edit_bid_path(:course_id =>@course.id, :bid_id => bid.id), :class => "fr mr10 work_edit") %> <% elsif @is_student%> <%= student_anonymous_comment bid %> @@ -59,4 +62,4 @@