activeadmin-settings 0.2.8 → 0.2.9
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.
- data/app/models/activeadmin_settings/setting.rb +18 -2
- data/lib/activeadmin-settings.rb +1 -1
- data/lib/activeadmin-settings/version.rb +1 -1
- data/lib/generators/activeadmin_settings/install_generator.rb +6 -0
- data/lib/generators/activeadmin_settings/templates/admin/settings.rb +4 -1
- data/lib/tasks/activeadmin_settings.rake +0 -15
- metadata +2 -2
@@ -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
|
7
|
-
|
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
|
data/lib/activeadmin-settings.rb
CHANGED
@@ -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
|
-
|
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.
|
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:
|
106
|
+
hash: 4606963073682429613
|
107
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
108
|
none: false
|
109
109
|
requirements:
|