redmine_crm 0.0.23 → 0.0.53
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/README.md +166 -33
- data/Rakefile +3 -12
- data/app/controllers/redmine_crm_controller.rb +26 -0
- data/app/views/redmine_crm/_money.html.erb +44 -0
- data/app/views/redmine_crm/settings.html.erb +10 -0
- data/bitbucket-pipelines.yml +54 -0
- data/config/currency_iso.json +12 -0
- data/config/locales/en.yml +13 -0
- data/config/locales/ru.yml +13 -0
- data/config/routes.rb +5 -0
- data/doc/CHANGELOG +123 -2
- data/lib/redmine_crm/acts_as_draftable/draft.rb +40 -0
- data/lib/redmine_crm/acts_as_draftable/rcrm_acts_as_draftable.rb +172 -0
- data/lib/redmine_crm/acts_as_list/list.rb +282 -0
- data/lib/redmine_crm/{rcrm_acts_as_taggable.rb → acts_as_taggable/rcrm_acts_as_taggable.rb} +112 -93
- data/lib/redmine_crm/acts_as_taggable/tag.rb +81 -0
- data/lib/redmine_crm/acts_as_taggable/tag_list.rb +111 -0
- data/lib/redmine_crm/acts_as_taggable/tagging.rb +16 -0
- data/lib/redmine_crm/acts_as_viewed/rcrm_acts_as_viewed.rb +274 -0
- data/lib/redmine_crm/{rcrm_acts_as_votable.rb → acts_as_votable/rcrm_acts_as_votable.rb} +15 -14
- data/lib/redmine_crm/acts_as_votable/rcrm_acts_as_voter.rb +20 -0
- data/lib/redmine_crm/{votable.rb → acts_as_votable/votable.rb} +54 -65
- data/lib/redmine_crm/{vote.rb → acts_as_votable/vote.rb} +6 -8
- data/lib/redmine_crm/{voter.rb → acts_as_votable/voter.rb} +29 -34
- data/lib/redmine_crm/assets_manager.rb +43 -0
- data/lib/redmine_crm/colors_helper.rb +192 -0
- data/lib/redmine_crm/compatibility/application_controller_patch.rb +33 -0
- data/lib/redmine_crm/currency/formatting.rb +5 -8
- data/lib/redmine_crm/currency/heuristics.rb +1 -1
- data/lib/redmine_crm/currency/loader.rb +5 -6
- data/lib/redmine_crm/currency.rb +28 -17
- data/lib/redmine_crm/engine.rb +4 -0
- data/lib/redmine_crm/helpers/external_assets_helper.rb +19 -0
- data/lib/redmine_crm/helpers/form_tag_helper.rb +76 -0
- data/lib/redmine_crm/helpers/tags_helper.rb +1 -3
- data/lib/redmine_crm/helpers/vote_helper.rb +29 -32
- data/lib/redmine_crm/hooks/views_layouts_hook.rb +11 -0
- data/lib/redmine_crm/liquid/drops/issues_drop.rb +191 -0
- data/lib/redmine_crm/liquid/drops/news_drop.rb +54 -0
- data/lib/redmine_crm/liquid/drops/projects_drop.rb +86 -0
- data/lib/redmine_crm/liquid/drops/time_entries_drop.rb +65 -0
- data/lib/redmine_crm/liquid/drops/users_drop.rb +68 -0
- data/lib/redmine_crm/liquid/filters/arrays.rb +187 -0
- data/lib/redmine_crm/liquid/filters/base.rb +217 -0
- data/lib/redmine_crm/liquid/filters/colors.rb +31 -0
- data/lib/redmine_crm/money_helper.rb +17 -18
- data/lib/redmine_crm/settings/money.rb +46 -0
- data/lib/redmine_crm/settings.rb +53 -0
- data/lib/redmine_crm/version.rb +1 -1
- data/lib/redmine_crm.rb +60 -21
- data/redmine_crm.gemspec +12 -6
- data/test/acts_as_draftable/draft_test.rb +29 -0
- data/test/acts_as_draftable/rcrm_acts_as_draftable_test.rb +178 -0
- data/test/{acts_as_taggable_test.rb → acts_as_taggable/rcrm_acts_as_taggable_test.rb} +117 -156
- data/test/acts_as_taggable/tag_list_test.rb +34 -0
- data/test/acts_as_taggable/tag_test.rb +72 -0
- data/test/acts_as_taggable/tagging_test.rb +15 -0
- data/test/{viewed_test.rb → acts_as_viewed/rcrm_acts_as_viewed_test.rb} +17 -15
- data/test/acts_as_votable/rcrm_acts_as_votable_test.rb +19 -0
- data/test/acts_as_votable/rcrm_acts_as_voter_test.rb +14 -0
- data/test/{votable_model_test.rb → acts_as_votable/votable_test.rb} +34 -5
- data/test/{voter_model_test.rb → acts_as_votable/voter_test.rb} +8 -8
- data/test/currency_test.rb +10 -10
- data/test/database.yml +14 -14
- data/test/fixtures/issues.yml +13 -1
- data/test/fixtures/news.yml +8 -0
- data/test/fixtures/projects.yml +10 -0
- data/test/fixtures/users.yml +6 -2
- data/test/liquid/drops/issues_drop_test.rb +34 -0
- data/test/liquid/drops/news_drop_test.rb +38 -0
- data/test/liquid/drops/projects_drop_test.rb +44 -0
- data/test/liquid/drops/uses_drop_test.rb +36 -0
- data/test/liquid/filters/arrays_filter_test.rb +31 -0
- data/test/liquid/filters/base_filter_test.rb +63 -0
- data/test/liquid/filters/colors_filter_test.rb +33 -0
- data/test/liquid/liquid_helper.rb +34 -0
- data/test/models/issue.rb +14 -0
- data/test/models/news.rb +3 -0
- data/test/models/project.rb +8 -0
- data/test/{fixtures → models}/user.rb +5 -1
- data/test/{fixtures → models}/vote_classes.rb +0 -21
- data/test/money_helper_test.rb +5 -5
- data/test/schema.rb +33 -10
- data/test/test_helper.rb +20 -72
- data/vendor/assets/images/money.png +0 -0
- data/vendor/assets/images/vcard.png +0 -0
- data/vendor/assets/javascripts/Chart.bundle.min.js +16 -0
- data/vendor/assets/javascripts/select2.js +2 -0
- data/vendor/assets/javascripts/select2_helpers.js +192 -0
- data/vendor/assets/stylesheets/money.css +3 -0
- data/vendor/assets/stylesheets/select2.css +424 -0
- metadata +190 -40
- data/lib/redmine_crm/rcrm_acts_as_viewed.rb +0 -287
- data/lib/redmine_crm/rcrm_acts_as_voter.rb +0 -27
- data/lib/redmine_crm/tag.rb +0 -81
- data/lib/redmine_crm/tag_list.rb +0 -112
- data/lib/redmine_crm/tagging.rb +0 -20
- data/test/fixtures/issue.rb +0 -14
- data/test/tag_test.rb +0 -64
- data/test/tagging_test.rb +0 -14
- data/test/votable_test.rb +0 -17
data/lib/redmine_crm/tag_list.rb
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
module RedmineCrm
|
2
|
-
class TagList < Array
|
3
|
-
cattr_accessor :delimiter
|
4
|
-
self.delimiter = ','
|
5
|
-
|
6
|
-
def initialize(*args)
|
7
|
-
add(*args)
|
8
|
-
end
|
9
|
-
|
10
|
-
# Add tags to the tag_list. Duplicate or blank tags will be ignored.
|
11
|
-
#
|
12
|
-
# tag_list.add("Fun", "Happy")
|
13
|
-
#
|
14
|
-
# Use the <tt>:parse</tt> option to add an unparsed tag string.
|
15
|
-
#
|
16
|
-
# tag_list.add("Fun, Happy", :parse => true)
|
17
|
-
def add(*names)
|
18
|
-
extract_and_apply_options!(names)
|
19
|
-
concat(names)
|
20
|
-
clean!
|
21
|
-
self
|
22
|
-
end
|
23
|
-
|
24
|
-
# Remove specific tags from the tag_list.
|
25
|
-
#
|
26
|
-
# tag_list.remove("Sad", "Lonely")
|
27
|
-
#
|
28
|
-
# Like #add, the <tt>:parse</tt> option can be used to remove multiple tags in a string.
|
29
|
-
#
|
30
|
-
# tag_list.remove("Sad, Lonely", :parse => true)
|
31
|
-
def remove(*names)
|
32
|
-
extract_and_apply_options!(names)
|
33
|
-
delete_if { |name| names.include?(name) }
|
34
|
-
self
|
35
|
-
end
|
36
|
-
|
37
|
-
# Toggle the presence of the given tags.
|
38
|
-
# If a tag is already in the list it is removed, otherwise it is added.
|
39
|
-
def toggle(*names)
|
40
|
-
extract_and_apply_options!(names)
|
41
|
-
|
42
|
-
names.each do |name|
|
43
|
-
include?(name) ? delete(name) : push(name)
|
44
|
-
end
|
45
|
-
|
46
|
-
clean!
|
47
|
-
self
|
48
|
-
end
|
49
|
-
|
50
|
-
# Transform the tag_list into a tag string suitable for edting in a form.
|
51
|
-
# The tags are joined with <tt>TagList.delimiter</tt> and quoted if necessary.
|
52
|
-
#
|
53
|
-
# tag_list = TagList.new("Round", "Square,Cube")
|
54
|
-
# tag_list.to_s # 'Round, "Square,Cube"'
|
55
|
-
def to_s
|
56
|
-
clean!
|
57
|
-
|
58
|
-
map do |name|
|
59
|
-
name.include?(delimiter) ? "\"#{name}\"" : name
|
60
|
-
end.join(delimiter.ends_with?(" ") ? delimiter : "#{delimiter} ")
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
# Remove whitespace, duplicates, and blanks.
|
65
|
-
def clean!
|
66
|
-
reject!(&:blank?)
|
67
|
-
map!(&:strip)
|
68
|
-
uniq!
|
69
|
-
end
|
70
|
-
|
71
|
-
def extract_and_apply_options!(args)
|
72
|
-
options = args.last.is_a?(Hash) ? args.pop : {}
|
73
|
-
options.assert_valid_keys :parse
|
74
|
-
|
75
|
-
if options[:parse]
|
76
|
-
args.map! { |a| self.class.from(a) }
|
77
|
-
end
|
78
|
-
|
79
|
-
args.flatten!
|
80
|
-
end
|
81
|
-
|
82
|
-
class << self
|
83
|
-
# Returns a new TagList using the given tag string.
|
84
|
-
#
|
85
|
-
# tag_list = TagList.from("One , Two, Three")
|
86
|
-
# tag_list # ["One", "Two", "Three"]
|
87
|
-
def from(source)
|
88
|
-
tag_list = new
|
89
|
-
|
90
|
-
case source
|
91
|
-
when Array
|
92
|
-
tag_list.add(source)
|
93
|
-
else
|
94
|
-
string = source.to_s.dup
|
95
|
-
|
96
|
-
# Parse the quoted tags
|
97
|
-
[
|
98
|
-
/\s*#{delimiter}\s*(['"])(.*?)\1\s*/,
|
99
|
-
/^\s*(['"])(.*?)\1\s*#{delimiter}?/
|
100
|
-
].each do |re|
|
101
|
-
string.gsub!(re) { tag_list << $2; "" }
|
102
|
-
end
|
103
|
-
|
104
|
-
tag_list.add(string.split(delimiter))
|
105
|
-
end
|
106
|
-
|
107
|
-
tag_list
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
data/lib/redmine_crm/tagging.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
module RedmineCrm
|
2
|
-
|
3
|
-
class Tagging < ActiveRecord::Base #:nodoc:
|
4
|
-
belongs_to :tag
|
5
|
-
belongs_to :taggable, :polymorphic => true
|
6
|
-
|
7
|
-
after_destroy :destroy_tag_if_unused
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def destroy_tag_if_unused
|
12
|
-
if Tag.destroy_unused
|
13
|
-
if tag.taggings.count.zero?
|
14
|
-
tag.destroy
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
data/test/fixtures/issue.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
class Issue < ActiveRecord::Base
|
2
|
-
rcrm_acts_as_taggable
|
3
|
-
rcrm_acts_as_viewed
|
4
|
-
# default_scope {where(:closed => false)}
|
5
|
-
belongs_to :user
|
6
|
-
validates_presence_of :description
|
7
|
-
|
8
|
-
def save_without_validation
|
9
|
-
save
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class SpecialIssue < Issue
|
14
|
-
end
|
data/test/tag_test.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
module RedmineCrm
|
4
|
-
class TagTest < ActiveSupport::TestCase
|
5
|
-
def test_name_required
|
6
|
-
t = Tag.create
|
7
|
-
assert_match /blank/, t.errors[:name].to_s
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_name_unique
|
11
|
-
t = Tag.create!(:name => "My tag")
|
12
|
-
duplicate = t.dup
|
13
|
-
assert !duplicate.save
|
14
|
-
assert_match /not uniq/, duplicate.errors[:name].to_s
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_taggings
|
18
|
-
assert_equivalent [taggings(:tag_for_error), taggings(:tag_for_error1), taggings(:tag_for_error2)
|
19
|
-
], tags(:error).taggings
|
20
|
-
assert_equivalent [taggings(:tag_for_question1), taggings(:tag_for_question2), taggings(:tag_for_question3)], tags(:question).taggings
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_to_s
|
24
|
-
assert_equal tags(:error).name, tags(:error).to_s
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_equality
|
28
|
-
assert_equal tags(:error), tags(:error)
|
29
|
-
assert_equal Tag.find(tags(:error).id), Tag.find(tags(:error).id)
|
30
|
-
assert_equal Tag.new(:name => 'A'), Tag.new(:name => 'A')
|
31
|
-
assert_not_equal Tag.new(:name => 'A'), Tag.new(:name => 'B')
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_taggings_removed_when_tag_destroyed
|
35
|
-
assert_difference("Tagging.count", -Tagging.where(:tag_id => tags(:error).id).count) do
|
36
|
-
assert tags(:error).destroy
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_all_counts
|
41
|
-
assert_tag_counts Tag.counts, :error => 3, :feature => 1, :bug => 1, :question => 3
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_all_counts_with_string_conditions
|
45
|
-
assert_tag_counts Tag.counts(:conditions => 'taggings.created_at >= \'2015-01-01\''),
|
46
|
-
:question => 3, :error => 2, :feature => 1, :bug => 1
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_all_counts_with_array_conditions
|
50
|
-
assert_tag_counts Tag.counts(:conditions => ['taggings.created_at >= ?', '2015-01-01']),
|
51
|
-
:question => 3, :error => 2, :feature => 1, :bug => 1
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_all_counts_with_hash_conditions
|
55
|
-
tag_counts = Tag.counts(
|
56
|
-
:conditions => {
|
57
|
-
:taggings => { :created_at => (DateTime.parse('2014-12-31 23:59') .. DateTime.parse('4000-01-01')) }
|
58
|
-
}
|
59
|
-
)
|
60
|
-
|
61
|
-
assert_tag_counts tag_counts, :question => 3, :error => 2, :feature => 1, :bug => 1
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
data/test/tagging_test.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
# require File.dirname(__FILE__) + '/fixtures/issue'
|
3
|
-
|
4
|
-
class TaggingTest < ActiveSupport::TestCase
|
5
|
-
|
6
|
-
def test_tag
|
7
|
-
assert_equal tags(:error), taggings(:tag_for_error).tag
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_taggable
|
11
|
-
assert_equal issues(:first_issue), taggings(:tag_for_error).taggable
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
data/test/votable_test.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
class VotableTest < ActiveSupport::TestCase
|
4
|
-
def test_not_be_votable
|
5
|
-
assert !NotVotable.votable?, false
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_be_votable
|
9
|
-
assert Votable.votable?, true
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_behaves_like_votable_model
|
13
|
-
assert Voter.create(:name => 'i can vote!')
|
14
|
-
assert VotableCache.create(:name => 'voting model with cache')
|
15
|
-
assert VotableVoter.create(:name => 'i can vote too!')
|
16
|
-
end
|
17
|
-
end
|