diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index cd467d2d7..73892b1d8 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -30,6 +30,7 @@ class RepositoriesController < ApplicationController before_filter :find_project_by_project_id, :only => [:new, :create] before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] before_filter :find_project_repository, :except => [:new, :create, :edit, :update, :destroy, :committers] + before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] before_filter :authorize accept_rss_auth :revisions @@ -185,16 +186,56 @@ class RepositoriesController < ApplicationController end def revision - raise ChangesetNotFound if @rev.blank? - @changeset = @repository.find_changeset_by_name(@rev) - raise ChangesetNotFound unless @changeset - respond_to do |format| format.html format.js {render :layout => false} end - rescue ChangesetNotFound - show_error_not_found + end + + # Adds a related issue to a changeset + # POST /projects/:project_id/repository/(:repository_id/)revisions/:rev/issues + def add_related_issue + @issue = @changeset.find_referenced_issue_by_id(params[:issue_id]) + if @issue && (!@issue.visible? || @changeset.issues.include?(@issue)) + @issue = nil + end + + if @issue + @changeset.issues << @issue + respond_to do |format| + format.js { + render :update do |page| + page.replace_html "related-issues", :partial => "related_issues" + page.visual_effect :highlight, "related-issue-#{@issue.id}" + end + } + end + else + respond_to do |format| + format.js { + render :update do |page| + page.alert(l(:label_issue) + ' ' + l('activerecord.errors.messages.invalid')) + end + } + end + end + end + + # Removes a related issue from a changeset + # DELETE /projects/:project_id/repository/(:repository_id/)revisions/:rev/issues/:issue_id + def remove_related_issue + @issue = Issue.visible.find_by_id(params[:issue_id]) + if @issue + @changeset.issues.delete(@issue) + end + + respond_to do |format| + format.js { + render :update do |page| + page.remove "related-issue-#{@issue.id}" + end if @issue + } + end end def diff @@ -282,6 +323,13 @@ class RepositoriesController < ApplicationController show_error_not_found end + def find_changeset + if @rev.present? + @changeset = @repository.find_changeset_by_name(@rev) + end + show_error_not_found unless @changeset + end + def show_error_not_found render_error :message => l(:error_scm_not_found), :status => 404 end diff --git a/app/models/changeset.rb b/app/models/changeset.rb index d017ad03b..1e9a12e7c 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -184,8 +184,6 @@ class Changeset < ActiveRecord::Base :from_revision => change[:from_revision]) end - private - # Finds an issue that can be referenced by the commit message def find_referenced_issue_by_id(id) return nil if id.blank? @@ -203,6 +201,8 @@ class Changeset < ActiveRecord::Base issue end + private + def fix_issue(issue) status = IssueStatus.find_by_id(Setting.commit_fix_status_id.to_i) if status.nil? diff --git a/app/views/repositories/_related_issues.html.erb b/app/views/repositories/_related_issues.html.erb new file mode 100644 index 000000000..d65d07945 --- /dev/null +++ b/app/views/repositories/_related_issues.html.erb @@ -0,0 +1,34 @@ +<% manage_allowed = User.current.allowed_to?(:manage_related_issues, @repository.project) %> + + diff --git a/app/views/repositories/revision.html.erb b/app/views/repositories/revision.html.erb index 7c44cd674..4e7ad4c2a 100644 --- a/app/views/repositories/revision.html.erb +++ b/app/views/repositories/revision.html.erb @@ -64,13 +64,8 @@ <%= textilizable @changeset.comments %> -<% if @changeset.issues.visible.any? %> -

<%= l(:label_related_issues) %>

- +<% if @changeset.issues.visible.any? || User.current.allowed_to?(:manage_related_issues, @repository.project) %> + <%= render :partial => 'related_issues' %> <% end %> <% if User.current.allowed_to?(:browse_repository, @project) %> diff --git a/config/locales/ar.yml b/config/locales/ar.yml index 6cbc4b273..2e262f83e 100644 --- a/config/locales/ar.yml +++ b/config/locales/ar.yml @@ -1022,3 +1022,4 @@ ar: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 4684cb708..8de05cd2c 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -1020,3 +1020,4 @@ bg: description_date_range_interval: Изберете диапазон чрез задаване на начална и крайна дати description_date_from: Въведете начална дата description_date_to: Въведете крайна дата + permission_manage_related_issues: Manage related issues diff --git a/config/locales/bs.yml b/config/locales/bs.yml index 031138623..147b687c2 100644 --- a/config/locales/bs.yml +++ b/config/locales/bs.yml @@ -1036,3 +1036,4 @@ bs: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 77097eac1..86e997c2e 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -1024,3 +1024,4 @@ ca: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 09f265d6e..f2e08f4d6 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -1025,3 +1025,4 @@ cs: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/da.yml b/config/locales/da.yml index 538a33bc0..386574965 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -1039,3 +1039,4 @@ da: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/de.yml b/config/locales/de.yml index b6f433ed1..aef545709 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1042,3 +1042,4 @@ de: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/el.yml b/config/locales/el.yml index 8c033eb36..50537d5aa 100644 --- a/config/locales/el.yml +++ b/config/locales/el.yml @@ -1022,3 +1022,4 @@ el: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index a89dafaf1..2cbd77065 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -1024,3 +1024,4 @@ en-GB: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/en.yml b/config/locales/en.yml index 47f009830..d2cdb8220 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -440,6 +440,7 @@ en: permission_delete_own_messages: Delete own messages permission_export_wiki_pages: Export wiki pages permission_manage_subtasks: Manage subtasks + permission_manage_related_issues: Manage related issues project_module_issue_tracking: Issue tracking project_module_time_tracking: Time tracking diff --git a/config/locales/es.yml b/config/locales/es.yml index 407e94c81..19531ca77 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1059,3 +1059,4 @@ es: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/eu.yml b/config/locales/eu.yml index 67c546a4a..a85e7cd8b 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -1025,3 +1025,4 @@ eu: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/fa.yml b/config/locales/fa.yml index 13e9161f9..bd10913a3 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -1024,3 +1024,4 @@ fa: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 2f8c01249..2da468723 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -1043,3 +1043,4 @@ fi: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 77241b293..7ba367c71 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -436,6 +436,7 @@ fr: permission_export_wiki_pages: Exporter les pages permission_manage_project_activities: Gérer les activités permission_manage_subtasks: Gérer les sous-tâches + permission_manage_related_issues: Gérer les demandes associées project_module_issue_tracking: Suivi des demandes project_module_time_tracking: Suivi du temps passé diff --git a/config/locales/gl.yml b/config/locales/gl.yml index c4e3216ed..17b583a08 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -1033,3 +1033,4 @@ gl: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/he.yml b/config/locales/he.yml index 73ad5b368..0a5671302 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -1027,3 +1027,4 @@ he: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/hr.yml b/config/locales/hr.yml index f4fc6e91b..462615d28 100644 --- a/config/locales/hr.yml +++ b/config/locales/hr.yml @@ -1028,3 +1028,4 @@ hr: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 96ea2bbc1..363575d44 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -1041,3 +1041,4 @@ text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/id.yml b/config/locales/id.yml index 9874afe1f..e6ab8d1a7 100644 --- a/config/locales/id.yml +++ b/config/locales/id.yml @@ -1028,3 +1028,4 @@ id: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/it.yml b/config/locales/it.yml index 4c2e2b08f..c91879396 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -1023,3 +1023,4 @@ it: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 0fbb23a9e..f6635cbfe 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -1052,3 +1052,4 @@ ja: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/ko.yml b/config/locales/ko.yml index f38641bd7..60f3af8ee 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -1072,3 +1072,4 @@ ko: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/lt.yml b/config/locales/lt.yml index a1cd35bb1..921e437f2 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -1082,3 +1082,4 @@ lt: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/lv.yml b/config/locales/lv.yml index adeafaff3..05a1cc763 100644 --- a/config/locales/lv.yml +++ b/config/locales/lv.yml @@ -1016,3 +1016,4 @@ lv: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/mk.yml b/config/locales/mk.yml index fb79c4cbe..6f2fb2a0f 100644 --- a/config/locales/mk.yml +++ b/config/locales/mk.yml @@ -1022,3 +1022,4 @@ mk: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/mn.yml b/config/locales/mn.yml index 4b589adbf..c4f3ca752 100644 --- a/config/locales/mn.yml +++ b/config/locales/mn.yml @@ -1022,3 +1022,4 @@ mn: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/nl.yml b/config/locales/nl.yml index f73b46bcf..4db1f7425 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -1004,3 +1004,4 @@ nl: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/no.yml b/config/locales/no.yml index 1acd50d79..18689cb92 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -1012,3 +1012,4 @@ text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 6d841e26d..4aa418167 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -1039,3 +1039,4 @@ pl: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 1dc70a179..b26d13367 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -1045,3 +1045,4 @@ pt-BR: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 737d8044c..ecbca9431 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -1027,3 +1027,4 @@ pt: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/ro.yml b/config/locales/ro.yml index 62378ce6e..6b243c65e 100644 --- a/config/locales/ro.yml +++ b/config/locales/ro.yml @@ -1019,3 +1019,4 @@ ro: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 8ac0e5903..ab1faecae 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -1135,3 +1135,4 @@ ru: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/sk.yml b/config/locales/sk.yml index 2d210d36d..d8c71c6ab 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -1022,3 +1022,4 @@ sk: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/sl.yml b/config/locales/sl.yml index e84766094..0016aceb1 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -1022,3 +1022,4 @@ sl: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/sr-YU.yml b/config/locales/sr-YU.yml index 6059c5ccf..a98aaedb3 100644 --- a/config/locales/sr-YU.yml +++ b/config/locales/sr-YU.yml @@ -1022,3 +1022,4 @@ sr-YU: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/sr.yml b/config/locales/sr.yml index 6baabf1ac..7c5b0f249 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -1023,3 +1023,4 @@ sr: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/sv.yml b/config/locales/sv.yml index 7f38a2e9f..e4a9dd893 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -1063,3 +1063,4 @@ sv: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/th.yml b/config/locales/th.yml index 81137e8f1..26e468c11 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -1019,3 +1019,4 @@ th: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/tr.yml b/config/locales/tr.yml index e9b1b2fb2..d73663adf 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -1041,3 +1041,4 @@ tr: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 1e7616cc1..86d1d9e0c 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -1019,3 +1019,4 @@ uk: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/vi.yml b/config/locales/vi.yml index ce72ef3f1..0d2068be9 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -1073,3 +1073,4 @@ vi: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 4d23b83b7..196dd2d82 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -1102,3 +1102,4 @@ text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 4fffcee9c..9da84db9e 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1024,3 +1024,4 @@ zh: text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} + permission_manage_related_issues: Manage related issues diff --git a/config/routes.rb b/config/routes.rb index d5794c913..15953076f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -250,6 +250,10 @@ ActionController::Routing::Routes.draw do |map| :action => 'revisions' repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev', :action => 'revision' + repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/issues', + :action => 'add_related_issue', :conditions => {:method => :post} + repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', + :action => 'remove_related_issue', :conditions => {:method => :delete} repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/diff', :action => 'diff' repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/diff.:format', @@ -272,6 +276,10 @@ ActionController::Routing::Routes.draw do |map| :action => 'revisions' repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision' + repository_views.connect 'projects/:id/repository/revisions/:rev/issues', + :action => 'add_related_issue', :conditions => {:method => :post} + repository_views.connect 'projects/:id/repository/revisions/:rev/issues/:issue_id', + :action => 'remove_related_issue', :conditions => {:method => :delete} repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff' repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', diff --git a/lib/redmine.rb b/lib/redmine.rb index b43a53b71..6cb88a9bc 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -128,6 +128,7 @@ Redmine::AccessControl.map do |map| map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] map.permission :view_changesets, :repositories => [:show, :revisions, :revision] map.permission :commit_access, {} + map.permission :manage_related_issues, {:repositories => [:add_related_issue, :remove_related_issue]} end map.project_module :boards do |map| diff --git a/lib/redmine/default_data/loader.rb b/lib/redmine/default_data/loader.rb index 5ebe69efa..88029ba54 100644 --- a/lib/redmine/default_data/loader.rb +++ b/lib/redmine/default_data/loader.rb @@ -73,7 +73,8 @@ module Redmine :manage_files, :browse_repository, :view_changesets, - :commit_access] + :commit_access, + :manage_related_issues] reporter = Role.create! :name => l(:default_role_reporter), :position => 3, diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index d0043fa11..29102fcb6 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -399,6 +399,8 @@ ul.projects div.root a.project { font-family: "Trebuchet MS", Verdana, sans-seri #tracker_project_ids ul { margin: 0; padding-left: 1em; } #tracker_project_ids li { list-style-type:none; } +#related-issues li img {vertical-align:middle;} + ul.properties {padding:0; font-size: 0.9em; color: #777;} ul.properties li {list-style-type:none;} ul.properties li span {font-style:italic;} diff --git a/test/fixtures/roles.yml b/test/fixtures/roles.yml index 0549ebe6c..0eaaafe72 100644 --- a/test/fixtures/roles.yml +++ b/test/fixtures/roles.yml @@ -53,6 +53,7 @@ roles_001: - :browse_repository - :manage_repository - :view_changesets + - :manage_related_issues - :manage_project_activities position: 1 diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb index 6bcbb6beb..844e8fa87 100644 --- a/test/functional/repositories_controller_test.rb +++ b/test/functional/repositories_controller_test.rb @@ -160,6 +160,38 @@ class RepositoriesControllerTest < ActionController::TestCase } end + def test_add_related_issue + @request.session[:user_id] = 2 + assert_difference 'Changeset.find(103).issues.size' do + post :add_related_issue, :id => 1, :rev => 4, :issue_id => 2 + assert_response :success + end + assert_select_rjs :replace_html, 'related-issues' + assert_equal [2], Changeset.find(103).issue_ids + end + + def test_add_related_issue_with_invalid_issue_id + @request.session[:user_id] = 2 + assert_no_difference 'Changeset.find(103).issues.size' do + post :add_related_issue, :id => 1, :rev => 4, :issue_id => 9999 + assert_response :success + end + assert_include 'alert("Issue is invalid")', @response.body + end + + def test_remove_related_issue + Changeset.find(103).issues << Issue.find(1) + Changeset.find(103).issues << Issue.find(2) + + @request.session[:user_id] = 2 + assert_difference 'Changeset.find(103).issues.size', -1 do + delete :remove_related_issue, :id => 1, :rev => 4, :issue_id => 2 + assert_response :success + end + assert_select_rjs :remove, 'related-issue-2' + assert_equal [1], Changeset.find(103).issue_ids + end + def test_graph_commits_per_month get :graph, :id => 1, :graph => 'commits_per_month' assert_response :success diff --git a/test/integration/routing/repositories_test.rb b/test/integration/routing/repositories_test.rb index 5b2ccbcac..44fe7309e 100644 --- a/test/integration/routing/repositories_test.rb +++ b/test/integration/routing/repositories_test.rb @@ -341,6 +341,32 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest ) end + def test_repositories_related_issues + assert_routing( + { :method => 'post', + :path => "/projects/redmine/repository/revisions/123/issues" }, + { :controller => 'repositories', :action => 'add_related_issue', :id => 'redmine', :rev => '123' } + ) + assert_routing( + { :method => 'delete', + :path => "/projects/redmine/repository/revisions/123/issues/25" }, + { :controller => 'repositories', :action => 'remove_related_issue', :id => 'redmine', :rev => '123', :issue_id => '25' } + ) + end + + def test_repositories_related_issues_with_repository_id + assert_routing( + { :method => 'post', + :path => "/projects/redmine/repository/foo/revisions/123/issues" }, + { :controller => 'repositories', :action => 'add_related_issue', :id => 'redmine', :repository_id => 'foo', :rev => '123' } + ) + assert_routing( + { :method => 'delete', + :path => "/projects/redmine/repository/foo/revisions/123/issues/25" }, + { :controller => 'repositories', :action => 'remove_related_issue', :id => 'redmine', :repository_id => 'foo', :rev => '123', :issue_id => '25' } + ) + end + private def repository_path_hash(arr)