symphonia 2.1.8 → 2.2.1
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 +4 -4
- data/app/assets/javascripts/symphonia/application.js.erb +15 -4
- data/app/helpers/symphonia/application_helper.rb +4 -4
- data/app/helpers/symphonia/renderer_helper.rb +2 -1
- data/app/models/symphonia/user.rb +4 -0
- data/app/views/symphonia/base/index.html.erb +5 -0
- data/lib/symphonia/base_controller.rb +11 -1
- data/lib/symphonia/controller_extensions.rb +8 -6
- data/lib/symphonia/model_filters/select_filter.rb +6 -2
- data/lib/symphonia/model_filters/string_filter.rb +1 -1
- data/lib/symphonia/user_management.rb +1 -1
- data/lib/symphonia/version.rb +1 -1
- data/spec/models/query/filters_spec.rb +29 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/shared_controllers.rb +2 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dbb027e9c0aabbd327fd90ec05a572978a20404790f27decfcecc1db39ca347
|
4
|
+
data.tar.gz: 11320d1a38c2ebc7b95cee4020ac1192849c1473fbca1bf58508ce6c882c4e91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74731d7d000a1591b7046715a9118fd566a990c30900ddac2e6638a9799b8350f256a11a074e9e6b6eb2b3ed43911fb5785348bd0407644d2581450b4ab278be
|
7
|
+
data.tar.gz: 5a38f655057548ff77d21b738aee676adfa25ac6117647e45ad00d80d41a1dee52f5c59af5ef2d86f8096d431f7ff9552486bbd1f99ab0ec05372460569399db
|
@@ -22,9 +22,20 @@ $(document).on("ready turbolinks:load", function () {
|
|
22
22
|
$("header ul.nav li").removeClass('active');
|
23
23
|
menuItem.className += ' active';
|
24
24
|
}
|
25
|
-
if (typeof($.colorbox) === "function") {
|
25
|
+
if (typeof ($.colorbox) === "function") {
|
26
26
|
$.colorbox.remove();
|
27
|
-
$('a.symphonia-lightbox[data-lightbox="true"]').colorbox({
|
27
|
+
$('a.symphonia-lightbox[data-lightbox="true"]').colorbox({
|
28
|
+
rel: 'gallery',
|
29
|
+
maxHeight: '80%',
|
30
|
+
photo: true,
|
31
|
+
current: function (settings) {
|
32
|
+
if (settings.el.title.length > 0) {
|
33
|
+
} else {
|
34
|
+
return settings.el.dataset.current || "image {current} of {total}";
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
});
|
28
39
|
}
|
29
40
|
var images = document.getElementById("editable_images");
|
30
41
|
if (images) {
|
@@ -108,7 +119,7 @@ Symphonia.filters = {
|
|
108
119
|
window.location.search = '';
|
109
120
|
}
|
110
121
|
},
|
111
|
-
removeRow: function(id) {
|
122
|
+
removeRow: function (id) {
|
112
123
|
var el = document.getElementById(id);
|
113
124
|
el.remove();
|
114
125
|
}
|
@@ -134,7 +145,7 @@ SymphoniaCheckboxes = {
|
|
134
145
|
toggler.dataset.checked = !isChecked;
|
135
146
|
},
|
136
147
|
toggle: function (input, isChecked) {
|
137
|
-
if (typeof(isChecked) === "undefined")
|
148
|
+
if (typeof (isChecked) === "undefined")
|
138
149
|
isChecked = input.checked;
|
139
150
|
|
140
151
|
input.checked = !isChecked;
|
@@ -23,7 +23,7 @@ module Symphonia
|
|
23
23
|
def render_flash_messages(flash_messages = nil)
|
24
24
|
s = ''
|
25
25
|
Array(flash_messages || flash).each do |type, message|
|
26
|
-
s << content_tag(:div, class: "alert #{bootstrap_class_for(type)}") do
|
26
|
+
s << content_tag(:div, class: "d-print-none alert #{bootstrap_class_for(type)}") do
|
27
27
|
content_tag(:button, '', class: 'fa fa-times-circle-o close', data: { dismiss: 'alert' }) + Array.wrap(message).collect { |m| fa_icon(type, text: m) }.join("<br>").html_safe
|
28
28
|
end
|
29
29
|
end
|
@@ -195,10 +195,10 @@ module Symphonia
|
|
195
195
|
|
196
196
|
anchor = options.has_key?(:anchor) ? options.delete(:anchor) : 'page_header'
|
197
197
|
label = options.delete(:label) || t("label_#{controller_name.singularize}_new")
|
198
|
-
|
199
|
-
|
198
|
+
model = controller.try(:model) || controller_name.singularize
|
199
|
+
url = options.delete(:url) || new_polymorphic_path(model, anchor: anchor)
|
200
200
|
|
201
|
-
|
201
|
+
link_to(fa_icon('add', text: label), url, { class: 'btn btn-primary' }.merge(options))
|
202
202
|
end
|
203
203
|
|
204
204
|
# change the default link renderer for will_paginate
|
@@ -45,7 +45,8 @@ module Symphonia
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def edit_link(entity)
|
48
|
-
@_c.
|
48
|
+
model = @_c.controller.try(:model) || @_c.controller_name
|
49
|
+
@_c.link_to(@_c.icon('edit', t(:button_edit)), @_c.edit_polymorphic_path(entity, back_url: @_c.polymorphic_path(model, page: @_c.params[:page])))
|
49
50
|
end
|
50
51
|
|
51
52
|
def delete_link(entity)
|
@@ -34,7 +34,7 @@ module Symphonia
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def new
|
37
|
-
@entity ||= instance_variable_set(:"@#{model_name}", model.new)
|
37
|
+
@entity ||= instance_variable_set(:"@#{model_name}", model.new(params.fetch(model_name, {}).permit(safe_attributes)))
|
38
38
|
end
|
39
39
|
|
40
40
|
def edit
|
@@ -44,6 +44,7 @@ module Symphonia
|
|
44
44
|
@entity ||= instance_variable_set(:"@#{model_name}", model.new(entity_params))
|
45
45
|
respond_to do |format|
|
46
46
|
if @entity.save
|
47
|
+
after_create
|
47
48
|
format.html { redirect_back_or_default @entity, notice: t(:text_created) }
|
48
49
|
format.json { render json: @entity, status: :created, location: @entity }
|
49
50
|
else
|
@@ -56,6 +57,7 @@ module Symphonia
|
|
56
57
|
def update
|
57
58
|
respond_to do |format|
|
58
59
|
if @entity.update(entity_params)
|
60
|
+
after_update
|
59
61
|
format.html { redirect_back_or_default @entity, notice: t(:text_updated) }
|
60
62
|
format.json { head :no_content }
|
61
63
|
else
|
@@ -92,5 +94,13 @@ module Symphonia
|
|
92
94
|
model.name.demodulize.underscore.to_sym
|
93
95
|
end
|
94
96
|
|
97
|
+
def after_create
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
def after_update
|
102
|
+
|
103
|
+
end
|
104
|
+
|
95
105
|
end
|
96
106
|
end
|
@@ -5,7 +5,8 @@ module Symphonia
|
|
5
5
|
|
6
6
|
|
7
7
|
included do
|
8
|
-
class Unauthorized < Exception;
|
8
|
+
class Unauthorized < Exception;
|
9
|
+
end
|
9
10
|
|
10
11
|
before_action :current_user, :menu_item
|
11
12
|
before_action :set_default_locale
|
@@ -73,8 +74,9 @@ module Symphonia
|
|
73
74
|
# private
|
74
75
|
|
75
76
|
def set_locale
|
76
|
-
client_lang = params.fetch(:locale, nil).presence || session[:locale].presence || request.env['HTTP_ACCEPT_LANGUAGE'].to_s.split(',').collect { |l| l.scan(/^[a-z]{2}/) }.flatten
|
77
|
-
|
77
|
+
client_lang = Array(params.fetch(:locale, nil).presence || session[:locale].presence || request.env['HTTP_ACCEPT_LANGUAGE'].to_s.split(',').collect { |l| l.scan(/^[a-z]{2}/) }.flatten)
|
78
|
+
client_lang.unshift current_user.language if current_user.language
|
79
|
+
@client_lang = client_lang.detect { |l| I18n.available_locales.include?(l.to_sym) }
|
78
80
|
|
79
81
|
I18n.locale = (@client_lang || I18n.default_locale)
|
80
82
|
session[:locale] = I18n.locale
|
@@ -97,9 +99,8 @@ module Symphonia
|
|
97
99
|
store_location
|
98
100
|
redirect_to symphonia.login_path, flash: { error: t(:text_login_require) }
|
99
101
|
end
|
100
|
-
format.json
|
101
|
-
|
102
|
-
end
|
102
|
+
format.json { render json: { errors: 'You must be logged in to access this endpoint' }, status: 401 }
|
103
|
+
format.any { head 401 }
|
103
104
|
end
|
104
105
|
return false
|
105
106
|
end
|
@@ -111,6 +112,7 @@ module Symphonia
|
|
111
112
|
|
112
113
|
def admin_require
|
113
114
|
return unless login_require
|
115
|
+
|
114
116
|
unless current_user.admin?
|
115
117
|
render_403
|
116
118
|
return false
|
@@ -18,7 +18,11 @@ module Symphonia
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def value=(q)
|
21
|
-
@value = Array
|
21
|
+
@value = if q.is_a?(Array)
|
22
|
+
q
|
23
|
+
else
|
24
|
+
q.to_s.split("|")
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
28
|
def operator=(o)
|
@@ -28,7 +32,7 @@ module Symphonia
|
|
28
32
|
end
|
29
33
|
|
30
34
|
def apply(scope)
|
31
|
-
|
35
|
+
Rails.logger.debug("Apply filter #{name} '#{operator}' #{value}")
|
32
36
|
t = scope.arel_table
|
33
37
|
scope.where(t[name].send(operator, value))
|
34
38
|
end
|
@@ -15,7 +15,7 @@ module Symphonia
|
|
15
15
|
validates :login, :mail, :first_name, :last_name, presence: true
|
16
16
|
|
17
17
|
def self.current=(entity)
|
18
|
-
Rails.logger.info("* #{entity.class.name}: #{entity.login} id: #{entity.id}")
|
18
|
+
Rails.logger.info("* #{entity.class.name}: #{entity.login} id: #{entity.id}") if entity
|
19
19
|
Thread.current[:"current_#{name.underscore}"] = entity
|
20
20
|
end
|
21
21
|
|
data/lib/symphonia/version.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
RSpec.describe Symphonia::ModelFilters::Base do
|
2
|
+
let(:query) { Symphonia::User.query.new }
|
3
|
+
let!(:user) { FactoryBot.create :user, email: "sample@dummy.cz", status: "active" }
|
4
|
+
|
5
|
+
describe "string" do
|
6
|
+
subject { Symphonia::ModelFilters::StringFilter.new attribute, query }
|
7
|
+
|
8
|
+
let(:attribute) { Symphonia::User.registered_attributes[:email] }
|
9
|
+
it "simple filter" do
|
10
|
+
subject.value = "~sample@dummy.cz"
|
11
|
+
expect(subject.apply(Symphonia::User.all).count).to eq 1
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "status" do
|
17
|
+
let(:attribute) { Symphonia::User.registered_attributes[:status] }
|
18
|
+
subject { Symphonia::ModelFilters::SelectFilter.new attribute, query }
|
19
|
+
|
20
|
+
it "simple filter" do
|
21
|
+
subject.value = "1"
|
22
|
+
expect(subject.apply(Symphonia::User.all).count).to eq 1
|
23
|
+
end
|
24
|
+
it "array filter" do
|
25
|
+
subject.value = "1|2|3"
|
26
|
+
expect(subject.apply(Symphonia::User.all).count).to eq 1
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -10,7 +10,7 @@ RSpec.shared_examples 'a controller actions' do |factory|
|
|
10
10
|
|
11
11
|
it '#destroy' do
|
12
12
|
entity # touch
|
13
|
-
expect { delete :destroy, params: { id: entity } }.to change(
|
13
|
+
expect { delete :destroy, params: { id: entity } }.to change(entity.class, :count).by(-1)
|
14
14
|
end
|
15
15
|
|
16
16
|
context 'json' do
|
@@ -24,7 +24,7 @@ RSpec.shared_examples 'a controller actions' do |factory|
|
|
24
24
|
it '#show' do
|
25
25
|
get :show, params: {id: entity, format: 'json'}
|
26
26
|
expect(response).to have_http_status(:success)
|
27
|
-
expect(response.body).to include
|
27
|
+
expect(response.body).to include "id", entity.id.to_s
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: symphonia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Pokorny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -524,6 +524,7 @@ files:
|
|
524
524
|
- app/views/symphonia/accounts/update.js.erb
|
525
525
|
- app/views/symphonia/admin/index.html.erb
|
526
526
|
- app/views/symphonia/attachments/destroy.js.erb
|
527
|
+
- app/views/symphonia/base/index.html.erb
|
527
528
|
- app/views/symphonia/common/_editable_images_grid.html.erb
|
528
529
|
- app/views/symphonia/common/_filters.html.erb
|
529
530
|
- app/views/symphonia/common/_locale_chooser.html.erb
|
@@ -619,6 +620,7 @@ files:
|
|
619
620
|
- spec/mailers/symphonia/notifier_spec.rb
|
620
621
|
- spec/models/attachment_spec.rb
|
621
622
|
- spec/models/query/attribute_spec.rb
|
623
|
+
- spec/models/query/filters_spec.rb
|
622
624
|
- spec/models/query/symphonia_query_spec.rb
|
623
625
|
- spec/models/role_spec.rb
|
624
626
|
- spec/models/user_spec.rb
|
@@ -657,8 +659,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
657
659
|
- !ruby/object:Gem::Version
|
658
660
|
version: '0'
|
659
661
|
requirements: []
|
660
|
-
|
661
|
-
rubygems_version: 2.7.6
|
662
|
+
rubygems_version: 3.0.4
|
662
663
|
signing_key:
|
663
664
|
specification_version: 4
|
664
665
|
summary: My administration
|
@@ -670,6 +671,7 @@ test_files:
|
|
670
671
|
- spec/models/attachment_spec.rb
|
671
672
|
- spec/models/query/attribute_spec.rb
|
672
673
|
- spec/models/query/symphonia_query_spec.rb
|
674
|
+
- spec/models/query/filters_spec.rb
|
673
675
|
- spec/models/user_spec.rb
|
674
676
|
- spec/models/role_spec.rb
|
675
677
|
- spec/requests/roles_spec.rb
|