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 / patches / project_patch.rb @ 745:4acfc770e79f

History | View | Annotate | Download (2.02 KB)

1 727:e3e958595e07 luis
# C4DM
2
3
require_dependency 'project'
4
5
module RedmineTags
6
  module Patches
7
    module ProjectPatch
8 729:291c4d7dc0b6 luis
      def self.included(base) # :nodoc:
9 727:e3e958595e07 luis
        base.extend(ClassMethods)
10 730:4a9bb3b8d5cd luis
        base.send(:include, InstanceMethods)
11 727:e3e958595e07 luis
12
        base.class_eval do
13
          unloadable
14 730:4a9bb3b8d5cd luis
15
          attr_accessor :tag_list
16
17 727:e3e958595e07 luis
          acts_as_taggable
18 730:4a9bb3b8d5cd luis
19 727:e3e958595e07 luis
        end
20
      end
21
22 730:4a9bb3b8d5cd luis
      def before_save_with_save_tags()
23
#        debugger
24
        logger.error { "GONNA SAVE TAG LIST" }
25 729:291c4d7dc0b6 luis
26 730:4a9bb3b8d5cd luis
27
#        params[:tag_list]
28
29
30
        # logger.error { @project.name }
31 729:291c4d7dc0b6 luis
32
    #    if params && params[:project] && !params[:project][:tag_list].nil?
33
    #      old_tags = context[:project].tag_list.to_s
34
    #      context[:project].tag_list = params[:project][:tag_list]
35
    #      new_tags = context[:project].tag_list.to_s
36
    #
37
    #      unless (old_tags == new_tags || context[:project].current_journal.blank?)
38
    #        context[:project].current_journal.details << JournalDetail.new(:property => 'attr',
39
    #                                                                     :prop_key => 'tag_list',
40
    #                                                                     :old_value => old_tags,
41
    #                                                                     :value => new_tags)
42
    #      end
43
    #    end
44
      end
45
46 730:4a9bb3b8d5cd luis
      module InstanceMethods
47
48
      end
49 729:291c4d7dc0b6 luis
50 727:e3e958595e07 luis
      module ClassMethods
51 739:b7ac21913927 luis
        def search_by_question(question)
52
          if question.length > 1
53
            search(RedmineProjectFiltering.calculate_tokens(question), nil, :all_words => true).first.sort_by(&:lft)
54
          else
55
            all(:order => 'lft')
56
          end
57
        end
58
59
60 745:4acfc770e79f luis
        # Returns available project tags
61
        #  does not show tags from private projects
62
        def available_tags
63
          options = {}
64 727:e3e958595e07 luis
          visible   = ARCondition.new
65 745:4acfc770e79f luis
66
          visible << ["#{Project.table_name}.is_public = \"1\""]
67 727:e3e958595e07 luis
          options[:conditions] = visible.conditions
68 745:4acfc770e79f luis
          self.all_tag_counts(options)
69 727:e3e958595e07 luis
        end
70
      end
71
    end
72
  end
73
end