refinerycms-inquiries 0.9.8.2 → 0.9.8.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,12 @@
1
1
  class Admin::InquirySettingsController < Admin::BaseController
2
2
 
3
- crudify :refinery_setting, :title_attribute => "name", :order => 'name ASC', :redirect_to_url => "admin_inquiries_url"
3
+ crudify :refinery_setting,
4
+ :title_attribute => "name",
5
+ :order => 'name ASC',
6
+ :redirect_to_url => "admin_inquiries_url"
4
7
 
5
8
  before_filter :redirect_back_to_inquiries?, :only => [:index]
6
- before_filter :set_url_override?, :only => [:edit]
9
+ before_filter :set_url_override?, :only => [:edit, :update]
7
10
  after_filter :save_subject_for_confirmation?, :only => [:create, :update]
8
11
  around_filter :rewrite_flash?, :only => [:create, :update]
9
12
 
@@ -23,12 +26,20 @@ protected
23
26
  end
24
27
 
25
28
  def set_url_override?
26
- @url_override = admin_inquiry_setting_url(@refinery_setting.name.to_sym, :dialog => from_dialog?)
29
+ @url_override = admin_inquiry_setting_url(@refinery_setting, :dialog => from_dialog?)
27
30
  end
28
31
 
29
32
  def find_refinery_setting
33
+ # ensure that we're dealing with the name of the setting, not the id.
34
+ begin
35
+ if params[:id].to_i.to_s == params[:id]
36
+ params[:id] = RefinerySetting.find(params[:id]).name.to_s
37
+ end
38
+ rescue
39
+ end
40
+
30
41
  # prime the setting first, if it's valid.
31
- if InquirySetting.methods.include?(params[:id].to_s.gsub('inquiry_', ''))
42
+ if InquirySetting.methods.map(&:to_sym).include?(params[:id].to_s.gsub('inquiry_', '').to_sym)
32
43
  InquirySetting.send(params[:id].to_s.gsub('inquiry_', '').to_sym)
33
44
  end
34
45
  @refinery_setting = RefinerySetting.find_by_name(params[:id])
@@ -7,7 +7,8 @@ class InquirySetting < ActiveRecord::Base
7
7
  end
8
8
 
9
9
  def self.confirmation_subject
10
- RefinerySetting.find_or_set(:inquiry_confirmation_subject, "Thank you for your inquiry")
10
+ RefinerySetting.find_or_set(:inquiry_confirmation_subject,
11
+ "Thank you for your inquiry")
11
12
  end
12
13
 
13
14
  def self.confirmation_subject=(value)
@@ -15,11 +16,13 @@ class InquirySetting < ActiveRecord::Base
15
16
  end
16
17
 
17
18
  def self.notification_recipients
18
- RefinerySetting.find_or_set(:inquiry_notification_recipients, (Role[:refinery].users.first.email if defined?(Role)))
19
+ RefinerySetting.find_or_set(:inquiry_notification_recipients,
20
+ (defined?(Role) ? Role[:refinery].users.first.email : '' rescue ''))
19
21
  end
20
22
 
21
23
  def self.notification_subject
22
- RefinerySetting.find_or_set(:inquiry_notification_subject, "New inquiry from your website")
24
+ RefinerySetting.find_or_set(:inquiry_notification_subject,
25
+ "New inquiry from your website")
23
26
  end
24
27
 
25
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-inquiries
3
3
  version: !ruby/object:Gem::Version
4
- hash: 35
4
+ hash: 33
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
9
  - 8
10
- - 2
11
- version: 0.9.8.2
10
+ - 3
11
+ version: 0.9.8.3
12
12
  platform: ruby
13
13
  authors:
14
14
  - Resolve Digital