qbrick 2.6.10 → 2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/qbrick/cms/admins_controller.rb +1 -1
- data/app/controllers/qbrick/cms/settings_controller.rb +20 -0
- data/app/helpers/qbrick/cms/admin_helper.rb +1 -2
- data/{lib/qbrick → app/models/concerns}/brick_list.rb +0 -0
- data/app/models/qbrick/admin.rb +2 -0
- data/app/models/qbrick/brick.rb +3 -2
- data/app/models/qbrick/page.rb +8 -11
- data/app/models/qbrick/settings.rb +28 -0
- data/app/views/devise/sessions/new.html.haml +2 -2
- data/app/views/qbrick/cms/backend/_main_navigation.html.haml +1 -1
- data/app/views/qbrick/cms/bricks/new.js.erb +1 -1
- data/app/views/qbrick/cms/settings/index.html.haml +24 -0
- data/config/initializers/rails_settings_ui.rb +10 -0
- data/config/locales/views/qbrick/cms/{settings_collection → settings}/de.yml +3 -2
- data/config/locales/views/qbrick/cms/{settings_collection → settings}/en.yml +2 -1
- data/config/routes.rb +5 -7
- data/db/migrate/26_change_settings.rb +18 -0
- data/db/seeds.rb +0 -20
- data/lib/qbrick.rb +2 -1
- data/lib/qbrick/version.rb +1 -1
- data/spec/controllers/qbrick/cms/settings_controller_spec.rb +39 -0
- data/spec/factories.rb +0 -5
- data/spec/models/settings_spec.rb +53 -0
- metadata +42 -12
- data/app/controllers/qbrick/cms/settings_collections_controller.rb +0 -26
- data/app/models/qbrick/setting.rb +0 -13
- data/app/models/qbrick/settings_collection.rb +0 -10
- data/app/views/qbrick/cms/settings_collections/_form.html.haml +0 -8
- data/app/views/qbrick/cms/settings_collections/index.html.haml +0 -6
- data/spec/models/setting_spec.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4a7a8140be43d0e7d62d35acc326f6e21c8908b
|
4
|
+
data.tar.gz: 4e6a28e356fe3faaca9df4c83004dabe902d0a61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4c3805524f4bc8d16a131ebbc283da844f54a79555651be867be95ab3defade6e4d46cae21ab4f773799d7c2c90f83efdf95812fe98e7186ca943e797e1569a
|
7
|
+
data.tar.gz: 7dfffed96761598156d00d841105eba80682be2d7586c2f716a883210ae9a142e7ef810a66b5c9fca86b31ac21e0c61e4b414f9defe4b512dcf55b1da3c5c285
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Qbrick
|
2
|
+
module Cms
|
3
|
+
class SettingsController < RailsSettingsUi::SettingsController
|
4
|
+
def update_all
|
5
|
+
if @casted_settings[:errors].any?
|
6
|
+
render :index
|
7
|
+
else
|
8
|
+
@casted_settings.map { |setting| RailsSettingsUi.settings_klass[setting[0]] = setting[1] if setting[0] != 'errors' }
|
9
|
+
redirect_to qbrick.url_for(action: :index)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def cast_settings_params
|
16
|
+
@casted_settings = RailsSettingsUi::TypeConverter.cast params[:settings]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -14,8 +14,7 @@ module Qbrick
|
|
14
14
|
action = 'edit'
|
15
15
|
end
|
16
16
|
|
17
|
-
link_to locale.to_s.upcase, url_for(
|
18
|
-
action: action, content_locale: locale)
|
17
|
+
link_to locale.to_s.upcase, qbrick.url_for(action: action, content_locale: locale)
|
19
18
|
end
|
20
19
|
|
21
20
|
def model_attribute_field(resource, column_name, f)
|
File without changes
|
data/app/models/qbrick/admin.rb
CHANGED
data/app/models/qbrick/brick.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative '../concerns/brick_list'
|
2
2
|
|
3
3
|
module Qbrick
|
4
4
|
class Brick < ActiveRecord::Base
|
5
|
+
include ::RailsSettings::Extend
|
5
6
|
include Qbrick::BrickList
|
6
7
|
|
7
8
|
belongs_to :brick_list, polymorphic: true, touch: true
|
@@ -32,7 +33,7 @@ module Qbrick
|
|
32
33
|
|
33
34
|
after_initialize do
|
34
35
|
self.position ||= has_siblings? ? brick_list.bricks.maximum(:position).to_i + 1 : 1
|
35
|
-
self.image_size ||= ImageSize.all.first.name.to_s
|
36
|
+
self.image_size ||= Qbrick::ImageSize.all.first.name.to_s if Qbrick::ImageSize.all.first.present?
|
36
37
|
end
|
37
38
|
|
38
39
|
after_save do
|
data/app/models/qbrick/page.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Qbrick
|
2
2
|
class Page < ActiveRecord::Base
|
3
|
+
include ::RailsSettings::Extend
|
3
4
|
include Qbrick::Engine.routes.url_helpers
|
4
5
|
include Qbrick::Orderable
|
5
6
|
include Qbrick::Translatable
|
@@ -144,21 +145,17 @@ module Qbrick
|
|
144
145
|
end
|
145
146
|
|
146
147
|
def translated_link_for(locale)
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
else
|
152
|
-
Qbrick::Page.roots.first.link
|
148
|
+
return Qbrick::Page.roots.first.link unless translated_to? locale
|
149
|
+
|
150
|
+
I18n.with_locale locale do
|
151
|
+
path_with_prefixed_locale
|
153
152
|
end
|
154
153
|
end
|
155
154
|
|
156
155
|
def link
|
157
|
-
if bricks.
|
158
|
-
|
159
|
-
|
160
|
-
path_with_prefixed_locale
|
161
|
-
end
|
156
|
+
return children.published.first.link if bricks.empty? && children.any?
|
157
|
+
|
158
|
+
path_with_prefixed_locale
|
162
159
|
end
|
163
160
|
|
164
161
|
def path_segments
|
@@ -0,0 +1,28 @@
|
|
1
|
+
RailsSettings::Settings.table_name = 'qbrick_settings'
|
2
|
+
|
3
|
+
module Qbrick
|
4
|
+
class Settings < ::RailsSettings::CachedSettings
|
5
|
+
scope :ordered, -> { order :var }
|
6
|
+
alias_attribute :key, :var
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def vars
|
10
|
+
pluck :var
|
11
|
+
end
|
12
|
+
alias keys vars
|
13
|
+
|
14
|
+
def all_object_hash(starting_with = nil)
|
15
|
+
vars = thing_scoped.ordered
|
16
|
+
vars = vars.where "var LIKE '#{starting_with}%'" if starting_with
|
17
|
+
|
18
|
+
Hash[vars.map { |record| [record.var, record] }].with_indifferent_access.tap do |result|
|
19
|
+
@@defaults.slice(*(@@defaults.keys - result.keys)).each do |key, value|
|
20
|
+
next if starting_with.present? && !key.start_with?(starting_with)
|
21
|
+
|
22
|
+
result[key] = Qbrick::Settings.new var: key, value: value
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -2,8 +2,8 @@
|
|
2
2
|
%h1 Sign in
|
3
3
|
.form
|
4
4
|
= simple_form_for(resource, as: resource_name, url: session_path(resource_name), wrapper: :bootstrap) do |f|
|
5
|
-
= f.input :email, :
|
6
|
-
= f.input :password, :
|
5
|
+
= f.input :email, required: false, autofocus: true
|
6
|
+
= f.input :password, required: false
|
7
7
|
|
8
8
|
- if devise_mapping.rememberable?
|
9
9
|
= f.input :remember_me, as: :boolean, wrapper_html: { class: 'checkbox-wrapper' }
|
@@ -15,6 +15,6 @@
|
|
15
15
|
%li= link_to t('.logout'), qbrick.destroy_admin_session_path, method: :delete
|
16
16
|
|
17
17
|
%ul.nav
|
18
|
-
%li= link_to t('.settings'), qbrick.
|
18
|
+
%li= link_to t('.settings'), qbrick.cms_settings_path
|
19
19
|
%li= link_to Qbrick::Page.model_name.human(count: 2), qbrick.cms_pages_path
|
20
20
|
%li= link_to Qbrick::Admin.model_name.human(count: 2), qbrick.cms_admins_path
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
$("#brick-form").empty();
|
6
6
|
|
7
|
-
$("#brick-form").append(<%= render('qbrick/cms/bricks/new', :
|
7
|
+
$("#brick-form").append(<%= render('qbrick/cms/bricks/new', brick: @brick, format: :html).to_json.html_safe %>);
|
8
8
|
|
9
9
|
$("#brick-form").find('textarea.ckeditor').each(function (index, elem) { initCKEditor(elem.id) });
|
10
10
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
%h1= t 'qbrick.cms.settings.index.title'
|
2
|
+
|
3
|
+
- if @casted_settings && @casted_settings[:errors].any?
|
4
|
+
.alert.alert-danger= t('settings.index.settings_include_errors')
|
5
|
+
|
6
|
+
= form_tag qbrick.update_all_cms_settings_path, method: :put, class: 'form' do
|
7
|
+
%table.table.table-striped
|
8
|
+
%thead
|
9
|
+
%tr
|
10
|
+
%th= t('settings.index.description')
|
11
|
+
%th= t('settings.index.value')
|
12
|
+
%tbody
|
13
|
+
- @settings.each do |name, value|
|
14
|
+
- next if name == :errors
|
15
|
+
%tr{ data: { name: name } }
|
16
|
+
%td= I18n.t("settings.attributes.#{name}.name")
|
17
|
+
%td.setting-value
|
18
|
+
- setting_with_error = @casted_settings && @casted_settings[:errors].include?(name)
|
19
|
+
%div{ class: "form-group #{ setting_with_error ? 'has-error' : ''}" }
|
20
|
+
= setting_field(name, value, @settings)
|
21
|
+
- if setting_with_error
|
22
|
+
%span.help-block= @casted_settings[:errors][name]
|
23
|
+
|
24
|
+
= submit_tag t('settings.index.save_all'), class: 'btn btn-primary btn-lg'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
RailsSettingsUi.parent_controller = 'Qbrick::Cms::BackendController'
|
2
|
+
RailsSettingsUi::ApplicationController.layout 'qbrick/cms/application'
|
3
|
+
|
4
|
+
RailsSettingsUi.setup do |config|
|
5
|
+
config.settings_class = 'Qbrick::Settings'
|
6
|
+
end
|
7
|
+
|
8
|
+
Rails.application.config.to_prepare do
|
9
|
+
RailsSettingsUi.inline_main_app_routes!
|
10
|
+
end
|
data/config/routes.rb
CHANGED
@@ -2,7 +2,9 @@ Qbrick::Engine.routes.draw do
|
|
2
2
|
devise_for :admins, class_name: 'Qbrick::Admin', module: :devise
|
3
3
|
|
4
4
|
namespace :cms do
|
5
|
-
resources :
|
5
|
+
resources :settings, only: %i(update_all index) do
|
6
|
+
put :update_all, on: :collection
|
7
|
+
end
|
6
8
|
resources :pages, except: :show do
|
7
9
|
post :sort, on: :collection
|
8
10
|
get :mirror
|
@@ -16,9 +18,7 @@ Qbrick::Engine.routes.draw do
|
|
16
18
|
resources :ckimages, only: %i(create index destroy)
|
17
19
|
|
18
20
|
resource :account, only: :edit do
|
19
|
-
collection
|
20
|
-
patch 'update_password'
|
21
|
-
end
|
21
|
+
patch :update_password, on: :collection
|
22
22
|
end
|
23
23
|
|
24
24
|
resources :admins
|
@@ -31,9 +31,7 @@ Qbrick::Engine.routes.draw do
|
|
31
31
|
resources :pages, only: :index
|
32
32
|
end
|
33
33
|
|
34
|
-
resources :pages,
|
35
|
-
only: %i(index),
|
36
|
-
defaults: { locale: I18n.locale }
|
34
|
+
resources :pages, only: %i(index), defaults: { locale: I18n.locale }
|
37
35
|
get '(*url)' => 'pages#show', as: :page
|
38
36
|
end
|
39
37
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class ChangeSettings < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
remove_index :qbrick_settings, :key
|
4
|
+
rename_column :qbrick_settings, :key, :var
|
5
|
+
remove_column :qbrick_settings, :settings_collection_id
|
6
|
+
|
7
|
+
change_table :qbrick_settings do |t|
|
8
|
+
t.change :var, :string, null: false
|
9
|
+
t.change :value, :text, null: false
|
10
|
+
|
11
|
+
t.integer :thing_id, null: true
|
12
|
+
t.string :thing_type, limit: 30, null: true
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
|
16
|
+
add_index :qbrick_settings, %i(thing_type thing_id var), unique: true
|
17
|
+
end
|
18
|
+
end
|
data/db/seeds.rb
CHANGED
@@ -18,26 +18,6 @@ brick_types.each do |bt|
|
|
18
18
|
brick_type.update! bt
|
19
19
|
end
|
20
20
|
|
21
|
-
# Add default settings
|
22
|
-
|
23
|
-
site_collection = Qbrick::SettingsCollection.find_or_create_by(collection_type: 'site')
|
24
|
-
page_collection = Qbrick::SettingsCollection.find_or_create_by(collection_type: 'page')
|
25
|
-
global_collection = Qbrick::SettingsCollection.find_or_create_by(collection_type: 'global')
|
26
|
-
|
27
|
-
settings = [
|
28
|
-
{ key: 'site_title', value: 'Default Site Title', settings_collection_id: site_collection.id },
|
29
|
-
{ key: 'site_description', value: 'Default Site Description', settings_collection_id: site_collection.id },
|
30
|
-
{ key: 'default_page_title', value: 'Default Page Title', settings_collection_id: page_collection.id },
|
31
|
-
{ key: 'default_page_description', value: 'Default Page Description', settings_collection_id: page_collection.id },
|
32
|
-
{ key: 'google_analytics_key', value: 'UA-xxxx-x', settings_collection_id: global_collection.id },
|
33
|
-
{ key: 'typekit_id', value: 'xxxxxxx', settings_collection_id: global_collection.id }
|
34
|
-
]
|
35
|
-
|
36
|
-
settings.each do |s|
|
37
|
-
setting = Qbrick::Setting.find_or_create_by(key: s[:key])
|
38
|
-
setting.update! s
|
39
|
-
end
|
40
|
-
|
41
21
|
unless Qbrick::Admin.any?
|
42
22
|
Qbrick::Admin.create(email: 'admin@admin.com', password: 'change-me-soon!')
|
43
23
|
end
|
data/lib/qbrick.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module Qbrick
|
2
|
+
require 'rails-settings-cached'
|
2
3
|
require 'devise'
|
3
4
|
require 'qbrick/engine'
|
4
5
|
require 'qbrick/orderable'
|
@@ -6,7 +7,6 @@ module Qbrick
|
|
6
7
|
require 'qbrick/translatable'
|
7
8
|
require 'qbrick/searchable'
|
8
9
|
require 'qbrick/gridded'
|
9
|
-
require 'qbrick/brick_list'
|
10
10
|
require 'qbrick/partial_extractor'
|
11
11
|
require 'qbrick/touch_placeholders'
|
12
12
|
require 'simple_form'
|
@@ -21,4 +21,5 @@ module Qbrick
|
|
21
21
|
require 'haml'
|
22
22
|
require 'ckeditor'
|
23
23
|
require 'inherited_resources'
|
24
|
+
require 'rails-settings-ui'
|
24
25
|
end
|
data/lib/qbrick/version.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Qbrick::Cms::SettingsController, type: :controller do
|
4
|
+
render_views
|
5
|
+
routes { Qbrick::Engine.routes }
|
6
|
+
|
7
|
+
before do
|
8
|
+
admin = double 'admin'
|
9
|
+
allow_message_expectations_on_nil
|
10
|
+
allow(request.env['warden']).to receive(:authenticate!) { admin }
|
11
|
+
allow(controller).to receive(:current_admin) { admin }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'GET index' do
|
15
|
+
it 'renders saved settings' do
|
16
|
+
Qbrick::Settings.highlighting_font = 'Comic Sans'
|
17
|
+
get :index
|
18
|
+
expect(response).to be_success
|
19
|
+
expect(response.body).to include(I18n.t 'settings.attributes.highlighting_font.name')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'renders default settings' do
|
23
|
+
Qbrick::Settings.defaults[:highlighting_font] = 'Comic Sans'
|
24
|
+
get :index
|
25
|
+
expect(response).to be_success
|
26
|
+
expect(response.body).to include(I18n.t 'settings.attributes.highlighting_font.name')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'POST update_all' do
|
31
|
+
it 'updates settings' do
|
32
|
+
Qbrick::Settings.defaults[:highlighting_font] = 'Comic Sans'
|
33
|
+
post :update_all, settings: { 'highlighting_font' => 'Comic Sans Neue' }
|
34
|
+
expect(response).to redirect_to("#{Qbrick::Engine.routes.url_helpers.cms_settings_path}?content_locale=#{I18n.locale}")
|
35
|
+
setting = Qbrick::Settings.find_by var: 'highlighting_font'
|
36
|
+
expect(setting.value).to eq 'Comic Sans Neue'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/spec/factories.rb
CHANGED
@@ -35,11 +35,6 @@ FactoryGirl.define do
|
|
35
35
|
a.file File.open("#{Qbrick::Engine.root}/spec/dummy/app/assets/images/spec-image.png")
|
36
36
|
end
|
37
37
|
|
38
|
-
factory :setting, class: Qbrick::Setting do |s|
|
39
|
-
s.key 'code'
|
40
|
-
s.value 'SomeValue'
|
41
|
-
end
|
42
|
-
|
43
38
|
factory :admin, class: Qbrick::Admin do
|
44
39
|
email 'test@test.com'
|
45
40
|
password 'somel33tPW'
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Qbrick
|
4
|
+
describe Settings, type: :model do
|
5
|
+
context 'setting exists' do
|
6
|
+
it 'returns the set value' do
|
7
|
+
Settings.code = 'SomeValue'
|
8
|
+
expect(Settings.code).to eq('SomeValue')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'keeps the value' do
|
12
|
+
[42, '23', [3, 4], nil].each do |value|
|
13
|
+
Settings.stuff = value
|
14
|
+
expect(Settings.stuff).to eq value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "setting doesn't exist" do
|
20
|
+
it 'returns nil for a call on a non-present setting' do
|
21
|
+
expect(Settings.does_not_exist).to be_nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'on an admin' do
|
26
|
+
it 'can be set on an instance' do
|
27
|
+
admin = create :admin
|
28
|
+
admin.settings.locale = 'cn'
|
29
|
+
admin.reload
|
30
|
+
expect(admin.settings.locale).to eq 'cn'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'on a brick' do
|
35
|
+
it 'can be set on an instance' do
|
36
|
+
brick = create :text_brick, brick_list: (Qbrick::Page.first || create(:page))
|
37
|
+
brick.settings.color = 'infrared'
|
38
|
+
brick.reload
|
39
|
+
expect(brick.settings.color).to eq 'infrared'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'on a page' do
|
44
|
+
it 'can be set on an instance' do
|
45
|
+
page = Qbrick::Page.first || create(:page)
|
46
|
+
page.settings.heisen = 'berg'
|
47
|
+
page.reload
|
48
|
+
|
49
|
+
expect(page.settings.heisen).to eq 'berg'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qbrick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: '2.7'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Immanuel Häussermann
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-08-
|
15
|
+
date: 2015-08-26 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rspec-rails
|
@@ -504,6 +504,34 @@ dependencies:
|
|
504
504
|
- - ">="
|
505
505
|
- !ruby/object:Gem::Version
|
506
506
|
version: '0'
|
507
|
+
- !ruby/object:Gem::Dependency
|
508
|
+
name: rails-settings-cached
|
509
|
+
requirement: !ruby/object:Gem::Requirement
|
510
|
+
requirements:
|
511
|
+
- - ">="
|
512
|
+
- !ruby/object:Gem::Version
|
513
|
+
version: '0'
|
514
|
+
type: :runtime
|
515
|
+
prerelease: false
|
516
|
+
version_requirements: !ruby/object:Gem::Requirement
|
517
|
+
requirements:
|
518
|
+
- - ">="
|
519
|
+
- !ruby/object:Gem::Version
|
520
|
+
version: '0'
|
521
|
+
- !ruby/object:Gem::Dependency
|
522
|
+
name: rails-settings-ui
|
523
|
+
requirement: !ruby/object:Gem::Requirement
|
524
|
+
requirements:
|
525
|
+
- - ">="
|
526
|
+
- !ruby/object:Gem::Version
|
527
|
+
version: 0.5.0
|
528
|
+
type: :runtime
|
529
|
+
prerelease: false
|
530
|
+
version_requirements: !ruby/object:Gem::Requirement
|
531
|
+
requirements:
|
532
|
+
- - ">="
|
533
|
+
- !ruby/object:Gem::Version
|
534
|
+
version: 0.5.0
|
507
535
|
description: Qbrick is a Rails engine that offers a simple CMS.
|
508
536
|
email: developers@screenconcept.ch
|
509
537
|
executables: []
|
@@ -536,7 +564,7 @@ files:
|
|
536
564
|
- app/controllers/qbrick/cms/bricks_controller.rb
|
537
565
|
- app/controllers/qbrick/cms/ckimages_controller.rb
|
538
566
|
- app/controllers/qbrick/cms/pages_controller.rb
|
539
|
-
- app/controllers/qbrick/cms/
|
567
|
+
- app/controllers/qbrick/cms/settings_controller.rb
|
540
568
|
- app/controllers/qbrick/pages_controller.rb
|
541
569
|
- app/controllers/qbrick/sitemaps_controller.rb
|
542
570
|
- app/helpers/cms_helper.rb
|
@@ -545,6 +573,7 @@ files:
|
|
545
573
|
- app/helpers/qbrick/cms/admin_helper.rb
|
546
574
|
- app/helpers/qbrick/cms/pages_helper.rb
|
547
575
|
- app/helpers/sitemaps_helper.rb
|
576
|
+
- app/models/concerns/brick_list.rb
|
548
577
|
- app/models/qbrick/accordion_brick.rb
|
549
578
|
- app/models/qbrick/accordion_item_brick.rb
|
550
579
|
- app/models/qbrick/admin.rb
|
@@ -566,8 +595,7 @@ files:
|
|
566
595
|
- app/models/qbrick/partition.rb
|
567
596
|
- app/models/qbrick/placeholder_brick.rb
|
568
597
|
- app/models/qbrick/publish_state.rb
|
569
|
-
- app/models/qbrick/
|
570
|
-
- app/models/qbrick/settings_collection.rb
|
598
|
+
- app/models/qbrick/settings.rb
|
571
599
|
- app/models/qbrick/slider_brick.rb
|
572
600
|
- app/models/qbrick/text_brick.rb
|
573
601
|
- app/models/qbrick/two_column_brick.rb
|
@@ -635,8 +663,7 @@ files:
|
|
635
663
|
- app/views/qbrick/cms/pages/new.html.haml
|
636
664
|
- app/views/qbrick/cms/pages/show.html.haml
|
637
665
|
- app/views/qbrick/cms/pages/sort.js.erb
|
638
|
-
- app/views/qbrick/cms/
|
639
|
-
- app/views/qbrick/cms/settings_collections/index.html.haml
|
666
|
+
- app/views/qbrick/cms/settings/index.html.haml
|
640
667
|
- app/views/qbrick/column_bricks/_column_brick.html.haml
|
641
668
|
- app/views/qbrick/column_bricks/column_brick/_edit.html.haml
|
642
669
|
- app/views/qbrick/image_bricks/_image_brick.html.haml
|
@@ -661,6 +688,7 @@ files:
|
|
661
688
|
- app/views/qbrick/video_bricks/_video_brick.html.haml
|
662
689
|
- app/views/qbrick/video_bricks/video_brick/_edit.html.haml
|
663
690
|
- config/initializers/devise.rb
|
691
|
+
- config/initializers/rails_settings_ui.rb
|
664
692
|
- config/initializers/simple_form.rb
|
665
693
|
- config/initializers/simple_form_bootstrap.rb
|
666
694
|
- config/locales/cms.de.yml
|
@@ -708,8 +736,8 @@ files:
|
|
708
736
|
- config/locales/views/qbrick/cms/navigation.yml
|
709
737
|
- config/locales/views/qbrick/cms/pages/de.yml
|
710
738
|
- config/locales/views/qbrick/cms/pages/en.yml
|
711
|
-
- config/locales/views/qbrick/cms/
|
712
|
-
- config/locales/views/qbrick/cms/
|
739
|
+
- config/locales/views/qbrick/cms/settings/de.yml
|
740
|
+
- config/locales/views/qbrick/cms/settings/en.yml
|
713
741
|
- config/locales/views/qbrick/image_brick/de.yml
|
714
742
|
- config/locales/views/qbrick/image_brick/en.yml
|
715
743
|
- config/locales/views/qbrick/search/de.yml
|
@@ -746,12 +774,12 @@ files:
|
|
746
774
|
- db/migrate/23_devise_create_qbrick_admins.rb
|
747
775
|
- db/migrate/24_localize_publish_column.rb
|
748
776
|
- db/migrate/25_rename_qbrick_pages_url_to_path.rb
|
777
|
+
- db/migrate/26_change_settings.rb
|
749
778
|
- db/seeds.rb
|
750
779
|
- lib/generators/qbrick/assets/install_generator.rb
|
751
780
|
- lib/generators/qbrick/custom_model_generator.rb
|
752
781
|
- lib/generators/qbrick/translations/add_generator.rb
|
753
782
|
- lib/qbrick.rb
|
754
|
-
- lib/qbrick/brick_list.rb
|
755
783
|
- lib/qbrick/engine.rb
|
756
784
|
- lib/qbrick/gridded.rb
|
757
785
|
- lib/qbrick/image_uploader_mounting.rb
|
@@ -777,6 +805,7 @@ files:
|
|
777
805
|
- spec/command_wrapper_helper.rb
|
778
806
|
- spec/controllers/qbrick/api/pages_controller_spec.rb
|
779
807
|
- spec/controllers/qbrick/cms/pages_controller_spec.rb
|
808
|
+
- spec/controllers/qbrick/cms/settings_controller_spec.rb
|
780
809
|
- spec/controllers/qbrick/pages_controller_spec.rb
|
781
810
|
- spec/controllers/qbrick/sitemaps_controller_spec.rb
|
782
811
|
- spec/dummy/Rakefile
|
@@ -850,7 +879,7 @@ files:
|
|
850
879
|
- spec/models/page_spec.rb
|
851
880
|
- spec/models/placeholder_brick_spec.rb
|
852
881
|
- spec/models/publish_state_spec.rb
|
853
|
-
- spec/models/
|
882
|
+
- spec/models/settings_spec.rb
|
854
883
|
- spec/models/slider_brick_spec.rb
|
855
884
|
- spec/models/text_brick_spec.rb
|
856
885
|
- spec/models/two_column_brick_spec.rb
|
@@ -894,6 +923,7 @@ test_files:
|
|
894
923
|
- spec/command_wrapper_helper.rb
|
895
924
|
- spec/controllers/qbrick/api/pages_controller_spec.rb
|
896
925
|
- spec/controllers/qbrick/cms/pages_controller_spec.rb
|
926
|
+
- spec/controllers/qbrick/cms/settings_controller_spec.rb
|
897
927
|
- spec/controllers/qbrick/pages_controller_spec.rb
|
898
928
|
- spec/controllers/qbrick/sitemaps_controller_spec.rb
|
899
929
|
- spec/dummy/Rakefile
|
@@ -967,7 +997,7 @@ test_files:
|
|
967
997
|
- spec/models/page_spec.rb
|
968
998
|
- spec/models/placeholder_brick_spec.rb
|
969
999
|
- spec/models/publish_state_spec.rb
|
970
|
-
- spec/models/
|
1000
|
+
- spec/models/settings_spec.rb
|
971
1001
|
- spec/models/slider_brick_spec.rb
|
972
1002
|
- spec/models/text_brick_spec.rb
|
973
1003
|
- spec/models/two_column_brick_spec.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Qbrick
|
2
|
-
module Cms
|
3
|
-
class SettingsCollectionsController < BackendController
|
4
|
-
def index
|
5
|
-
@settings_collections = [
|
6
|
-
Qbrick::SettingsCollection.find_by(collection_type: 'site'),
|
7
|
-
Qbrick::SettingsCollection.find_by(collection_type: 'page'),
|
8
|
-
Qbrick::SettingsCollection.find_by(collection_type: 'global')
|
9
|
-
]
|
10
|
-
end
|
11
|
-
|
12
|
-
def update
|
13
|
-
@settings_collection = Qbrick::SettingsCollection.find(params[:id])
|
14
|
-
@settings_collection.update_attributes(settings_collection_params)
|
15
|
-
|
16
|
-
respond_with @settings_collection, location: cms_settings_collections_path
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def settings_collection_params
|
22
|
-
params.require(:settings_collection).permit(settings_attributes: [:value, :id])
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
= simple_form_for settings, url: cms_settings_collection_path(settings), method: :patch, wrapper: :bootstrap, html: { class: 'form-horizontal' } do |f|
|
2
|
-
|
3
|
-
.form-inputs
|
4
|
-
= f.simple_fields_for :settings do |nf|
|
5
|
-
= nf.input :value, label: t(".#{nf.object.key}"), as: :string
|
6
|
-
|
7
|
-
.form-actions
|
8
|
-
= f.button :submit, t('.save')
|
data/spec/models/setting_spec.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Qbrick
|
4
|
-
describe Setting, type: :model do
|
5
|
-
before do
|
6
|
-
create(:setting)
|
7
|
-
create(:setting, key: 'stuff', value: nil)
|
8
|
-
end
|
9
|
-
|
10
|
-
describe '[](key)' do
|
11
|
-
context 'setting exists' do
|
12
|
-
it 'returns the set value' do
|
13
|
-
expect(Setting[:code]).to eq('SomeValue')
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'returns empty string for empty setting' do
|
17
|
-
expect(Setting[:stuff]).to eq('')
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context "setting doesn't exist" do
|
22
|
-
it 'returns empty string for a call on a non-present setting' do
|
23
|
-
expect(Setting[:does_not_exist]).to eq('')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|