diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index a137b7cd1..c6cb018a5 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -102,6 +102,7 @@ class IssuesController < ApplicationController @issue_count = @query.issue_count @test = params[:test] @project_sort = 'issues.updated_on desc' + if params[:test] != "0" case @test when "1" @@ -284,11 +285,11 @@ class IssuesController < ApplicationController # 用户编辑更改issue def update - # params[:assigned_to_id] = nil if params[:assigned_to_id].to_i == 0 + # params[:assigned_to_id] = nil if params[:assigned_to_id].to_i == 0 + # params[:fixed_version_id] = nil if params[:fixed_version_id].to_i == 0 if params[:issue_detail] issue = Issue.find(params[:id]) issue = update_user_issue_detail(issue, params) - @issue.assigned_to_id = nil if @issue.assigned_to_id == 0 @saved = update_user_issue_detail(issue, params) return else @@ -296,6 +297,7 @@ class IssuesController < ApplicationController return unless update_issue_from_params @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads])) @issue.assigned_to_id = nil if @issue.assigned_to_id == 0 + @issue.fixed_version_id = nil if @issue.fixed_version_id == 0 saved = false begin @saved = @issue.save_issue_with_child_records(params, @time_entry) @@ -630,7 +632,9 @@ class IssuesController < ApplicationController end end # 搜索结果 - @issues_filter = @query.issues(:order => @project_sort) + # SELECT assigned_to_id, count(*) as ac FROM `issues` where project_id = @project.id group by assigned_to_id order by ac desc; + @issues_filter = @query.issues.sort_by{ |i| Issue.where(:project_id => @project.id , :assigned_to_id => i.assigned_to_id).count }.reverse + # @issues_filter = @query.issues(:order => @project_sort) # if params[:type] == 1 || params[:type].nil? # @results = @issues_filter @@ -668,7 +672,7 @@ class IssuesController < ApplicationController @alltotal[issue.tracker_id.to_i] = @alltotal[issue.tracker_id.to_i] + 1 user_id = issue.assigned_to_id if issue.assigned_to_id.nil? - user_id = issue.author_id + user_id = 0 end if !@results[user_id].nil? @@ -696,7 +700,7 @@ class IssuesController < ApplicationController tmpuser = User.find(user_id) - @results[user_id][:name] = tmpuser.nil? ? " " : tmpuser.show_name + @results[user_id][:name] = tmpuser.nil? ? "" : tmpuser.show_name #所有的 @results[user_id][0] = 1 for i in 1..17 do diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 2bdaddb25..304ab8e02 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -739,7 +739,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 +799,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 + @gitlab_repository.destroy + @gitlab_repository = nil + @project.update_attribute(:gpid, nil) + scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first + @repository = Repository.factory(scm) + @repository.is_default = @project.repository.nil? + g.delete_project(@project.gpid) + 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"} diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index e481b09a6..ec9f98ccf 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -95,7 +95,7 @@ class PullRequestsController < ApplicationController if params[:target_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(target_project_id).try(:name) + @fork_project_name = Project.find(params[:target_project_id]).try(:name) @fork_pr_message = true if @fork_project_name else request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 3dff9c414..653afef62 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -267,6 +267,16 @@ module ProjectsHelper project_name = versions.blank? ? "" : versions.first.project.name grouped = Hash.new {|h,k| h[k] = []} grouped[project_name] << ["请选择里程碑", 0] + +=begin + unless selected.nil? + if (params[:action] == "show" ) && Version.find(selected.id).status == "closed" + version_name = Version.find(selected.id).name + grouped[project_name] << [version_name, selected.id] + end + end +=end + versions.each do |version| grouped[version.project.name] << [version.name, version.id] end @@ -302,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/users_helper.rb b/app/helpers/users_helper.rb index 228e83080..4dd3399a3 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -100,7 +100,7 @@ module UsersHelper def applied_project_users applied_message # case applied_message.status # when 3,2,1,5,4,7,6 - user = User.find(applied_message.applied_user_id) + user = User.find(applied_message.applied_user_id).show_name # end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 1b47d80cc..46a42cb34 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -854,7 +854,8 @@ class Issue < ActiveRecord::Base return @assignable_versions if @assignable_versions # versions = project.shared_versions.open.all - versions = Version.where(:project_id => project.id, :status => "open").order("created_on desc") + # versions = Version.where(:project_id => project.id, :status => "open").order("created_on desc") + versions = Version.where(:project_id => project.id).order("created_on desc") if fixed_version if fixed_version_id_changed? # nothing to do diff --git a/app/models/organization.rb b/app/models/organization.rb index 50f62ea11..284754c03 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -9,6 +9,7 @@ class Organization < ActiveRecord::Base has_many :org_subfields, :dependent => :destroy has_many :users, :through => :org_members has_many :files + has_many :org_messages, :class_name => 'OrgMessage', :dependent => :destroy acts_as_attachable validates_uniqueness_of :name after_create :save_as_org_activity, :add_default_subfields diff --git a/app/views/attachments/_project_file_links.html.erb b/app/views/attachments/_project_file_links.html.erb index cccc8382c..a1a978a48 100644 --- a/app/views/attachments/_project_file_links.html.erb +++ b/app/views/attachments/_project_file_links.html.erb @@ -30,9 +30,9 @@ <% for attachment in attachments %>

- <%if is_float%> -

- <% end%> + <% if is_float %> +
+ <% end %> <% if options[:length] %> <% if User.current.logged? %> @@ -42,15 +42,15 @@ <% end %> <% else %> <% if User.current.logged? %> - <%= link_to_short_attachment attachment, :length=> 58,:class => 'hidden link_file_a fl newsBlue mw400', :download => true -%> + <%= link_to_short_attachment attachment, :length => 58,:class => 'hidden link_file_a fl newsBlue mw400 h15', :download => true -%> <% else %> - <%= link_to(attachment.filename, signin_url_without_domain,:length=> 58, :class => "hidden link_file_a fl newsBlue mw400") %> + <%= link_to(attachment.filename, signin_url_without_domain,:length => 58, :class => "hidden link_file_a fl newsBlue mw400 h15") %> <% end %> <% end %> - <%if is_float%> + <% if is_float %>
- <% end%> + <% end %> <% if attachment.is_text? %> <%= link_to image_tag('magnifier.png'), diff --git a/app/views/issues/_form.html.erb b/app/views/issues/_form.html.erb index 02ae7f677..94b55f3e2 100644 --- a/app/views/issues/_form.html.erb +++ b/app/views/issues/_form.html.erb @@ -98,8 +98,8 @@
  • <% if @issue.safe_attribute? 'start_date' %> <%= f.text_field :start_date, :size => 22, :disabled => !@issue.leaf?, :no_label => true, - :required => @issue.required_attribute?('start_date'), :onchange=>"issue_start_date_change();", - :class=>"fl calendar_input", :style=>"width:170px;" %> + :required => @issue.required_attribute?('start_date'), :onchange => "issue_start_date_change();", + :class => "fl calendar_input", :style => "width:170px;" %> <%= calendar_for('issue_start_date', 'start_date') if @issue.leaf? %> <% end %>
  • @@ -110,8 +110,8 @@ <% if @issue.safe_attribute? 'due_date' %> <%= f.text_field :due_date, :size => 22, :disabled => !@issue.leaf?, :no_label => true, - :required => @issue.required_attribute?('due_date'), :onchange=>"issue_end_date_change();", - :class=>"fl calendar_input",:style=>"width: 170px;", :placeholder=> "请选择结束日期" %> + :required => @issue.required_attribute?('due_date'), :onchange => "issue_end_date_change();", + :class => "fl calendar_input",:style => "width: 170px;", :placeholder => "请选择结束日期" %> <%= calendar_for('issue_due_date', 'start_date') if @issue.leaf? %> <% end %> @@ -121,7 +121,7 @@
  • <% if @issue.safe_attribute? 'estimated_hours' %> <%= f.text_field :estimated_hours, :size => 22, :disabled => !@issue.leaf?, :no_label => true, - :required => @issue.required_attribute?('estimated_hours'), :placeholder=> "请填写预计工时" %> + :required => @issue.required_attribute?('estimated_hours'), :placeholder => "请填写预计工时" %> <% end %>
  • <%= l(:field_estimated_hours) %>
  • @@ -160,9 +160,5 @@ } // 里程碑添加默认选项 $("#issue_fixed_version_id option[value='']").remove(); - <%# if params[:action] == "new" %> -// $('#issue_fixed_version_id').prepend(""); - <%# else %> -// $('#issue_fixed_version_id').prepend(""); - <%# end %> + diff --git a/app/views/issues/_statistics_all.html.erb b/app/views/issues/_statistics_all.html.erb index 0ef85057a..b9b593b91 100644 --- a/app/views/issues/_statistics_all.html.erb +++ b/app/views/issues/_statistics_all.html.erb @@ -11,9 +11,18 @@ + + 合计 + <%= @alltotal[0] %> + <%= @alltotal[2] %> + <%= @alltotal[4] %> + <%= @alltotal[1] %> + <%= @alltotal[3] %> + <%= @alltotal[5] %> + <% @results.each do |k,v|%> - <%= v[:name] %> + <%= v[:name] =="Anonymous" ? "未指派" : v[:name] %> <%= v[0] %> <%= v[2] %> <%= v[4] %> @@ -22,14 +31,5 @@ <%= v[5] %> <% end %> - - Total - <%= @alltotal[0] %> - <%= @alltotal[2] %> - <%= @alltotal[4] %> - <%= @alltotal[1] %> - <%= @alltotal[3] %> - <%= @alltotal[5] %> - \ No newline at end of file diff --git a/app/views/issues/_statistics_lock.html.erb b/app/views/issues/_statistics_lock.html.erb index f8628144e..edcd9b090 100644 --- a/app/views/issues/_statistics_lock.html.erb +++ b/app/views/issues/_statistics_lock.html.erb @@ -11,10 +11,19 @@ + + 合计 + <%= @closetotal[0] %> + <%= @closetotal[2] %> + <%= @closetotal[4] %> + <%= @closetotal[1] %> + <%= @closetotal[3] %> + <%= @closetotal[5] %> + <% @results.each do |k,v|%> <% if v[12] > 0 %> - <%= v[:name] %> + <%= v[:name] == "Anonymous" ? "未指派" : v[:name] %> <%= v[12] %> <%= v[14] %> <%= v[16] %> @@ -24,14 +33,5 @@ <% end %> <% end %> - - Total - <%= @closetotal[0] %> - <%= @closetotal[2] %> - <%= @closetotal[4] %> - <%= @closetotal[1] %> - <%= @closetotal[3] %> - <%= @closetotal[5] %> - \ No newline at end of file diff --git a/app/views/issues/_statistics_open.html.erb b/app/views/issues/_statistics_open.html.erb index d5eb843f7..e5d07a138 100644 --- a/app/views/issues/_statistics_open.html.erb +++ b/app/views/issues/_statistics_open.html.erb @@ -11,10 +11,19 @@ + + 合计 + <%= @opentotal[0] %> + <%= @opentotal[2] %> + <%= @opentotal[4] %> + <%= @opentotal[1] %> + <%= @opentotal[3] %> + <%= @opentotal[5] %> + <% @results.each do |k,v|%> <% if v[6] > 0 %> - <%= v[:name] %> + <%= v[:name] =="Anonymous" ? "未指派" : v[:name] %> <%= v[6] %> <%= v[8] %> <%= v[10] %> @@ -24,14 +33,5 @@ <% end %> <% end %> - - Total - <%= @opentotal[0] %> - <%= @opentotal[2] %> - <%= @opentotal[4] %> - <%= @opentotal[1] %> - <%= @opentotal[3] %> - <%= @opentotal[5] %> - \ No newline at end of file diff --git a/app/views/projects/_reposistory_destory_pop.html.erb b/app/views/projects/_reposistory_destory_pop.html.erb new file mode 100644 index 000000000..1f8dd06f2 --- /dev/null +++ b/app/views/projects/_reposistory_destory_pop.html.erb @@ -0,0 +1,22 @@ +
    +
    +

    提示

    + +
    +
    +
    +
      +
    • + 删除操作会彻底删除版本库及源码,一旦删除不能恢复
      + 你确定删除吗? +
    • +
    • + + 取  消 + + <%= link_to "确 定", destroy_repository_project_path(@project, :is_true => true), :remote => true, :class => "sy_btn_blue fl ml20", :onclick => "hideModal();" %> +
      +
    • +
    +
    +
    \ No newline at end of file diff --git a/app/views/projects/destroy_repository.js.erb b/app/views/projects/destroy_repository.js.erb new file mode 100644 index 000000000..3bc1d727b --- /dev/null +++ b/app/views/projects/destroy_repository.js.erb @@ -0,0 +1,6 @@ +<% if @is_true %> +$("#pro_st_tbc_06").html('<%= escape_javascript( render :partial => 'projects/settings/new_repositories') %>'); +<% else %> +var htmlvalue = "<%= escape_javascript(render :partial => 'projects/reposistory_destory_pop') %>"; +pop_box_new(htmlvalue,460,316); +<% end %> diff --git a/app/views/projects/settings/_new_repositories.html.erb b/app/views/projects/settings/_new_repositories.html.erb index a531e904a..7322a0615 100644 --- a/app/views/projects/settings/_new_repositories.html.erb +++ b/app/views/projects/settings/_new_repositories.html.erb @@ -14,11 +14,11 @@ - <%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false, :label=>"", :no_label => true, :class => "w650 fl", :style => "height: 28px;", :id => "project_setting_repository" %> + <%= f.text_field :identifier, :disabled => @repository.nil? || @repository.identifier_frozen? ? true:false, :label=>"", :no_label => true, :class => "w650 fl", :style => "height: 28px;", :id => "project_setting_repository" %>
  • - +

    1.长度必须在1到254个字符之间
    2.仅限使用小写字母(a-z)、数字、破折号(-)和下划线(_)
    3.一旦保存,标识无法修改

    @@ -35,14 +35,22 @@ 版本库名 管理系统 - 库路径 + 库路径 +   <%= @gitlab_repository.identifier %> Git - <%=h @repos_url %> + <%=h @repos_url %> + + <% if is_project_manager?(User.current.id, @project.id) %> + <%= link_to "删除", destroy_repository_project_path(@project), :class => "c_blue", :remote => true %> + <% else %> + <%= "删除" %> + <% end %> + diff --git a/app/views/pull_requests/index.html.erb b/app/views/pull_requests/index.html.erb index 2e10d6598..f2591b6ea 100644 --- a/app/views/pull_requests/index.html.erb +++ b/app/views/pull_requests/index.html.erb @@ -3,9 +3,18 @@
      -
    • <%= link_to "待处理#{@requests_opened_count}".html_safe, project_pull_requests_path(:type => "1"), :remote => true, :class => "new_roadmap_type_nomal" %>
    • -
    • <%= link_to "已处理#{@requests_merged_count}".html_safe, project_pull_requests_path(:type => "2"), :remote => true, :class => "new_roadmap_type_nomal" %>
    • -
    • <%= link_to "已关闭#{@requests_closed_count}".html_safe, project_pull_requests_path(:type => "3"), :remote => true, :class => "new_roadmap_type_nomal" %>
    • +
    • + <%= link_to "待处理#{@requests_opened_count}".html_safe, + project_pull_requests_path(:type => "1"), :remote => true, :class => "new_roadmap_type_nomal", :id => "new_roadmap_type_1", :id => "new_roadmap_type_1" %> +
    • +
    • + <%= link_to "已处理#{@requests_merged_count}".html_safe, + project_pull_requests_path(:type => "2"), :remote => true, :class => "new_roadmap_type_nomal", :id => "new_roadmap_type_1", :id => "new_roadmap_type_2" %> +
    • +
    • + <%= link_to "已关闭#{@requests_closed_count}".html_safe, + project_pull_requests_path(:type => "3"), :remote => true, :class => "new_roadmap_type_nomal", :id => "new_roadmap_type_1", :id => "new_roadmap_type_3" %> +
    <% if allow_pull_request(@project) && User.current.member_of?(@project) %> <%= link_to "创建Pull Request", new_project_pull_request_path, :class => "btn btn-green fr mr15 mt10" %> @@ -34,11 +43,23 @@ <% else %> <%= render :partial => "projects/no_data" %> diff --git a/app/views/users/_user_at_message.html.erb b/app/views/users/_user_at_message.html.erb index 7bcbe8aa8..024934471 100644 --- a/app/views/users/_user_at_message.html.erb +++ b/app/views/users/_user_at_message.html.erb @@ -2,7 +2,9 @@