diff --git a/.gitignore b/.gitignore index 9d33b264c..601f691a1 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ public/javascripts/wechat/node_modules/ .access_token tmux*.log config/wechat.yml +config/oneapm.yml diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index eeea2d01a..8c6cc4f0c 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -26,7 +26,7 @@ class BlogsController < ApplicationController @type = 2 @topics.each do |topic| - topic[:infocount] = get_praise_num(topic) + (topic.parent ? topic.parent.children.count : topic.children.count) + topic[:infocount] = get_praise_num(topic) + BlogComment.where("root_id = #{topic.id}").count if topic[:infocount] < 0 topic[:infocount] = 0 end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 2bdaddb25..13a1a1e58 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # @@ -739,7 +740,7 @@ class ProjectsController < ApplicationController rescue Exception => e puts e end - # 删除Trustie班额本库记录 + # 删除Trustie版本库记录 repoisitory = Repository.where(:project_id => @project.id, :type => GITLABTYPE).first repoisitory.delete @project.update_column(:gpid, nil) @@ -799,6 +800,31 @@ class ProjectsController < ApplicationController @project = nil end + REP_TYPE = "Repository::Gitlab" + # Delete @project's repository + def destroy_repository + if is_project_manager?(User.current.id, @project.id) + @gitlab_repository = Repository.where(:project_id => @project, :type => REP_TYPE).first + @is_true = params[:is_true] + if @is_true + begin + g = Gitlab.client + g.delete_project(@project.gpid) + @gitlab_repository.destroy + @gitlab_repository = nil + scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first + @repository = Repository.factory(scm) + @repository.is_default = @project.repository.nil? + @project.update_attribute(:gpid, nil) + rescue Exception => e + puts e + end + end + else + return render_403 + end + end + def show_projects_score respond_to do |format| format.html { render :layout => "base_projects"} @@ -946,6 +972,14 @@ class ProjectsController < ApplicationController else @users -= watched.watcher_users if @watched end + @watchers = @project.watcher_users + @limit = 20 + @is_remote = true + @watchers_count = @watchers.count + @watcher_pages = Paginator.new @watchers_count, @limit, params['page'] || 1 + @offset ||= @watcher_pages.offset + #@curse_attachments_all = @all_attachments[@offset, @limit] + @watchers = paginateHelper @watchers,20 end end @@ -962,5 +996,7 @@ class ProjectsController < ApplicationController end return projects end + #gcmend end + diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index ec9f98ccf..a71f9c105 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -92,7 +92,7 @@ class PullRequestsController < ApplicationController if compare_pull_request(source_branch, target_project_id, target_branch) # 如果传送了目标项目ID即向fork源项目发送请求 # if params[:forked_project_id] && params[:source_project] == "forked_project_name" - if params[:target_project_id] + if params[:target_project_id].to_i != @project.id target_project_id = params[:forked_project_id].to_i request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch, :target_project_id => target_project_id) @fork_project_name = Project.find(params[:target_project_id]).try(:name) @@ -109,7 +109,7 @@ class PullRequestsController < ApplicationController format.js{redirect_to new_project_pull_request_path(:show_tip => tip)} end end - rescue Exception => e + rescue Gitlab::Error::Conflict => e @message = e.message end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 56b536d30..049789115 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1369,9 +1369,10 @@ class UsersController < ApplicationController @jour = jours.limit(10).offset(@page * 10) @type = params[:type] if User.current == @user - jours.update_all(:is_readed => true, :status => false) - jours.each do |journal| - fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false) + @jour.update_all(:is_readed => true, :status => false) + @jour.each do |journal| + # fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false) + journal.delay.set_children_readed_delay end end @state = false diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb index da0c5733a..6f0d96dfa 100644 --- a/app/controllers/watchers_controller.rb +++ b/app/controllers/watchers_controller.rb @@ -37,7 +37,9 @@ class WatchersController < ApplicationController @list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all(); @action = 'fans' else - + if params[:target_id] + @user = User.find(params[:target_id]) + end end if params[:object_type] == 'project' @@ -78,6 +80,9 @@ class WatchersController < ApplicationController @list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all(); @action = 'fans' else + if params[:target_id] + @user = User.find(params[:target_id]) + end end if params[:object_type] == 'project' @project = Project.find(params[:object_id]) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index a082d72ff..654f83855 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -137,7 +137,7 @@ class WechatsController < ActionController::Base on :fallback, respond: 'fallback message' on :click, with: 'FEEDBACK' do |request, key| - request.reply.text "如有问题反馈,请您:\n1、直接切换至输入框,发微信给我们。\n2、加入QQ群:373967360,直接互动。\n\n如您有合作事宜洽谈,请联系:\n王林春 老师\n手机:13467631747\nQQ:494496321" + request.reply.text "如有问题反馈,请您:\n1、直接切换至输入框,发微信给我们。\n2、加入QQ群:373967360,直接互动。\n3、登录网站:www.trustie.net,给我们留言。\n\n如您有合作事宜洽谈,请联系:\n王林春 老师\n手机:13467631747\nQQ:494496321" end on :click, with: 'MY_NEWS' do |request, key| diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 188481cb2..653afef62 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -312,6 +312,16 @@ module ProjectsHelper type << option2 end + # 判断用户是否为项目管理员 + def is_project_manager?(user_id, project_id) + @result = false + mem = Member.where("user_id = ? and project_id = ?",user_id, project_id) + unless mem.blank? + @result = mem.first.roles.to_s.include?("Manager") ? true : false + end + return @result + end + # 用来判断用户是否是项目的管理员 # added by william def is_manager?(user_id,project_id) diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index acece2307..09d9115b4 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -333,6 +333,7 @@ module WatchersHelper return '' unless user && user.logged? objects = Array.wrap(objects) watched = objects.any? {|object| object.watched_by?(user)} + watched = true if user.id == @project.user_id @watch_flag = objects.first.instance_of?(Project) id = watcher_css(objects) text = @watch_flag ? @@ -340,8 +341,13 @@ module WatchersHelper url = watch_path(:object_type => objects.first.class.to_s.underscore, :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)) method = watched ? 'delete' : 'post' - link_to text, url, :remote => true, :method => method, - :class => "pro_new_topbtn_left fl" ,:id=>id + if user.id != @project.user_id + link_to text, url, :remote => true, :method => method, + :class => "pro_new_topbtn_left fl" ,:id => id + else + link_to "关注", "javascript:void(0)", :remote => true, :method => method, + :class => "pro_new_grey_topbtn_left fl" , :id => id + end end def store_project_link project_id, user_id diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 4a9601d07..aa83c2210 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -344,4 +344,9 @@ class JournalsForMessage < ActiveRecord::Base def content_detail self.notes end + + def set_children_readed_delay + # fetch_user_leaveWord_reply(self).update_all(:is_readed => true, :status => false) + end + end diff --git a/app/views/issues/_statistics.html.erb b/app/views/issues/_statistics.html.erb index b144b8e6b..8b1fc6f22 100644 --- a/app/views/issues/_statistics.html.erb +++ b/app/views/issues/_statistics.html.erb @@ -12,7 +12,7 @@ <%= link_to "打开#{@issue_open_count}".html_safe, "", :remote => true, :class => "new_roadmap_type_nomal", :id => "new_roadmap_type_1", :id => "new_roadmap_type_2" %>
  • - <%= link_to "锁定#{@issue_close_count}".html_safe, "", :remote => true, :class => "new_roadmap_type_nomal", :id => "new_roadmap_type_1", :id => "new_roadmap_type_3" %> + <%= link_to "关闭#{@issue_close_count}".html_safe, "", :remote => true, :class => "new_roadmap_type_nomal", :id => "new_roadmap_type_1", :id => "new_roadmap_type_3" %>
  • diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 07be357dc..7846efa18 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -148,7 +148,7 @@
  • 粉丝
    - <%= @user.watcher_users.count %> + <%= @user.watcher_users.count %>
  • diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 2a4b3b480..fd7425aab 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -214,7 +214,8 @@
  • 确认密码 :