symphonia 3.3.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -4
- data/CHANGELOG.md +33 -3
- data/README.md +16 -0
- data/app/controllers/symphonia/accounts_controller.rb +14 -12
- data/app/controllers/symphonia/admin_controller.rb +1 -4
- data/app/helpers/symphonia/application_helper.rb +17 -61
- data/app/mailers/symphonia/notifier.rb +2 -1
- data/app/models/symphonia/user.rb +0 -4
- data/app/views/layouts/symphonia/application.pdf.erb +0 -1
- data/app/views/symphonia/accounts/_form.html.erb +5 -0
- data/app/views/symphonia/accounts/lost_password.html.erb +1 -1
- data/app/views/symphonia/accounts/reset_password.html.erb +2 -2
- data/app/views/symphonia/admin/index.html.erb +1 -11
- data/app/views/symphonia/login/_form.html.erb +0 -2
- data/app/views/symphonia/notifier/reset_password_user.html.erb +1 -2
- data/app/views/symphonia/notifier/reset_password_user.text.erb +1 -1
- data/config/locales/cs.yml +2 -0
- data/db/migrate/20130714140501_create_roles.rb +6 -4
- data/db/migrate/20200428180001_add_uuid_to_users.rb +4 -2
- data/db/migrate/20210509141420_roles_change_permissions_to_json.rb +18 -0
- data/db/migrate/20210509180525_roles_change_permissions_to_native_json.rb +7 -0
- data/lib/generators/symphonia/setup/setup_generator.rb +17 -14
- data/lib/generators/symphonia/setup/templates/{settings.rb → app/config/initializers/settings.rb.tt} +0 -0
- data/lib/generators/symphonia/setup/templates/{404.html → public/404.html.tt} +2 -2
- data/lib/generators/symphonia/setup/templates/{500.html → public/500.html.tt} +2 -2
- data/lib/generators/symphonia/setup/templates/{spec_helper.rb → spec/spec_helper.rb.tt} +3 -2
- data/lib/symphonia.rb +4 -1
- data/lib/symphonia/controller_extensions.rb +2 -2
- data/lib/symphonia/engine.rb +0 -1
- data/lib/symphonia/model_attributes/attribute.rb +30 -14
- data/lib/symphonia/model_filters/base.rb +13 -15
- data/lib/symphonia/model_filters/boolean_filter.rb +10 -11
- data/lib/symphonia/model_filters/date_filter.rb +32 -31
- data/lib/symphonia/model_filters/integer_filter.rb +4 -5
- data/lib/symphonia/model_filters/select_filter.rb +19 -17
- data/lib/symphonia/model_filters/string_filter.rb +4 -5
- data/lib/symphonia/query.rb +10 -34
- data/lib/symphonia/query_columns.rb +1 -2
- data/lib/symphonia/query_columns/attribute_column.rb +59 -5
- data/lib/symphonia/spec_helper.rb +5 -3
- data/lib/symphonia/user_management.rb +14 -4
- data/lib/symphonia/version.rb +3 -1
- data/spec/controllers/account_controller_spec.rb +66 -69
- data/spec/controllers/admin_controller_spec.rb +24 -25
- data/spec/factories/factories.rb +2 -14
- data/spec/libs/some_lib_spec.rb +5 -0
- data/spec/mailers/previews/symphonia/notifier_preview.rb +1 -2
- data/spec/mailers/symphonia/notifier_spec.rb +1 -1
- data/spec/rails_helper.rb +4 -3
- data/spec/requests/accounts_spec.rb +2 -2
- data/spec/spec_helper.rb +3 -9
- metadata +76 -179
- data/app/models/symphonia/admin_module.rb +0 -18
- data/app/views/symphonia/filters/table.html.erb +0 -21
- data/db/migrate/20130828175114_create_attachments.rb +0 -20
- data/db/migrate/20141213204351_create_admin_modules.rb +0 -20
- data/lib/symphonia/query_columns/generic_column.rb +0 -165
- data/spec/support/common_file.txt +0 -2
- data/spec/support/symphonia.jpg +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68c44e1f10ceb644917147a7e5cd28caa1a6054a8bffed6e85fa7e76a90d9956
|
4
|
+
data.tar.gz: dfaa2c7d6d6e0c6960a59722998542af1e16ca644fdeefbe6ffcc5be5087ef96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f9b8fca0586ade8130cf789e367b5724a38f7cf44597f48b15819098034a53b3e2d42007d05a13fd73e70e91922e3cd681fffef284abc70a67b1fef868586ca
|
7
|
+
data.tar.gz: '08bc13b2b16c0001c9389238771b2dfc0c1c97400fecad96540f6fdadcd9ac343a2c918bcd8699b8c7bf11fe9c862b0826ae6be62628fbec54518b9b6480ff95'
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
AllCops:
|
2
2
|
TargetRubyVersion: 2.5
|
3
|
+
NewCops: enable
|
3
4
|
|
4
5
|
Layout/EmptyLinesAroundClassBody:
|
5
6
|
EnforcedStyle: empty_lines_special
|
@@ -12,15 +13,13 @@ Metrics/AbcSize:
|
|
12
13
|
Enabled: false
|
13
14
|
Metrics/BlockLength:
|
14
15
|
Enabled: false
|
15
|
-
#Metrics/LineLength:
|
16
|
-
# Enabled: false
|
17
16
|
Metrics/MethodLength:
|
18
17
|
Enabled: false
|
19
18
|
|
20
|
-
#Style/BracesAroundHashParameters:
|
21
|
-
# EnforcedStyle: context_dependent
|
22
19
|
Style/Documentation:
|
23
20
|
Enabled: false
|
21
|
+
Style/FrozenStringLiteralComment:
|
22
|
+
Enabled: false
|
24
23
|
Style/MutableConstant:
|
25
24
|
Enabled: false
|
26
25
|
Style/NegatedIf:
|
data/CHANGELOG.md
CHANGED
@@ -6,10 +6,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
### Removed
|
9
|
-
-
|
9
|
+
- development dependency in gemspec replaced by `symphonia_spec` gem
|
10
|
+
- GenericColumn in Query
|
11
|
+
- AdminModule class/table = its not used, its not working
|
12
|
+
### Changed
|
13
|
+
- Rails 6.1 support
|
14
|
+
- Query#to_params boolean argument to named
|
15
|
+
- update generators
|
16
|
+
- use native JSON columns instead of serializations
|
17
|
+
### Added
|
18
|
+
- Gemfile.lock
|
19
|
+
|
20
|
+
## [3.4.0] - 2021-03-22
|
21
|
+
### Changed
|
22
|
+
- upgrade authlogic to 6.4.1 (rails6.1 compatible)
|
23
|
+
|
24
|
+
## [3.3.4] - 2020-12-28
|
25
|
+
### Fixed
|
26
|
+
- default responses (render_40x) works for any format
|
27
|
+
## [3.3.3] - 2020-10-24
|
28
|
+
### Changed
|
29
|
+
- prefill login from email
|
30
|
+
- allow login edit for legacy accounts
|
31
|
+
## [3.3.2] - 2020-10-17
|
32
|
+
### Added
|
33
|
+
- `render_super` for templates
|
34
|
+
### Changed
|
35
|
+
- lost password check
|
36
|
+
## [3.3.1] - 2020-09-28
|
37
|
+
### Removed
|
38
|
+
- openapi (it seems to be unnecessarily)
|
10
39
|
- paperclip support
|
40
|
+
- the_sortable_tree
|
11
41
|
### Changed
|
12
|
-
- upgrade authlogic to 6.
|
42
|
+
- upgrade authlogic to 6.2.0
|
13
43
|
## [3.2.4] - 2020-05-10
|
14
44
|
### Added
|
15
45
|
- sidekiq-cron gem
|
@@ -80,7 +110,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
80
110
|
- do not require password for SSO users
|
81
111
|
- hide password field from form of SSO users
|
82
112
|
## [3.0.0] - 2019-07-06
|
83
|
-
###
|
113
|
+
### Added
|
84
114
|
- external_id on user
|
85
115
|
### Changed
|
86
116
|
- users/show only for logged users
|
data/README.md
CHANGED
@@ -14,3 +14,19 @@ after `bundle install` run post-installation: `rails g symphonia:setup`
|
|
14
14
|
> Setup prepare `config/initializers/settings.rb`, create `spec/spec_helper.rb`, add stylesheets and javascripts references and copy basic layout.
|
15
15
|
|
16
16
|
|
17
|
+
## Upgrade to v4.0
|
18
|
+
1. update Gemfile:
|
19
|
+
```ruby
|
20
|
+
gem 'rails', '~> 6.1'
|
21
|
+
gem 'symphonia', '~> 4.0'
|
22
|
+
source "https://gems.luk4s.cz" do
|
23
|
+
gem 'symphonia_spec', group: %i[development test]
|
24
|
+
end
|
25
|
+
```
|
26
|
+
And `bundle update`
|
27
|
+
2. upgrade rails:
|
28
|
+
https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
|
29
|
+
```bash
|
30
|
+
export THOR_MERGE=vimdiff
|
31
|
+
rails app:update
|
32
|
+
```
|
@@ -100,6 +100,8 @@ module Symphonia
|
|
100
100
|
|
101
101
|
end
|
102
102
|
|
103
|
+
# @!group Reset lost password
|
104
|
+
|
103
105
|
def reset_password
|
104
106
|
@user = find_account_by_token(params.require(:id))
|
105
107
|
return render_404 if @user.nil?
|
@@ -109,28 +111,28 @@ module Symphonia
|
|
109
111
|
end
|
110
112
|
|
111
113
|
if @user.changed? && @user.save
|
112
|
-
|
114
|
+
logger.info "#{@user.id} has changed password"
|
115
|
+
return redirect_to(login_path, notice: t(:text_password_reset_success))
|
113
116
|
end
|
114
117
|
end
|
115
118
|
|
116
119
|
def lost_password
|
117
120
|
@user = find_account_by_mail(params[:email]) if params[:email]
|
118
|
-
if @user
|
119
|
-
|
120
|
-
|
121
|
-
|
121
|
+
if @user&.active?
|
122
|
+
@user.reset_perishable_token!
|
123
|
+
activation_url = url_for(action: "reset_password", id: @user.perishable_token, only_path: false)
|
124
|
+
Notifier.reset_password_user(@user, activation_url).deliver_later
|
125
|
+
end
|
126
|
+
respond_to do |format|
|
127
|
+
format.html do
|
122
128
|
redirect_to login_path, notice: t(:text_reset_password_resend)
|
123
|
-
else
|
124
|
-
redirect_to login_path, flash: { error: t("authlogic.error_messages.not_active") }
|
125
|
-
end
|
126
|
-
else
|
127
|
-
respond_to do |format|
|
128
|
-
format.html
|
129
|
-
format.js
|
130
129
|
end
|
130
|
+
format.js
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
+
# @!endgroup
|
135
|
+
|
134
136
|
private
|
135
137
|
|
136
138
|
def prepare_user
|
@@ -3,9 +3,6 @@ module Symphonia
|
|
3
3
|
before_action :login_require
|
4
4
|
|
5
5
|
def index
|
6
|
-
@admin_modules = AdminModule.where(user_id: [nil, current_user.id]).order(:position).all
|
7
|
-
@modules_count = @admin_modules.count
|
8
|
-
|
9
6
|
respond_to do |format|
|
10
7
|
format.html
|
11
8
|
end
|
@@ -19,4 +16,4 @@ module Symphonia
|
|
19
16
|
|
20
17
|
end
|
21
18
|
|
22
|
-
end
|
19
|
+
end
|
@@ -242,6 +242,23 @@ module Symphonia
|
|
242
242
|
fa_icon(fa, (text && { text: content_tag(:span, text, class: 'd-none d-sm-inline') } || {}).merge(options))
|
243
243
|
end
|
244
244
|
|
245
|
+
# Render original template from engine
|
246
|
+
# Useful for override part of engine view
|
247
|
+
#
|
248
|
+
# @example render_super "login/new"
|
249
|
+
# @param [String] template_name
|
250
|
+
# @param [Class<Symphonia::Engine>] engine
|
251
|
+
# @param [String] format
|
252
|
+
def render_super(template_name, engine: Symphonia::Engine, format: "html")
|
253
|
+
resolver = lookup_context.view_paths.paths.find do |resolver|
|
254
|
+
resolver.path == engine.root.join("app", "views").to_s
|
255
|
+
end
|
256
|
+
template = resolver.find_all(template_name, engine.engine_name, false, { locale: ["."], formats: [format], variants: [], handlers: [:erb] }, nil, {}).first
|
257
|
+
return "" unless template
|
258
|
+
|
259
|
+
render template: template
|
260
|
+
end
|
261
|
+
|
245
262
|
def render_symphonia_dialog(*args, &block)
|
246
263
|
ActiveSupport::Deprecation.warn "Use `render_modal` instead"
|
247
264
|
options = args.extract_options!
|
@@ -356,67 +373,6 @@ module Symphonia
|
|
356
373
|
end
|
357
374
|
|
358
375
|
end
|
359
|
-
|
360
|
-
# Example of use
|
361
|
-
# <%=
|
362
|
-
# table_header_tag_for(User) do |t|
|
363
|
-
# t.th :login
|
364
|
-
# t.th :email
|
365
|
-
# end
|
366
|
-
# %>
|
367
|
-
# options:
|
368
|
-
# => column : DB full name of column
|
369
|
-
#
|
370
|
-
# def table_header_tag_for(model, &block)
|
371
|
-
# tags = TableHeaderTag.new(model, self)
|
372
|
-
# yield tags
|
373
|
-
# tags.to_html
|
374
|
-
# end
|
375
|
-
#
|
376
|
-
# class TableHeaderTag
|
377
|
-
#
|
378
|
-
# attr_reader :view, :model
|
379
|
-
#
|
380
|
-
# def initialize(model, view)
|
381
|
-
# @model = model
|
382
|
-
# @tags = Array.new
|
383
|
-
# @view = view
|
384
|
-
# end
|
385
|
-
#
|
386
|
-
# def th(*args)
|
387
|
-
# options = args.extract_options!
|
388
|
-
# attribute = args.first
|
389
|
-
# label = args[1]
|
390
|
-
# raise ArgumentError if attribute.nil?
|
391
|
-
#
|
392
|
-
# sort_options = options.delete(:sort_options) || {}
|
393
|
-
# html_options = options.delete(:html_options) || {}
|
394
|
-
#
|
395
|
-
# label ||= @model.send(:human_attribute_name, attribute, options[:i18n] || {})
|
396
|
-
# @tags << @view.content_tag(:th, html_options) do
|
397
|
-
# if options[:sort] === false
|
398
|
-
# label
|
399
|
-
# else
|
400
|
-
# sort_options[:column] ||= options.delete(:column)
|
401
|
-
# sort_options[:column] ||= "#{@model.send(:table_name)}.#{attribute}"
|
402
|
-
# # @view.sortable_column(label, sort_options) # TODO: Rails 5 error
|
403
|
-
# label
|
404
|
-
# end
|
405
|
-
# end
|
406
|
-
#
|
407
|
-
# end
|
408
|
-
#
|
409
|
-
# def to_html
|
410
|
-
# @tags.join("\n").html_safe
|
411
|
-
# end
|
412
|
-
#
|
413
|
-
# end
|
414
|
-
|
415
|
-
# def render_share_buttons(url, name, options = {})
|
416
|
-
# options[:icon_css] ||= ''
|
417
|
-
# render(partial: 'common/share_links', locals: options.merge({ url: url, name: name }))
|
418
|
-
# end
|
419
376
|
end
|
420
377
|
end
|
421
378
|
|
422
|
-
#ApplicationHelper.send :include, Symphonia::ApplicationHelperExtension
|
@@ -21,8 +21,9 @@ module Symphonia
|
|
21
21
|
mail({ to: @user.mail, subject: 'Váš účet je aktivován' })
|
22
22
|
end
|
23
23
|
|
24
|
-
def reset_password_user(user)
|
24
|
+
def reset_password_user(user, url)
|
25
25
|
@user = user
|
26
|
+
@url = url
|
26
27
|
mail({ to: @user.mail, subject: t(:subject_reset_password_mail) })
|
27
28
|
end
|
28
29
|
|
@@ -21,7 +21,6 @@ module Symphonia
|
|
21
21
|
acts_as_authentic do |config|
|
22
22
|
config.crypto_provider = ::Authlogic::CryptoProviders::SCrypt
|
23
23
|
end
|
24
|
-
validates :email, uniqueness: { case_sensitive: false }
|
25
24
|
validates :password,
|
26
25
|
confirmation: { if: :require_password? },
|
27
26
|
length: {
|
@@ -51,9 +50,6 @@ module Symphonia
|
|
51
50
|
before_save do |model|
|
52
51
|
Rails.cache.delete_matched('user_allowed_to*') if model.role_id_changed?
|
53
52
|
end
|
54
|
-
before_validation do |model|
|
55
|
-
model.login ||= model.email
|
56
|
-
end
|
57
53
|
|
58
54
|
def allowed_to?(action)
|
59
55
|
return true if admin?
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= form_tag
|
1
|
+
<%= form_tag url_for({action: 'lost_password'}) do %>
|
2
2
|
<div class="form-group required">
|
3
3
|
<%= label_tag(:email, t(:'attributes.mail'), required: true, class: 'sr-only') %>
|
4
4
|
<%= email_field_tag(:email, nil, autofocus: true, placeholder: t(:'attributes.mail'), required: true, size: 35, class: 'form-control') %>
|
@@ -3,11 +3,11 @@
|
|
3
3
|
<div class="card w-75 mx-auto">
|
4
4
|
<div class="card-body">
|
5
5
|
<h4 class="card-title"><%= t(:label_reset_password) %></h4>
|
6
|
-
<%= symphonia_form_tag(url:
|
6
|
+
<%= symphonia_form_tag(url: url_for(action: "reset_password", id: params[:id]), method: 'put') do |f| %>
|
7
7
|
<%= f.error_messages %>
|
8
8
|
<%= f.password_field(:password, label: t(:'attributes.password'), required: true, wrapper_class: 'required') -%>
|
9
9
|
|
10
|
-
<%= f.submit(t(:
|
10
|
+
<%= f.submit(t(:button_save), class: 'btn btn-primary btn-block') -%>
|
11
11
|
<% end %>
|
12
12
|
</div>
|
13
13
|
</div>
|
@@ -1,15 +1,5 @@
|
|
1
1
|
<%= title 'Administrace' %>
|
2
|
-
<% @admin_modules.each_with_index do |admin_module, _index| %>
|
3
|
-
<div class="col-lg-<%= @modules_count == 1 ? '12' : '6' %>" id="<%= dom_id(admin_module) %>">
|
4
|
-
<h3><%= t(admin_module.title, scope: [:admin_module, :titles], default: admin_module.title) %></h3>
|
5
|
-
<% if admin_module.body_path.is_a?(Symbol) %>
|
6
|
-
<%= render(partial: "admin_modules/#{admin_module.body_path}", locals: { admin_module: admin_module }) -%>
|
7
|
-
<% else %>
|
8
|
-
<%= format_text(admin_module.body_path) -%>
|
9
|
-
<% end -%>
|
10
|
-
</div>
|
11
|
-
<% end -%>
|
12
2
|
|
13
3
|
<%= content_for :meta_tags do %>
|
14
4
|
<meta name="turbolinks-root" content="/admin">
|
15
|
-
<% end %>
|
5
|
+
<% end %>
|
@@ -8,7 +8,6 @@
|
|
8
8
|
<%= f.check_box :remember_me %>
|
9
9
|
<% end %>
|
10
10
|
|
11
|
-
<%= f.form_group class: 'text-center' do %>
|
12
11
|
<%= f.submit t(:button_login), class: 'btn btn-primary btn-block' %>
|
13
12
|
<% if f.object.is_a?(Symphonia::UserSession) %>
|
14
13
|
<%= link_to(t(:label_reset_password), lost_password_account_path, remote: true, class: 'btn btn-link btn-sm ') %>
|
@@ -16,4 +15,3 @@
|
|
16
15
|
<%= link_to(t(:button_register), register_path, class: 'btn btn-link btn-sm ') %>
|
17
16
|
<% end %>
|
18
17
|
<% end %>
|
19
|
-
<% end %>
|
data/config/locales/cs.yml
CHANGED
@@ -153,6 +153,8 @@ cs:
|
|
153
153
|
text_error_query_not_init: Filtry nejsou nastaveny. Registruj query!
|
154
154
|
text_error_there_is_no_filters_available: Nejsou zaregistrované žádné validní filtry.
|
155
155
|
text_error_login_required: Přihlašte se prosím
|
156
|
+
text_password_reset_success: "Nové heslo uloženo. Přihlašte se prosím"
|
157
|
+
|
156
158
|
|
157
159
|
title_toggle_multiselect: Přepnout multiselect
|
158
160
|
title_login: Přihlášení
|
@@ -1,10 +1,11 @@
|
|
1
|
-
class CreateRoles < ActiveRecord::Migration[
|
1
|
+
class CreateRoles < ActiveRecord::Migration[6.1]
|
2
|
+
|
2
3
|
def up
|
3
4
|
create_table :roles do |t|
|
4
|
-
t.string
|
5
|
-
t.text
|
5
|
+
t.string :name, null: false
|
6
|
+
t.text :description, null: true
|
6
7
|
|
7
|
-
t.text
|
8
|
+
t.text :permissions
|
8
9
|
|
9
10
|
t.timestamps
|
10
11
|
end
|
@@ -13,4 +14,5 @@ class CreateRoles < ActiveRecord::Migration[5.1]
|
|
13
14
|
def down
|
14
15
|
drop_table :roles
|
15
16
|
end
|
17
|
+
|
16
18
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class AddUuidToUsers < ActiveRecord::Migration[6.0]
|
2
|
+
|
2
3
|
def change
|
3
|
-
uuid_type = connection.adapter_name =~ /PostgreSQL/i ? :uuid : :string
|
4
|
-
add_column :users, :uuid,
|
4
|
+
# uuid_type = connection.adapter_name =~ /PostgreSQL/i ? :uuid : :string
|
5
|
+
add_column :users, :uuid, :uuid
|
5
6
|
end
|
7
|
+
|
6
8
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class RolesChangePermissionsToJson < ActiveRecord::Migration[6.1]
|
2
|
+
|
3
|
+
def up
|
4
|
+
say_with_time "Convert 'roles.permissions' YAML to JSON" do
|
5
|
+
i = 0
|
6
|
+
Symphonia::Role.where.not(permissions: nil).each do |role|
|
7
|
+
yaml = product.read_attribute_before_type_cast :permissions
|
8
|
+
next unless yaml.start_with? "---"
|
9
|
+
|
10
|
+
role.update_columns permissions: YAML.safe_load(yaml)
|
11
|
+
i += 1
|
12
|
+
end
|
13
|
+
|
14
|
+
i
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|