From be25a57eaf16aa5c1addf9172d15bb0c165a9b90 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sun, 1 Nov 2015 21:49:07 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E7=94=A8=E6=88=B7bug?= =?UTF-8?q?=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 4 +++- lib/gitlab-cli/lib/gitlab/client/users.rb | 5 +++++ lib/trustie/gitlab/helper.rb | 16 ++++++++++++++-- lib/trustie/gitlab/manage_user.rb | 1 - 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index e68fc7d8e..edc29c015 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -209,7 +209,7 @@ class User < Principal validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true validate :validate_password_length # validates_email_realness_of :mail - before_create :set_mail_notification, :sync_gitlab_user + before_create :set_mail_notification before_save :update_hashed_password before_destroy :remove_references_before_destroy # added by fq @@ -218,6 +218,8 @@ class User < Principal # 更新邮箱用户或用户名的同事,同步更新邀请信息 after_update :update_invite_list + include Trustie::Gitlab::ManageUser + scope :in_group, lambda {|group| group_id = group.is_a?(Group) ? group.id : group.to_i where("#{User.table_name}.id IN (SELECT gu.user_id FROM #{table_name_prefix}groups_users#{table_name_suffix} gu WHERE gu.group_id = ?)", group_id) diff --git a/lib/gitlab-cli/lib/gitlab/client/users.rb b/lib/gitlab-cli/lib/gitlab/client/users.rb index 3fc83cd1b..37bfc0d74 100644 --- a/lib/gitlab-cli/lib/gitlab/client/users.rb +++ b/lib/gitlab-cli/lib/gitlab/client/users.rb @@ -60,6 +60,11 @@ class Gitlab::Client put("/users/#{user_id}", :body => options) end + + def delete_user(user_id) + delete("/users/#{user_id}") + end + # Creates a new user session. # # @example diff --git a/lib/trustie/gitlab/helper.rb b/lib/trustie/gitlab/helper.rb index 5ea4c13e1..57c333875 100644 --- a/lib/trustie/gitlab/helper.rb +++ b/lib/trustie/gitlab/helper.rb @@ -4,15 +4,26 @@ module Trustie module Gitlab module Helper def change_password(uid, en_pwd, salt) + return unless uid options = {:encrypted_password=>en_pwd, :password_salt=>salt} self.g.put("/users/ext/#{uid}", :body => options) # g.edit_user(uid, :encrypted_password=>en_pwd, :password_salt=>salt) end + def find_user(user) + us = self.g.get("/users?search=#{user.mail}") + if Array === us + us.each do |u| + return u if u.email == user.mail + end + end + return nil + end + def add_user(user) u = nil begin - u = self.g.get("/users?search=#{user.mail}").first + u = find_user(user) unless u u = self.g.create_user(user.mail, user.hashed_password, @@ -29,7 +40,8 @@ module Trustie end def del_user(user) - ## gitlab unimplement + return unless user.gid + self.g.delete_user(user.gid) end end diff --git a/lib/trustie/gitlab/manage_user.rb b/lib/trustie/gitlab/manage_user.rb index 76528739c..15bd7ef78 100644 --- a/lib/trustie/gitlab/manage_user.rb +++ b/lib/trustie/gitlab/manage_user.rb @@ -27,7 +27,6 @@ module Trustie change_password(self.gid, self.hashed_password, self.salt) end - private def g @g ||= ::Gitlab.client end From fa0332babd387650b5885a094fef8a8bef8e5962 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sun, 1 Nov 2015 22:25:42 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E5=8F=AA=E6=9C=89=E5=9C=A8=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E9=A1=B9=E7=9B=AE=E6=97=B6=E6=89=8D=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 16 ++--------- lib/trustie/gitlab/manage_user.rb | 4 +-- lib/trustie/gitlab/sync.rb | 33 +++++++++++++++++++++- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 4cec85833..8a1b3bbe0 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -125,20 +125,8 @@ update @repository.type = 'Repository::Gitlab' @repository.url = @repository.identifier if request.post? && @repository.save - g = ::Gitlab.client - gid = @project.owner.gid - gproject = g.create_project(@repository.identifier, - path: @repository.identifier, - description: @project.description, - wiki_enabled: false, - wall_enabled: false, - issues_enabled: false, - snippets_enabled: false, - public: false, - user_id: gid - ) - @project.gpid = gproject.id - @project.save! + s = Trustie::Gitlab::Sync.new + s.create_project(@project, @repository) redirect_to settings_project_url(@project, :tab => 'repositories') else redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages) diff --git a/lib/trustie/gitlab/manage_user.rb b/lib/trustie/gitlab/manage_user.rb index 15bd7ef78..a87984490 100644 --- a/lib/trustie/gitlab/manage_user.rb +++ b/lib/trustie/gitlab/manage_user.rb @@ -9,8 +9,8 @@ module Trustie def self.included(base) base.class_eval { - before_create :add_gitlab_user - before_destroy :delete_gitlab_user + #before_create :add_gitlab_user + #before_destroy :delete_gitlab_user before_save :change_gitlab_user } end diff --git a/lib/trustie/gitlab/sync.rb b/lib/trustie/gitlab/sync.rb index ae1cded6c..3a8e8380c 100644 --- a/lib/trustie/gitlab/sync.rb +++ b/lib/trustie/gitlab/sync.rb @@ -26,10 +26,37 @@ module Trustie user.mail_notification = "day" end user.save! + u + end + + + def create_project(project, repository) + gid = project.owner.gid + unless gid + gid = sync_user(project.owner).id + end + raise "unknow gid" unless gid + + gproject = g.create_project(repository.identifier, + path: repository.identifier, + description: project.description, + wiki_enabled: false, + wall_enabled: false, + issues_enabled: false, + snippets_enabled: false, + public: false, + user_id: gid + ) + project.gpid = gproject.id + project.save! end def sync_project(project, opt={}) gid = project.owner.gid + unless gid + gid = sync_user(project.owner).id + end + raise "unknow gid" unless gid path = opt[:path] raise "unknow path" unless path @@ -61,7 +88,11 @@ module Trustie project.members.each do |m| begin - self.g.add_team_member(gproject.id, m.user.gid, UserLevel::DEVELOPER) + gid = m.user.gid + unless gid + gid = sync_user(m.user).id + end + self.g.add_team_member(gproject.id, gid, UserLevel::DEVELOPER) rescue => e puts e end From 681f33ee2ca552b4c5e4491e791a0f5dee6433a9 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 2 Nov 2015 09:35:13 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=A4=A7=E7=BA=B2=20?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/syllabus.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/syllabus.html.erb b/app/views/courses/syllabus.html.erb index 18f5817b0..bf6980dd2 100644 --- a/app/views/courses/syllabus.html.erb +++ b/app/views/courses/syllabus.html.erb @@ -58,7 +58,7 @@ '取消大纲', {:controller => 'blog_comments',:action => 'destroy',:user_id=>BlogComment.find(@course.outline).author_id,:blog_id=>BlogComment.find(@course.outline).blog_id, :id => @course.outline,:course_id=>@course.id}, :method => :delete, - :data => {:confirm => l(:text_are_you_sure)}, + :data => {:confirm => '确定取消么'}, :class => 'postOptionLink' ) if User.current && User.current.id == @article.author.id %> From 6288151f406b86ae3f06b337b793372a1ac91536 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 2 Nov 2015 09:49:21 +0800 Subject: [PATCH 4/8] =?UTF-8?q?qq=E7=BE=A4=E5=8A=A0=E5=85=A5=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_new_feedback.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_new_feedback.html.erb b/app/views/layouts/_new_feedback.html.erb index 8814d1043..0ef55d278 100644 --- a/app/views/layouts/_new_feedback.html.erb +++ b/app/views/layouts/_new_feedback.html.erb @@ -25,7 +25,7 @@ <%#= l(:label_technical_support) %> - + 请加入:师姐答疑群 From 25e1eb75ab989c9ae9cef9fddb8a67d87be5c77f Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 2 Nov 2015 09:49:58 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=86=85=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E4=BD=9C=E4=B8=9A=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/course.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/javascripts/course.js b/public/javascripts/course.js index ed920b48a..da24e2878 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -666,6 +666,7 @@ function regex_homework_end_publish_time() $("#homework_publish_time").val(myDate.toLocaleDateString()); } var publish_time = Date.parse($("#homework_publish_time").val()); + var end_time = Date.parse($("#homework_end_time").val()); if(end_time < publish_time) { $("#homework_end_time_span").text("截止日期不能小于发布日期"); @@ -1258,4 +1259,4 @@ function course_outline(id){ // $('#course_outline_search').on('input',function(){ // alert('<%= @course.id%>') // }) -//}) +//}) From 6e7a6909d619710df9ba9417348e9d9fd8732686 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 2 Nov 2015 10:02:02 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E6=9C=AA=E5=8F=91=E5=B8=83=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=8F=91=E5=B8=83=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_homework_detail.html.erb | 5 +++++ config/locales/zh.yml | 1 + 2 files changed, 6 insertions(+) diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index cffb1d97a..fb4ec6bbe 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -41,6 +41,11 @@ <%= homework_common.language_name%> <% end %> + <% if homework_common.homework_detail_manual.comment_status == 0 %> +
+ <%= l(:label_publish_time)%>:<%= homework_common.publish_time%> +
+ <% end %>
<%= l(:label_end_time)%>:<%= homework_common.end_time%>
diff --git a/config/locales/zh.yml b/config/locales/zh.yml index a7274c3c2..12c1b9258 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2024,6 +2024,7 @@ zh: label_creat: 创建 #api end + label_publish_time: 发布时间 label_end_time: 截止时间 label_send_email: 确定发送 label_input_email: 请输入邮箱地址(必填) From 6fffcec250856e82020d0a99015895371d0bfc1e Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 2 Nov 2015 10:10:32 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=A1=AB=E5=86=99=E7=9C=9F=E5=AE=9E=E5=90=8D=E5=AD=97=E7=9A=84?= =?UTF-8?q?=E8=AF=9D=EF=BC=8C=E9=82=A3=E4=B9=88=E5=B0=B1=E8=A6=81=E7=94=A8?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D=E4=BA=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/new_base_user.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 7b951f152..1eddeb517 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -46,7 +46,7 @@
<% if (@user.user_extensions && (@user.user_extensions.identity != 2) ) %> From 0aa2aefe03a1ffacf5a9bad69ccaf5be7439b49c Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 2 Nov 2015 10:30:51 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8D=E5=AF=86=E7=A0=81=E4=B8=8D=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/my/account.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 7bc674ea6..7e39ad5fa 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -170,7 +170,7 @@
  • 确认 - +