From bb4a4d16d15e4ac5dc01f6776f4fb3ca595b4706 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Rekucki?= Date: Tue, 25 May 2010 13:46:03 +0200 Subject: [PATCH 1/1] Moved the redmine plugin to a seperate repositiory: http://github.com/fnp/redakcja_redmine --- redmine/redmine_publications/README.rdoc | 3 - .../controllers/publications_controller.rb | 60 -------------- .../app/helpers/publications_helper.rb | 2 - .../app/models/issue_publication.rb | 4 - .../app/models/publication.rb | 4 - .../app/views/issues/_issue_form_pub.html.erb | 5 -- .../app/views/issues/_issue_view_pub.erb | 8 -- .../app/views/publications/index.html.erb | 7 -- .../app/views/publications/issues.html.erb | 4 - .../app/views/publications/refresh.erb | 10 --- .../settings/_publications_settings.html.erb | 18 ----- .../db/migrate/001_create_publications.rb | 11 --- .../migrate/002_create_issue_publications.rb | 12 --- .../migrate/003_publications_add_repo_id.rb | 8 -- .../db/migrate/004_publications_add_name.rb | 8 -- redmine/redmine_publications/init.rb | 38 --------- redmine/redmine_publications/lang/en.yml | 2 - .../lib/issue_publication_hook.rb | 55 ------------- .../lib/redmine_publications/change_patch.rb | 40 ---------- .../lib/redmine_publications/issue_patch.rb | 78 ------------------- redmine/redmine_publications/locales/en.yml | 3 - redmine/redmine_publications/locales/pl.yml | 3 - redmine/redmine_publications/routes.rb | 10 --- .../test/fixtures/publications.yml | 7 -- .../publications_controller_test.rb | 8 -- .../redmine_publications/test/test_helper.rb | 5 -- .../test/unit/publication_test.rb | 10 --- 27 files changed, 423 deletions(-) delete mode 100644 redmine/redmine_publications/README.rdoc delete mode 100644 redmine/redmine_publications/app/controllers/publications_controller.rb delete mode 100644 redmine/redmine_publications/app/helpers/publications_helper.rb delete mode 100644 redmine/redmine_publications/app/models/issue_publication.rb delete mode 100644 redmine/redmine_publications/app/models/publication.rb delete mode 100644 redmine/redmine_publications/app/views/issues/_issue_form_pub.html.erb delete mode 100644 redmine/redmine_publications/app/views/issues/_issue_view_pub.erb delete mode 100644 redmine/redmine_publications/app/views/publications/index.html.erb delete mode 100644 redmine/redmine_publications/app/views/publications/issues.html.erb delete mode 100644 redmine/redmine_publications/app/views/publications/refresh.erb delete mode 100644 redmine/redmine_publications/app/views/settings/_publications_settings.html.erb delete mode 100644 redmine/redmine_publications/db/migrate/001_create_publications.rb delete mode 100644 redmine/redmine_publications/db/migrate/002_create_issue_publications.rb delete mode 100644 redmine/redmine_publications/db/migrate/003_publications_add_repo_id.rb delete mode 100644 redmine/redmine_publications/db/migrate/004_publications_add_name.rb delete mode 100644 redmine/redmine_publications/init.rb delete mode 100644 redmine/redmine_publications/lang/en.yml delete mode 100644 redmine/redmine_publications/lib/issue_publication_hook.rb delete mode 100644 redmine/redmine_publications/lib/redmine_publications/change_patch.rb delete mode 100644 redmine/redmine_publications/lib/redmine_publications/issue_patch.rb delete mode 100644 redmine/redmine_publications/locales/en.yml delete mode 100644 redmine/redmine_publications/locales/pl.yml delete mode 100644 redmine/redmine_publications/routes.rb delete mode 100644 redmine/redmine_publications/test/fixtures/publications.yml delete mode 100644 redmine/redmine_publications/test/functional/publications_controller_test.rb delete mode 100644 redmine/redmine_publications/test/test_helper.rb delete mode 100644 redmine/redmine_publications/test/unit/publication_test.rb diff --git a/redmine/redmine_publications/README.rdoc b/redmine/redmine_publications/README.rdoc deleted file mode 100644 index 2bcee99b..00000000 --- a/redmine/redmine_publications/README.rdoc +++ /dev/null @@ -1,3 +0,0 @@ -= publications - -Description goes here diff --git a/redmine/redmine_publications/app/controllers/publications_controller.rb b/redmine/redmine_publications/app/controllers/publications_controller.rb deleted file mode 100644 index c7a11948..00000000 --- a/redmine/redmine_publications/app/controllers/publications_controller.rb +++ /dev/null @@ -1,60 +0,0 @@ -class PublicationsController < ApplicationController - unloadable - - # before_filter :authorize, :only => [:issues] - - def index - @publications = Publication.all - respond_to do |format| - format.html - format.xml { render :xml => @publications } - format.json { render :json => @publications } - end - end - - def refresh - regexp = Regexp.new(Setting.plugin_redmine_publications[:pattern]) - repo = Repository.find(:first, :conditions => ['project_id = ?', Setting.plugin_redmine_publications[:project]] ) - - Rails.logger.info('[INFO] Importing changes from ' << repo.url) - Rails.logger.info('[INFO] Change list: ' << repo.changes.find(:all).inspect ) - - @repo_status = [] - repo.changes.find(:all).each do |change| - Rails.logger.info('[INFO] Importing change ' << change.path) - match = change.path.match(regexp) - if match - Publication.find_or_create_by_name(:name => match[1], - :source_file => change.path, :repository_id => repo.id) - @repo_status += [{:path => change.path, :match => match[1], :matched => true}] - else - @repo_status += [{:path => change.path, :match => nil, :matched => false}] - end - end - - respond_to do |format| - format.html - format.xml { render :xml => @repo_status} - format.json { render :json => @repo_status } - end - end - - def issues - @publication = Publication.find_by_name(params[:pub]) - - joins = "JOIN issue_publications ON (issues.id = issue_publications.issue_id)" - conditions = ['issue_publications.publication_id = ? ', @publication.id ] - @issues = Issue.all(:joins => joins, :conditions => conditions) - - respond_to do |fmt| - fmt.json { render :json => @issues, :callback => params[:callback] } - end - end - - private - - def find_project - @project = Project.find(params[:project_id]) - end - -end diff --git a/redmine/redmine_publications/app/helpers/publications_helper.rb b/redmine/redmine_publications/app/helpers/publications_helper.rb deleted file mode 100644 index 50f110e8..00000000 --- a/redmine/redmine_publications/app/helpers/publications_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module PublicationsHelper -end diff --git a/redmine/redmine_publications/app/models/issue_publication.rb b/redmine/redmine_publications/app/models/issue_publication.rb deleted file mode 100644 index ef7bf92a..00000000 --- a/redmine/redmine_publications/app/models/issue_publication.rb +++ /dev/null @@ -1,4 +0,0 @@ -class IssuePublication < ActiveRecord::Base - belongs_to :publication - belongs_to :issue -end diff --git a/redmine/redmine_publications/app/models/publication.rb b/redmine/redmine_publications/app/models/publication.rb deleted file mode 100644 index 15444023..00000000 --- a/redmine/redmine_publications/app/models/publication.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Publication < ActiveRecord::Base - has_many :issues, :through => :issuepublications - belongs_to :repository -end diff --git a/redmine/redmine_publications/app/views/issues/_issue_form_pub.html.erb b/redmine/redmine_publications/app/views/issues/_issue_form_pub.html.erb deleted file mode 100644 index ebb903c0..00000000 --- a/redmine/redmine_publications/app/views/issues/_issue_form_pub.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -
-

-' /> -

diff --git a/redmine/redmine_publications/app/views/issues/_issue_view_pub.erb b/redmine/redmine_publications/app/views/issues/_issue_view_pub.erb deleted file mode 100644 index a22c78be..00000000 --- a/redmine/redmine_publications/app/views/issues/_issue_view_pub.erb +++ /dev/null @@ -1,8 +0,0 @@ - - <%= l(:field_publications) %>: - -<% @issue.publication_names.each do |pub| %> - <%= pub %>
-<% end %> - - diff --git a/redmine/redmine_publications/app/views/publications/index.html.erb b/redmine/redmine_publications/app/views/publications/index.html.erb deleted file mode 100644 index 3fa02993..00000000 --- a/redmine/redmine_publications/app/views/publications/index.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -

Publikacje

-

Odśwież listę publikacji

-
    -<% @publications.each do |pub| %> -
  1. <%= pub.name %>
  2. -<% end %> -
diff --git a/redmine/redmine_publications/app/views/publications/issues.html.erb b/redmine/redmine_publications/app/views/publications/issues.html.erb deleted file mode 100644 index f36a875d..00000000 --- a/redmine/redmine_publications/app/views/publications/issues.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -

Issues for publication: <%= @publication.name %>

-<% @issues.each do |issue| %> -

<%= issue.subject %>

-<% end %> diff --git a/redmine/redmine_publications/app/views/publications/refresh.erb b/redmine/redmine_publications/app/views/publications/refresh.erb deleted file mode 100644 index 311ed33e..00000000 --- a/redmine/redmine_publications/app/views/publications/refresh.erb +++ /dev/null @@ -1,10 +0,0 @@ - - -<% @repo_status.each do |status| %> - - - - - -<% end %> -
Ścieżka zasobuRozpoznanoID zasobu
<%= status[:path] %><%= (status[:matched] && 'Tak') || 'Nie' %><%= status[:match] || '' %>
diff --git a/redmine/redmine_publications/app/views/settings/_publications_settings.html.erb b/redmine/redmine_publications/app/views/settings/_publications_settings.html.erb deleted file mode 100644 index 255460e9..00000000 --- a/redmine/redmine_publications/app/views/settings/_publications_settings.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<% @project = Project.find(:first, :conditions => ["id = ?", @settings[:project]]) %> -
-

- - <%= collection_select(:project, :id, Project.all, :id, :name, {}, {:name => "settings[project]"}) %> -

- -

- - <%= text_field_tag 'settings[pattern]', @settings[:pattern] || '' %> -

- -

- - <%= text_field_tag 'settings[editorurl]', @settings[:editorurl] || '' %> -

- -
diff --git a/redmine/redmine_publications/db/migrate/001_create_publications.rb b/redmine/redmine_publications/db/migrate/001_create_publications.rb deleted file mode 100644 index f9d93ef2..00000000 --- a/redmine/redmine_publications/db/migrate/001_create_publications.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreatePublications < ActiveRecord::Migration - def self.up - create_table :publications do |t| - t.column :source_file, :string, :null => false - end - end - - def self.down - drop_table :publications - end -end diff --git a/redmine/redmine_publications/db/migrate/002_create_issue_publications.rb b/redmine/redmine_publications/db/migrate/002_create_issue_publications.rb deleted file mode 100644 index 07b64bd3..00000000 --- a/redmine/redmine_publications/db/migrate/002_create_issue_publications.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateIssuePublications < ActiveRecord::Migration - def self.up - create_table :issue_publications do |t| - t.column :publication_id, :integer, :null => false - t.column :issue_id, :integer, :null => false - end - end - - def self.down - drop_table :issue_publications - end -end diff --git a/redmine/redmine_publications/db/migrate/003_publications_add_repo_id.rb b/redmine/redmine_publications/db/migrate/003_publications_add_repo_id.rb deleted file mode 100644 index 8f232c92..00000000 --- a/redmine/redmine_publications/db/migrate/003_publications_add_repo_id.rb +++ /dev/null @@ -1,8 +0,0 @@ -class PublicationsAddRepoId < ActiveRecord::Migration - def self.up - add_column :publications, :repository_id, :integer, :null => false, :default => 0 - end - - def self.down - end -end diff --git a/redmine/redmine_publications/db/migrate/004_publications_add_name.rb b/redmine/redmine_publications/db/migrate/004_publications_add_name.rb deleted file mode 100644 index 6b5bac61..00000000 --- a/redmine/redmine_publications/db/migrate/004_publications_add_name.rb +++ /dev/null @@ -1,8 +0,0 @@ -class PublicationsAddName < ActiveRecord::Migration - def self.up - add_column :publications, :name, :string - end - - def self.down - end -end diff --git a/redmine/redmine_publications/init.rb b/redmine/redmine_publications/init.rb deleted file mode 100644 index 01afeab6..00000000 --- a/redmine/redmine_publications/init.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'redmine' - -# Patches to the Redmine core. -require 'dispatcher' - -Dispatcher.to_prepare :redmine_publications do - require_dependency 'issue' - - #Guards against including the module multiple time (like in tests) - # and registering multiple callbacks - unless Issue.included_modules.include? RedminePublications::IssuePatch - Issue.send(:include, RedminePublications::IssuePatch) - end - - unless Change.included_modules.include? RedminePublications::ChangePatch - Change.send(:include, RedminePublications::ChangePatch) - end -end - -require_dependency 'issue_publication_hook' - -Redmine::Plugin.register :redmine_publications do - name 'Publications managment plugin' - author 'Łukasz Rekucki' - description 'This plugn helps manage issues related to a publication.' - version '0.0.9' - - # permission :view_issues_for_publication, :publications => :issues - - settings :partial => 'settings/publications_settings', - :default => { :project => '0', :pattern => '[^\$].xml', :editorurl => 'http://localhost/:pubid'} - - menu :application_menu, :publications, { :controller => 'publications', :action => 'index' }, :caption => 'Publikacje' - -# requires_redmine :version_or_higher => '0.8.0' - -end - diff --git a/redmine/redmine_publications/lang/en.yml b/redmine/redmine_publications/lang/en.yml deleted file mode 100644 index e338591e..00000000 --- a/redmine/redmine_publications/lang/en.yml +++ /dev/null @@ -1,2 +0,0 @@ -# English strings go here -my_label: "My label" diff --git a/redmine/redmine_publications/lib/issue_publication_hook.rb b/redmine/redmine_publications/lib/issue_publication_hook.rb deleted file mode 100644 index 788a72f4..00000000 --- a/redmine/redmine_publications/lib/issue_publication_hook.rb +++ /dev/null @@ -1,55 +0,0 @@ -# Provides a link to the document on the platform -class IssuesPublicationHook < Redmine::Hook::ViewListener - - def self.render_on(hook, options={}) - define_method hook do |context| - if !options.include?(:if) || evaluate_if_option(options[:if], context) - context[:controller].send(:render_to_string, {:locals => context}.merge(options)) - end - end - end - - private - - def evaluate_if_option(if_option, context) - case if_option - when Symbol - send(if_option, context) - when Method, Proc - if_option.call(context) - end - end - - def is_pticket?(context) - context[:issue].project_id == Setting.plugin_redmine_publications[:project].to_i - end - - public - - render_on :view_issues_show_details_bottom, :partial => 'issue_view_pub', :if => :is_pticket? - render_on :view_issues_form_details_bottom, :partial => 'issue_form_pub', :if => :is_pticket? - - # names = context[:issue].publication_names {|name| "" + name + ""} - # result << names.join(', ') - - def controller_issues_edit_before_save(context) - if is_pticket?context - old_value = context[:issue].publication_names - new_value = context[:params][:publications].split(',').map { |n| n.strip } - context[:journal].details << JournalDetail.new( - :property => 'attr', :prop_key => "publications", - :old_value => old_value.join(', '), - :value => new_value.join(', ') ) unless new_value==old_value - context[:issue].publication_names = new_value - end - end - - - def controller_issues_new_after_save(context) - if is_pticket?context - value = context[:params][:publications].split(',').map { |n| n.strip } - context[:issue].publication_names = value - context[:issue].save - end - end -end diff --git a/redmine/redmine_publications/lib/redmine_publications/change_patch.rb b/redmine/redmine_publications/lib/redmine_publications/change_patch.rb deleted file mode 100644 index b8e5c4b6..00000000 --- a/redmine/redmine_publications/lib/redmine_publications/change_patch.rb +++ /dev/null @@ -1,40 +0,0 @@ -module RedminePublications - # Patches Redmine's Issues dynamically. Adds a +after_save+ filter. - - module ChangePatch - def self.included(base) # :nodoc: - base.extend(ClassMethods) - - base.send(:include, InstanceMethods) - - # Same as typing in the class - base.class_eval do - unloadable # Send unloadable so it will not be unloaded in development - after_save :update_publication - end - - end - - module ClassMethods - end - - module InstanceMethods - - def update_publication - if (self.action == 'A') and (self.changeset.repository.project_id == Setting.plugin_redmine_publications[:project].to_i) - regexp = Regexp.new(Setting.plugin_redmine_publications[:pattern]) - match = self.path.match(regexp) - if match - Rails.logger.info('[INFO] Adding publication: "' << match[1]) - Publication.find_or_create_by_name(:name => match[1], - :source_file => self.path, :repository_id => self.changeset.repository.id ) - end - end - end - - end - - end - - -end diff --git a/redmine/redmine_publications/lib/redmine_publications/issue_patch.rb b/redmine/redmine_publications/lib/redmine_publications/issue_patch.rb deleted file mode 100644 index bd1f73eb..00000000 --- a/redmine/redmine_publications/lib/redmine_publications/issue_patch.rb +++ /dev/null @@ -1,78 +0,0 @@ -module RedminePublications - # Patches Redmine's Issues dynamically. Adds a +after_save+ filter. - - module IssuePatch - def self.included(base) # :nodoc: - base.extend(ClassMethods) - - base.send(:include, InstanceMethods) - - # Same as typing in the class - base.class_eval do - unloadable # Send unloadable so it will not be unloaded in development - - validate :check_relations - after_save :update_relations - end - - end - - module ClassMethods - end - - module InstanceMethods - - def publication_names - if not @pubnames - self.publications.map { |pub| pub.name } - else - @pubnames - end - end - - def publication_names=(value) - @pubnames = value.sort! - end - - def publications - Publication.all( - :joins => - "JOIN issue_publications ON (issue_publications.publication_id = publications.id)", - :conditions => - ["issue_publications.issue_id = ? ", self.id] ) - end - - def check_relations - current_names = self.publication_names - non_existant = [] - - pubs = Publication.find_all_by_name(current_names).map {|i| i.name} - missing = current_names.select {|name| not pubs.include?name } - - if not missing.empty? - errors.add("publications", "Missing publication(s): " + missing.join(', ')) - end - end - - def update_relations - old = self.publications - current_names = self.publication_names - Rails.logger.info('[INFO] Updating relations: old= ' << old.inspect << ' current=' << current_names.inspect) - - # delete unused relations - deleted = old.select { |v| not (current_names.include?(v.name)) } - deleted.each do |pub| - IssuePublication.delete_all(["issue_publications.issue_id = ? AND issue_publications.publication_id = ?", self.id, pub.id]) - end - - current_names.each do |name| - pub = Publication.find_by_name(name) - IssuePublication.find_or_create_by_publication_id_and_issue_id(pub.id, self.id) - end - - return true - end - - end - end -end diff --git a/redmine/redmine_publications/locales/en.yml b/redmine/redmine_publications/locales/en.yml deleted file mode 100644 index 3932ef20..00000000 --- a/redmine/redmine_publications/locales/en.yml +++ /dev/null @@ -1,3 +0,0 @@ -## YAML Template. -en: - field_publications: Publications diff --git a/redmine/redmine_publications/locales/pl.yml b/redmine/redmine_publications/locales/pl.yml deleted file mode 100644 index 2bf07833..00000000 --- a/redmine/redmine_publications/locales/pl.yml +++ /dev/null @@ -1,3 +0,0 @@ -## YAML Template. -pl: - field_publications: Publikacje diff --git a/redmine/redmine_publications/routes.rb b/redmine/redmine_publications/routes.rb deleted file mode 100644 index 8752c692..00000000 --- a/redmine/redmine_publications/routes.rb +++ /dev/null @@ -1,10 +0,0 @@ -connect 'publications/:action', - :controller => 'publications', - :format => 'html' - -connect 'publications/:action.:format', - :controller => 'publications' - -connect 'publications/:action/:pub', - :controller => 'publications', :format => 'json', - :pub => /[^\/?]+/ diff --git a/redmine/redmine_publications/test/fixtures/publications.yml b/redmine/redmine_publications/test/fixtures/publications.yml deleted file mode 100644 index 9d7d1132..00000000 --- a/redmine/redmine_publications/test/fixtures/publications.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html -one: - id: 1 - source_file: One -two: - id: 2 - source_file: Two diff --git a/redmine/redmine_publications/test/functional/publications_controller_test.rb b/redmine/redmine_publications/test/functional/publications_controller_test.rb deleted file mode 100644 index 62b35f68..00000000 --- a/redmine/redmine_publications/test/functional/publications_controller_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class MicrorestControllerTest < ActionController::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/redmine/redmine_publications/test/test_helper.rb b/redmine/redmine_publications/test/test_helper.rb deleted file mode 100644 index bd1ed0c5..00000000 --- a/redmine/redmine_publications/test/test_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Load the normal Rails helper -require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper') - -# Ensure that we are using the temporary fixture path -Engines::Testing.set_fixture_path diff --git a/redmine/redmine_publications/test/unit/publication_test.rb b/redmine/redmine_publications/test/unit/publication_test.rb deleted file mode 100644 index ccf8aa40..00000000 --- a/redmine/redmine_publications/test/unit/publication_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class PublicationTest < Test::Unit::TestCase - fixtures :publications - - # Replace this with your real tests. - def test_truth - assert true - end -end -- 2.20.1