activeadmin-settings 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,16 @@
1
1
  class ActiveadminSettings::Setting
2
2
  include Mongoid::Document
3
3
  include Mongoid::Timestamps
4
+ include Mongoid::Globalize
4
5
 
5
6
  # Fields
6
- field :name
7
- field :string, :default => ""
7
+ field :name
8
+
9
+ translates do
10
+ field :string, :default => ""
11
+ fallbacks_for_empty_translations!
12
+ end
13
+
8
14
  mount_uploader :file, ActiveadminSettings::SettingsFileUploader
9
15
 
10
16
  # Validators
@@ -39,4 +45,14 @@ class ActiveadminSettings::Setting
39
45
  val = default_value if val.empty?
40
46
  val.html_safe
41
47
  end
48
+
49
+ # Class
50
+ def self.initiate_setting(name)
51
+ s = self.new(name: name)
52
+ if s.type == "text" or s.type == "html"
53
+ s.string = s.default_value
54
+ end
55
+ s.save
56
+ s
57
+ end
42
58
  end
@@ -39,7 +39,7 @@ module ActiveadminSettings
39
39
  def self.groups
40
40
  @groups = []
41
41
  load_config.each do |key, settings|
42
- @groups << { :name => key,
42
+ @groups << {:name => key,
43
43
  :slug => key.downcase.gsub(" ", "_"),
44
44
  :default_settings => settings,
45
45
  :settings => [] }
@@ -1,3 +1,3 @@
1
1
  module ActiveadminSettings
2
- VERSION = "0.2.8"
2
+ VERSION = "0.2.9"
3
3
  end
@@ -34,6 +34,12 @@ module ActiveadminSettings
34
34
  puts "It doesn't look like you've installed activeadmin: active_admin.scss is missing.\nPlease install it and try again."
35
35
  end
36
36
  end
37
+
38
+ def add_gems
39
+ gem "carrierwave-mongoid", :require => "carrierwave/mongoid"
40
+ gem "mini_magick"
41
+ gem "mongoid_globalize"
42
+ end
37
43
  end
38
44
  end
39
45
  end
@@ -12,7 +12,10 @@ ActiveAdmin.register_page "Settings" do
12
12
  groups.each do |g|
13
13
  g[:default_settings].each_key do |name|
14
14
  s = all_settings[name]
15
- g[:settings] << s if s
15
+ unless s
16
+ s = ActiveadminSettings::Setting.initiate_setting(name)
17
+ end
18
+ g[:settings] << s
16
19
  end
17
20
  end
18
21
 
@@ -10,21 +10,6 @@ namespace :activeadmin do
10
10
  password: password"
11
11
  end
12
12
 
13
- desc "Add missing settings from activeadmin_settings.yml file to the db"
14
- task :add => :environment do
15
- ActiveadminSettings.all_settings.each_key do |name|
16
- puts "Add setting: #{name}"
17
- s = ActiveadminSettings::Setting.find_or_create_by(name: name)
18
-
19
- # Save default text values to db,
20
- # as this way it's more easy to edit them
21
- if s.type == "text" or s.type == "html"
22
- s.string = s.default_value
23
- s.save
24
- end
25
- end
26
- end
27
-
28
13
  desc "Add settings from activeadmin_settings.yml file to the db"
29
14
  task :flush => :environment do
30
15
  ActiveadminSettings::Setting.all.destroy
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -103,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  segments:
105
105
  - 0
106
- hash: -140399498841524941
106
+ hash: 4606963073682429613
107
107
  required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  none: false
109
109
  requirements: