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" diff --git a/app/models/message.rb b/app/models/message.rb index e6df9493b..58b0c1b9e 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -83,7 +83,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| @@ -261,7 +261,7 @@ class Message < ActiveRecord::Base ws = WechatService.new 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) content = strip_html self.subject, 200 @@ -269,7 +269,7 @@ class Message < ActiveRecord::Base 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) content = strip_html self.content.html_safe, 200 @@ -279,7 +279,7 @@ 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) content = strip_html self.subject, 200 @@ -287,7 +287,7 @@ class Message < ActiveRecord::Base 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) content = strip_html self.content.html_safe, 200 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