symphonia 3.2.1 → 3.3.2

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +95 -0
  3. data/app/controllers/symphonia/accounts_controller.rb +14 -13
  4. data/app/controllers/symphonia/roles_controller.rb +3 -64
  5. data/app/controllers/symphonia/users_controller.rb +1 -6
  6. data/app/helpers/symphonia/application_helper.rb +18 -62
  7. data/app/mailers/symphonia/notifier.rb +2 -1
  8. data/app/models/symphonia/user.rb +1 -26
  9. data/app/views/layouts/symphonia/application.pdf.erb +0 -1
  10. data/app/views/symphonia/accounts/_form.html.erb +19 -8
  11. data/app/views/symphonia/accounts/edit.html.erb +2 -2
  12. data/app/views/symphonia/accounts/lost_password.html.erb +1 -1
  13. data/app/views/symphonia/accounts/reset_password.html.erb +2 -2
  14. data/app/views/symphonia/login/_form.html.erb +0 -2
  15. data/app/views/symphonia/notifier/reset_password_user.html.erb +1 -2
  16. data/app/views/symphonia/notifier/reset_password_user.text.erb +1 -1
  17. data/app/views/symphonia/users/_form.html.erb +7 -7
  18. data/app/views/symphonia/users/edit.html.erb +17 -15
  19. data/app/views/symphonia/users/new.html.erb +2 -2
  20. data/config/locales/cs.yml +2 -0
  21. data/config/routes.rb +1 -0
  22. data/lib/symphonia.rb +0 -1
  23. data/lib/symphonia/action_cable/connection.rb +1 -1
  24. data/lib/symphonia/admin_constraint.rb +2 -1
  25. data/lib/symphonia/base_controller.rb +0 -1
  26. data/lib/symphonia/engine.rb +5 -5
  27. data/lib/symphonia/user_management.rb +9 -1
  28. data/lib/symphonia/version.rb +1 -1
  29. data/spec/controllers/account_controller_spec.rb +1 -1
  30. data/spec/factories/factories.rb +2 -15
  31. data/spec/mailers/previews/symphonia/notifier_preview.rb +1 -2
  32. data/spec/mailers/symphonia/notifier_spec.rb +1 -1
  33. data/spec/requests/accounts_spec.rb +2 -2
  34. data/spec/spec_helper.rb +1 -2
  35. metadata +39 -89
  36. data/app/controllers/concerns/symphonia/swagger/base_controller.rb +0 -134
  37. data/app/controllers/symphonia/api_controller.rb +0 -78
  38. data/app/controllers/symphonia/attachments_controller.rb +0 -37
  39. data/app/controllers/symphonia/images_controller.rb +0 -16
  40. data/app/models/symphonia/attachment.rb +0 -16
  41. data/app/models/symphonia/common_file.rb +0 -9
  42. data/app/models/symphonia/image.rb +0 -46
  43. data/app/models/symphonia/swagger/error_model.rb +0 -24
  44. data/app/models/symphonia/swagger/parameters.rb +0 -21
  45. data/app/models/symphonia/swagger/responses.rb +0 -27
  46. data/lib/symphonia/attachable.rb +0 -35
  47. data/spec/controllers/api_controller_spec.rb +0 -9
  48. data/spec/controllers/images_controller_spec.rb +0 -5
  49. data/spec/models/attachment_spec.rb +0 -22
  50. data/spec/requests/attachments_controller_spec.rb +0 -23
  51. data/spec/support/common_file.txt +0 -2
  52. data/spec/support/symphonia.jpg +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b48c59788b2e00b86be3e0db6b90f15833b9b26668673aa56c41a676ebca438
4
- data.tar.gz: 3fa0287a83b8463b1e2a630ce39dd0ad49d7810ed7aefafbaffce517219bea3c
3
+ metadata.gz: 81d7e486f9226d136f252f53841733cf7fd1f76a84a27b80ff0472cfc574ae30
4
+ data.tar.gz: 39fa3ee78ed46669f2dcd583179818e7288fd392c54556b943d7ca2a9b1b312b
5
5
  SHA512:
6
- metadata.gz: c588275faf8d81e32e22b71fc9cf0cbbdb66ee3b6f328aa83540d0129b513368f51294813535eda0432ae6c8681497cbd83484f2d9947b48985b5408dece2b99
7
- data.tar.gz: f5a33405a69db155dda2ef9fa8527f066d5bf995b3618baad9d465936943fc379320a28c1a468077a882ced2f4e9a875bbc32a855eb0f1bf9fe78da754e4575a
6
+ metadata.gz: 16fa7bf6a6fbfbb875f0d6bf84c554ecd48ba9d2aacf2c259b361c3e5cb90ac57d448bd1da3c95ab3a1918f18b1a22a05ed3db1517bb36dcc34a4d10e30b7577
7
+ data.tar.gz: 4fd6defbf9b4128295eb1c5d90c9ec9476c08e4d80adb58fdcd275cc5998190adad1db771d496cbb97f6ed128d6fafa46109b9b96b320ec892544ebb6c5a3743
@@ -0,0 +1,95 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+ ## [3.3.2] - 2020-10-17
9
+ ### Added
10
+ - `render_super` for templates
11
+ ### Changed
12
+ - lost password check
13
+ ## [3.3.1] - 2020-09-28
14
+ ### Removed
15
+ - openapi (it seems to be unnecessarily)
16
+ - paperclip support
17
+ - the_sortable_tree
18
+ ### Changed
19
+ - upgrade authlogic to 6.2.0
20
+ ## [3.2.4] - 2020-05-10
21
+ ### Added
22
+ - sidekiq-cron gem
23
+ ## [3.2.3] - 2020-05-07
24
+ ### Fixed
25
+ - find user by token from session
26
+ ## [3.2.2] - 2020-05-05
27
+ ### Changed
28
+ - user/account form layout
29
+ - Sidekiq v6
30
+ ### Fixed
31
+ - UsersController#update Role should be sorted
32
+ ## [3.2.1] - 2020-05-01
33
+ ### Added
34
+ - avatar_url to users
35
+ - uuid to users
36
+ - openapi support
37
+ ### Changed
38
+ - improve setup generator
39
+ - anonymous user have no "enforced" language
40
+ ### Fixed
41
+ - update .rubocop
42
+ - bootstrap_form update to 4.4.0
43
+ - show time in localtime
44
+ ### Removed
45
+ - ckeditor-jquery
46
+ ## [3.1.5] - 2020-01-20
47
+ ### Changed
48
+ - improve split name (Symphonia::UserManagement#name=)
49
+ ## [3.1.4] - 2020-01-17
50
+ ### Changed
51
+ - improve role form
52
+ ## [3.1.3] - 2019-12-21
53
+ ### Added
54
+ - bootstrap_modal_helper extended by `link_to_modal` feature
55
+ ### Changed
56
+ - helper Symphonia::BootstrapModalHelper in BaseController
57
+ - new argument options in `icon` method (pass into `fa_icon`)
58
+ ## [3.1.2] - 2019-12-07
59
+ ### Added
60
+ - skip permission check in link_to_new_entity method
61
+ ### Fixed
62
+ - login form additional buttons
63
+ - lost_password form & mail
64
+ - reset_password form & mail
65
+ ## [3.1.1] - 2019-12-07
66
+ ### Changed
67
+ - accounts registration validation
68
+ - update static 500.html
69
+ ## [3.1.0] - 2019-12-07
70
+ ### Added
71
+ - BaseController for simplier create CRUD inheritance
72
+ - base views (new, form, edit, show and index)
73
+ - general EntityDecorator
74
+ - input field in model Attribute
75
+ - TextAttribute format
76
+ ### Changed
77
+ - registration form refactored
78
+ - update dummy to Rails 6
79
+ ### Removed
80
+ - wicked_pdf dependency
81
+ ## [3.0.3] - 2019-10-06
82
+ ### Changed
83
+ - rubocop.yml
84
+ - use real user in tests instead a dummy object
85
+ ## [3.0.1] - 2019-07-08
86
+ ### Changed
87
+ - do not require password for SSO users
88
+ - hide password field from form of SSO users
89
+ ## [3.0.0] - 2019-07-06
90
+ ### Added
91
+ - external_id on user
92
+ ### Changed
93
+ - users/show only for logged users
94
+ - upgrade to authlogic 5
95
+ - minor improvements
@@ -100,38 +100,39 @@ 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?
106
108
 
107
109
  if params[:password] # && params[:password_confirmation]
108
110
  @user.password = params[:password]
109
- # @user.password_confirmation = params[:password_confirmation]
110
111
  end
111
112
 
112
113
  if @user.changed? && @user.save
113
- return redirect_to(user_current_path, notice: t(:text_updated))
114
+ logger.info "#{@user.id} has changed password"
115
+ return redirect_to(login_path, notice: t(:text_password_reset_success))
114
116
  end
115
117
  end
116
118
 
117
119
  def lost_password
118
120
  @user = find_account_by_mail(params[:email]) if params[:email]
119
- if @user
120
- if @user.active?
121
- @user.reset_perishable_token!
122
- Notifier.reset_password_user(@user).deliver_later
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
123
128
  redirect_to login_path, notice: t(:text_reset_password_resend)
124
- else
125
- redirect_to login_path, flash: { error: t("authlogic.error_messages.not_active") }
126
- end
127
- else
128
- respond_to do |format|
129
- format.html
130
- format.js
131
129
  end
130
+ format.js
132
131
  end
133
132
  end
134
133
 
134
+ # @!endgroup
135
+
135
136
  private
136
137
 
137
138
  def prepare_user
@@ -14,87 +14,26 @@ module Symphonia
14
14
  #
15
15
  # before_action :authorize
16
16
  before_action :load_permissions, only: [:new, :edit, :update, :create]
17
- #
18
- # #layout 'admin'
19
- #
20
- # def index
21
- # @query = Symphonia::Role.query.new(self)
22
- # @entities = @query.entities
23
- # respond_to do |format|
24
- # format.html do
25
- # @entities = @entities.page(params[:page])
26
- # render layout: !request.xhr?
27
- # end
28
- # format.xml { render xml: @entities.all }
29
- # format.json { render json: @entities.all }
30
- # end
31
- # end
32
- #
33
- # def show
34
- # @role = Role.find(params[:id])
35
- # respond_to do |format|
36
- # format.html
37
- # format.json { render json: @role }
38
- # end
39
- # end
40
- #
41
- # def new
42
- # @role = Role.new
43
- # end
44
- #
45
- # def edit
46
- # @role = Role.find(params[:id])
47
- # end
48
17
 
49
18
  def create
50
19
  @entity = @role = Role.new(entity_params)
51
20
  @role.permissions = Symphonia::Permissions.find_all(params[:permissions]).map(&:name)
52
21
  super
53
- # respond_to do |format|
54
- # if @role.save
55
- # format.html { redirect_to((params[:continue] ? new_role_path : roles_path), notice: t(:text_created)) }
56
- # format.json { render(json: @role, status: :created, location: @role) }
57
- # else
58
- # format.html { render(action: 'new') }
59
- # format.json { render(json: @role.errors, status: :unprocessable_entity) }
60
- # end
61
- # end
62
22
  end
63
23
 
64
24
  def update
65
25
  @entity = @role = Role.find(params[:id])
66
26
  @role.permissions = Symphonia::Permissions.find_all(params[:permissions]).map(&:name)
67
27
  super
68
- # respond_to do |format|
69
- # if @role.update_attributes(role_params)
70
- # format.html { redirect_to(edit_role_path(@role), notice: t(:text_updated)) }
71
- # format.json { head(:no_content) }
72
- # else
73
- # format.html { render(action: 'edit') }
74
- # format.json { render(json: @role.errors, status: :unprocessable_entity) }
75
- # end
76
- # end
28
+
77
29
  end
78
30
 
79
- # def destroy
80
- # @role = Role.find(params[:id])
81
- # @role.destroy
82
- # respond_to do |format|
83
- # format.html { redirect_to(roles_url, notice: t(:text_destroyed)) }
84
- # format.json { head :no_content }
85
- # format.js { render js: "Symphonia.filters.removeRow('#{view_context.dom_id(@role)}')"}
86
- # end
87
- # end
88
- #
89
31
  private
90
- #
32
+
91
33
  def load_permissions
92
34
  @permissions = Symphonia::Permissions.all
93
35
  end
94
- #
95
- # def role_params
96
- # params.require(:role).permit(:name, :description, permissions: [])
97
- # end
36
+
98
37
  end
99
38
 
100
39
  end
@@ -1,10 +1,5 @@
1
1
  module Symphonia
2
2
  class UsersController < ApplicationController
3
- include Symphonia::Swagger::BaseController
4
- def self.tag_list
5
- %w[User admin]
6
- end
7
- swagger_me entity: "User", base_path: "/admin/users"
8
3
 
9
4
  helper Symphonia::RendererHelper
10
5
 
@@ -80,7 +75,7 @@ module Symphonia
80
75
  format.any(:json, :xml) { head :no_content }
81
76
  else
82
77
  format.html do
83
- @roles = Symphonia::Role.all
78
+ @roles = Symphonia::Role.sorted
84
79
  render action: 'edit'
85
80
  end
86
81
  format.xml { render xml: @user.errors, status: :unprocessable_entity }
@@ -38,7 +38,7 @@ module Symphonia
38
38
  end
39
39
  options[:container_class] ||= 'mr-auto'
40
40
 
41
- return content_tag(:ul, s.html_safe, itemscope: '', itemtype: 'http://data-vocabulary.org/BreadcrumbList', class: "navbar-nav #{options[:container_class]}", id: menu.to_s)
41
+ return content_tag(:ul, s.html_safe, itemscope: '', itemtype: 'http://schema.org/BreadcrumbList', class: "navbar-nav #{options[:container_class]}", id: menu.to_s)
42
42
  end
43
43
 
44
44
  def render_menu_node(menu, item, options = {})
@@ -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
 
@@ -19,8 +19,8 @@ module Symphonia
19
19
  end
20
20
 
21
21
  acts_as_authentic do |config|
22
+ config.crypto_provider = ::Authlogic::CryptoProviders::SCrypt
22
23
  end
23
- validates :email, uniqueness: { case_sensitive: false }
24
24
  validates :password,
25
25
  confirmation: { if: :require_password? },
26
26
  length: {
@@ -30,31 +30,6 @@ module Symphonia
30
30
 
31
31
  include UserManagement
32
32
 
33
- include ::Swagger::Blocks
34
- swagger_component do
35
- schema :User do
36
- key :required, %w[id login email]
37
- property :id do
38
- key :type, "integer"
39
- key :format, "int64"
40
- end
41
- property :fist_name do
42
- key :type, "string"
43
- end
44
- property :last_name do
45
- key :type, "string"
46
- end
47
- property :email do
48
- key :type, "string"
49
- key :format, "email"
50
- end
51
- property :status do
52
- key :type, "string"
53
- key :enum, Symphonia::User.statuses.keys
54
- end
55
- end
56
- end
57
-
58
33
  attr_writer :password_confirmation
59
34
 
60
35
  has_and_belongs_to_many :preferences, foreign_key: 'user_id'
@@ -10,6 +10,5 @@
10
10
  <section id="main" class="container-fluid">
11
11
  <%= yield %>
12
12
  </section>
13
-
14
13
  </body>
15
14
  </html>
@@ -1,9 +1,20 @@
1
- <div class="row">
2
- <!-- <div class="col-xs-12 col-sm-6 col-md-3"><%#= f.text_field :login, required: true %></div>-->
3
- <div class="col-xs-12 col-sm-6 col-md-3"><%= f.email_field :mail, required: true %></div>
4
- <div class="col-xs-12 col-sm-6 col-md-3"><%= f.text_field :first_name, required: true %></div>
5
- <div class="col-xs-12 col-sm-6 col-md-3"><%= f.text_field :last_name, required: true %></div>
6
- <% if f.object.external_id.blank? %>
7
- <div class="col-xs-12 col-sm-6 col-md-3"><%= f.password_field :password, required: f.object.new_record?, prepend: icon('key') %></div>
8
- <% end %>
1
+ <div class="row justify-content-center">
2
+ <div class="col-lg-8">
3
+ <%= f.email_field :email, required: true %>
4
+ </div>
5
+ <div class="col-lg-8">
6
+ <%= f.text_field :first_name, required: true %>
7
+
8
+ </div>
9
+ <div class="col-lg-8">
10
+ <%= f.text_field :last_name, required: true %>
11
+
12
+ </div>
13
+ <div class="col-lg-8">
14
+ <% if f.object.external_id.blank? %>
15
+ <%= f.password_field :password, required: f.object.new_record?, prepend: icon('key') %>
16
+ <% end %>
17
+ </div>
9
18
  </div>
19
+
20
+