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/25] =?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/25] =?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/25] =?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/25] =?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/25] =?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 689ec5cdfc0038b523ec8916c49106832f756734 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 21 May 2015 15:57:58 +0800 Subject: [PATCH 06/25] =?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 %> -

+
From a3fd5411198f95fd77124e9a513f48a09ac23196 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 May 2015 10:15:57 +0800 Subject: [PATCH 09/25] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E9=82=80=E8=AF=B7=E6=96=B0=E7=94=A8=E6=88=B7=E3=80=81=E5=B7=B2?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 6 +++--- app/helpers/account_helper.rb | 12 ++++++++++++ app/models/mailer.rb | 8 ++------ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index c79d0862f..536ea6bba 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -247,9 +247,9 @@ class ProjectsController < ApplicationController # 1、自动注册 # 2、加入项目、创建角色 # 3、用户得分 - if params[:email] - user = User.find_by_mail(params[:email].to_s) - Member.create(:role_ids => [4], :user_id => user.id,:project_id => @project.id) + if params[:mail] + Member.create(:role_ids => [4], :user_id => params[:user],:project_id => params[:id]) + UserGrade.create(:user_id =>params[:user], :project_id => params[:id]) end if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) return diff --git a/app/helpers/account_helper.rb b/app/helpers/account_helper.rb index 7ad6fe65b..827557a40 100644 --- a/app/helpers/account_helper.rb +++ b/app/helpers/account_helper.rb @@ -47,6 +47,18 @@ module AccountHelper user end + # 自动创建一个新用户,但是初始状态是锁定的 + def automatically_register_lock(user, &block) + user.lock + user.last_login_on = Time.now + if user.save + UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0) + else + yield if block_given? + end + user + end + def administrator_manually__register(user, &block) if user.save UserStatus.create(:user_id => user.id ,:changsets_count => 0, :watchers_count => 0) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 7756b7e27..2c3a94874 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -58,14 +58,10 @@ class Mailer < ActionMailer::Base us = UsersService.new # 自动激活用户 user = us.register_auto(login, @email, @password) - - Member.create(:role_ids => [4], :user_id => user.id,:project_id => project.id) - UserGrade.create(:user_id => user.id, :project_id => project.id) User.current = user unless User.current.nil? @user = user @token = Token.get_token_from_user(user, 'autologin') - @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id,:user => user, :token => @token.value - ) + @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user => user.id, :mail => true, :token => @token.value) mail :to => email, :subject => @subject end @@ -77,7 +73,7 @@ class Mailer < ActionMailer::Base @project_name = "#{project.name}" @user = user @token = Token.get_token_from_user(user, 'autologin') - @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :email => email, :token => @token.value) + @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user => user.id, :mail => true, :token => @token.value) mail :to => email, :subject => @subject end From 975b19c5dec9b8a543727dddea2e8c58f4a0f823 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 May 2015 10:35:27 +0800 Subject: [PATCH 10/25] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E2=80=9C=E6=B7=BB=E5=8A=A0=E4=BA=8E=E2=80=9D=E2=80=9C=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BA=8E=E2=80=9D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/issues/show.html.erb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index cff5aae06..112b64745 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -19,11 +19,11 @@

<%= @issue.author %> - <% if @issue.created_on != @issue.updated_on %> - 更新于 <%= format_time(@issue.created_on).html_safe %> - <% else %> - 添加于 <%= format_time(@issue.updated_on).html_safe %> - <% end %> + <%# if @issue.created_on != @issue.updated_on %> + 添加于 <%= format_time(@issue.created_on).html_safe %> + <%# else %> + <%#= format_time(@issue.updated_on).html_safe %> + <%# end %> 'action_menu' %> From fcb5444076d8fdd50ecb37a191fe2549f42fb818 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 May 2015 10:43:50 +0800 Subject: [PATCH 11/25] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=BB=93=E6=9E=9C=E9=A1=B5=E9=9D=A2=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/contests/index.html.erb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/views/contests/index.html.erb b/app/views/contests/index.html.erb index 170f11037..26e9e2114 100644 --- a/app/views/contests/index.html.erb +++ b/app/views/contests/index.html.erb @@ -46,9 +46,7 @@ <%= text_field_tag 'name', params[:name], :size => 30, :onkeyup => 'regexName1();', :width => "125px" %> <%= hidden_field_tag 'project_type', params[:project_type] %> <%#= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %> - - <%= l(:label_search)%> - + <%= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %>
From 67061d0ee5eaaef4fd6698bad2ce929034d9afc7 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 May 2015 11:18:31 +0800 Subject: [PATCH 12/25] =?UTF-8?q?=E5=85=81=E8=AE=B8=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E9=87=8D=E5=90=8D=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/project.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/project.rb b/app/models/project.rb index f257058ea..47878dbec 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -114,7 +114,7 @@ class Project < ActiveRecord::Base validates_presence_of :name, :identifier validates_uniqueness_of :identifier - validates_uniqueness_of :name + # validates_uniqueness_of :name validates_associated :wiki#, :repository # validates_length_of :description, :maximum => 255 validates_length_of :name, :maximum => 255 From 04e9618a5926fda4cce4f1caf5e23d9da5306fa5 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 22 May 2015 11:20:41 +0800 Subject: [PATCH 13/25] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug#2357:=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE--=E9=82=80=E8=AF=B7=E6=B3=A8=E5=86=8C=E7=94=A8?= =?UTF-8?q?=E6=88=B7=EF=BC=8C=E6=88=90=E5=8A=9F=E6=90=9C=E7=B4=A2=E5=90=8E?= =?UTF-8?q?=E8=8B=A5=E5=BF=98=E4=BA=86=E9=80=89=E6=8B=A9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=88=96=E8=A7=92=E8=89=B2=E7=9B=B4=E6=8E=A5=E9=82=80=E8=AF=B7?= =?UTF-8?q?=EF=BC=8C=E5=BB=BA=E8=AE=AE=E4=B8=8D=E8=A6=81=E5=86=8D=E8=AE=A9?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=87=8D=E6=96=B0=E6=90=9C=E7=B4=A2=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/invite_members.html.erb | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/app/views/projects/invite_members.html.erb b/app/views/projects/invite_members.html.erb index d30ecd8e4..97b36406e 100644 --- a/app/views/projects/invite_members.html.erb +++ b/app/views/projects/invite_members.html.erb @@ -1,4 +1,3 @@ -

<%= l(:label_invite_join) %>

@@ -68,5 +67,32 @@ var text=$(label).text(); $(label).attr("title",text); } + + function nh_show_err_message(msg){ + $("#RSide>.flash").remove(); + $("#RSide").prepend('
'+msg+'
'); + } + $('#new_membership').submit(function(){ + var user_ischeck=false; + $("input[name='membership[user_ids][]']").each(function(){ + if($(this).prop('checked')){ + user_ischeck=true; + } + }); + if(user_ischeck==false){ + nh_show_err_message('请选择用户!'); + return false; + } + var role_ischeck=false; + $("input[name='membership[role_ids][]']").each(function(){ + if($(this).prop('checked')){ + role_ischeck=true; + } + }); + if(role_ischeck==false){ + nh_show_err_message('请选择角色!'); + return false; + } + }); }); \ No newline at end of file From a6e15f56090aa2e70acedbc55eb3e4f8f8a2f0c1 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 22 May 2015 11:27:47 +0800 Subject: [PATCH 14/25] ... --- app/views/issues/index.html.erb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index 9bd0f6ac4..bb8ea1bef 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -55,7 +55,7 @@
@@ -86,19 +86,19 @@ %>
-
-
创建时间 : 
-
- <%= text_field_tag 'issue_create_date_start', '',:readonly=>true, :size=>15, :onchange => "remote_function()",:style=>'float:left;'%> - <%= calendar_for('issue_create_date_start') %> -
-
 - 
-
- <%= text_field_tag 'issue_create_date_end', '',:readonly=>true, :size=>15, :onchange => "remote_function()",:style=>'float:left;'%> - <%= calendar_for('issue_create_date_end') %> -
-
-
+ + + + + + + + + + + + + <% end %>

<%= l(:label_issues_sum) %>:<%= @project.issues.visible.all.count %> <%= l(:lable_issues_undo) %>:<%= @project.issues.where('status_id in (1,2,4,6)').visible.all.count %> From b5d9cf55fff6354252b45000ffbf9714f750f73c Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 22 May 2015 15:59:37 +0800 Subject: [PATCH 15/25] =?UTF-8?q?=E5=B0=86=E5=9F=9F=E5=90=8D=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8A=A0=E5=85=A5=E5=88=B0=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E5=90=8E=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/settings/_general.html.erb | 5 +++++ config/locales/en.yml | 4 ++++ config/locales/zh.yml | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/app/views/settings/_general.html.erb b/app/views/settings/_general.html.erb index 763b65515..fdb3c6f85 100644 --- a/app/views/settings/_general.html.erb +++ b/app/views/settings/_general.html.erb @@ -15,6 +15,11 @@

<%= setting_text_field :activity_days_default, :size => 6 %> <%= l(:label_day_plural) %>

<%= setting_text_field :host_name, :size => 60 %> +

<%= setting_text_field :host_course, :size => 60 %> +

<%= setting_text_field :host_contest, :size => 60 %> +

<%= setting_text_field :host_user, :size => 60 %> +

<%= setting_text_field :host_repository, :size => 60 %> + <%= l(:label_example) %>: <%= @guessed_host_and_path %>

<%= setting_select :protocol, [['HTTP', 'http'], ['HTTPS', 'https']] %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index 844818ae4..09897c1eb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -183,6 +183,10 @@ en: setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_plain_text_mail: Plain text mail (no HTML) setting_host_name: Host name and path + setting_host_course: Host course and path + setting_host_contest: Host contest and path + setting_host_user: Host user and path + setting_host_repository: Host repository and path setting_text_formatting: Text formatting setting_wiki_compression: Wiki history compression setting_feeds_limit: Maximum number of items in Atom feeds diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 24702ad46..4c752660a 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -190,6 +190,10 @@ zh: setting_bcc_recipients: 使用密件抄送 (bcc) setting_plain_text_mail: 纯文本(无HTML) setting_host_name: 主机名称 + setting_host_course: 课程域名 + setting_host_contest: 竞赛域名 + setting_host_user: 用户域名 + setting_host_repository: 仓库域名 setting_text_formatting: 文本格式 setting_wiki_compression: 压缩Wiki历史文档 setting_feeds_limit: RSS Feed内容条数限制 From 052d293f82769541015d8f2935de8c29498d6dde Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 May 2015 16:30:22 +0800 Subject: [PATCH 16/25] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=97=B6=E5=80=99=EF=BC=9A=20=E5=A6=82=E6=9E=9C=E6=88=91?= =?UTF-8?q?=E7=9A=84=E9=A1=B9=E7=9B=AE=E4=B8=AD=E6=9C=89=E9=87=8D=E5=90=8D?= =?UTF-8?q?=E7=9A=84=E9=A1=B9=E7=9B=AE=E4=B8=8D=E5=85=81=E8=AE=B8=E6=96=B0?= =?UTF-8?q?=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/projects_helper.rb | 10 ++++++++++ public/javascripts/project.js | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 508e58ba3..12925b0b1 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -65,6 +65,16 @@ module ProjectsHelper content_tag('div', content, :class => "tabs") end + # 判断我的项目中是否有重名项目 + def judge_same_projectname(user, project_name) + result = false + my_projects = user.projects + my_projects.each do |mp| + result = true if mp.name == project_name + end + return result + end + # Added by young def course_settings_tabs tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural, :course=>'1'}, diff --git a/public/javascripts/project.js b/public/javascripts/project.js index 0a04b2a7b..f9f88703d 100644 --- a/public/javascripts/project.js +++ b/public/javascripts/project.js @@ -425,4 +425,35 @@ $(function(){ personalized_init(); }); -//cookie记忆html区块 显示/隐藏 的代码 end \ No newline at end of file +//cookie记忆html区块 显示/隐藏 的代码 end + +// 新建项目的时候判断是否与我已有的项目重复 +function judgeprojectname(){ + $('#new_project').validate({ + errorPlacement: function(error, element){ + alert('error') + }, + success: function(label){ + alert('ok') + }, + onkeyup: false, + rules : { + name:{required : true, + remote : { + url : 'projects/judge_same_projectname', + type:'get', + dataType:'text', + data:{ + name : function(){ return $.trim( $("#name").val() ); } + }, + dataFilter:function( data ){ + if( data=='true')return false; else return true; + } + } + } + }, + messages : { + name:{required : "请填写项目名称!",remote:'您已新建过同名项目,请修改项目名称!'} + } + }); +} \ No newline at end of file From 9c848374923ae4fcf7a3b6ce79ecd4d5d2c42a34 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 22 May 2015 16:38:26 +0800 Subject: [PATCH 17/25] ... --- app/helpers/queries_helper.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index 1347c3026..5e78e3f98 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -255,7 +255,7 @@ module QueriesHelper # Give it a name, required to be valid @query = IssueQuery.new(:name => "_") @query.project = @project - params[:f] = %w(subject status_id priority_id author_id assigned_to_id created_on) unless params[:status_id].nil? + params[:f] = %w(subject status_id priority_id author_id assigned_to_id) unless params[:status_id].nil? params[:op] = {'subject' => "~" , 'status_id' => ( params[:status_id] == '0' ? "!":"=" ), 'priority_id' => ( params[:priority_id] == '0' ? "!":"=" ), @@ -266,19 +266,19 @@ module QueriesHelper 'priority_id' => [params[:priority_id]], 'author_id' => [params[:author_id]], 'assigned_to_id' => [params[:assigned_to_id]]} unless params[:status_id].nil? - if(params[:status_id] != nil) - if( params[:issue_create_date_start]!=nil && params[:issue_create_date_start]!='' && - params[:issue_create_date_end]!=nil && params[:issue_create_date_end]!='' ) - params[:op][:created_on]='><' - params[:v][:created_on]=[params[:issue_create_date_start],params[:issue_create_date_end]] - elsif(params[:issue_create_date_start]!=nil && params[:issue_create_date_start]!='') - params[:op][:created_on]='>=' - params[:v][:created_on]=[params[:issue_create_date_start]] - elsif(params[:issue_create_date_end]!=nil && params[:issue_create_date_end]!='') - params[:op][:created_on]='<=' - params[:v][:created_on]=[params[:issue_create_date_end]] - end - end + # if(params[:status_id] != nil) + # if( params[:issue_create_date_start]!=nil && params[:issue_create_date_start]!='' && + # params[:issue_create_date_end]!=nil && params[:issue_create_date_end]!='' ) + # params[:op][:created_on]='><' + # params[:v][:created_on]=[params[:issue_create_date_start],params[:issue_create_date_end]] + # elsif(params[:issue_create_date_start]!=nil && params[:issue_create_date_start]!='') + # params[:op][:created_on]='>=' + # params[:v][:created_on]=[params[:issue_create_date_start]] + # elsif(params[:issue_create_date_end]!=nil && params[:issue_create_date_end]!='') + # params[:op][:created_on]='<=' + # params[:v][:created_on]=[params[:issue_create_date_end]] + # end + # end @query.build_from_params(params) #session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names} # else From 2ac2884bf1d1072a68cce15a1fd9dfcdcf35ef22 Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 23 May 2015 10:10:38 +0800 Subject: [PATCH 18/25] =?UTF-8?q?=E4=BF=AE=E6=94=B9issue=E6=B3=A8=E5=85=A5?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=8A=A5=E9=94=99=EF=BC=88=E6=AF=94=E5=A6=82?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=90=8D=E5=B8=A6=E7=82=B9=E5=8F=B7=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 8acca7f81..4631a3348 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -169,7 +169,7 @@ class IssuesController < ApplicationController attrs = {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} redirect_to new_project_issue_url(@issue.project, :issue => attrs) else - redirect_to issue_url(@issue) + redirect_to issue_url(@issue.id) end } format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) } From 5460e9852682439ba8483083ac2fc98ad7f865e1 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Sat, 23 May 2015 10:10:47 +0800 Subject: [PATCH 19/25] ... --- app/helpers/queries_helper.rb | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index 5e78e3f98..43d01a5dd 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -255,7 +255,7 @@ module QueriesHelper # Give it a name, required to be valid @query = IssueQuery.new(:name => "_") @query.project = @project - params[:f] = %w(subject status_id priority_id author_id assigned_to_id) unless params[:status_id].nil? + params[:f] = %w(subject status_id priority_id author_id assigned_to_id created_on) unless params[:status_id].nil? params[:op] = {'subject' => "~" , 'status_id' => ( params[:status_id] == '0' ? "!":"=" ), 'priority_id' => ( params[:priority_id] == '0' ? "!":"=" ), @@ -266,19 +266,22 @@ module QueriesHelper 'priority_id' => [params[:priority_id]], 'author_id' => [params[:author_id]], 'assigned_to_id' => [params[:assigned_to_id]]} unless params[:status_id].nil? - # if(params[:status_id] != nil) - # if( params[:issue_create_date_start]!=nil && params[:issue_create_date_start]!='' && - # params[:issue_create_date_end]!=nil && params[:issue_create_date_end]!='' ) - # params[:op][:created_on]='><' - # params[:v][:created_on]=[params[:issue_create_date_start],params[:issue_create_date_end]] - # elsif(params[:issue_create_date_start]!=nil && params[:issue_create_date_start]!='') - # params[:op][:created_on]='>=' - # params[:v][:created_on]=[params[:issue_create_date_start]] - # elsif(params[:issue_create_date_end]!=nil && params[:issue_create_date_end]!='') - # params[:op][:created_on]='<=' - # params[:v][:created_on]=[params[:issue_create_date_end]] - # end - # end + if(params[:status_id] != nil) + if( params[:issue_create_date_start]!=nil && params[:issue_create_date_start]!='' && + params[:issue_create_date_end]!=nil && params[:issue_create_date_end]!='' ) + params[:op][:created_on]='><' + params[:v][:created_on]=[params[:issue_create_date_start],params[:issue_create_date_end]] + elsif(params[:issue_create_date_start]!=nil && params[:issue_create_date_start]!='') + params[:op][:created_on]='>=' + params[:v][:created_on]=[params[:issue_create_date_start]] + elsif(params[:issue_create_date_end]!=nil && params[:issue_create_date_end]!='') + params[:op][:created_on]='<=' + params[:v][:created_on]=[params[:issue_create_date_end]] + else + params[:op][:created_on]='!' + params[:v][:created_on]='' + end + end @query.build_from_params(params) #session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names} # else From 491a7a13aa30cacab8697aa7142aa90506c78e87 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Sat, 23 May 2015 10:17:16 +0800 Subject: [PATCH 20/25] bug#2659 --- app/views/projects/invite_members.html.erb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/views/projects/invite_members.html.erb b/app/views/projects/invite_members.html.erb index 97b36406e..a6a13e2b7 100644 --- a/app/views/projects/invite_members.html.erb +++ b/app/views/projects/invite_members.html.erb @@ -79,20 +79,25 @@ user_ischeck=true; } }); - if(user_ischeck==false){ - nh_show_err_message('请选择用户!'); - return false; - } var role_ischeck=false; $("input[name='membership[role_ids][]']").each(function(){ if($(this).prop('checked')){ role_ischeck=true; } }); + if(user_ischeck==false && role_ischeck==false){ + nh_show_err_message('请选择用户和角色!'); + return false; + } + if(user_ischeck==false){ + nh_show_err_message('请选择用户!'); + return false; + } if(role_ischeck==false){ nh_show_err_message('请选择角色!'); return false; } + return true; }); }); \ No newline at end of file From 379de18cd6a4a015c112cf4d6b5c9e5c35f9f2ee Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 23 May 2015 10:40:15 +0800 Subject: [PATCH 21/25] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=BA=93=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2=EF=BC=9A=201?= =?UTF-8?q?=E3=80=81=E6=90=9C=E7=B4=A2=E6=9D=A1=E4=BB=B6=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E4=B8=8D=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=85=A8=E9=83=A8=E8=B5=84=E6=BA=90=202?= =?UTF-8?q?=E3=80=81=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2=EF=BC=8C=E9=9D=9E?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E4=B8=8A=E4=BC=A0=E7=9A=84=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E4=B8=8D=E5=85=81=E8=AE=B8=E6=9F=A5=E7=9C=8B=203=E3=80=81?= =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2=EF=BC=8C=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E8=83=BD=E8=AE=BE=E7=BD=AE=E5=85=AC?= =?UTF-8?q?=E5=BC=80=E6=9D=83=E9=99=90=E7=9A=84=E8=B5=84=E6=BA=90=E5=9C=A8?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E6=90=9C=E7=B4=A2=E4=B8=AD=E4=B9=9F=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 14 ++++++++------ app/helpers/application_helper.rb | 4 ++-- app/views/files/_project_file_list.html.erb | 10 +++++----- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index aa2c9574b..0003f7586 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -67,9 +67,7 @@ class FilesController < ApplicationController end sort = "#{@sort} #{@order}" end - # show_attachments [@course] - begin q = "%#{params[:name].strip}%" #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? @@ -108,14 +106,18 @@ class FilesController < ApplicationController end sort = "#{@sort} #{@order}" end - begin q = "%#{params[:name].strip}%" #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? if params[:insite] - @result = find_public_attache q,sort - @result = visable_attachemnts_insite @result,@project - @searched_attach = paginateHelper @result,10 + if q == "%%" + @result = [] + @searched_attach = paginateHelper @result,10 + else + @result = find_public_attache q,sort + @result = visable_attachemnts_insite @result,@project + @searched_attach = paginateHelper @result,10 + end else @result = find_project_attache q,@project,sort @result = visable_attachemnts @result diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0836bf307..a07ff320d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -622,8 +622,8 @@ module ApplicationHelper # 公开项目资源可以引用,admin和管理员和资源上传者拥有设置公开私有权限 def authority_pubilic_for_files(project, file) @result = false - if (is_project_manager?(User.current.id, @project.id) || file.author_id == User.current.id || User.current.admin) && - project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project" + if (is_project_manager?(User.current.id, @project.id) && User.current.allowed_to?(:manage_files, project)) || file.author_id == User.current.id || User.current.admin && + project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project" @result = true end return @result diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb index d32d2319f..35aa36195 100644 --- a/app/views/files/_project_file_list.html.erb +++ b/app/views/files/_project_file_list.html.erb @@ -1,4 +1,4 @@ - +<% delete_allowed = User.current.allowed_to?(:manage_files, project) %>

共有 <%= all_attachments.count%> 个资源

@@ -22,13 +22,13 @@ <% if User.current.logged? %> <% if (manage_allowed || file.author_id == User.current.id) && project_contains_attachment?(project,file) %> <%= link_to(l(:label_slected_to_other_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> - <% else %> - <%= link_to(l(:label_slected_to_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> - <% end %> - <% if authority_pubilic_for_files(project, file) %> + <% if authority_pubilic_for_files(project, file) && delete_allowed %> <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %> + <% end %> + <% else %> + <%= link_to(l(:label_slected_to_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> <% end %> <% end %>

From ceafa459fdebbf078fa536aa8592852b0a0b406d Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 23 May 2015 11:26:36 +0800 Subject: [PATCH 22/25] =?UTF-8?q?issues=E7=BC=96=E8=BE=91=E6=97=B6?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 3 ++- app/views/issues/_action_menu.html.erb | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 4631a3348..83f68d8d8 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -239,7 +239,8 @@ class IssuesController < ApplicationController flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? respond_to do |format| - format.html { redirect_back_or_default issue_path(@issue) } + + format.html { redirect_to issue_url(@issue.id) } format.api { render_api_ok } end else diff --git a/app/views/issues/_action_menu.html.erb b/app/views/issues/_action_menu.html.erb index ff498f100..a5823ede3 100644 --- a/app/views/issues/_action_menu.html.erb +++ b/app/views/issues/_action_menu.html.erb @@ -2,7 +2,5 @@ <%#= 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_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), :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), :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) %> +<%= 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 c4c2da48db6e4955187d440abefa08e81891d711 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Sat, 23 May 2015 11:55:26 +0800 Subject: [PATCH 23/25] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug#2485:=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE--=E9=97=AE=E9=A2=98=E8=B7=9F=E8=B8=AA=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E5=BB=BA=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/issues/index.html.erb | 54 +++++++++++++++------------------ 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index bb8ea1bef..d075ae301 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -1,16 +1,9 @@