To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / vendor / plugins / redmine_tags / lib / redmine_tags / hooks / model_project_hook.rb @ 823:73057b65abcb

History | View | Annotate | Download (2.35 KB)

1
# This file is a part of redmine_tags
2
# redMine plugin, that adds tagging support.
3
#
4
# Copyright (c) 2010 Eric Davis
5
# Copyright (c) 2010 Aleksey V Zapparov AKA ixti
6
#
7
# redmine_tags is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# redmine_tags is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with redmine_tags.  If not, see <http://www.gnu.org/licenses/>.
19

    
20
module RedmineTags
21
  module Hooks
22
    class ModelProjectHook < Redmine::Hook::ViewListener
23
      def controller_project_before_save(context={})
24
        debugger
25
        save_tags_to_project(context, true)
26
      end
27

    
28
      # Issue has an after_save method that calls reload (update_nested_set_attributes)
29
      # This makes it impossible for a new record to get a tag_list, it's
30
      # cleared on reload. So instead, hook in after the Issue#save to update
31
      # this issue's tag_list and call #save ourselves.
32
      def controller_projects_before_save(context={})
33
        debugger
34
        save_tags_to_project(context, false)
35
        context[:project].save
36
      end
37

    
38
      def save_tags_to_project(context, create_journal)
39
        params = context[:params]
40
        debugger
41
        logger.error { "WORKING" }
42

    
43
   #     if params && params[:issue] && !params[:issue][:tag_list].nil?
44
   #       old_tags = context[:issue].tag_list.to_s
45
   #       context[:issue].tag_list = params[:issue][:tag_list]
46
   #       new_tags = context[:issue].tag_list.to_s
47
   #
48
   #       if create_journal and not (old_tags == new_tags || context[:issue].current_journal.blank?)
49
   #         context[:issue].current_journal.details << JournalDetail.new(:property => 'attr',
50
   #                                                                      :prop_key => 'tag_list',
51
   #                                                                      :old_value => old_tags,
52
   #                                                                      :value => new_tags)
53
   #       end
54
   #     end
55
      end
56
    end
57
  end
58
end