From bd4ea6a19902b9b248d235247333263cecbf08b8 Mon Sep 17 00:00:00 2001 From: "Gan Yi.ang" Date: Thu, 26 Nov 2015 09:13:41 +0800 Subject: [PATCH 01/14] just test tag1 --- tag1.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 tag1.txt diff --git a/tag1.txt b/tag1.txt new file mode 100644 index 000000000..391fb7fb3 --- /dev/null +++ b/tag1.txt @@ -0,0 +1 @@ +just test \ No newline at end of file From 3516cde5553c138c43f5e376e6f3f0602eaf1404 Mon Sep 17 00:00:00 2001 From: "Gan Yi.ang" Date: Sat, 28 Nov 2015 10:25:53 +0800 Subject: [PATCH 02/14] =?UTF-8?q?sync=5Fgitlab=5Fuser=E5=8A=A0=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/sync_gitlab_user.rake | 39 ++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/lib/tasks/sync_gitlab_user.rake b/lib/tasks/sync_gitlab_user.rake index fb84f5f08..9259353c0 100644 --- a/lib/tasks/sync_gitlab_user.rake +++ b/lib/tasks/sync_gitlab_user.rake @@ -6,32 +6,55 @@ namespace :gitlab do users = User.find_by_sql("select * from users where gid is null") s = Trustie::Gitlab::Sync.new g = Gitlab.client - logger = Logger.new('./log/add_gid.log', 'daily') #按天生成 + logger_i = Logger.new('./log/task_add_gid.log', 'daily') + logger_e = Logger.new('./log/task_add_gid_error.log', 'daily') + NAMESPACE_REGEX_STR = '(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_])'.freeze + MAIL_REGEX_STR ='^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$'.freeze + error_cnt=0 + success_cnt=0 + p "同步Gitlab用户开始..." users.each do |user| + info="userid=#{user.id},mail=#{user.mail},login(username)=#{user.login},name=#{user.show_name}" + # username不能有特殊字符,不能有保留字符,邮箱特殊字符(比如‘>’)导致search失败的,name不能为空串 + if !(user.login =~ /\A#{NAMESPACE_REGEX_STR}\Z/.freeze) + logger_e.error("#{info},error=校验失败:username特殊字符") + error_cnt+=1 + next + elsif !(user.mail.downcase =~ /#{MAIL_REGEX_STR}/) + logger_e.error("#{info},error=校验失败:邮箱特殊字符") + error_cnt+=1 + next + elsif user.show_name.lstrip.rstrip.blank? + logger_e.error("#{info},error=校验失败:name不正常") + error_cnt+=1 + next + end begin us = g.get("/users?search=#{user.mail}") - puts user.mail if us.blank? - puts "55555555555555555" s.sync_user(user) + logger_i.info("sync_remote_user:id=#{user.id},mail=#{user.mail}") + success_cnt+=1 else - # 解决查询的时候出现多值的情况,比如:123@163.com和g123@163.com - puts "66666666666666666666" - puts user.id if Array === us us.each do |u| if u.email == user.mail user.gid = u.id - user.save + # !爆炸方法抛出异常 + user.save! + logger_i.info("sync_local_user:#{info}") + success_cnt+=1 end end end end rescue => e - logger.error("userid=#{user.id},mail=#{user.mail},login=#{user.login},error=#{e}") + logger_e.error("#{info},error=#{e}") puts e end end + p "同步Gitlab用户结束..." + p "同步成功#{success_cnt},未完成#{error_cnt}" end task :sync_members => :environment do From bb7bcf46a9771ee1f7f0cbbc4239d67220c1d50f Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 8 Dec 2015 15:30:58 +0800 Subject: [PATCH 03/14] =?UTF-8?q?1.=E8=AE=BE=E7=BD=AE=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E8=B7=B3=E8=BD=AC=E8=87=B3=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E9=A6=96=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/_show_org_document.html.erb | 2 +- app/views/organizations/set_homepage.js.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb index 7588c7f6f..f2c635e90 100644 --- a/app/views/organizations/_show_org_document.html.erb +++ b/app/views/organizations/_show_org_document.html.erb @@ -27,7 +27,7 @@
    • - <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'set_homepage', :id => document.organization_id, :home_id => document.id}, :method => "put", :remote => true) do |f| %> + <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'set_homepage', :id => document.organization_id, :home_id => document.id, :show_homepage => 1}, :method => "put", :remote => true) do |f| %> 设为首页 <% end %>
    • diff --git a/app/views/organizations/set_homepage.js.erb b/app/views/organizations/set_homepage.js.erb index b25c4c4d4..5b56d57b3 100644 --- a/app/views/organizations/set_homepage.js.erb +++ b/app/views/organizations/set_homepage.js.erb @@ -1,2 +1,2 @@ //location.reload(); -window.location.href ='<%= organization_path(@org)%>' \ No newline at end of file +window.location.href ='<%= organization_path(@org, :show_homepage => params[:show_homepage])%>'; \ No newline at end of file From 56cb83ffba1a1d24c5dac8ac2d86ea64e3f126cc Mon Sep 17 00:00:00 2001 From: houxiang Date: Tue, 8 Dec 2015 15:56:31 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E6=B2=A1=E6=9C=89=E7=BB=9F=E8=AE=A1commit=5Fcount?= =?UTF-8?q?=EF=BC=8C=E5=85=B7=E4=BD=93=E7=9A=84=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E5=9C=A8=E5=BC=80=E5=A7=8B=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 42 +++++++++++--------- app/views/repositories/show.html.erb | 3 +- db/schema.rb | 45 +++++++++------------- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index c1e124063..dd3f4ede9 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -347,27 +347,13 @@ update # end - #add by hx - if g.commits(@project.gpid , :page=>25).count==0 - count = count_commits(@project.gpid , 0 , 25) - elsif g.commits(@project.gpid , :page=>50).count ==0 - count = count_commits(@project.gpid , 25 , 50)+ 25 * 20 - elsif g.commits(@project.gpid , :page=>75).count ==0 - count = count_commits(@project.gpid , 50 , 75)+ 50 * 20 - elsif g.commits(@project.gpid , :page=>100).count== 0 - count = count_commits(@project.gpid , 75 , 100) + 75 * 20 - elsif g.commits(@project.gpid , :page=>125).count==0 - count = count_commits(@project.gpid , 100 , 125) + 100 * 20 - elsif g.commits(@project.gpid , :page=>150).count==0 - count = count_commits(@project.gpid , 125 , 150) + 125 * 20 - else - count = count_commits(@project.gpid , 150 ,200) + 150 * 20 - end + + @changesets = g.commits(@project.gpid) # @changesets = @repository.latest_changesets(@path, @rev) # @changesets_count = @repository.latest_changesets(@path, @rev).count - @changesets_all_count = count + @changesets_all_count = 0 @changesets_latest_coimmit = @changesets[0] @properties = @repository.properties(@path, @rev) @repositories = @project.repositories @@ -410,8 +396,28 @@ update limit = 20 #每次页面的换回值从1开始,但是gitlab的页面查询是从0开始,所以先改变page的类型减一在改回来 @commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s) + + #add by hx + if g.commits(@project.gpid , :page=>200).count > 0 + count = 4020 + elsif g.commits(@project.gpid , :page=>25).count==0 + count = count_commits(@project.gpid , 0 , 25) + elsif g.commits(@project.gpid , :page=>50).count ==0 + count = count_commits(@project.gpid , 25 , 50)+ 25 * 20 + elsif g.commits(@project.gpid , :page=>75).count ==0 + count = count_commits(@project.gpid , 50 , 75)+ 50 * 20 + elsif g.commits(@project.gpid , :page=>100).count== 0 + count = count_commits(@project.gpid , 75 , 100) + 75 * 20 + elsif g.commits(@project.gpid , :page=>125).count==0 + count = count_commits(@project.gpid , 100 , 125) + 100 * 20 + elsif g.commits(@project.gpid , :page=>150).count==0 + count = count_commits(@project.gpid , 125 , 150) + 125 * 20 + else + count = count_commits(@project.gpid , 150 ,200) + 150 * 20 + end + #页面传递必须要str类型,但是Paginator的初始化必须要num类型,需要类型转化 - @commits_count = params[:commit_count].to_i + @commits_count = count @commits_pages = Redmine::Pagination::Paginator.new @commits_count,limit,params[:page] @commit = g.commit(@project.gpid,@rev) diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index ca62b9664..ee6d23bf7 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -52,7 +52,8 @@ - <%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1 ,:commit_count =>"#{@changesets_all_count}"} %> 提交 + + <%=link_to"全部提交次数", {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1 ,:commit_count =>"#{@changesets_all_count}"} %> diff --git a/db/schema.rb b/db/schema.rb index 6cc6b90c4..96dcae227 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -543,23 +543,26 @@ ActiveRecord::Schema.define(:version => 20151204062220) do add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["project_id"], :name => "documents_project_id" - create_table "dts", :force => true do |t| - t.string "IPLineCode" - t.string "Description" - t.string "Num" - t.string "Variable" - t.string "TraceInfo" - t.string "Method" + create_table "dts", :primary_key => "Num", :force => true do |t| + t.string "Defect", :limit => 50 + t.string "Category", :limit => 50 t.string "File" - t.string "IPLine" - t.string "Review" - t.string "Category" - t.string "Defect" - t.string "PreConditions" - t.string "StartLine" + t.string "Method" + t.string "Module", :limit => 20 + t.string "Variable", :limit => 50 + t.integer "StartLine" + t.integer "IPLine" + t.string "IPLineCode", :limit => 200 + t.string "Judge", :limit => 15 + t.integer "Review", :limit => 1 + t.string "Description" + t.text "PreConditions", :limit => 2147483647 + t.text "TraceInfo", :limit => 2147483647 + t.text "Code", :limit => 2147483647 t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "id", :null => false end create_table "enabled_modules", :force => true do |t| @@ -891,16 +894,6 @@ ActiveRecord::Schema.define(:version => 20151204062220) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_details_copy", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" @@ -970,7 +963,6 @@ ActiveRecord::Schema.define(:version => 20151204062220) do t.integer "course_group_id", :default => 0 end - add_index "members", ["course_id"], :name => "index_members_on_course_id" add_index "members", ["project_id"], :name => "index_members_on_project_id" add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true add_index "members", ["user_id"], :name => "index_members_on_user_id" @@ -1519,6 +1511,7 @@ ActiveRecord::Schema.define(:version => 20151204062220) do end add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" + add_index "student_works", ["homework_common_id"], :name => "index" create_table "student_works_evaluation_distributions", :force => true do |t| t.integer "student_work_id" From 09f0d0201eb731462daca693fa28eef04abf503d Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 9 Dec 2015 09:23:22 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=A0=8F=E7=9B=AE=E5=8F=91=E5=B8=96=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org_document_comments_controller.rb | 9 +++- app/models/org_subfield.rb | 1 + app/views/org_document_comments/new.html.erb | 45 +++++++++++++------ .../_org_left_subfield_list.html.erb | 2 +- .../organizations/_show_org_document.html.erb | 2 +- ...20151208073241_add_subfield_to_document.rb | 5 +++ 6 files changed, 47 insertions(+), 17 deletions(-) create mode 100644 db/migrate/20151208073241_add_subfield_to_document.rb diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 29b728268..e9f3d47fb 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -11,10 +11,17 @@ class OrgDocumentCommentsController < ApplicationController @org_document_comment = OrgDocumentComment.new(:organization_id => @organization.id, :creator_id => User.current.id) @org_document_comment.title = params[:org_document_comment][:title] @org_document_comment.content = params[:org_document_comment][:content] + if params[:field_id] + @org_document_comment.org_subfield_id = params[:field_id].to_i + end if @org_document_comment.save flash.keep[:notice] = l(:notice_successful_create) EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document_comment.id, :created_at => @org_document_comment.updated_at) - redirect_to organization_org_document_comments_path(@organization) + if params[:field_id] + redirect_to organization_path(@organization) + else + redirect_to organization_org_document_comments_path(@organization) + end else redirect_to new_org_document_comment_path(:organization_id => @organization.id) end diff --git a/app/models/org_subfield.rb b/app/models/org_subfield.rb index 1660310f8..087120b69 100644 --- a/app/models/org_subfield.rb +++ b/app/models/org_subfield.rb @@ -1,3 +1,4 @@ class OrgSubfield < ActiveRecord::Base belongs_to :organization, :foreign_key => :organization_id + has_many :org_document_comments end \ No newline at end of file diff --git a/app/views/org_document_comments/new.html.erb b/app/views/org_document_comments/new.html.erb index 11a7e9359..9150be608 100644 --- a/app/views/org_document_comments/new.html.erb +++ b/app/views/org_document_comments/new.html.erb @@ -1,24 +1,41 @@ <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg'%> -<%= form_tag organization_org_document_comments_path(:organization_id => @organization.id), :id => 'new_org_document_form' do |f| %> +<%= form_tag organization_org_document_comments_path(:organization_id => @organization.id, :field_id => params[:field_id]), :id => 'new_org_document_form' do |f| %>
      -