redmine_extensions 0.3.3 → 0.3.4

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
  SHA256:
3
- metadata.gz: e01494fb8634b6116c7ee6df38c54a79845aed25438558c1bd068a24bc551d60
4
- data.tar.gz: 3018303ecf9d11f4b9ed3720729cb7bcf0eef94adbdfebbc83fba0959a648698
3
+ metadata.gz: f91868f692beaaf8a3a69f028088732385f8670b4ff2103334708cf547827ae2
4
+ data.tar.gz: aae4b3809dd2ea1b11d8e754853d45e93c9bb1980fd0ee64cc9e1a95fde479b9
5
5
  SHA512:
6
- metadata.gz: 10c0ece096eeeaa651feeae6aafa0004270bd7a87ff15f4e4f8118e596f0dae6c17c0cbd0841a132c079cdc8e49bbcd5f509a0d0adf6bb528692806354c3a7c0
7
- data.tar.gz: 0c77dcfcafb5d125ab9cdb22fc7b134665cf4afa45373bcfc39ea1e6c42c3050dda90061be766f8d45a15a1cabd9d196ef85a1ce3089da9e74299342120151ee
6
+ metadata.gz: f7195001a6d347fed1b5708bfb3820d6dd9378b6a15900a9b740526bb5462f7b6a35ed1a1eac905778cd546269270179162994b14ff40f5bc81943a6cd52b8a7
7
+ data.tar.gz: 0d9d725a78e71b4fe08797515e02fc64930c14d4c1b89487684a67fc67d268f107b7994444e4384bb5a65ba65da5e5031ef7584c30bb704fb974fe653c4f801b
@@ -4,3 +4,5 @@ en:
4
4
  label_no_output: No output has been selected
5
5
  label_easy_query_outputs: Outputs
6
6
  text_modal_is_closing: This modal dialog will be closed automatically, please wait.
7
+ error_entity_name_is_used: "Entity name %{entity_name} is already used. Please use different"
8
+ error_plugin_name_is_used: "Plugin name %{plugin_name} is already used. Please use different"
@@ -30,6 +30,9 @@ module RedmineExtensions
30
30
  attr_reader :rys
31
31
  def initialize(*args)
32
32
  super
33
+ @model_name_camelized = model_name.camelize
34
+ check_existing_const
35
+
33
36
  @rys = !!options["rys"]
34
37
  @plugin_name_underscored = plugin_name.underscore
35
38
  @plugin_pretty_name = @plugin_name_underscored.titleize
@@ -44,6 +47,15 @@ module RedmineExtensions
44
47
  prepare_columns
45
48
  end
46
49
 
50
+ def check_existing_const
51
+ begin
52
+ @model_name_camelized.constantize
53
+ raise I18n.t(:error_entity_name_is_used, entity_name: @model_name_camelized)
54
+ rescue LoadError, NameError
55
+ # OK
56
+ end
57
+ end
58
+
47
59
  def copy_templates
48
60
  template '_form.html.erb.erb', "#{plugin_path}/app/views/#{model_name_pluralize_underscored}/_form.html.erb"
49
61
  template '_sidebar.html.erb.erb', "#{plugin_path}/app/views/#{model_name_pluralize_underscored}/_sidebar.html.erb"
@@ -2,7 +2,7 @@ class <%= model_name %>Mailer < Mailer
2
2
 
3
3
  helper :<%= model_name_pluralize_underscored %>
4
4
 
5
- def <%= model_name_underscored %>_added(<%= model_name_underscored %>)
5
+ def <%= model_name_underscored %>_added(recipient, <%= model_name_underscored %>)
6
6
  <%- if project? -%>
7
7
  redmine_headers 'Project' => <%= model_name_underscored %>.project.identifier
8
8
 
@@ -16,11 +16,11 @@ class <%= model_name %>Mailer < Mailer
16
16
  message_id <%= model_name_underscored %>
17
17
  references <%= model_name_underscored %>
18
18
 
19
- mail to: <%= model_name_underscored %>.notified_users,
19
+ mail to: recipient,
20
20
  subject: "#{l(:label_<%= model_name_underscored %>)}: #{<%= model_name_underscored %>.to_s}"
21
21
  end
22
22
 
23
- def <%= model_name_underscored %>_updated(<%= model_name_underscored %>)
23
+ def <%= model_name_underscored %>_updated(recipient, <%= model_name_underscored %>)
24
24
  <%- if project? -%>
25
25
  redmine_headers 'Project' => <%= model_name_underscored %>.project.identifier
26
26
 
@@ -34,7 +34,7 @@ class <%= model_name %>Mailer < Mailer
34
34
  message_id <%= model_name_underscored %>
35
35
  references <%= model_name_underscored %>
36
36
 
37
- mail to: <%= model_name_underscored %>.notified_users,
37
+ mail to: recipient,
38
38
  subject: "#{l(:label_<%= model_name_underscored %>)}: #{<%= model_name_underscored %>.to_s}"
39
39
  end
40
40
 
@@ -132,13 +132,17 @@ class <%= model_name %> < ActiveRecord::Base
132
132
 
133
133
  def send_create_notification
134
134
  # if Setting.notified_events.include?('<%= model_name_underscored %>_added')
135
- <%= model_name %>Mailer.<%= model_name_underscored %>_added(self).deliver
135
+ notified_users.each do |user|
136
+ <%= model_name %>Mailer.<%= model_name_underscored %>_added(user, self).deliver
137
+ end
136
138
  # end
137
139
  end
138
140
 
139
141
  def send_update_notification
140
142
  # if Setting.notified_events.include?('<%= model_name_underscored %>_updated')
141
- <%= model_name %>Mailer.<%= model_name_underscored %>_updated(self).deliver
143
+ notified_users.each do |user|
144
+ <%= model_name %>Mailer.<%= model_name_underscored %>_updated(user, self).deliver
145
+ end
142
146
  # end
143
147
  end
144
148
  <%- end -%>
@@ -15,6 +15,16 @@ module RedmineExtensions
15
15
 
16
16
  @plugin_path = (easy_plugin ? "plugins/easyproject/easy_plugins" : "plugins") + "/#{plugin_name_underscored}"
17
17
  @plugin_title = @plugin_name_underscored.camelize
18
+ check_existing_const
19
+ end
20
+
21
+ def check_existing_const
22
+ begin
23
+ @plugin_title.constantize
24
+ raise I18n.t(:error_plugin_name_is_used, plugin_name: @plugin_title)
25
+ rescue LoadError, NameError
26
+ # OK
27
+ end
18
28
  end
19
29
 
20
30
  def copy_templates
@@ -1,3 +1,3 @@
1
1
  module RedmineExtensions
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Easy Software Ltd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-14 00:00:00.000000000 Z
11
+ date: 2019-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails