From e23262225a39f49a313b052d1427753461d2521f Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 Apr 2016 10:34:45 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E5=90=8D?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=98=AF=E5=85=A8=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/repository.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index 571bba1b9..305c82f97 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -44,7 +44,7 @@ class Repository < ActiveRecord::Base # validates_uniqueness_of :identifier, :allow_blank => true validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph) # donwcase letters, digits, dashes, underscores but not digits only - validates_format_of :identifier, :with => /^[a-z0-9_\-]+$/, :allow_blank => true + validates_format_of :identifier, :with => /^[a-zA-Z0-9_\-]*[a-zA-Z_\-]+[a-zA-Z0-9_\-]*$/, :allow_blank => true # Checks if the SCM is enabled when creating a repository validate :repo_create_validation, :on => :create From aaeec3ab6c59138cd07c7f51c0141ef7865146f6 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 Apr 2016 10:58:41 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93show=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=BB=A3=E7=A0=81=E7=AE=80=E5=8C=96=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 25 ++++------------------ 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 0edd11129..b73ecf9b9 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -325,27 +325,11 @@ update end end - # unless @repository.gitlab? - # # redirect_to to_gitlab_project_repository_path(@project, @repository) - # render :to_gitlab - # return - # end - - #if( !User.current.member_of?(@project) || @project.hidden_repo) - # @repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty? - - # :name, :path, :kind, :size, :lastrev, :changeset @entries = @repository.entries(@path, @rev) - # @trees = g.trees(project, @path) @changeset = @repository.find_changeset_by_name(@rev) - #@project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT - #@ip = RepositoriesHelper::REPO_IP_ADDRESS - if request.xhr? @entries ? render(:partial => 'dir_list_content') : render(:nothing => true) else - #Modified by young - # (show_error_not_found; return) unless @entries g = Gitlab.client @changesets = g.commits(@project.gpid, :ref_name => @rev) g_project = g.project(@project.gpid) @@ -360,17 +344,16 @@ update if @changesets_all_count != @project.project_score.changeset_num && @changesets_all_count != 0 update_commits_count(@project, @changesets_all_count) end - # end # 最近一次提交 @changesets_latest_coimmit = @changesets[0] unless @changesets[0].blank? update_commits_date(@project, @changesets_latest_coimmit) end @creator = User.where("id =?", @project.user_id).first.try(:login) - @properties = @repository.properties(@path, @rev) - @repositories = @project.repositories - project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT - ip = RepositoriesHelper::REPO_IP_ADDRESS + # @properties = @repository.properties(@path, @rev) + # @repositories = @project.repositories + # project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT + # ip = RepositoriesHelper::REPO_IP_ADDRESS gitlab_address = Redmine::Configuration['gitlab_address'] if @repository.type.to_s == "Repository::Gitlab" @repos_url = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+@repository.identifier+"."+"git" From c4bd78e4421ee2531361ddca0a10b68b2efd77b5 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 Apr 2016 12:44:37 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=BF=98=E5=8E=9F=E5=8F=8A=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/message.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/message.rb b/app/models/message.rb index f5df220a0..bb12473be 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -80,7 +80,7 @@ class Message < ActiveRecord::Base # after_create :add_author_as_watcher, :reset_counters!, :add_boards_count after_update :update_messages_board, :update_activity after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score - after_create :act_as_course_activity, :act_as_forge_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count + after_create :act_as_course_activity, :act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count #before_save :be_user_score scope :visible, lambda {|*args| @@ -257,13 +257,13 @@ class Message < ActiveRecord::Base def act_as_system_message if self.course if self.parent_id.nil? # 主贴 - self.course.members.each do |m| + self.course.members.includes(:user).each do |m| if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) end end else # 回帖 - self.course.members.each do |m| + self.course.members.includes(:user).each do |m| if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) end @@ -271,13 +271,13 @@ class Message < ActiveRecord::Base end elsif self.project # 项目相关 if self.parent_id.nil? # 主贴 - self.project.members.each do |m| + self.project.members.includes(:user).each do |m| if m.user_id != self.author_id self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) end end else # 回帖 - self.project.members.each do |m| + self.project.members.includes(:user).each do |m| if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) end