From: zuber Date: Fri, 21 Aug 2009 08:01:43 +0000 (+0200) Subject: Merge branch 'master' of git@stigma.nowoczesnapolska.org.pl:platforma X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/4708236959fbdf64a236fd2c1faa80cf1b98831e?hp=6e239bbd00ade064ee50c172b0124ade78b14b72 Merge branch 'master' of git@stigma.nowoczesnapolska.org.pl:platforma --- diff --git a/redmine/redmine_publications/app/controllers/publications_controller.rb b/redmine/redmine_publications/app/controllers/publications_controller.rb index 1220bea1..bb74d03f 100644 --- a/redmine/redmine_publications/app/controllers/publications_controller.rb +++ b/redmine/redmine_publications/app/controllers/publications_controller.rb @@ -13,7 +13,7 @@ class PublicationsController < ApplicationController end def refresh - regexp = Regexp.new(Setting.plugin_redmine_publications['pattern']) + regexp = Regexp.new(Setting.plugin_redmine_publications[:pattern]) Repository.all.each do |repo| repo.entries.each do |entry| match = entry.path.match(regexp) diff --git a/redmine/redmine_publications/app/views/settings/_publications_settings.html.erb b/redmine/redmine_publications/app/views/settings/_publications_settings.html.erb index 65e436eb..626e5c62 100644 --- a/redmine/redmine_publications/app/views/settings/_publications_settings.html.erb +++ b/redmine/redmine_publications/app/views/settings/_publications_settings.html.erb @@ -1,4 +1,4 @@ -<% @tracker = Tracker.find(settings['tracker']) %> +<% @tracker = Tracker.find(@settings['tracker']) %>

diff --git a/redmine/redmine_publications/db/migrate/002_create_issue_publications.rb b/redmine/redmine_publications/db/migrate/002_create_issue_publications.rb index e9724428..07b64bd3 100644 --- a/redmine/redmine_publications/db/migrate/002_create_issue_publications.rb +++ b/redmine/redmine_publications/db/migrate/002_create_issue_publications.rb @@ -2,7 +2,7 @@ class CreateIssuePublications < ActiveRecord::Migration def self.up create_table :issue_publications do |t| t.column :publication_id, :integer, :null => false - t.column :issue_id, :intrger, :null => false + t.column :issue_id, :integer, :null => false end end diff --git a/redmine/redmine_publications/init.rb b/redmine/redmine_publications/init.rb index f2b5b59c..b1739c33 100644 --- a/redmine/redmine_publications/init.rb +++ b/redmine/redmine_publications/init.rb @@ -2,10 +2,11 @@ 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) + + #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) @@ -27,7 +28,7 @@ Redmine::Plugin.register :redmine_publications do menu :application_menu, :publications, { :controller => 'publications', :action => 'index' }, :caption => 'Publikacje' - requires_redmine :version_or_higher => '0.8.0' +# requires_redmine :version_or_higher => '0.8.0' end diff --git a/redmine/redmine_publications/lib/issue_publication_hook.rb b/redmine/redmine_publications/lib/issue_publication_hook.rb index 9c972339..77fa215e 100644 --- a/redmine/redmine_publications/lib/issue_publication_hook.rb +++ b/redmine/redmine_publications/lib/issue_publication_hook.rb @@ -3,7 +3,7 @@ class IssuesPublicationHook < Redmine::Hook::ViewListener def view_issues_show_details_bottom(context) # TODO: złapać wyjątek konwersji - if context[:issue].tracker_id == Setting.plugin_redmine_publications['tracker'].to_i + if context[:issue].tracker_id == Setting.plugin_redmine_publications[:tracker].to_i result = "Publication(s):" names = context[:issue].publication_names {|name| "" + name + ""} result << names.join(', ') @@ -12,11 +12,25 @@ class IssuesPublicationHook < Redmine::Hook::ViewListener end def controller_issues_edit_before_save(context) - if context[:issue].tracker_id == Setting.plugin_redmine_publications['tracker'].to_i - pub_field = context[:params][:publications] - context[:issue].publication_names = pub_field.split(',').map { |n| n.strip } + if context[:issue].tracker.id == Setting.plugin_redmine_publications[:tracker].to_i + 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 context[:issue].tracker.id == Setting.plugin_redmine_publications[:tracker].to_i + value = context[:params][:publications].split(',').map { |n| n.strip } + context[:issue].publication_names = value + context[:issue].save + end + end + render_on :view_issues_form_details_bottom, :partial => 'issue_form_pub' end diff --git a/redmine/redmine_publications/lib/redmine_publications/issue_patch.rb b/redmine/redmine_publications/lib/redmine_publications/issue_patch.rb index f8a83c4b..c1087999 100644 --- a/redmine/redmine_publications/lib/redmine_publications/issue_patch.rb +++ b/redmine/redmine_publications/lib/redmine_publications/issue_patch.rb @@ -12,13 +12,7 @@ module RedminePublications unloadable # Send unloadable so it will not be unloaded in development validate :check_relations - after_save :update_relations - - # Add visible to Redmine 0.8.x - unless respond_to?(:visible) - named_scope :visible, lambda {|*args| { :include => :project, - :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } } - end + after_save :update_relations end end @@ -61,9 +55,9 @@ module RedminePublications end def update_relations - self.reload 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)) }