[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#864330: unblock: redmine-plugin-pretend/0.0.2+git20130821-4



Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock
Affects: -1 redmine-plugin-pretend

Please unblock redmine-plugin-pretend/0.0.2+git20130821-4

This change fixes compatibility with current Redmine in Stretch.

Thanks.

--
All the best,
 Dmitry Smirnov.


The information contained in this email and any attached files are strictly private and confidential. This email should be read only by the intended addressee only. If the recipient of this message is not the intended addressee, please call Staples Australia Pty Limited on +61 2 9335 0555 or Staples New Zealand Limited on +64 9 271 7600 and promptly delete this email and any attachments. The intended recipient of this email may only use, reproduce, disclose or distribute the information contained in this email and any attached files with the prior written permission of StaplesTM. If you are not the intended addressee, you are strictly prohibited from using, reproducing, disclosing or distributing the information contained in this email and any attached files. StaplesTM advises that this email and any attached files should be scanned to detect viruses. StaplesTM accepts no liability for loss or damage (whether caused by negligence or not) resulting from the use of any attache!
d files.
diff --git a/debian/changelog b/debian/changelog
index 37e74ac..71f40a2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+redmine-plugin-pretend (0.0.2+git20130821-4) unstable; urgency=medium
+
+  * New upstream patch for compatibility with Redmine v3.2+.
+
+ -- Dmitry Smirnov <onlyjob@debian.org>  Sun, 21 May 2017 14:38:49 +1000
+
 redmine-plugin-pretend (0.0.2+git20130821-3) unstable; urgency=medium
 
   * "no_route_match.patch" updated as per upstream commit.
diff --git a/debian/patches/3.2.patch b/debian/patches/3.2.patch
new file mode 100644
index 0000000..6b9298a
--- /dev/null
+++ b/debian/patches/3.2.patch
@@ -0,0 +1,202 @@
+Last-Update: 2017-05-19
+Origin: upstream, https://github.com/batizhevsky/redmine_pretend/commit/08919a20bedf38430068aea0fdbe84a1d4178d15
+From: Leonid Batizhevsky <l.batizhevsky@fun-box.ru>
+Date: Wed, 20 Jan 2016 23:25:04 +0400
+Subject: redmine 3.2 support, drop support of < 2
+
+--- /dev/null
++++ b/app/helpers/pretend_helper.rb
+@@ -0,0 +1,9 @@
++module PretendHelper
++  def can_user_pretend_to?(user)
++    !session[:real_user_id] && User.current.admin? && User.current != user
++  end
++
++  def current_unpretended_user
++    User.find_by_id(session[:real_user_id])
++  end
++end
+--- a/app/views/user/_pretend_to.html.erb
++++ b/app/views/user/_pretend_to.html.erb
+@@ -1,4 +1,4 @@
+-<%= link_to l(:button_pretend), pretend_to_path(@user), :class => 'icon', :method => :post if !session[:real_user_id] && User.current.admin? %>
++<%= link_to l(:button_pretend), pretend_to_path(@user), :class => 'icon', :method => :post if can_user_pretend_to?(@user)  %>
+ 
+ 
+ 
+--- a/app/views/user/_unpretend.html.erb
++++ b/app/views/user/_unpretend.html.erb
+@@ -1,6 +1,6 @@
+ <% if session[:real_user_id] %>
+   <div class="flash error">
+-    <%= l(:pretend_message) %> <%= User.find_by_id(User.active.find(session[:real_user_id])) %>
++    <%= l(:pretend_message) %> <%= current_unpretended_user %>
+     <%= link_to l(:button_unpretend), unpretend_path, :class => 'icon', :method => :post %>
+   </div>
+-<% end %>
+\ No newline at end of file
++<% end %>
+--- a/config/routes.rb
++++ b/config/routes.rb
+@@ -1,11 +1,4 @@
+-if Rails::VERSION::MAJOR >= 3
+-  RedmineApp::Application.routes.draw do
+-    post 'admin/pretend_to/:id' => 'application#pretend_to', :as => 'pretend_to'
+-    post 'admin/unpretend' => 'application#unpretend', :as => 'unpretend'
+-  end
+-else
+-  ActionController::Routing::Routes.draw do |map|
+-    map.pretend_to 'admin/pretend_to/:id', :controller => 'application', :action => 'pretend_to'
+-    map.unpretend 'admin/unpretend', :controller => 'application', :action => 'unpretend'
+-  end
++RedmineApp::Application.routes.draw do
++  post 'admin/pretend_to/:id' => 'application#pretend_to', :as => 'pretend_to'
++  post 'admin/unpretend' => 'application#unpretend', :as => 'unpretend'
+ end
+--- a/init.rb
++++ b/init.rb
+@@ -1,31 +1,23 @@
+ require 'redmine'
+ 
+ require_dependency 'redmine_pretend/hooks'
+ 
+-if Rails::VERSION::MAJOR >= 3
+-  Rails.logger.info 'Starting Pretend plugin for RedMine'
+-else
+-  RAILS_DEFAULT_LOGGER.info 'Starting Pretend plugin for RedMine'
+-end
++Rails.logger.info 'Starting Pretend plugin for RedMine'
+ 
+ Redmine::Plugin.register :redmine_pretend do
+   name 'Redmine Pretend plugin'
+   author 'Leonid Batizhevsky'
+   description 'Plugin to pretend selected user'
+-  version '0.0.3'
++  version '2.0.0'
+   url 'https://github.com/leonko/redmine_pretend'
+ 
+-  requires_redmine :version_or_higher => '0.9.0'
++  requires_redmine :version_or_higher => '2.0.0'
+ end
+ 
+-                                                     
+-if Rails::VERSION::MAJOR < 3                         
+-  require 'dispatcher'                               
+-  prepare = Dispatcher                               
+-else
+-  prepare = ActionDispatch::Callbacks
++ActionDispatch::Reloader.to_prepare do
++  ApplicationHelper.send :include, PretendHelper
+ end
+ 
+-prepare.to_prepare do
++ActionDispatch::Callbacks.to_prepare do
+   require_dependency 'redmine_pretend/application_controller_patch'
+ end
+--- a/lib/redmine_pretend/application_controller_patch.rb
++++ b/lib/redmine_pretend/application_controller_patch.rb
+@@ -1,50 +1,72 @@
+ require_dependency 'application_controller'
+ 
+ module PretendPatches
+- module ApplicationControllerPatch
+-  def self.included(base)
+-    base.extend(ClassMethods)
+-    base.send(:include, InstanceMethods)
+-
+-     base.class_eval do
+-       unloadable # Send unloadable so it will not be unloaded in development
+-     end
+-  end
++  module ApplicationControllerPatch
++    def self.included(base)
++      base.extend(ClassMethods)
++      base.send(:include, InstanceMethods)
+ 
+-  module ClassMethods
+-  end
++      base.class_eval do
++        unloadable # Send unloadable so it will not be unloaded in development
++      end
++    end
++
++    module ClassMethods
++    end
++
++    module InstanceMethods
++      def pretend_to
++        render_403 unless can_pretend?
+ 
+-  module InstanceMethods
+-    def pretend_to
+-      if User.current.logged? && User.current.admin?
+-        if !session[:real_user_id]
+-          session[:real_user_id] = User.current.id
++        if not_pretended?
++          remember_current_user
+           user = User.find(params[:id])
+-          logger.info "#{User.current} is pretend as #{user}"
+-          User.current = user
+-          session[:user_id] = user.id
++
++          logger.info "#{ User.current } is pretend as #{user}"
++          set_user(user)
+         end
++
+         redirect_to :back
+-      else
+-        render_403
+       end
+-    end
+ 
+-    def unpretend
+-      if real_user
+-        logger.info "#{session[:real_user_id]} stop pretend"
+-        self.logged_user = real_user
+-        session[:real_user_id] = nil
++      def unpretend
++        if real_user
++          logger.info "#{ session[:real_user_id] } stop pretend"
++          set_user(real_user)
++          reset_pretent_storage
++        end
++        redirect_to :back
+       end
+-      redirect_to :back
+-    end
+ 
+-    def real_user
+-      @real_user ||= User.find_by_id(User.active.find(session[:real_user_id]))
++      def real_user
++        @real_user ||= User.find_by_id(User.active.find(session[:real_user_id]))
++      end
++
++      private
++
++      def set_user(user)
++        User.current = user
++        start_user_session(user)
++      end
++
++      def not_pretended?
++        !session[:real_user_id]
++      end
++
++      def can_pretend?
++        User.current.logged? && User.current.admin?
++      end
++
++      def remember_current_user
++        session[:real_user_id] = User.current.id
++      end
++
++      def reset_pretent_storage
++        session[:real_user_id] = nil
++      end
+     end
+   end
+- end
+ end
+ 
+ unless ApplicationController.included_modules.include?(PretendPatches::ApplicationControllerPatch)
+   ApplicationController.send(:include, PretendPatches::ApplicationControllerPatch)
diff --git a/debian/patches/series b/debian/patches/series
index 16f6ed0..208d0bf 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 no_route_match.patch
+3.2.patch

Reply to: