redmine_crm 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b37a6a71a78445ab8bd0a7943289f7d2de66266
4
- data.tar.gz: 7314f12328b7d335d16ab0b188ea97805c17b420
3
+ metadata.gz: 98f6edf8cd9c627f119640dc72c109b501716c0e
4
+ data.tar.gz: a361e4228e0087d21df1a61a1eade63e4d470c91
5
5
  SHA512:
6
- metadata.gz: 5acbbd27b7da55822a2ccd98894623b8c940ae2ce97937b1d5739e37c17a21ac0767a04b055a83ed5b63578e2a24d519bab5e34a35c7d66d6fb82a8e94db22ae
7
- data.tar.gz: 5c60eb6ba7e3f5994780dba765274d004e4e37d87322e95fef54d5b1ce2cc00ff1b82c638cc7f2f616ac9f75bb4586f53b36f76e5172a6150e5d01fe17ae42de
6
+ metadata.gz: 16c88a5ab553ce3a01d141be49929b402f7e4f4d252c7dc9b0c476d5b1d6e9f51ab5773728a4d47c4f0fcd229829ae22e96e280f45f19b9cb6b124f013925fc4
7
+ data.tar.gz: 49ce508bdf8fa137cd395c6f46c726cd9760561b311e33c948ad65ac0775150262488584a7b2abbdbb49002786369cc4230aaa40abf35e47045537e82be21996
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  /Gemfile.lock
4
4
  /_yardoc/
5
5
  /coverage/
6
- /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
data/README.md CHANGED
@@ -8,7 +8,7 @@ Gem include next functional for Redmine plugins:
8
8
  Add this line to your application's Gemfile:
9
9
 
10
10
  ```ruby
11
- gem "redmine_crm", :git => "git@bitbucket.org:redminecrm/redmine_crm.git"
11
+ gem "redmine_crm"
12
12
  ```
13
13
 
14
14
  And then execute:
@@ -24,9 +24,7 @@ Create migration with next code:
24
24
  require 'redmine_crm/rcrm_acts_as_taggable'
25
25
 
26
26
  def self.up
27
- # unless table_exists?(:viewings)
28
- ActiveRecord::Base.create_taggable_table
29
- # end
27
+ ActiveRecord::Base.create_taggable_table
30
28
  end
31
29
 
32
30
  def self.down
@@ -0,0 +1,11 @@
1
+ == Redmine CRM gem changelog
2
+
3
+ Redmine crm gem - general functions for plugins (tags, vote, viewing, currency)
4
+ Copyright (C) 2011-2015 RedmineCRM
5
+ http://www.redminecrm.com/
6
+
7
+ == 2015-09-23 v0.0.14
8
+
9
+ * Fixed bug in viewed? function
10
+ * Add check for existing columns in table for votes
11
+ * Fixed bug with thousands delimiter
File without changes
@@ -26,7 +26,7 @@ module RedmineCrm
26
26
  alias_method name, method
27
27
  end
28
28
 
29
-
29
+
30
30
  def format(value, currency, *rules)
31
31
  # support for old format parameters
32
32
  rules = normalize_formatting_rules(rules)
@@ -35,10 +35,10 @@ module RedmineCrm
35
35
  if currency
36
36
  rules = self.localize_formatting_rules(rules, currency)
37
37
  rules = self.translate_formatting_rules(rules, currency.code) if rules[:translate]
38
- rules[:decimal_mark] = currency.decimal_mark
38
+ rules[:decimal_mark] = currency.decimal_mark unless rules[:decimal_mark]
39
39
  rules[:decimal_places] = currency.decimal_places
40
40
  rules[:subunit_to_unit] = currency.subunit_to_unit
41
- rules[:thousands_separator] = currency.thousands_separator
41
+ rules[:thousands_separator] = currency.thousands_separator unless rules[:thousands_separator]
42
42
  end
43
43
 
44
44
  # if fractional == 0
@@ -58,13 +58,13 @@ module RedmineCrm
58
58
 
59
59
  # if rules[:rounded_infinite_precision]
60
60
  if currency
61
- formatted.gsub!(/#{currency.decimal_mark}/, '.') unless '.' == currency.decimal_mark
61
+ formatted.gsub!(/#{rules[:decimal_mark]}/, '.') unless '.' == rules[:decimal_mark]
62
62
  formatted = ((BigDecimal(formatted) * currency.subunit_to_unit).round / BigDecimal(currency.subunit_to_unit.to_s)).to_s("F")
63
63
  formatted.gsub!(/\..*/) do |decimal_part|
64
64
  decimal_part << '0' while decimal_part.length < (currency.decimal_places + 1)
65
65
  decimal_part
66
66
  end
67
- formatted.gsub!(/\./, currency.decimal_mark) unless '.' == currency.decimal_mark
67
+ formatted.gsub!(/\./, rules[:decimal_mark]) unless '.' == rules[:decimal_mark]
68
68
  end
69
69
 
70
70
  sign = value < 0 ? '-' : ''
@@ -206,12 +206,8 @@ module RedmineCrm
206
206
  rules = rules.pop
207
207
  rules = { rules => true } if rules.is_a?(Symbol)
208
208
  end
209
- if !rules.include?(:decimal_mark) && rules.include?(:separator)
210
- rules[:decimal_mark] = rules[:separator]
211
- end
212
- if !rules.include?(:thousands_separator) && rules.include?(:delimiter)
213
- rules[:thousands_separator] = rules[:delimiter]
214
- end
209
+ rules[:decimal_mark] = rules[:separator] || ContactsSetting.decimal_separator || rules[:decimal_mark]
210
+ rules[:thousands_separator] = rules[:delimiter] || ContactsSetting.thousands_delimiter || rules[:thousands_separator]
215
211
  rules
216
212
  end
217
213
 
@@ -232,4 +228,4 @@ module RedmineCrm
232
228
  end
233
229
 
234
230
  end
235
- end
231
+ end
@@ -89,6 +89,33 @@ module RedmineCrm
89
89
  end
90
90
 
91
91
  module SingletonMethods
92
+ #Return all avalible tags for a project or global
93
+ #Example: Question.available_tags(@project_id )
94
+ def available_tags(project=nil, limit=30)
95
+ scope = Tag.where({})
96
+ scope = scope.where("#{Project.table_name}.id = ?", project) if project
97
+ class_name = quote_value(base_class.name, nil)
98
+ join = []
99
+ join << "JOIN #{Tagging.table_name} ON #{Tagging.table_name}.tag_id = #{Tag.table_name}.id "
100
+ join << "JOIN #{table_name} ON #{table_name}.id = #{Tagging.table_name}.taggable_id
101
+ AND #{Tagging.table_name}.taggable_type = #{class_name} "
102
+ if project
103
+ join << "JOIN #{Project.table_name} ON #{Project.table_name}.id = #{table_name}.project_id"
104
+ else
105
+ scope = scope.where("#{table_name}.project_id IS NULL")
106
+ end
107
+
108
+ group_fields = ""
109
+ group_fields << ", #{Tag.table_name}.created_at" if Tag.respond_to?(:created_at)
110
+ group_fields << ", #{Tag.table_name}.updated_at" if Tag.respond_to?(:updated_at)
111
+
112
+ scope = scope.joins(join.join(' '))
113
+ scope = scope.select("#{Tag.table_name}.*, COUNT(DISTINCT #{Tagging.table_name}.taggable_id) AS count")
114
+ scope = scope.group("#{Tag.table_name}.id, #{Tag.table_name}.name #{group_fields} HAVING COUNT(*) > 0")
115
+ scope = scope.order("#{Tag.table_name}.name")
116
+ scope = scope.limit(limit) if limit
117
+ scope
118
+ end
92
119
  # Returns an array of related tags.
93
120
  # Related tags are all the other tags that are found on the models tagged with the provided tags.
94
121
  #
@@ -132,7 +132,7 @@ module RedmineCrm
132
132
  # Is this object viewed already?
133
133
  def viewed?
134
134
  return (!self.views.nil? && self.views > 0) if attributes.has_key? 'views'
135
- !viewings.find(:first).nil?
135
+ !viewings.first.nil?
136
136
  end
137
137
 
138
138
  # Get the number of viewings for this object based on the views field,
@@ -20,8 +20,14 @@ module RedmineCrm
20
20
 
21
21
  end
22
22
 
23
+ def create_index(table_name, column_name)
24
+ return if self.connection.index_exists?(table_name, column_name)
25
+
26
+ self.connection.add_index table_name, column_name
27
+ end
28
+
23
29
  def create_votable_table options = {}
24
- votes_name_table = options[:votes] || :votes
30
+ votes_name_table = options[:votes] || :votes
25
31
 
26
32
  if !self.connection.table_exists?(votes_name_table)
27
33
  self.connection.create_table(votes_name_table) do |t|
@@ -32,22 +38,33 @@ module RedmineCrm
32
38
  t.column :vote_scope, :string
33
39
  t.column :vote_weight, :integer
34
40
 
35
- # t.boolean :vote_flag
36
- # t.string :vote_scope
37
- # t.integer :vote_weight
38
-
39
41
  t.timestamps
40
42
  end
41
- # byebug
42
- # if ActiveRecord::VERSION::MAJOR < 4
43
- if self.parent::VERSION::MAJOR < 4
44
- self.connection.add_index :votes, [:votable_id, :votable_type]
45
- self.connection.add_index :votes, [:voter_id, :voter_type]
43
+ else #if table exists - check existence of separate columns
44
+ fields = {
45
+ :votable_id => :integer,
46
+ :votable_type => :string,
47
+ :voter_id => :integer,
48
+ :voter_type => :string,
49
+ :vote_flag => :boolean,
50
+ :vote_scope => :string,
51
+ :vote_weight => :integer
52
+ }
53
+ fields.each do |name, type|
54
+ if !self.connection.column_exists?(votes_name_table, name)
55
+ self.connection.add_column(votes_name_table, name, type)
56
+ end
46
57
  end
47
58
 
48
- self.connection.add_index :votes, [:voter_id, :voter_type, :vote_scope]
49
- self.connection.add_index :votes, [:votable_id, :votable_type, :vote_scope]
50
59
  end
60
+
61
+ if self.parent::VERSION::MAJOR < 4
62
+ create_index votes_name_table, [:votable_id, :votable_type]
63
+ create_index votes_name_table, [:voter_id, :voter_type]
64
+ end
65
+
66
+ create_index votes_name_table, [:voter_id, :voter_type, :vote_scope]
67
+ create_index votes_name_table, [:votable_id, :votable_type, :vote_scope]
51
68
  end
52
69
 
53
70
  def drop_votable_table options = {}
@@ -1,3 +1,3 @@
1
1
  module RedmineCrm
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_crm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - RedmineCRM
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-25 00:00:00.000000000 Z
11
+ date: 2015-09-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: plugins for Redmine
14
14
  email:
@@ -19,10 +19,11 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - ".gitignore"
21
21
  - Gemfile
22
- - LICENSE.txt
23
22
  - README.md
24
23
  - Rakefile
25
24
  - config/currency_iso.json
25
+ - doc/CHANGELOG
26
+ - doc/LICENSE.txt
26
27
  - lib/generators/redmine_crm_migration/redmine_crm_migration_generator.rb
27
28
  - lib/generators/redmine_crm_migration/templates/migration.rb
28
29
  - lib/redmine_crm.rb