From 49d836d3314ac2c3a445818e124b2f66d5908c64 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 15 May 2015 23:47:22 +0800 Subject: [PATCH 01/56] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=A4=B4=E5=83=8F?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=92=8C=E5=9B=BE=E7=89=87=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=9C=A8=E5=90=8E=E5=8F=B0=E5=8A=A0=E5=85=A5=E9=99=90=E5=88=B6?= =?UTF-8?q?,=E4=B8=94=E9=80=9A=E8=BF=87=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/avatar_controller.rb | 64 +++++++++++++++----------- config/locales/en.yml | 1 + config/locales/zh.yml | 1 + lib/trustie/utils/image.rb | 28 ++++++++++- public/javascripts/jq-upload/upload.js | 15 ++++-- spec/requests/course_request_spec.rb | 42 ++++++++++++++++- 6 files changed, 118 insertions(+), 33 deletions(-) diff --git a/app/controllers/avatar_controller.rb b/app/controllers/avatar_controller.rb index ef7cdf2f7..afd206c92 100644 --- a/app/controllers/avatar_controller.rb +++ b/app/controllers/avatar_controller.rb @@ -1,9 +1,9 @@ class AvatarController < ApplicationController - - + + include ActionView::Helpers::NumberHelper #before_filter :set_cache_buster include AvatarHelper - + def upload # Make sure that API users get used to set this content type # as it won't trigger Rails' automatic parsing of the request body for parameters @@ -29,43 +29,51 @@ class AvatarController < ApplicationController end if @temp_file && (@temp_file.size > 0) - diskfile=disk_filename(@source_type,@source_id) - @urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file)) + if @temp_file.size > Setting.upload_avatar_max_size.to_i + @status = 1 + @msg = l(:error_upload_avatar_to_large, :max_size => number_to_human_size(Setting.upload_avatar_max_size.to_i)) + elsif Trustie::Utils::Image.new(@temp_file.tempfile.path).image? + diskfile=disk_filename(@source_type,@source_id) + @urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file)) - # 用户头像上传时进行特别处理 - if @source_type == 'User' + # 用户头像上传时进行特别处理 + if @source_type == 'User' diskfile += "temp" @urlfile += "temp" - end + end - logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)") - path = File.dirname(diskfile) - unless File.directory?(path) - FileUtils.mkdir_p(path) - end - md5 = Digest::MD5.new - File.open(diskfile, "wb") do |f| - if @temp_file.respond_to?(:read) - buffer = "" - while (buffer = @temp_file.read(8192)) - f.write(buffer) - md5.update(buffer) + logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)") + path = File.dirname(diskfile) + unless File.directory?(path) + FileUtils.mkdir_p(path) + end + md5 = Digest::MD5.new + File.open(diskfile, "wb") do |f| + if @temp_file.respond_to?(:read) + buffer = "" + while (buffer = @temp_file.read(8192)) + f.write(buffer) + md5.update(buffer) + end + else + f.write(@temp_file) + md5.update(@temp_file) end - else - f.write(@temp_file) - md5.update(@temp_file) end + + Trustie::Utils::Image.new(diskfile,true).compress(300) + @status = 0 + @msg = '' + else + @status = 2 + @msg = l(:not_valid_image_file) end -# self.digest = md5.hexdigest end @temp_file = nil - image = Trustie::Utils::Image.new(diskfile,true) - image.compress(300) - respond_to do |format| format.json{ - render :inline => "#{@urlfile.to_s}?#{Time.now.to_i}",:content_type => 'text/html' + render :inline => {status: @status, message:@msg, url:"#{@urlfile.to_s}?#{Time.now.to_i}"}.to_json,:content_type => 'text/html' return } format.js diff --git a/config/locales/en.yml b/config/locales/en.yml index 8989ae36a..844818ae4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1521,4 +1521,5 @@ en: label_commit_failed: commit failed #api end error_upload_avatar_to_large: "too big (%{max_size})" + not_valid_image_file: not a valid image file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 5fcb1fb5c..a91faac0f 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1984,3 +1984,4 @@ zh: label_code: 代码 error_upload_avatar_to_large: "超过大小限制 (%{max_size})" + not_valid_image_file: 不是有效的图片文件 diff --git a/lib/trustie/utils/image.rb b/lib/trustie/utils/image.rb index 9178b291a..f4ec328b3 100644 --- a/lib/trustie/utils/image.rb +++ b/lib/trustie/utils/image.rb @@ -3,11 +3,37 @@ module Trustie module Utils class Image - def initialize(file, bak) + def initialize(file, bak=false) @file = file @bak = bak end + def bitmap?(data) + data[0,2]==77.chr + 66.chr + end + + def gif?(data) + data[0,4]==71.chr + 73.chr + 70.chr + 56.chr + end + + def jpeg?(data) + data[0,4]== 0xff.chr + 0xd8.chr + 0xff.chr + 0xe0.chr + end + def png?(data) + data[0,2]==0x89.chr + 80.chr + end + + def image? + begin + f = File.open(@file,'rb') # rb means to read using binary + return false if f.size < 9 + data = f.read(9) # magic numbers are up to 9 bytes + return bitmap?(data) || gif?(data) || jpeg?(data) || png?(data) + ensure + f.close + end + end + def compress(size=300) backup if @bak begin diff --git a/public/javascripts/jq-upload/upload.js b/public/javascripts/jq-upload/upload.js index 985450648..71dbefc32 100644 --- a/public/javascripts/jq-upload/upload.js +++ b/public/javascripts/jq-upload/upload.js @@ -44,9 +44,18 @@ $(function() { }, done: function(e, data) { var imgSpan = jQuery('#avatar_image'); - imgSpan.attr({ - "src": data.result.text ? data.result.text() : data.result - }); + var result = data.result.text ? data.result.text() : data.result; + if(result){ + var o = JSON.parse(result); + if(o.status == 0){ + imgSpan.attr({ + "src": o.url + }); + } else { + alert(o.message); + } + } + } }); }); diff --git a/spec/requests/course_request_spec.rb b/spec/requests/course_request_spec.rb index d58df398e..99e4486b0 100644 --- a/spec/requests/course_request_spec.rb +++ b/spec/requests/course_request_spec.rb @@ -35,13 +35,53 @@ RSpec.describe "课程", :type => :request do context "修改课程图片" do include Rack::Test::Methods let(:avatar) {Rack::Test::UploadedFile.new("#{Rails.root}/spec/fixtures/test.jpg",'image/jpg')} + context "正常图片上传成功" do subject(:resp) {post upload_avatar_path(source_type: 'Course', source_id: course.id, format: :json),"avatar"=>{image: avatar}} it{ expect(subject).to be_ok } it{ expect(subject.body).not_to be_empty } + it "状态要为0" do + o = ActiveSupport::JSON.decode(subject.body) + expect(o["status"]).to eq(0) + end + it "要回传图片地址" do + o = ActiveSupport::JSON.decode(subject.body) + expect(o["url"]).not_to be_empty + end + end + + context "不是图片,上传失败" do + let(:invalid_avatar) {Rack::Test::UploadedFile.new("#{Rails.root}/spec/fixtures/hah.txt",'text/plain')} + before do + resp = post upload_avatar_path(source_type: 'Course', source_id: course.id, format: :json),"avatar"=>{image: invalid_avatar} + @o = ActiveSupport::JSON.decode(resp.body) + end + it "状态要为0" do + expect(@o["status"]).not_to eq(0) + end + it "要回传错误信息" do + expect(@o["message"]).to be_include("图片") + end + end + + context "文件过大,上传失败" do + before do + big_file = Rack::Test::UploadedFile.new("#{Rails.root}/spec/fixtures/test.jpg",'image/jpg') + allow(ActionDispatch::Http::UploadedFile).to receive(:new).and_return(double('BigFile',size: 10*1024*1024, original_filename: 'rais.jpg', tempfile: nil)) + # trace = TracePoint.new(:call) do |tp| + # p [tp.lineno, tp.defined_class, tp.method_id, tp.event] if tp.method_id == :post + # end + resp = post upload_avatar_path(source_type: 'Course', source_id: course.id, format: :json),'avatar[image]'=> big_file + @o = ActiveSupport::JSON.decode(resp.body) + end + it "状态要为0" do + expect(@o["status"]).not_to eq(0) + end + it "要回传错误信息" do + expect(@o["message"]).to be_include("大") + end end - it "不是图片,上传失败" end end From d546069051efe627fa2eb234255dadbb04d3c05e Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 16 May 2015 09:59:14 +0800 Subject: [PATCH 02/56] =?UTF-8?q?spec=20=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/models/forum_observer_spec.rb | 5 ----- spec/models/memo_observer_spec.rb | 5 ----- spec/requests/course_request_spec.rb | 4 ++-- 3 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 spec/models/forum_observer_spec.rb delete mode 100644 spec/models/memo_observer_spec.rb diff --git a/spec/models/forum_observer_spec.rb b/spec/models/forum_observer_spec.rb deleted file mode 100644 index 76d68fafa..000000000 --- a/spec/models/forum_observer_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe ForumObserver do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/memo_observer_spec.rb b/spec/models/memo_observer_spec.rb deleted file mode 100644 index 82603ba7a..000000000 --- a/spec/models/memo_observer_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe MemoObserver do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/requests/course_request_spec.rb b/spec/requests/course_request_spec.rb index 99e4486b0..feca37259 100644 --- a/spec/requests/course_request_spec.rb +++ b/spec/requests/course_request_spec.rb @@ -56,7 +56,7 @@ RSpec.describe "课程", :type => :request do resp = post upload_avatar_path(source_type: 'Course', source_id: course.id, format: :json),"avatar"=>{image: invalid_avatar} @o = ActiveSupport::JSON.decode(resp.body) end - it "状态要为0" do + it "状态不为0" do expect(@o["status"]).not_to eq(0) end it "要回传错误信息" do @@ -74,7 +74,7 @@ RSpec.describe "课程", :type => :request do resp = post upload_avatar_path(source_type: 'Course', source_id: course.id, format: :json),'avatar[image]'=> big_file @o = ActiveSupport::JSON.decode(resp.body) end - it "状态要为0" do + it "状态不为0" do expect(@o["status"]).not_to eq(0) end it "要回传错误信息" do From 9b0602fd9ca506e0d1502951bee9c4383bfd1e96 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Mon, 18 May 2015 17:26:50 +0800 Subject: [PATCH 03/56] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E4=B8=8B=E8=BD=BDspec?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/commons/en.yml | 3 ++- config/locales/commons/zh.yml | 3 ++- spec/factories/attachments.rb | 10 ++++++++ spec/factories/homeworks.rb | 17 ++++++++++++++ spec/factories/users.rb | 8 +++++++ spec/requests/zipdown_request_spec.rb | 34 +++++++++++++++++++++++++++ 6 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 spec/factories/attachments.rb create mode 100644 spec/factories/homeworks.rb diff --git a/config/locales/commons/en.yml b/config/locales/commons/en.yml index 5eb92f07e..c0e29b797 100644 --- a/config/locales/commons/en.yml +++ b/config/locales/commons/en.yml @@ -113,6 +113,7 @@ en: one: "1 error prohibited this %{model} from being saved" other: "%{count} errors prohibited this %{model} from being saved" messages: + record_invalid: "validate error: %{errors}" inclusion: "is not included in the list" exclusion: "is reserved" invalid: "is invalid" @@ -428,4 +429,4 @@ en: previous: "« Previous" next: "Next »" truncate: "..." - \ No newline at end of file + diff --git a/config/locales/commons/zh.yml b/config/locales/commons/zh.yml index 231c5280a..9ba8cba7a 100644 --- a/config/locales/commons/zh.yml +++ b/config/locales/commons/zh.yml @@ -121,6 +121,7 @@ zh: one: "由于发生了一个错误 %{model} 无法保存" other: "%{count} 个错误使得 %{model} 无法保存" messages: + record_invalid: "校验失败: %{errors}" inclusion: "不包含于列表中" exclusion: "是保留关键字" invalid: "是无效的" @@ -435,4 +436,4 @@ zh: last: "末页 »" previous: "« 上一页" next: "下一页 »" - truncate: "..." \ No newline at end of file + truncate: "..." diff --git a/spec/factories/attachments.rb b/spec/factories/attachments.rb new file mode 100644 index 000000000..da8e787ed --- /dev/null +++ b/spec/factories/attachments.rb @@ -0,0 +1,10 @@ +#coding=utf-8 +# +FactoryGirl.define do + factory :attachment do + filename "11.gif" + filesize 296833 + digest "8a74e086d7716f89bc4fbac0606589c7" + disk_directory "2015/05" + end +end diff --git a/spec/factories/homeworks.rb b/spec/factories/homeworks.rb new file mode 100644 index 000000000..208255a8d --- /dev/null +++ b/spec/factories/homeworks.rb @@ -0,0 +1,17 @@ +#coding=utf-8 +# +#:author_id, :budget, :deadline, :name, :description, :homework_type, :password + +FactoryGirl.define do + factory :homework, class: Bid do + name "test homework" + budget 0 + deadline {(Time.now+1.days).strftime('%Y-%m-%d')} + description "description" + homework_type 3 + reward_type 3 + end + + factory :homework_attach, class: HomeworkAttach do + end +end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 2c695b920..4595aacc5 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -6,4 +6,12 @@ FactoryGirl.define do password "foobar111" password_confirmation "foobar111" end + + factory :student, class: User do + login "student" + mail "student@example.com" + password "foobar111" + password_confirmation "foobar111" + end + end diff --git a/spec/requests/zipdown_request_spec.rb b/spec/requests/zipdown_request_spec.rb index eb179f104..72831d26f 100644 --- a/spec/requests/zipdown_request_spec.rb +++ b/spec/requests/zipdown_request_spec.rb @@ -1,6 +1,40 @@ require 'rails_helper' +require 'shared_account_spec' +# "attachments"=>{"1"=>{"filename"=>"11.gif", "description"=>"", "is_public_checkbox"=>"1", "token"=>"33731.8a74e086d7716f89bc4fbac0606589c7"}} RSpec.describe "作业打包下载", :type => :request do + let(:student){FactoryGirl.create(:student)} describe "单独下载某学生作业" do + include_context "create user" + before { + FactoryGirl.create(:user) + shared_login + @homework = FactoryGirl.create(:homework, author_id: current_user.id) + + @attch = HomeworkAttach.new + @attch.bid_id = @homework.id + @attch.user_id = student.id + @attachment = Attachment.new(:file => File.open(File.join(Rails.root, "spec/fixtures/test.jpg"))) + @attachment.author = User.current + @attachment.container_type = 'HomeworkAttach' + @attachment.container_id = @attch.id + @attachment.filename = "test.jpg" + @attachment.save + params = {"1"=>{"filename" => "test.jpg", "description" =>"", + "is_public_checkbox"=>"1", + "token" => "#{@attachment.id}.#{@attachment.digest}" } + } + @attch.save_attachments(params) + @attch.name = "test.jpg" + @attch.save! + } + it "正常下载" do + uu = current_user + allow(uu).to receive(:admin?).and_return(true) + allow(User).to receive(:current).and_return(uu) + get zipdown_download_user_homework_path, {homework:@attch.id} + expect(response).to have_http_status(:success) + expect(response.content_type).to eq(Mime::Type.new("applcation/zip",:zip)) + end end end From 1355dc805f45ec643624f160914681d6a6f71e80 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Mon, 18 May 2015 17:31:53 +0800 Subject: [PATCH 04/56] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E8=BF=94=E5=9B=9E500=E9=94=99=E8=AF=AF=20#2610?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_users.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 1f74ccd5d..269017eb8 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -199,7 +199,7 @@ <% end %> - <% elsif @user.user_extensions.identity == 3 && @user.user_extensions.occupation.empty? %> + <% elsif @user.user_extensions.identity == 3 && @user.user_extensions.occupation %> <%= l(:field_occupation) %>: From e3633e702c22138ccfdf8d9986d11479ac4a4150 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 May 2015 08:53:51 +0800 Subject: [PATCH 05/56] =?UTF-8?q?firefox=E6=A0=B7=E5=BC=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/application.css | 1 + 1 file changed, 1 insertion(+) diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index edde12527..c0ad5f93c 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -2782,3 +2782,4 @@ div.repos_explain{ padding-bottom: 20px; } .upload_img img{max-width: 100%;} +#activity .upload_img img{width: 580px;} From 8e04b4e565014e935b0e1c9b04db5c11c3559a60 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 21 May 2015 15:57:35 +0800 Subject: [PATCH 06/56] =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E7=95=99=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/users.rb | 6 ++++-- app/services/users_service.rb | 21 +++++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 675ad33c5..fa1856b3d 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -111,11 +111,13 @@ module Mobile requires :token, type: String requires :user_id, type: Integer,desc: '被留言的用户id' requires :content,type:String,desc:'留言内容' - optional :refer_user_id,type:Integer,desc:'被回复的用户id' + requires :ref_user_id,type:Integer,desc:'被回复的用户id' + requires :parent_id,type:Integer,desc:'留言父id' + requires :ref_message_id,type:Integer,desc:'引用消息id' end post ':user_id/leave_message' do us = UsersService.new - jours = us.leave_messages params,current_user + jours = us.reply_user_messages params,current_user present :status,0 end diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 6e566b519..a8aacb095 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -166,13 +166,22 @@ class UsersService jours end - # 给某个用户留言 - def leave_messages params,current_user + # 回复用户 + def reply_user_messages params,current_user user = User.find(params[:user_id]) - user.add_jour(current_user, params[:content], params[:refer_user_id] ||= 0) - unless params[:refer_user_id].nil? || params[:refer_user_id] == 0 || params[:refer_user_id] == User.current.id - User.find(params[:refer_user_id]).add_jour(current_user, params[:content], params[:refer_user_id]) - end + parent_id = params[:parent_id] + author_id = current_user.id + reply_user_id = params[:ref_user_id] + reply_id = params[:ref_message_id] + content = params[:content] + options = {:user_id => author_id, + :status => true, + :m_parent_id => parent_id, + :m_reply_id => reply_id, + :reply_id => reply_user_id, + :notes => content, + :is_readed => false} + user.add_jour(nil, nil,nil,options) end From 689ec5cdfc0038b523ec8916c49106832f756734 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 21 May 2015 15:57:58 +0800 Subject: [PATCH 07/56] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9B=B4=E5=A4=9A=E5=8A=9F=E8=83=BDbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/news/_course_news.html.erb | 4 +- public/javascripts/course.js | 578 ++++++++++++--------------- 2 files changed, 251 insertions(+), 331 deletions(-) diff --git a/app/views/news/_course_news.html.erb b/app/views/news/_course_news.html.erb index 947b95076..7877782f6 100644 --- a/app/views/news/_course_news.html.erb +++ b/app/views/news/_course_news.html.erb @@ -36,9 +36,9 @@ <%= link_to h(news.title), news_path(news),:class => 'problem_tit fl fb c_dblue' %>
-

+

<%= news.description.html_safe %> -

+
- - - - <%#= link_to "", + + + + <%#= link_to "", # {:controller => 'watchers', :action => 'new', :project_id => @issue.project}, # :remote => true, # :method => 'get', :class => "pic_sch mt5 ml5" %> - + <%#= javascript_tag "observeSearchfield('user_search', 'users_for_watcher', '#{ escape_javascript watchers_autocomplete_for_user_path(:user => @available_watchers, :format => 'js', :flag => 'ture') }')" %> - - - + + + <%= call_hook(:view_issues_form_details_bottom, {:issue => @issue, :form => f}) %> diff --git a/app/views/issues/new.html.erb b/app/views/issues/new.html.erb index 137e203ef..77f3baf31 100644 --- a/app/views/issues/new.html.erb +++ b/app/views/issues/new.html.erb @@ -1,3 +1,4 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>

<%= l(:label_issue_new) %>

@@ -10,7 +11,7 @@ <%= render :partial => 'issues/form', :locals => {:f => f} %> - + <%= l(:button_create) %> <%#= preview_link preview_new_issue_path(:project_id => @project), 'issue-form', 'preview', {:class => "blue_btn fl ml10"} %> diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index 112b64745..88bbb4a71 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -1,3 +1,4 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>

<%= l(:label_issue_edit) %>

@@ -32,7 +33,7 @@ <% if @issue.description? || @issue.attachments.any? -%> <% if @issue.description? %> <%#= link_to l(:button_quote), quoted_issue_path(@issue.id), :remote => true, :method => 'post', :class => 'icon icon-comment' if authorize_for('issues', 'edit') %> - <%= textilizable @issue, :description, :attachments => @issue.attachments %> + <%= textAreailizable @issue, :description, :attachments => @issue.attachments %> <% end %>
@@ -108,7 +109,7 @@

- + <%= l(:button_submit) %> <% end %> diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 586704d16..6961b23c8 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -93,6 +93,7 @@ h4{ font-size:14px; color:#3b3b3b;} .w520{ width:520px;} .w543{ width:543px;} .w557{ width:557px;} +.w576{ width:576px;} .w583{ width:583px;} .w350{ width:350px;} .w610{ width:610px;} From a7aa83be8c978bb86ce5fa24d78a49e911a57cd4 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 26 May 2015 16:50:10 +0800 Subject: [PATCH 39/56] =?UTF-8?q?module=E9=85=8D=E7=BD=AE=E6=9C=AA?= =?UTF-8?q?=E9=80=89=E6=97=B6=E5=80=99=EF=BC=8C=E7=A6=81=E6=AD=A2=E5=85=B6?= =?UTF-8?q?=E5=AE=83=E6=96=B9=E5=BC=8F=E7=9A=84=E8=AE=BF=E9=97=AE=20?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=97=A0=E7=94=A8=E6=96=87=E4=BB=B6=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_projects.html.erb | 10 +++-- app/views/layouts/project_base.html.erb | 47 ------------------------ 2 files changed, 6 insertions(+), 51 deletions(-) delete mode 100644 app/views/layouts/project_base.html.erb diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index beade0a7a..43861d99a 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -144,10 +144,12 @@ <%= l(:label_member) %>(<%= link_to "#{@project.members.count}", project_member_path(@project), :class => 'info_foot_num c_blue' %>) <%= l(:label_user_watcher) %>(<%= link_to "#{@project.watcher_users.count}", {:controller=>"projects", :action=>"watcherlist", :id => @project.id}, :class => 'info_foot_num c_blue' %>) - - <%= l(:project_module_attachments) %>( - <% attaments_num = @project.attachments.count+Attachment.where(["`container_type` = 'Version' and `container_id` in (?)",@project.versions.map{ |v| v.id}]).all.count %> - <%= link_to "#{attaments_num}", project_files_path(@project), :class => 'info_foot_num c_blue' %>) + <% unless @project.enabled_modules.where("name = 'files'").empty? %> + + <%= l(:project_module_attachments) %>( + <% attaments_num = @project.attachments.count+Attachment.where(["`container_type` = 'Version' and `container_id` in (?)",@project.versions.map{ |v| v.id}]).all.count %> + <%= link_to "#{attaments_num}", project_files_path(@project), :class => 'info_foot_num c_blue' %>) + <% end %>
diff --git a/app/views/layouts/project_base.html.erb b/app/views/layouts/project_base.html.erb deleted file mode 100644 index af376b1f5..000000000 --- a/app/views/layouts/project_base.html.erb +++ /dev/null @@ -1,47 +0,0 @@ -<% @nav_dispaly_project_label = 1 - @nav_dispaly_forum_label = 1 %> - - - - - <%=h html_title %> - - - <%= csrf_meta_tag %> - <%= favicon %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %> - <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> - <%= javascript_heads %> - <%= javascript_include_tag "jquery.leanModal.min" %> - <%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%> - <%= heads_for_theme %> - <%= call_hook :view_layouts_base_html_head %> - - <%= yield :header_tags -%> - - -
-
-
- <%=render :partial => 'layouts/base_header'%> -
-
- <%= render_flash_messages %> - <%= yield %> - <%= call_hook :view_layouts_base_content %> -
- <%=render :partial => 'layouts/base_footer'%> -
- -
-
- - - - - -
-
-<%= call_hook :view_layouts_base_body_bottom %> - - From f3a15ce313692cc438a7969136bec00829fa5c90 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 26 May 2015 23:09:10 +0800 Subject: [PATCH 40/56] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E5=88=86=E6=9E=90=20oneapm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 4 ++ config/oneapm.yml | 135 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 config/oneapm.yml diff --git a/Gemfile b/Gemfile index fbe74f8dd..a43efbaeb 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,10 @@ unless RUBY_PLATFORM =~ /w32/ gem 'iconv' end +source 'http://rubygems.oneapm.com' do + gem 'oneapm_rpm' +end + gem "mysql2", "= 0.3.18" gem 'redis-rails' gem 'rubyzip' diff --git a/config/oneapm.yml b/config/oneapm.yml new file mode 100644 index 000000000..e5b2e7bed --- /dev/null +++ b/config/oneapm.yml @@ -0,0 +1,135 @@ +# +# OneApm RubyAgent Configuration +# + +# Here are the settings that are common to all environments +common: &default_settings + # ============================== LICENSE KEY =============================== + + # + # Get your license key from oneapm.com + # + license_key: 'BAQMBw8FUwR2542UFFpDXFgVVk66e2dZWB4EBlQHSf846wgBGwICFQoD0498BAEfBgNIAlQ=' + + # Agent Enabled (Ruby/Rails Only) + # Valid values are true, false and auto. + # + # agent_enabled: auto + + # This app_name will be the application name in oneapm.com in your account. + # + # Caution: If you change this name, a new application will appear in the OneApm + # user interface with the new name, and data will stop reporting to the + # app with the old name. + # + app_name: trusite + + # When "true", the agent collects performance data about your + # application and reports this data to the OneApm service at + # oneapm.com. This global switch is normally overridden for each + # environment below. (formerly called 'enabled') + monitor_mode: true + + # Specify its log level here. + log_level: info + + # log_file_path: 'log' + # log_file_name: 'oneapm_agent.log' + + # The oneapm agent communicates with the service via https by default. + # ssl: true + + # ======================== Browser Monitoring ============================= + browser_monitoring: + # By default the agent automatically injects the monitoring JavaScript + # into web pages. Set this attribute to false to turn off this behavior. + auto_instrument: true + + # Proxy settings for connecting to the OneApm server. + # + # proxy_host: hostname + # proxy_port: 8080 + # proxy_user: + # proxy_pass: + + # Tells transaction tracer and error collector (when enabled) + # whether or not to capture HTTP params. When true, frameworks can + # exclude HTTP parameters from being captured. + # Rails: the RoR filter_parameter_logging excludes parameters + capture_params: false + + # Transaction tracer captures deep information about slow + # transactions and sends this to the OneApm service once a + # minute. Included in the transaction is the exact call sequence of + # the transactions including any SQL statements issued. + transaction_tracer: + + # Transaction tracer is enabled by default. + enabled: true + + # Threshold in seconds for when to collect a transaction + # trace. When the response time of a controller action exceeds + # this threshold, a transaction trace will be recorded and sent to + # OneApm. Valid values are any float value, or (default) "apdex_f", + # which will use the threshold for an dissatisfying Apdex + # controller action - four times the Apdex T value. + transaction_threshold: apdex_f + + # When transaction tracer is on, SQL statements can optionally be + # recorded. The recorder has three modes, "off" which sends no + # SQL, "raw" which sends the SQL statement in its original form, + # and "obfuscated", which strips out numeric and string literals. + record_sql: obfuscated + + # Threshold in seconds for when to collect stack trace for a SQL + # call. In other words, when SQL statements exceed this threshold, + # then capture and send to OneApm the current stack trace. This is + # helpful for pinpointing where long SQL calls originate from. + stack_trace_threshold: 0.500 + + # Determines whether the agent will capture query plans for slow + # SQL queries. Only supported in mysql and postgres. Should be + # set to false when using other adapters. + # explain_enabled: true + + # Threshold for query execution time below which query plans will + # not be captured. Relevant only when `explain_enabled` is true. + # explain_threshold: 0.5 + + # Error collector captures information about uncaught exceptions and + # sends them to OneApm for viewing + error_collector: + + # Error collector is enabled by default. + enabled: true + + # Ignore the following errors, add your own. + ignore_errors: "ActionController::RoutingError,Sinatra::NotFound" + +# ===================== Application Environments ======================== +# Environment-specific settings are in this section. +# For Rails applications, RAILS_ENV is used to determine the environment. + +# NOTE if your application has other named environments, you should +# provide oneapm configuration settings for these environments here. + +development: + <<: *default_settings + # Turn on communication to OneApm service in development mode + monitor_mode: true + app_name: My Application (Development) + +test: + <<: *default_settings + monitor_mode: false + +# Turn on the agent in production for 24x7 monitoring. +production: + <<: *default_settings + monitor_mode: true + +# Staging environment which behaves identically to production. +staging: + <<: *default_settings + monitor_mode: true + app_name: My Application (Staging) From 9ce1916fbb3f309e2045e2e15f02372fb7eb8f81 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 26 May 2015 23:10:08 +0800 Subject: [PATCH 41/56] =?UTF-8?q?autologin=20token=20cookies=20domain?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 7976e1aa4..75be302cd 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -336,6 +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', :httponly => true } cookies[autologin_cookie_name] = cookie_options From 3fa5179026e83a57aa18c957d36e45ff13556026 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 26 May 2015 23:11:10 +0800 Subject: [PATCH 42/56] =?UTF-8?q?issue=E6=95=B0=E7=BB=9F=E8=AE=A1=E6=8B=96?= =?UTF-8?q?=E6=85=A2=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/_development_group.html.erb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/projects/_development_group.html.erb b/app/views/projects/_development_group.html.erb index 676761831..726e9646f 100644 --- a/app/views/projects/_development_group.html.erb +++ b/app/views/projects/_development_group.html.erb @@ -8,9 +8,10 @@ <% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %>
+ <% if @issue.editable? %>
<%= render :partial => 'edit' %>
-

<%= l(:button_submit) %> diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index f3c453019..ffeeaef82 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -51,7 +51,7 @@ <%= link_to format_activity_title("#{act.issue.tracker} ##{act.issue.project_issues_index}: #{act.issue.subject}"), {:controller => 'issues', :action => 'show', :id => act.issue.id, :anchor => "change-#{act.id}"}, :class => "problem_tit fl fb" %>
-

<%= textAreailizable act,:notes %>
+

<%= textilizable act,:notes %>
<%= l :label_activity_time %> :<%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %>

From 10e24bebd50c9e4e3bc63ca68f87266e65e7e8ce Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 27 May 2015 08:56:34 +0800 Subject: [PATCH 44/56] =?UTF-8?q?=E5=8A=A8=E6=80=81=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=94=B9=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/courses_service.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 26d8df16f..49170bf30 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -364,19 +364,20 @@ class CoursesService latest_course_dynamics = [] latest_news = course.news.order("created_on desc").first unless latest_news.nil? - latest_course_dynamics << {:type => 1,:time => latest_news.created_on,:message => l(:label_recently_updated_notification,:locale => get_user_language(current_user))} + latest_course_dynamics << {:type => 1,:time => latest_news.created_on, + :message =>latest_news.author.realname<< l(:label_recently_updated_notification,:locale => get_user_language(current_user))<<":"<< latest_news.title } end latest_message = course.journals_for_messages.order("created_on desc").first unless latest_message.nil? - latest_course_dynamics << {:type => 2,:time => latest_message.created_on,:message => l(:label_recently_updated_message,:locale => get_user_language(current_user))} + latest_course_dynamics << {:type => 2,:time => latest_message.created_on,:message =>latest_message.user.realname << l(:label_recently_updated_message,:locale => get_user_language(current_user))<<":"< 3,:time => latest_attachment.created_on,:message => l(:label_recently_updated_courseware,:locale => get_user_language(current_user))} + latest_course_dynamics << {:type => 3,:time => latest_attachment.created_on,:message =>latest_attachment.author.realname<< l(:label_recently_updated_courseware,:locale => get_user_language(current_user))<<":"< 4,:time => latest_bid.updated_on,:message => l(:label_recently_updated_homework,:locale => get_user_language(current_user))} + latest_course_dynamics << {:type => 4,:time => latest_bid.updated_on,:message => latest_bid.author.realname< get_user_language(current_user))<<":"< 4,:time => latest_homework_attach.updated_at,:message => l(:label_recently_updated_homework,:locale => get_user_language(current_user))} + latest_course_dynamics << {:type => 4,:time => latest_homework_attach.updated_at,:message =>latest_homework_attach.user.realname<< l(:label_recently_updated_homework,:locale => get_user_language(current_user))<<":"<<(latest_homework_attach.name.nil? ? latest_homework_attach.description : latest_homework_attach.name)} end latest_course_dynamics.sort!{|order,newer| newer[:time] <=> order[:time]} latest_course_dynamic = latest_course_dynamics.first From 1919292c583388ffef1fe3f43229471b8a629916 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 27 May 2015 09:23:48 +0800 Subject: [PATCH 45/56] =?UTF-8?q?=E8=BF=98=E6=98=AFissues=20count=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/_research_team.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/projects/_research_team.html.erb b/app/views/projects/_research_team.html.erb index b2b0e3c33..8bd32a98e 100644 --- a/app/views/projects/_research_team.html.erb +++ b/app/views/projects/_research_team.html.erb @@ -8,8 +8,8 @@ <% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %> -<% end%> \ No newline at end of file +<% end%> From 5af284e8a47cac37226b35e2cb4fc8c1bf1762b6 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 27 May 2015 10:43:03 +0800 Subject: [PATCH 46/56] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 2 +- app/views/layouts/base_projects.html.erb | 115 +++++++++--------- .../projects/_development_group.html.erb | 1 - app/views/projects/_friend_group.html.erb | 1 - app/views/projects/_research_team.html.erb | 1 - 5 files changed, 56 insertions(+), 64 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index cadff5f15..539d84e65 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -130,7 +130,7 @@ class IssuesController < ApplicationController @project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base'#by young @available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq - respond_to do |format| + respond_to do |format|`` format.html { retrieve_previous_and_next_issue_ids render :template => 'issues/show', :layout => @project_base_tag#by young diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 43861d99a..87ceeaf9a 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -18,54 +18,7 @@ <%= yield :header_tags -%> - - @@ -83,13 +36,7 @@ @@ -166,14 +114,14 @@ <% end %> - + <%#--project_new_type: 1为开发组;2为科研组;3为朋友圈子--%>
<% if @project.project_new_type == 1 || @project.project_new_type.nil? %> - <%= render :partial => 'projects/development_group', :locals => {:project => @project}%> + <%= render :partial => 'projects/development_group', :locals => {:project => @project, :attaments_num => attaments_num} %> <% elsif @project.project_new_type == 2 %> - <%= render :partial => 'projects/research_team', :locals => {:project => @project}%> + <%= render :partial => 'projects/research_team', :locals => {:project => @project, :attaments_num => attaments_num} %> <% else %> - <%= render :partial => 'projects/friend_group', :locals => {:project => @project}%> + <%= render :partial => 'projects/friend_group', :locals => {:project => @project, :attaments_num => attaments_num} %> <% end %>
@@ -232,8 +180,55 @@
  • id="friend_organization"/>
  • 确定 - + +
    123
    <%= render :partial => 'layouts/new_feedback' %> diff --git a/app/views/projects/_development_group.html.erb b/app/views/projects/_development_group.html.erb index 726e9646f..d4bc7012a 100644 --- a/app/views/projects/_development_group.html.erb +++ b/app/views/projects/_development_group.html.erb @@ -1,4 +1,3 @@ -<% attaments_num = @project.attachments.count+Attachment.where(["`container_type` = 'Version' and `container_id` in (?)",@project.versions.map{ |v| v.id}]).all.count %>
    From df5c040aab9d389a5d75d81568fd6b8558593818 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 27 May 2015 16:00:11 +0800 Subject: [PATCH 50/56] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AEissue?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/issues/_action_menu.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/issues/_action_menu.html.erb b/app/views/issues/_action_menu.html.erb index a5823ede3..2643c93e7 100644 --- a/app/views/issues/_action_menu.html.erb +++ b/app/views/issues/_action_menu.html.erb @@ -1,6 +1,6 @@ <%#= watcher_link_issue(@issue, User.current) %> -<%#= link_to l(:button_copy), project_copy_issue_path(@project, @issue), :class => 'icon icon-copy' if User.current.allowed_to?(:add_issues, @project) %> +<%= link_to l(:button_copy), project_copy_issue_path(@project, @issue), :class => 'talk_edit fr' if User.current.allowed_to?(:add_issues, @project) %> <%= link_to l(:button_delete), issue_path(@issue.id), :data => {:confirm => issues_destroy_confirmation_message(@issue)}, :method => :delete, :class => 'talk_edit fr' if User.current.allowed_to?(:delete_issues, @project) %> <%= link_to l(:button_edit), edit_issue_path(@issue.id), :onclick => 'showAndScrollTo("all_attributes"); return false;', :class => 'talk_edit fr', :accesskey => accesskey(:edit) if @issue.editable? && User.current.allowed_to?(:edit_issues, @project) %> <%= link_to l(:label_user_newfeedback), edit_issue_path(@issue.id), :onclick => 'showAndScrollTo("update", "issue_notes"); return false;', :class => 'talk_edit fr', :accesskey => accesskey(:edit) if @issue.editable? && User.current.allowed_to?(:add_issue_notes, @project) %> 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 51/56] =?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 52/56] =?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 @@
      <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
    -
    \ No newline at end of file +
    diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb index 06c67320a..74560909d 100644 --- a/app/views/users/user_homeworks.html.erb +++ b/app/views/users/user_homeworks.html.erb @@ -1,4 +1,4 @@ - +u <% if @user.user_extensions.identity == 0 %> <%= render :partial => 'my_create_homework' %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 09897c1eb..8419ae188 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -759,6 +759,7 @@ en: button_create_and_continue: Create and continue button_test: Test button_edit: Edit + button_delete: Delete button_edit_associated_wikipage: "Edit associated Wiki page: %{page_title}" button_add: Add button_change: Change diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 4c752660a..73a97c035 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -849,6 +849,7 @@ zh: button_create_and_continue: 创建并继续 button_test: 测试 button_edit: 编辑 + button_delete: 删除 button_edit_associated_wikipage: "编辑相关wiki页面: %{page_title}" button_add: 新增 button_change: 修改 diff --git a/config/routes.rb b/config/routes.rb index 411386afc..9a8e71156 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -251,7 +251,7 @@ RedmineApp::Application.routes.draw do post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit' post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy' # boards end - post 'bids/homework_destroy', :to => 'bids#homework_destroy' + delete 'bids/homework', :to => 'bids#homework_destroy' # Misc issue routes. TODO: move into resources match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues' diff --git a/spec/requests/homework_request_spec.rb b/spec/requests/homework_request_spec.rb new file mode 100644 index 000000000..05733a56d --- /dev/null +++ b/spec/requests/homework_request_spec.rb @@ -0,0 +1,52 @@ +require 'rails_helper' +require 'shared_account_spec' + +RSpec.describe "homework", type: :request do + include_context "create user" + let(:course) {FactoryGirl.create(:course, teacher: current_user)} + let(:homework){FactoryGirl.attributes_for(:homework)} + + before { + shared_register + } + describe "创建作业" do + before do + post calls_create_homework_path(course_id: course.id), { + bid: homework + } + @homework = assigns(:bid) + end + it "参数正确,可以成功创建作业" do + expect(response).to redirect_to(course_homework_url(course.id)) + end + it {expect(course.homeworks).to_not be_empty} + it {expect(@homework.acts).to_not be_empty} + it {expect(@homework.watchers).to_not be_empty} + it {expect(@homework.attachments).to_not be_empty} + end + + describe "删除作业" do + before do + shared_login + post calls_create_homework_path(course_id: course.id), { + bid: homework + } + @homework = assigns(:bid) + delete bids_homework_path(id: @homework.id) + end + it{expect(response).to redirect_to(course_homework_path(course.id))} + it "homework_for_courses应删除" do + expect(course.homeworks).to be_empty + end + it "相关活动也删除" do + expect(@homework.acts).to be_empty + end + it "watches 删除" do + expect(@homework.watchers).to be_empty + end + it "附件 删除" do + expect(@homework.attachments).to be_empty + end + end + +end From 5279c2d3e5123abb02571f8415df99f0434194e2 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 28 May 2015 09:51:32 +0800 Subject: [PATCH 53/56] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=89=80=E6=9C=89?= =?UTF-8?q?=E7=9A=84=E5=9F=9F=E7=9A=84autologin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 02b2f0d1d..88cd51d67 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, domain: Redmine::Configuration['cookie_domain']) + cookies.delete(autologin_cookie_name, domain: :all) # Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin']) self.logged_user = nil end From e2ec7d5f3e40ad98d79c30a08f65257bd9d7ef44 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 28 May 2015 15:45:36 +0800 Subject: [PATCH 54/56] =?UTF-8?q?QQ=E5=9C=A8=E7=BA=BF=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_base_feedback.html.erb | 6 ++++-- app/views/layouts/_new_feedback.html.erb | 7 +++---- config/locales/commons/zh.yml | 2 +- public/stylesheets/public.css | 3 ++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/views/layouts/_base_feedback.html.erb b/app/views/layouts/_base_feedback.html.erb index d9bd5e376..07f852914 100644 --- a/app/views/layouts/_base_feedback.html.erb +++ b/app/views/layouts/_base_feedback.html.erb @@ -14,7 +14,7 @@ .close_btn span { display:none;} .side_center .custom_service p { text-align:center; padding:6px 0; margin:0; vertical-align:middle;} .msgserver { margin:2px 0px 0px 4px; padding-top: 0px} - .msgserver a { background:url(/images/sidebar_bg.png) no-repeat -119px -115px; padding-left:22px;} + .msgserver a { padding-left:4px;} .opnionText{ width:122px; height:180px; border-color: #DFDFDF; background:#fff; color:#999; padding:3px; font-size:12px;} .opnionButton{ display:block; background:#15bccf; width:130px; height:23px; margin-top:5px; text-align:center; padding-top:3px;} .opnionButton:hover{background: #0fa9bb; } @@ -180,7 +180,9 @@ function cookieget(n) <% end %>
    diff --git a/app/views/layouts/_new_feedback.html.erb b/app/views/layouts/_new_feedback.html.erb index 67b4af32c..3b8098ed5 100644 --- a/app/views/layouts/_new_feedback.html.erb +++ b/app/views/layouts/_new_feedback.html.erb @@ -22,10 +22,9 @@ <% end %>
    diff --git a/config/locales/commons/zh.yml b/config/locales/commons/zh.yml index 9ba8cba7a..a023bc8cb 100644 --- a/config/locales/commons/zh.yml +++ b/config/locales/commons/zh.yml @@ -353,7 +353,7 @@ zh: # label_feedback: 意见反馈 label_feedback_tips: "欢迎反馈网站问题,课程中遇到的问题请反馈给相关老师!" - label_technical_support: "技术支持:" + label_technical_support: "QQ 在线支持:" label_feedback_success: "您的意见已经反馈到公共贴吧的新手讨论吧,我们会第一时间解决您的问题,谢谢支持!" label_feedback_value: "该帖来自用户反馈:)" diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 6961b23c8..c8d18609f 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -287,7 +287,8 @@ html{ overflow-x:hidden;} .close_btn span { display:none;} .side_center .custom_service p { text-align:center; padding:6px 0; margin:0; vertical-align:middle;} .msgserver { margin-top:5px;} -.msgserver a { background:url(../images/sidebar_bg.png) no-repeat -119px -112px; padding-left:22px; height:21px; display:block; } +/*.msgserver a { background:url(../images/sidebar_bg.png) no-repeat -119px -112px; padding-left:22px; height:21px; display:block; }*/ +.msgserver a { padding-left:4px; height:21px; display:block; } .opnionText{box-shadow:none; width:122px; height:180px; border-color: #DFDFDF; background:#fff; color:#999; padding:3px; font-size:12px;overflow:auto; background-attachment:fixed;border-style:solid;} a.opnionButton{ display:block; background:#15bccf; width:130px; height:23px; margin-top:5px; text-align:center; padding-top:3px;} a:hover.opnionButton{background: #0fa9bb; } From 065c196edc8c0e91ca41a4289a074ce7d369a255 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Thu, 28 May 2015 16:18:48 +0800 Subject: [PATCH 55/56] ... --- public/javascripts/project.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/project.js b/public/javascripts/project.js index f9f88703d..918c438e3 100644 --- a/public/javascripts/project.js +++ b/public/javascripts/project.js @@ -419,7 +419,7 @@ $(function(){ cookiesave(personalized_expand_key,JSON.stringify(personalized_map)); target.toggle(timeout); } - $("*[nhtype='toggle4cookie']").click(function(){ + $("*[nhtype='toggle4cookie']").live('click',function(){ personalized_click($(this),500); }); From ad99cb8535468af88bd0103ca3a699afd996fedd Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 28 May 2015 17:51:50 +0800 Subject: [PATCH 56/56] =?UTF-8?q?=E4=B8=8E=E6=88=91=E7=9B=B8=E5=85=B3=20?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E7=9B=B8=E5=85=B3=E7=9A=84=E8=AF=A6=E7=BB=86?= =?UTF-8?q?=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/comments.rb | 13 +++++++ app/api/mobile/apis/users.rb | 14 ++++++++ app/api/mobile/entities/jours.rb | 10 ++++++ app/services/comment_service.rb | 13 +++++++ app/services/users_service.rb | 60 +++++++++++++++++++++++++++----- 5 files changed, 102 insertions(+), 8 deletions(-) diff --git a/app/api/mobile/apis/comments.rb b/app/api/mobile/apis/comments.rb index edc7bcf54..544ebf0ce 100644 --- a/app/api/mobile/apis/comments.rb +++ b/app/api/mobile/apis/comments.rb @@ -99,6 +99,19 @@ module Mobile present :status, 0 end + desc '留言详情' + params do + requires :token, type: String + requires :comment_parent_id,type:Integer,desc:'留言id' + optional :course_id,type:Integer,desc:'课程id' + end + get ':comment_parent_id/comment_details' do + cs = CommentService.new + jour = cs.comment_detail params,current_user + present :data, jour, with: Mobile::Entities::Jours + present :status, 0 + end + end end end diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 96b788dab..583a130d1 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -115,6 +115,8 @@ module Mobile requires :ref_user_id,type:Integer,desc:'被回复的用户id' requires :parent_id,type:Integer,desc:'留言父id' requires :ref_message_id,type:Integer,desc:'引用消息id' + optional :type,type:Integer,desc:'回复类型' + optional :course_id,type:Integer,desc:'课程id' end post ':user_id/reply_message' do us = UsersService.new @@ -133,6 +135,18 @@ module Mobile us.leave_message params,current_user present :data,0 end + + desc "与我相关" + params do + requires :token, type: String + requires :page,type:Integer,desc:'页码' + end + get ':user_id/all_my_dynamic' do + us = UsersService.new + my_jours = us.reply_my_messages params,current_user + present :data,my_jours,with:Mobile::Entities::Jours + present :status,0 + end end end end diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb index 10fd0f893..97eabd21f 100644 --- a/app/api/mobile/entities/jours.rb +++ b/app/api/mobile/entities/jours.rb @@ -14,6 +14,11 @@ module Mobile else f.send(field) end + else + case f + when :course_name + f[:jour_type] == "Course" ? f.course.name : "" + end end end end @@ -27,6 +32,11 @@ module Mobile jours_expose :notes jours_expose :m_reply_id jours_expose :m_parent_id + expose :course,using:Mobile::Entities::Course do |f,opt| + if f.is_a?(::JournalsForMessage) && f[:jour_type] == "Course" + f.course + end + end expose :reply_user,using: Mobile::Entities::User do |f, opt| f.at_user end diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb index f75e14b85..a742d0eee 100644 --- a/app/services/comment_service.rb +++ b/app/services/comment_service.rb @@ -101,4 +101,17 @@ class CommentService @jours end + def comment_detail params,current_user + if !params[:course_id].nil? && params[:course_id] != 0 + course = Course.find(params[:course_id]) + jour = course.journals_for_messages.where("id = ? ",params[:comment_parent_id]) + jour + else + jour1 = JournalsForMessage.where("id = ? ",params[:comment_parent_id]) + jour1 + end + end + + + end \ No newline at end of file diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 7d7976bb5..77cebe0b1 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -169,19 +169,26 @@ class UsersService # 回复用户 def reply_user_messages params,current_user user = User.find(params[:user_id]) - parent_id = params[:parent_id] + + m_parent_id = params[:parent_id] author_id = current_user.id - reply_user_id = params[:ref_user_id] - reply_id = params[:ref_message_id] + reply_id = params[:ref_user_id] + ref_message_id = params[:ref_message_id] content = params[:content] - options = {:user_id => author_id, + options = {:user_id => author_id, # 作者id :status => true, - :m_parent_id => parent_id, - :m_reply_id => reply_id, - :reply_id => reply_user_id, + :m_parent_id => m_parent_id,# 父留言id + :m_reply_id => ref_message_id, # 子留言 id + :reply_id => reply_id, # 被留言用户id :notes => content, :is_readed => false} - user.add_jour(nil, nil,nil,options) + if(params[:type] == 1) + user.add_jour(nil, nil,nil,options) + elsif(params[:type] == 2) + Course.find(params[:course_id]).journals_for_messages.build(options).save! unless params[:course_id].nil? + else + end + end # 给用户留言 @@ -258,4 +265,41 @@ class UsersService scope end + # 课程留言中与我相关的回复 + def my_course_messages params,current_user + #找到我所有的课程 + @user = current_user + if !current_user.admin? && !@user.active? + raise '404' + return + end + if current_user == @user || current_user.admin? + membership = @user.coursememberships.all + end + # membership.sort! {|older, newer| newer.created_on <=> older.created_on } + message_list = [] + membership.each do |mp| + #课程轮询找到与我相关的回复 + message_list << mp.course.journals_for_messages.where("reply_id = ?",current_user.id) + end + message_list + end + + # 获取与我相关的留言:我的留言,回复我的留言 + def my_personal_messages params,current_user + jours = current_user.journals_for_messages.where('m_parent_id is null or reply_id = ?',current_user.id) + jours.update_all(:is_readed => true, :status => false) + jours + end + + def reply_my_messages params,current_user + jours = my_personal_messages params,current_user + jours1 = my_course_messages params,current_user + my_jours = [] + my_jours << jours << jours1 + my_jours.flatten!.sort! {|older, newer| newer.created_on <=> older.created_on } + my_jours_arr = Kaminari.paginate_array(my_jours, total_count: my_jours.count).page(params[:page] || 1).per(10) + my_jours_arr + end + end