effective_email_templates 0.3.5 → 0.4.0

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: 53e93687531dcc1bdbcabef5d5d4621b10a79c54
4
- data.tar.gz: 5ec371fa23130f08297fc0efdae95d29e86a2f5a
3
+ metadata.gz: 22f145ef5bb62900fbd74958509c12281582c84f
4
+ data.tar.gz: 6ee09134ecff68909d39c29ff6f6fb4dbdbd3124
5
5
  SHA512:
6
- metadata.gz: c53d990fd88a40e7be908cab99c3617191ef3b0dc0c195e2232b88248be2001b72b38212ee1ad70f3a35fde2a47e9f27038bca246f61d2837b851632eb69301b
7
- data.tar.gz: 9a95f27403b2def66c31dc4c6e53f52072cf3f60f0087f936f445591bf4f3ebc66d2a70d3539fbd80079b64af3ff08f939c54d43a74a43897582572f394a1a33
6
+ metadata.gz: ac82b99c9b4c8b756ea97fd244683c3e42f3b0e42a47b8a2fcbd48ebd0d44b94d17dd8723dbb8a6e73be355308bb5d2f066265891e814498e69cbb5b3b9cc3ed
7
+ data.tar.gz: a6a8f151c292a9be331efb8393553a1edd99058e68c410d3bcb039bdd1938e8e52034c23e658c76723a2dcf2d1503197b2b86f932422ecd57f29168c53956832
data/README.md CHANGED
@@ -44,7 +44,7 @@ This is very similar to creating other emails in Rails.
44
44
 
45
45
  1. Create a new mailer object (i.e. `/app/mailers/template_mailer.rb`)
46
46
  - Mailer objects need to inherit from `Effective::LiquidMailer`
47
-
47
+
48
48
  2. Create a method inside the mailer object based on the name of your email (i.e. `def welcome_email`)
49
49
 
50
50
  3. Create a default email template file (i.e. `/app/views/template_mailer/welcome_email.liquid`)
@@ -158,6 +158,14 @@ rescue_from Effective::AccessDenied do |exception|
158
158
  end
159
159
  ```
160
160
 
161
+ ### Permissions
162
+
163
+ To allow a user to see the admin area, using CanCan:
164
+
165
+ ```ruby
166
+ can :admin, :effective_email_templates
167
+ ```
168
+
161
169
 
162
170
  ## License
163
171
 
@@ -5,51 +5,52 @@ module Admin
5
5
  layout (EffectiveEmailTemplates.layout.kind_of?(Hash) ? EffectiveEmailTemplates.layout[:admin_email_templates] : EffectiveEmailTemplates.layout)
6
6
 
7
7
  def index
8
- EffectiveEmailTemplates.authorized?(self, :index, Effective::EmailTemplate)
9
-
10
- @page_title = 'Manage Email Templates'
11
- @datatable = Effective::Datatables::EmailTemplates.new() if defined?(EffectiveDatatables)
8
+ @datatable = Effective::Datatables::EmailTemplates.new()
12
9
  @page_title = 'Email Templates'
10
+
11
+ authorize_effective_email_templates!
13
12
  end
14
13
 
15
14
  def new
16
15
  @email_template = Effective::EmailTemplate.new
17
- EffectiveEmailTemplates.authorized?(self, :new, @email_template)
18
-
19
16
  @page_title = 'New Email Template'
17
+
18
+ authorize_effective_email_templates!
20
19
  end
21
20
 
22
21
  def create
23
22
  @email_template = Effective::EmailTemplate.new(email_template_params)
24
- EffectiveEmailTemplates.authorized?(self, :create, @email_template)
23
+ @page_title = 'New Email Template'
24
+
25
+ authorize_effective_email_templates!
25
26
 
26
27
  if @email_template.save
27
28
  flash[:success] = "Email template created successfully"
28
29
  redirect_to effective_email_templates.admin_email_templates_path
29
30
  else
30
31
  flash.now[:error] = "Could not create email template"
31
- @page_title = 'New Email Template'
32
32
  render :new
33
33
  end
34
34
  end
35
35
 
36
36
  def edit
37
37
  @email_template = Effective::EmailTemplate.find(params[:id])
38
- EffectiveEmailTemplates.authorized?(self, :edit, @email_template)
39
-
40
38
  @page_title = 'Edit Email Template'
39
+
40
+ authorize_effective_email_templates!
41
41
  end
42
42
 
43
43
  def update
44
44
  @email_template = Effective::EmailTemplate.find(params[:id])
45
- EffectiveEmailTemplates.authorized?(self, :update, @email_template)
45
+ @page_title = 'Edit Email Template'
46
+
47
+ authorize_effective_email_templates!
46
48
 
47
49
  if @email_template.update(email_template_params)
48
50
  flash[:success] = "Email template updated successfully"
49
51
  redirect_to effective_email_templates.admin_email_templates_path
50
52
  else
51
53
  flash.now[:error] = "Could not update email template"
52
- @page_title = 'Edit Email Template'
53
54
  render :edit
54
55
  end
55
56
  end
@@ -59,5 +60,11 @@ module Admin
59
60
  def email_template_params
60
61
  params.require(:effective_email_template).permit([ :from, :cc, :bcc, :subject, :body ])
61
62
  end
63
+
64
+ def authorize_effective_email_templates!
65
+ EffectiveEmailTemplates.authorized?(self, :admin, :effective_email_templates)
66
+ EffectiveEmailTemplates.authorized?(self, action_name.to_sym, @email_template || Effective::EmailTemplate)
67
+ end
68
+
62
69
  end
63
70
  end
@@ -15,4 +15,3 @@ unless defined?(Effective::AccessDenied)
15
15
  end
16
16
  end
17
17
  end
18
-
@@ -1,3 +1,3 @@
1
- %h1 Edit Email Template
1
+ %h1.effective-admin-heading= @page_title
2
2
 
3
3
  = render partial: 'form', locals: { email_template: @email_template }
@@ -1,3 +1,3 @@
1
- %h1 Email Templates
1
+ %h1.effective-admin-heading= @page_title
2
2
 
3
3
  = render_datatable(@datatable)
@@ -45,7 +45,7 @@ EffectiveEmailTemplates.setup do |config|
45
45
  #
46
46
  # Or disable the check completely:
47
47
  # config.authorization_method = false
48
- config.authorization_method = Proc.new { |controller, action, resource| can?(action, resource) } # CanCan gem
48
+ config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) } # CanCanCan
49
49
 
50
50
 
51
51
  end
@@ -1,8 +1,8 @@
1
- require "effective_email_templates/engine"
2
1
  require "effective_email_templates/liquid_resolver"
3
2
  require "effective_email_templates/email_view_template"
4
3
  require "effective_email_templates/template_importer"
5
4
  require "effective_email_templates/version"
5
+ require "effective_email_templates/engine"
6
6
 
7
7
  require "effective/liquid_mailer"
8
8
  Effective::LiquidMailer.send(:append_view_path, EffectiveEmailTemplates::LiquidResolver.new)
@@ -19,7 +19,7 @@ module EffectiveEmailTemplates
19
19
 
20
20
  # Set up our default configuration options.
21
21
  initializer "effective_email_templates.defaults", :before => :load_config_initializers do |app|
22
- eval File.read("#{config.root}/lib/generators/templates/effective_email_templates.rb")
22
+ eval File.read("#{config.root}/config/effective_email_templates.rb")
23
23
  end
24
24
 
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveEmailTemplates
2
- VERSION = '0.3.5'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -3,9 +3,9 @@ module EffectiveEmailTemplates
3
3
  class InstallGenerator < Rails::Generators::Base
4
4
  include Rails::Generators::Migration
5
5
 
6
- desc "Creates an EffectiveEmailTemplates initializer in your application."
6
+ desc 'Creates an EffectiveEmailTemplates initializer in your application.'
7
7
 
8
- source_root File.expand_path("../../templates", __FILE__)
8
+ source_root File.expand_path('../../templates', __FILE__)
9
9
 
10
10
  def self.next_migration_number(dirname)
11
11
  if not ActiveRecord::Base.timestamped_migrations
@@ -16,16 +16,12 @@ module EffectiveEmailTemplates
16
16
  end
17
17
 
18
18
  def copy_initializer
19
- template "effective_email_templates.rb", "config/initializers/effective_email_templates.rb"
19
+ template ('../' * 3) + 'config/effective_email_templates.rb', 'config/initializers/effective_email_templates.rb'
20
20
  end
21
21
 
22
22
  def create_migration_file
23
23
  @email_templates_table_name = ':' + EffectiveEmailTemplates.email_templates_table_name.to_s
24
- migration_template '../../../db/migrate/01_create_effective_email_templates.rb.erb', 'db/migrate/create_effective_email_templates.rb'
25
- end
26
-
27
- def show_readme
28
- readme "README" if behavior == :invoke
24
+ migration_template ('../' * 3) + 'db/migrate/01_create_effective_email_templates.rb.erb', 'db/migrate/create_effective_email_templates.rb'
29
25
  end
30
26
  end
31
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_email_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-05 00:00:00.000000000 Z
11
+ date: 2016-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- - !ruby/object:Gem::Dependency
56
- name: migrant
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '1.3'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '1.3'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: liquid
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -95,21 +81,21 @@ dependencies:
95
81
  - !ruby/object:Gem::Version
96
82
  version: 1.0.0
97
83
  - !ruby/object:Gem::Dependency
98
- name: rspec-rails
84
+ name: effective_datatables
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - ">="
102
88
  - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
89
+ version: 2.0.0
90
+ type: :runtime
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
94
  - - ">="
109
95
  - !ruby/object:Gem::Version
110
- version: '0'
96
+ version: 2.0.0
111
97
  - !ruby/object:Gem::Dependency
112
- name: factory_girl_rails
98
+ name: rspec-rails
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - ">="
@@ -123,7 +109,7 @@ dependencies:
123
109
  - !ruby/object:Gem::Version
124
110
  version: '0'
125
111
  - !ruby/object:Gem::Dependency
126
- name: sqlite3
112
+ name: factory_girl_rails
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
115
  - - ">="
@@ -137,19 +123,19 @@ dependencies:
137
123
  - !ruby/object:Gem::Version
138
124
  version: '0'
139
125
  - !ruby/object:Gem::Dependency
140
- name: effective_datatables
126
+ name: sqlite3
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
129
  - - ">="
144
130
  - !ruby/object:Gem::Version
145
- version: 2.0.0
131
+ version: '0'
146
132
  type: :development
147
133
  prerelease: false
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
136
  - - ">="
151
137
  - !ruby/object:Gem::Version
152
- version: 2.0.0
138
+ version: '0'
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: pry
155
141
  requirement: !ruby/object:Gem::Requirement
@@ -191,9 +177,9 @@ files:
191
177
  - app/assets/javascripts/effective_email_templates.js
192
178
  - app/assets/stylesheets/effective_email_templates.css.scss
193
179
  - app/controllers/admin/email_templates_controller.rb
194
- - app/errors/effective/access_denied.rb
195
180
  - app/helpers/effective_email_templates_helper.rb
196
181
  - app/mailers/effective/email_template_mailer.rb
182
+ - app/models/effective/access_denied.rb
197
183
  - app/models/effective/datatables/email_templates.rb
198
184
  - app/models/effective/email_template.rb
199
185
  - app/views/admin/email_templates/_actions.html.haml
@@ -201,6 +187,7 @@ files:
201
187
  - app/views/admin/email_templates/edit.html.haml
202
188
  - app/views/admin/email_templates/index.html.haml
203
189
  - app/views/effective/email_template_mailer/templated_email.html.haml
190
+ - config/effective_email_templates.rb
204
191
  - config/routes.rb
205
192
  - db/migrate/01_create_effective_email_templates.rb.erb
206
193
  - lib/effective/liquid_mailer.rb
@@ -211,8 +198,6 @@ files:
211
198
  - lib/effective_email_templates/template_importer.rb
212
199
  - lib/effective_email_templates/version.rb
213
200
  - lib/generators/effective_email_templates/install_generator.rb
214
- - lib/generators/templates/README
215
- - lib/generators/templates/effective_email_templates.rb
216
201
  - lib/tasks/effective_email_templates/import_default_views.rake
217
202
  - spec/controllers/admin/email_templates_controller_spec.rb
218
203
  - spec/dummy/README.rdoc
@@ -290,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
275
  version: '0'
291
276
  requirements: []
292
277
  rubyforge_project:
293
- rubygems_version: 2.4.3
278
+ rubygems_version: 2.4.6
294
279
  signing_key:
295
280
  specification_version: 4
296
281
  summary: Effective Email Templates provides an admin access to modify email templates
@@ -1 +0,0 @@
1
- Thanks for using EffectiveEmailTemplates