symphonia 4.1.3 → 5.0.0

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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +27 -1
  4. data/app/assets/javascripts/symphonia/application.js +3 -3
  5. data/app/assets/javascripts/symphonia/symphonia_bootstrap_dialog.js +23 -23
  6. data/app/assets/stylesheets/symphonia/_font_awesome.scss +8 -6
  7. data/app/assets/stylesheets/symphonia/_layout.scss +33 -1
  8. data/app/assets/stylesheets/symphonia/basic.scss +3 -99
  9. data/app/assets/stylesheets/symphonia/filters.scss +3 -5
  10. data/app/assets/stylesheets/symphonia/symphonia_bootstrap.scss +1 -1
  11. data/app/controllers/symphonia/accounts_controller.rb +7 -3
  12. data/app/controllers/symphonia/application_controller.rb +2 -1
  13. data/app/controllers/symphonia/users_controller.rb +17 -29
  14. data/app/helpers/symphonia/application_helper.rb +48 -26
  15. data/app/models/symphonia/preference.rb +5 -5
  16. data/app/models/symphonia/user.rb +3 -35
  17. data/app/models/symphonia/user_ability.rb +46 -0
  18. data/app/views/common/403.html.erb +4 -3
  19. data/app/views/layouts/symphonia/application.html.erb +4 -4
  20. data/app/views/symphonia/accounts/_detail.html.erb +21 -18
  21. data/app/views/symphonia/common/_filters.html.erb +15 -15
  22. data/app/views/symphonia/common/_share_links.html.erb +2 -3
  23. data/app/views/symphonia/users/_form.html.erb +1 -6
  24. data/app/views/symphonia/users/show.html.erb +15 -20
  25. data/config/locales/cs.yml +3 -2
  26. data/db/migrate/20130714140500_create_users.rb +0 -2
  27. data/db/seeds.rb +3 -3
  28. data/lib/generators/symphonia/entity_controller/entity_controller_generator.rb +2 -2
  29. data/lib/generators/symphonia/entity_controller/templates/{controller.rb → controller.rb.tt} +0 -0
  30. data/lib/symphonia/admin_constraint.rb +1 -1
  31. data/lib/symphonia/base_controller.rb +9 -17
  32. data/lib/symphonia/controller_extensions.rb +5 -15
  33. data/lib/symphonia/engine.rb +12 -43
  34. data/lib/symphonia/form_builder.rb +17 -16
  35. data/lib/symphonia/menu_manager.rb +15 -11
  36. data/lib/symphonia/model_attributes/attribute.rb +3 -3
  37. data/lib/symphonia/object.rb +9 -9
  38. data/lib/symphonia/spec_helper.rb +8 -4
  39. data/lib/symphonia/user_management.rb +1 -1
  40. data/lib/symphonia/version.rb +1 -1
  41. data/lib/symphonia.rb +12 -9
  42. data/spec/factories/factories.rb +0 -4
  43. data/spec/models/user_spec.rb +39 -2
  44. data/spec/spec_helper.rb +0 -1
  45. data/spec/support/stub_users.rb +7 -7
  46. metadata +41 -140
  47. data/app/controllers/symphonia/roles_controller.rb +0 -39
  48. data/app/models/symphonia/role.rb +0 -55
  49. data/app/views/symphonia/roles/_form.html.erb +0 -26
  50. data/app/views/symphonia/roles/edit.html.erb +0 -5
  51. data/app/views/symphonia/roles/index.html.erb +0 -6
  52. data/app/views/symphonia/roles/new.html.erb +0 -4
  53. data/app/views/symphonia/roles/show.html.erb +0 -11
  54. data/db/migrate/20130714140501_create_roles.rb +0 -18
  55. data/db/migrate/20210509141420_roles_change_permissions_to_json.rb +0 -18
  56. data/db/migrate/20210509180525_roles_change_permissions_to_native_json.rb +0 -7
  57. data/lib/symphonia/permissions.rb +0 -93
  58. data/spec/controllers/roles_controller_spec.rb +0 -12
  59. data/spec/models/role_spec.rb +0 -13
  60. data/spec/requests/roles_spec.rb +0 -10
@@ -1,7 +1,6 @@
1
- # require 'symphonia/bootstrap_link_render'
2
1
  module Symphonia
3
2
  module ApplicationHelper
4
- include FontAwesome::Rails::IconHelper
3
+
5
4
  include FormHelper
6
5
 
7
6
  def bootstrap_class_for(flash_type)
@@ -23,8 +22,8 @@ module Symphonia
23
22
  def render_flash_messages(flash_messages = nil)
24
23
  s = ''
25
24
  Array(flash_messages || flash).each do |type, message|
26
- s << content_tag(:div, class: "d-print-none alert #{bootstrap_class_for(type)}") do
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
25
+ s << tag.div(class: "d-print-none alert #{bootstrap_class_for(type)}") do
26
+ tag.button('', class: 'fa fa-circle-xmark close', data: { dismiss: 'alert' }) + Array.wrap(message).collect { |m| icon(type, text: m) }.join("<br>").html_safe
28
27
  end
29
28
  end
30
29
 
@@ -38,11 +37,13 @@ module Symphonia
38
37
  end
39
38
  options[:container_class] ||= 'mr-auto'
40
39
 
41
- content_tag(:ul, s.html_safe, itemscope: '', itemtype: 'http://schema.org/BreadcrumbList', class: "navbar-nav #{options[:container_class]}", id: menu.to_s)
40
+ tag.ul(s.html_safe, itemscope: '', itemtype: 'http://schema.org/BreadcrumbList', class: "navbar-nav #{options[:container_class]}", id: menu.to_s)
42
41
  end
43
42
 
44
43
  def render_menu_node(menu, item, options = {})
45
44
  condition = item[:if] ? item[:if].call : true
45
+ return nil unless condition
46
+
46
47
  selected = @menu_item.to_sym == menu
47
48
  label = case item[:label].class.name
48
49
  when 'NilClass'
@@ -57,16 +58,16 @@ module Symphonia
57
58
  raise "MenuManager error: Label is unknown type: #{item[:label].class}"
58
59
  end
59
60
  if item[:children].blank?
60
- return content_tag(:li, render_menu_link(item, label, options), class: "nav-item #{menu} #{'active' if selected} #{options[:class]}", id: item[:id]) if condition
61
+ tag.li(render_menu_link(item, label, options), class: "nav-item #{menu} #{'active' if selected} #{options[:class]}", id: item[:id])
61
62
  else
62
63
  children = ''
63
64
  item[:children].each do |child, subitem|
64
65
  children << render_menu_node(menu, subitem, class: 'dropdown-item').to_s
65
66
  end
66
- unless children.blank?
67
- return content_tag(:li, class: "nav-item dropdown #{menu}") do
67
+ if children.present?
68
+ tag.li(class: "nav-item dropdown #{menu}") do
68
69
  concat render_menu_link(item.merge({ class: 'dropdown-toggle', data: { toggle: 'dropdown' } }), label, { is_submenu: true })
69
- concat content_tag(:ul, children.html_safe, class: 'dropdown-menu')
70
+ concat tag.ul(children.html_safe, class: 'dropdown-menu')
70
71
  end
71
72
  end
72
73
  end
@@ -87,7 +88,7 @@ module Symphonia
87
88
  item[:url]
88
89
  end
89
90
  link_to(
90
- (content_tag(:i, '', class: "#{item[:icon]}") + "\n" + content_tag(:span, label, itemprop: 'title')).html_safe,
91
+ (tag.i('', class: "#{item[:icon]}") + "\n" + tag.span(label, itemprop: 'title')).html_safe,
91
92
  url,
92
93
  class: "nav-link #{item[:class]}",
93
94
  data: item[:data],
@@ -133,20 +134,21 @@ module Symphonia
133
134
  ''
134
135
  else
135
136
  html_title(header_text.dup)
136
- header_text << "\n" + content_tag(:small, small, class: 'text-muted') if small.present?
137
+ header_text << ("\n" << tag.small(small, class: 'text-muted')) if small.present?
137
138
  s = ''
138
139
  if options[:back] && !request.xhr?
139
140
  back_url = options[:back] unless options[:back].is_a? TrueClass
140
141
  s << link_to_back(back_url)
141
142
  end
142
143
  s << capture(&block).to_s if block_given?
143
- header_tag = content_tag request.xhr? && :h5 || :h1, id: 'page_header', class: s.present? && "col-6" || nil do
144
+ header_class = (s.present? && "col-6") || nil
145
+ header_tag = content_tag(((request.xhr? && :h5) || :h1), id: 'page_header', class: header_class) do
144
146
  header_text.html_safe
145
147
  end
146
148
  return header_tag if s.blank?
147
149
 
148
- content_tag :div, class: "row" do
149
- header_tag + content_tag(:div, s.html_safe, class: "col-6 text-right")
150
+ tag.div(class: "row") do
151
+ header_tag + tag.div(s.html_safe, class: "col-6 text-right")
150
152
  end
151
153
  end
152
154
  end
@@ -154,7 +156,7 @@ module Symphonia
154
156
  alias_method :page_header, :title
155
157
 
156
158
  def render_no_data(message = nil)
157
- content_tag(:div, message || t(:text_no_data), class: 'nodata')
159
+ tag.div(icon("circle-info", text: message || t(:text_no_data)), class: 'alert alert-info text-center nodata')
158
160
  end
159
161
 
160
162
  def content_for(name, content = nil, &block)
@@ -175,7 +177,7 @@ module Symphonia
175
177
  end
176
178
 
177
179
  def format_html(text)
178
- content_tag(:div, (defined?(Ckeditor) ? text.html_safe : format_text(text)), class: 'formatted-text')
180
+ tag.div((defined?(Ckeditor) ? text.html_safe : format_text(text)), class: 'formatted-text')
179
181
  end
180
182
 
181
183
  def format_price(value, options = {})
@@ -183,7 +185,7 @@ module Symphonia
183
185
  end
184
186
 
185
187
  def multiselect_toggler(id = nil)
186
- link_to(fa_icon(:plus), 'javascript:void(0);', onclick: "toggleMultiSelect(#{id || 'this'});return false", class: 'btn fa fa-border')
188
+ link_to(icon('plus'), 'javascript:void(0);', onclick: "toggleMultiSelect(#{id || 'this'});return false", class: 'btn fa fa-border')
187
189
  end
188
190
 
189
191
  def link_to_back(url = nil)
@@ -191,14 +193,12 @@ module Symphonia
191
193
  end
192
194
 
193
195
  def link_to_new_entity(options = {})
194
- return '' if !options.has_key?(:skip_permission_check) && !User.current.allowed_to?(:"manage_#{controller_name}")
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
198
  model = controller.try(:model) || controller_name.singularize
199
199
  url = options.delete(:url) || new_polymorphic_path(model, anchor: anchor)
200
200
 
201
- link_to(fa_icon('add', text: label), url, { class: 'btn btn-primary' }.merge(options))
201
+ link_to(icon('square-plus', text: label), url, { class: 'btn btn-primary' }.merge(options))
202
202
  end
203
203
 
204
204
  # change the default link renderer for will_paginate
@@ -238,8 +238,30 @@ module Symphonia
238
238
  javascript_tag("$(document).ready(function() {#{js.html_safe}})".html_safe)
239
239
  end
240
240
 
241
- def icon(fa, text = nil, **options)
242
- fa_icon(fa, (text && { text: content_tag(:span, text, class: 'd-none d-sm-inline') } || {}).merge(options))
241
+ # prepend FontAwesome::Sass::Rails::ViewHelpers
242
+ def icon(icon, text = nil, html_options = {})
243
+ if text.is_a?(Hash)
244
+ html_options = text
245
+ text = nil
246
+ end
247
+
248
+ text_content = if text
249
+ tag.span(text, class: 'd-none d-sm-inline')
250
+ elsif html_options[:text]
251
+ html_options.delete(:text)
252
+ end
253
+ html_options[:title] ||= text
254
+ html_options[:class] = "fa-regular fa-#{icon}"
255
+ html_options['aria-hidden'] ||= true
256
+
257
+ html = tag.i(nil, **html_options)
258
+ html << ' ' << text_content.to_s if text_content.present?
259
+ html
260
+ end
261
+
262
+ def fa_icon(fa, options = {})
263
+ ActiveSupport::Deprecation.warn "use `icon` instead"
264
+ icon(fa, options.delete(:text), options)
243
265
  end
244
266
 
245
267
  # Render original template from engine
@@ -332,11 +354,11 @@ module Symphonia
332
354
 
333
355
  def to_html
334
356
  html = "<div id='#{@modal_id}' style='' class='modal fade' role='dialog'><div class='modal-dialog #{'modal-lg' if size.present?}'><div class='modal-content'>"
335
- html << @c.content_tag(:div, class: 'modal-header') do
336
- @c.content_tag(:button, '', class: 'close fa fa-times', data: { dismiss: 'modal' }, 'aria-hidden' => true) + @c.content_tag(:h4, @title, class: 'modal-title') + @header.to_s
357
+ html << @c.tag.div(class: 'modal-header') do
358
+ @c.tag.button('', class: 'close fa fa-times', data: { dismiss: 'modal' }, 'aria-hidden' => true) + @c.tag.h4(@title, class: 'modal-title') + @header.to_s
337
359
  end
338
- content = @c.content_tag(:div, @c.content_tag(:div, body.html_safe, class: 'modal-content-inner-container container-fluid'), class: 'modal-body')
339
- content << @c.content_tag(:div, footer.html_safe, class: 'modal-footer')
360
+ content = @c.tag.div(@c.tag.div(body.html_safe, class: 'modal-content-inner-container container-fluid'), class: 'modal-body')
361
+ content << @c.tag.div(footer.html_safe, class: 'modal-footer')
340
362
 
341
363
  html << content.html_safe
342
364
  html << '</div></div></div>'
@@ -3,10 +3,10 @@ module Symphonia
3
3
  self.table_name = 'preferences'
4
4
 
5
5
  validates :name, uniqueness: true
6
- # has_and_belongs_to_many :symphonia_units, association_foreign_key: 'user_id'
7
- has_and_belongs_to_many :users, join_table: 'preferences_users', association_foreign_key: 'user_id', class_name: 'Symphonia::User'
6
+ has_and_belongs_to_many :users, join_table: 'preferences_users', association_foreign_key: 'user_id',
7
+ class_name: 'Symphonia::User'
8
8
 
9
- scope :visible, ->(user = Symphonia::User.current) { user.admin? ? all : where(restrict: false)}
10
- end
9
+ scope :visible, ->(user = Symphonia::User.current) { user.admin? ? all : where(restrict: false) }
11
10
 
12
- end
11
+ end
12
+ end
@@ -11,7 +11,6 @@ module Symphonia
11
11
  add_attribute :last_name
12
12
  add_attribute :email, :mail, default: true
13
13
  add_attribute :status, :enum, filter: "select"
14
- add_attribute :role, :reference
15
14
  add_attribute :admin, :boolean
16
15
  add_attribute :login_count
17
16
  add_attribute :last_login_ip
@@ -34,8 +33,7 @@ module Symphonia
34
33
 
35
34
  has_and_belongs_to_many :preferences, foreign_key: 'user_id'
36
35
 
37
- belongs_to :edited_by, class_name: 'Symphonia::User', required: false
38
- belongs_to :role, required: false
36
+ belongs_to :edited_by, class_name: 'Symphonia::User', optional: true
39
37
 
40
38
  accepts_nested_attributes_for :preferences
41
39
 
@@ -46,29 +44,6 @@ module Symphonia
46
44
 
47
45
  alias_attribute :mail, :email
48
46
 
49
-
50
- before_save do |model|
51
- Rails.cache.delete_matched('user_allowed_to*') if model.role_id_changed?
52
- end
53
-
54
- def allowed_to?(action)
55
- return true if admin?
56
-
57
- Rails.cache.fetch([:user_allowed_to, self, action]) do
58
- role_id && role.allowed_to?(action)
59
- end
60
- end
61
-
62
- def authorize?(controller, action)
63
- return true if admin?
64
-
65
- if role_id
66
- role.authorize?(controller, action)
67
- else
68
- false
69
- end
70
- end
71
-
72
47
  # def form_path
73
48
  # 'symphonia/users/form'
74
49
  # end
@@ -97,14 +72,6 @@ module Symphonia
97
72
  'anonym@nothing'
98
73
  end
99
74
 
100
- def allowed_to?(_action)
101
- false
102
- end
103
-
104
- def authorize?(_controller, _action)
105
- false
106
- end
107
-
108
75
  def save
109
76
  false
110
77
  end
@@ -117,7 +84,7 @@ module Symphonia
117
84
  false
118
85
  end
119
86
 
120
- alias_method :admin?, :admin
87
+ alias admin? admin
121
88
 
122
89
  def logged_in?
123
90
  false
@@ -130,6 +97,7 @@ module Symphonia
130
97
  def language
131
98
  nil
132
99
  end
100
+
133
101
  end
134
102
 
135
103
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Symphonia
4
+ class UserAbility
5
+ include CanCan::Ability
6
+
7
+ def initialize(user)
8
+ return unless user.logged_in?
9
+
10
+ can :update, User, id: user.id
11
+ can :read, User, id: user.id
12
+ return unless user.admin?
13
+
14
+ can :archive, User, status: :active
15
+ can :activate, User, status: :pending
16
+ can :unarchive, User, status: :archived
17
+
18
+ can %i[read create update destroy], :all
19
+ # Define abilities for the user here. For example:
20
+ #
21
+ # return unless user.present?
22
+ # can :read, :all
23
+ # return unless user.admin?
24
+ # can :manage, :all
25
+ #
26
+ # The first argument to `can` is the action you are giving the user
27
+ # permission to do.
28
+ # If you pass :manage it will apply to every action. Other common actions
29
+ # here are :read, :create, :update and :destroy.
30
+ #
31
+ # The second argument is the resource the user can perform the action on.
32
+ # If you pass :all it will apply to every resource. Otherwise pass a Ruby
33
+ # class of the resource.
34
+ #
35
+ # The third argument is an optional hash of conditions to further filter the
36
+ # objects.
37
+ # For example, here the user can only update published articles.
38
+ #
39
+ # can :update, Article, published: true
40
+ #
41
+ # See the wiki for details:
42
+ # https://github.com/CanCanCommunity/cancancan/blob/develop/docs/define_check_abilities.md
43
+ end
44
+
45
+ end
46
+ end
@@ -1,5 +1,6 @@
1
- <i class="fa fa-hand-stop-o fa-5x pull-left"></i> <%= page_header 403 %>
2
- <p class="clearfix">
1
+ <%= page_header 403 %>
2
+ <p class="alert alert-danger">
3
+ <i class="fa fa-hand-stop-o fa-5x"></i>
3
4
  <%= t :text_access_deny %>
4
5
  </p>
5
- <%= link_to icon('back', t(:button_back)), :back, class: 'btn btn-link' %>
6
+ <%= link_to icon('back', t(:button_back)), :back, class: 'btn btn-link' %>
@@ -8,9 +8,9 @@
8
8
  <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': true %>
9
9
  <%= yield :stylesheet_tags %>
10
10
  <%= javascript_include_tag 'application', 'data-turbolinks-track': true %>
11
- <script type="text/javascript">
12
- Symphonia.routes.reorderImagesPath = '<%= symphonia.reorder_attachment_path %>';
13
- </script>
11
+ <!-- <script type="text/javascript">-->
12
+ <!-- Symphonia.routes.reorderImagesPath = '<%#= symphonia.reorder_attachment_path %>';-->
13
+ <!-- </script>-->
14
14
  <%= yield :javascript_tags %>
15
15
  <%= csrf_meta_tags %>
16
16
  </head>
@@ -19,7 +19,7 @@
19
19
  <nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
20
20
  <!--<a class="navbar-brand" href="#">Navbar</a>-->
21
21
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
22
- <%= fa_icon('bars') %>
22
+ <%= icon('bars') %>
23
23
  </button>
24
24
 
25
25
  <div class="collapse navbar-collapse" id="navbarSupportedContent">
@@ -1,16 +1,17 @@
1
+ <%= ActiveSupport::Deprecation.warn "View 'accounts/_detail' partial should not use anymore" %>
1
2
  <div class="buttons contextual">
2
3
  <% if Symphonia::User.current.admin? %>
3
4
  <% controller = account.class.name.underscore.pluralize %>
4
5
  <%= link_to(icon('edit', t(:button_edit)), edit_polymorphic_path(account), class: 'btn btn-primary') %>
5
6
  <% if use_service_buttons %>
6
7
  <% if account.active? %>
7
- <%= link_to(fa_icon('lock', text: t(:button_archive)), {:controller => controller, :action => 'archive', :id => account, :back_url => polymorphic_path(account)}, :class => 'btn btn-secondary', :data => {:method => 'post', :confirm => t(:text_are_you_sure)}) %>
8
+ <%#= link_to(icon('lock', text: t(:button_archive)), polymorphic_path([controller_name, 'archive', account], back_url: polymorphic_path(account)), class: 'btn btn-secondary', data: { method: 'post', confirm: t(:text_are_you_sure) }) %>
8
9
  <% elsif account.status_new? %>
9
- <%= link_to(fa_icon('bolt', text: t(:button_active)), {:controller => controller, :action => 'unarchive', :id => account, :back_url => polymorphic_path(account)}, :class => 'btn btn-secondary', :data => {:method => 'post', :confirm => t(:text_are_you_sure) + "\n #{t(:text_confirm_send_unlock_mail)}"}) %>
10
+ <%= link_to(icon('bolt', text: t(:button_active)), { controller: controller, action: 'unarchive', id: account, back_url: polymorphic_path(account) }, class: 'btn btn-secondary', data: { method: 'post', confirm: t(:text_are_you_sure) + "\n #{t(:text_confirm_send_unlock_mail)}" }) %>
10
11
  <% else %>
11
- <%= link_to(fa_icon('unlock', text: t(:button_unarchive)), {:controller => controller, :action => 'unarchive', :id => account, :back_url => polymorphic_path(account)}, :class => 'btn btn-secondary', :data => {:method => 'post', :confirm => t(:text_are_you_sure) + "\n #{t(:text_confirm_send_unlock_mail)}"}) %>
12
+ <%= link_to(icon('unlock', text: t(:button_unarchive)), { controller: controller, action: 'unarchive', id: account, back_url: polymorphic_path(account) }, class: 'btn btn-secondary', data: { method: 'post', confirm: t(:text_are_you_sure) + "\n #{t(:text_confirm_send_unlock_mail)}" }) %>
12
13
  <% end %>
13
- <%= link_to(fa_icon('delete', text: t(:button_delete)), account, :class => 'btn btn-danger', :method => 'delete', :data => {:confirm => t(:text_are_you_sure)}) %>
14
+ <%= link_to(icon('delete', text: t(:button_delete)), account, class: 'btn btn-danger', method: 'delete', data: { :confirm => t(:text_are_you_sure) }) %>
14
15
  <% end -%>
15
16
  <% else %>
16
17
  <%= link_to(icon('edit', t(:button_edit)), edit_polymorphic_path(controller_name.singularize, id: account.id), :class => 'btn btn-primary', :remote => true) %>
@@ -24,29 +25,31 @@
24
25
  <div class="col-md-4">
25
26
  <div class="row">
26
27
  <div class="col-md-6"><b><%= account.class.human_attribute_name(:login) %></b></div>
27
- <div class="col-md-6"><span ><%= account.login %></span></div>
28
+ <div class="col-md-6"><span><%= account.login %></span></div>
28
29
  </div>
29
30
  </div>
30
31
  <div class="col-md-4">
31
32
  <div class="row">
32
33
  <div class="col-md-6"><b><%= account.class.human_attribute_name(:email) %></b></div>
33
- <div class="col-md-6"><span ><%= account.format_value(:email, self) %></span></div>
34
+ <div class="col-md-6"><span><%= account.format_value(:email, self) %></span></div>
34
35
  </div>
35
36
  </div>
36
37
  </div>
37
38
 
38
39
  <div id="customer_detail" style="display: none">
39
40
  <div class="clearfix">
40
- <%= content_tag(:strong, account.class.human_attribute_name(:current_login_at), :class => 'col-xs-6') %>
41
- <%= content_tag(:div, account.current_login_at ? time_tag(account.current_login_at) : '-', :class => 'col-xs-6') %>
42
- <%= content_tag(:strong, account.class.human_attribute_name(:current_login_ip), :class => 'col-xs-6') %>
43
- <%= content_tag(:div, account.current_login_ip || '-', :class => 'col-xs-6') %>
44
- <%= content_tag(:strong, account.class.human_attribute_name(:last_login_at), :class => 'col-xs-6') %>
45
- <%= content_tag(:div, account.last_login_at ? time_tag(account.last_login_at.localtime) : '-', :class => 'col-xs-6') %>
46
- <%= content_tag(:strong, account.class.human_attribute_name(:last_login_ip), :class => 'col-xs-6') %>
47
- <%= content_tag(:div, account.last_login_ip || '-', :class => 'col-xs-6') %>
48
- <%= content_tag(:strong, account.class.human_attribute_name(:single_access_token), :class => 'col-xs-6') %>
49
- <%= content_tag(:div, text_field_tag(:token, account.single_access_token, :style => 'border:none'), :class => 'col-xs-6') %>
41
+ <b class="col-xs-6"><%= account.class.human_attribute_name(:current_login_at) %></b>
42
+ <div class="col-xs-6"><%= account.current_login_at ? time_tag(account.current_login_at) : '-' %></div>
43
+ <b class="col-xs-6"><%= account.class.human_attribute_name(:current_login_ip) %></b>
44
+ <div class="col-xs-6"><%= account.current_login_ip || '-' %></div>
45
+ <b class="col-xs-6"><%= account.class.human_attribute_name(:last_login_at) %></b>
46
+ <div class="col-xs-6"><%= account.last_login_at ? time_tag(account.last_login_at.localtime) : '-' %></div>
47
+ <b class="col-xs-6"><%= account.class.human_attribute_name(:last_login_ip) %></b>
48
+ <div class="col-xs-6"><%= account.last_login_ip || '-' %></div>
49
+ <b class="col-xs-6"><%= account.class.human_attribute_name(:single_access_token) %></b>
50
+ <div class="col-xs-6">
51
+ <%= text_field_tag(:token, account.single_access_token, style: 'border:none') %>
52
+ </div>
50
53
  </div>
51
54
  </div>
52
55
 
@@ -54,7 +57,7 @@
54
57
  SymphoniaUserDetail = {
55
58
  popup: {
56
59
  dialog: null,
57
- show: function() {
60
+ show: function () {
58
61
  if (!this.dialog) {
59
62
  this.dialog = new SymphoniaDialog("customer_detail");
60
63
  }
@@ -62,4 +65,4 @@
62
65
  }
63
66
  }
64
67
  };
65
- </script>
68
+ </script>
@@ -1,23 +1,23 @@
1
1
  <% if @query %>
2
2
  <%#= bootstrap_form_tag(url: {set_filter: 1}, method: :get, class: 'form-horizontal', id: 'symphonia_filters_form') do |f| %>
3
- <div class="row hidden-print">
4
- <% if @query.search? %>
5
- <div class="col-sm-12">
6
- <div class="input-group input-group-sm">
7
- <%= search_field_tag(:q, params[:q], class: 'form-control input-sm', id: 'symphonia_query_q', placeholder: t(:label_search), autofocus: params[:q].present? || nil, data: {remote: local_assigns[:remote]}, onchange: 'submitSymphoniaQueryQ(this)') %>
8
- <div class="input-group-append">
9
- <div class="input-group-text">
10
- <%= link_to(fa_icon('search'), 'javascript:void(0)', {onclick: 'Symphonia.filters.search(document.getElementById("symphonia_query_q"))', title: t(:button_search)}) %>
11
- <%= link_to(fa_icon('filter'), symphonia.filters_options_path(@query.model.name, @query.to_params.merge(path: j(request.url))), remote: true, title: t(:title_advanced_filters)) unless local_assigns.key?(:hide_advanced_filter) %>
12
- <%= link_to(fa_icon('false'), 'javascript:void(0)', onclick: 'Symphonia.filters.resetSearch(document.getElementById("symphonia_query_q"))') if params[:q] %>
13
- </div>
14
-
3
+ <div class="row hidden-print">
4
+ <% if @query.search? %>
5
+ <div class="col-sm-12">
6
+ <div class="input-group input-group-sm">
7
+ <%= search_field_tag(:q, params[:q], class: 'form-control input-sm', id: 'symphonia_query_q', placeholder: t(:label_search), autofocus: params[:q].present? || nil, data: { remote: local_assigns[:remote] }, onchange: 'submitSymphoniaQueryQ(this)') %>
8
+ <div class="input-group-append">
9
+ <div class="input-group-text">
10
+ <%= link_to(icon('search'), 'javascript:void(0)', { onclick: 'Symphonia.filters.search(document.getElementById("symphonia_query_q"))', title: t(:button_search) }) %>
11
+ <%= link_to(icon('filter'), symphonia.filters_options_path(@query.model.name, @query.to_params.merge(path: j(request.url))), remote: true, title: t(:title_advanced_filters)) unless local_assigns.key?(:hide_advanced_filter) %>
12
+ <%= link_to(icon('false'), 'javascript:void(0)', onclick: 'Symphonia.filters.resetSearch(document.getElementById("symphonia_query_q"))') if params[:q] %>
15
13
  </div>
14
+
16
15
  </div>
17
16
  </div>
18
- <% end %>
19
- </div>
17
+ </div>
18
+ <% end %>
19
+ </div>
20
20
  <%# end %>
21
21
  <% else %>
22
- <%= content_tag(:p, t(:text_error_query_not_init), class: 'no-data') %>
22
+ <%= render_no_data t(:text_error_query_not_init) %>
23
23
  <% end -%>
@@ -1,5 +1,4 @@
1
1
  <span class="share-buttons">
2
- <%= link_to(fa_icon("facebook-square #{icon_css}"), "http://www.facebook.com/share.php?u=#{url}&title=#{name}", :title => t(:facebook, :scope => [:share_on, :title]), :target => '_blank') %>
3
- <%= link_to(fa_icon("twitter-square #{icon_css}"), "http://twitter.com/home?status=#{name}+#{url}", :title => t(:twitter, :scope => [:share_on, :title]), :target => '_blank') %>
4
- <%= link_to(fa_icon("google-plus-square #{icon_css}"), "https://plus.google.com/share?url=#{url}", :title => t(:google_plus, :scope => [:share_on, :title]), :target => '_blank') %>
2
+ <%= link_to(icon("facebook-square #{icon_css}"), "http://www.facebook.com/share.php?u=#{url}&title=#{name}", title: t("share_on.title.facebook"), target: '_blank') %>
3
+ <%= link_to(icon("twitter-square #{icon_css}"), "http://twitter.com/home?status=#{name}+#{url}", title: t("share_on.title.twitter"), target: '_blank') %>
5
4
  </span>
@@ -2,12 +2,7 @@
2
2
  <% if Symphonia::User.current.admin? %>
3
3
  <div class="row justify-content-center">
4
4
  <div class="col-8">
5
- <%= f.check_box :admin, id: 'user_admin', layout: :inline %>
5
+ <%= f.check_box :admin, id: 'user_admin' %>
6
6
  </div>
7
- <% if @roles.any? %>
8
- <div class="col-9">
9
- <%= f.select(:role_id, options_from_collection_for_select(@roles, :id, :name, selected: @user.role_id), include_blank: true, layout: :horizontal) %>
10
- </div>
11
- <% end -%>
12
7
  </div>
13
8
  <% end %>
@@ -5,17 +5,12 @@
5
5
  <h4 class="card-title"><%= html_title(@user.name).join %></h4>
6
6
  <div class="card-text row">
7
7
  <div class="col-sm-8">
8
- <% %i(login email admin).each do |attribute| %>
8
+ <% %i[login email admin].each do |attribute| %>
9
9
  <% next if @user.send(attribute).to_s.blank? %>
10
10
  <dt><%= @user.class.human_attribute_name attribute %></dt>
11
11
  <dd><%= @user.format_value(attribute, self) %></dd>
12
12
  <% end %>
13
13
 
14
- <% if @user.role %>
15
- <dt><%= @user.class.human_attribute_name :role %></dt>
16
- <dd><%= @user.format_value(:role, Symphonia::User.current.admin? && self || nil) %></dd>
17
- <% end %>
18
-
19
14
  <% if @user.preferences.any? %>
20
15
  <dt><%= t(:label_user_notifications) %></dt>
21
16
  <% @user.preferences.each do |p| %>
@@ -25,20 +20,20 @@
25
20
  </div>
26
21
  <div class="col-sm-4">
27
22
 
28
- <% if Symphonia::User.current.admin? %>
23
+ <% if can? :edit, @user %>
29
24
  <%= link_to(icon('edit', t(:button_edit)), edit_user_path(@user), class: 'btn btn-primary btn-block') %>
30
- <% if true %>
31
- <% if @user.active? %>
32
- <%= link_to(icon('lock', t(:button_archive)), archive_user_path(@user, back_url: polymorphic_path(@user)), data: { method: 'post', confirm: t(:text_are_you_sure) }, class: 'btn btn-secondary btn-block') %>
33
- <% elsif @user.status_new? %>
34
- <%= link_to(icon('bolt', t(:button_active)), unarchive_user_path(@user, back_url: polymorphic_path(@user)), class: 'btn btn-secondary', data: { method: 'post', confirm: t(:text_are_you_sure) + "\n #{t(:text_confirm_send_unlock_mail)}" }) %>
35
- <% else %>
36
- <%= link_to(icon('unlock', t(:button_unarchive)), unarchive_user_path(@user, back_url: polymorphic_path(@user)), class: 'btn btn-secondary btn-block', data: { method: 'post', confirm: t(:text_are_you_sure) + "\n #{t(:text_confirm_send_unlock_mail)}" }) %>
37
- <% end %>
38
- <%= link_to(icon('delete', t(:button_delete)), @user, class: 'btn btn-danger btn-block', method: 'delete', data: { confirm: t(:text_are_you_sure) }) %>
39
- <% end -%>
40
- <% else %>
41
- <%= link_to(icon('edit', t(:button_edit)), edit_user_path(@user), class: 'btn btn-primary btn-block', remote: true) %>
25
+ <% end %>
26
+ <% if can? :archive, @user %>
27
+ <%= link_to(icon('lock', t(:button_archive)), archive_user_path(@user, back_url: polymorphic_path(@user)), data: { method: 'post', confirm: t(:text_are_you_sure) }, class: 'btn btn-secondary btn-block') %>
28
+ <% end %>
29
+ <% if can? :activate, @user %>
30
+ <%= link_to(icon('bolt', t(:button_active)), unarchive_user_path(@user, back_url: polymorphic_path(@user)), class: 'btn btn-secondary btn-block', data: { method: 'post', confirm: t(:text_are_you_sure) + "\n #{t(:text_confirm_send_unlock_mail)}" }) %>
31
+ <% end %>
32
+ <% if can? :unarchive, @user %>
33
+ <%= link_to(icon('unlock', t(:button_unarchive)), unarchive_user_path(@user, back_url: polymorphic_path(@user)), class: 'btn btn-secondary btn-block', data: { method: 'post', confirm: t(:text_are_you_sure) + "\n #{t(:text_confirm_send_unlock_mail)}" }) %>
34
+ <% end %>
35
+ <% if can? :destroy, @user %>
36
+ <%= link_to(icon('delete', t(:button_delete)), @user, class: 'btn btn-danger btn-block', method: 'delete', data: { confirm: t(:text_are_you_sure) }) %>
42
37
  <% end %>
43
38
  <%= link_to(icon('key', t(:detail)), 'javascript:void(0)', onclick: %q{Symphonia.dialog.show('customer_detail')}, class: 'btn btn-info btn-block') %>
44
39
  </div>
@@ -60,4 +55,4 @@
60
55
  <%= content_tag(:strong, @user.class.human_attribute_name(:single_access_token), :class => 'col-xs-6') %>
61
56
  <%= content_tag(:div, text_field_tag(:token, @user.single_access_token, :style => 'border:none'), :class => 'col-xs-6') %>
62
57
  </div>
63
- </div>
58
+ </div>
@@ -25,8 +25,9 @@ cs:
25
25
  present: Současnot
26
26
  future: Budoucnost
27
27
  formats:
28
- default: "%d. %B %Y %H:%M"
28
+ # default: "%d. %B %Y %H:%M"
29
29
  short: "%-d. %-m. %Y %H:%M"
30
+ long: "%-d. %-m. %Y %H:%M"
30
31
  attributes:
31
32
  updated_at: Aktualizováno
32
33
  created_at: Vytvořeno
@@ -50,7 +51,7 @@ cs:
50
51
  attachment: Příloha
51
52
  errors:
52
53
  template:
53
- body: "Formulář obsahuje chybně vyplněná pole:"
54
+ body: "Formulář obsahuje chyby:"
54
55
  attributes:
55
56
  attachment:
56
57
  attachment_file_name: Název souboru
@@ -37,8 +37,6 @@ class CreateUsers < ActiveRecord::Migration[5.1]
37
37
  t.references :edited_by
38
38
  t.datetime :edited_at
39
39
 
40
- t.references :role
41
-
42
40
  t.timestamps
43
41
  end
44
42
  end
data/db/seeds.rb CHANGED
@@ -3,11 +3,11 @@ u.attributes = {
3
3
  login: 'admin',
4
4
  first_name: 'Lukáš',
5
5
  last_name: 'Pokorný',
6
- email: 'luk4s.pokorny@gmail.com',
6
+ email: 'admin@luk4s.cz',
7
7
  password: 'admin',
8
8
  # password_confirmation: 'admin',
9
9
  admin: true,
10
- avatar_url: "https://secure.gravatar.com/avatar/3657d5f0e9747c1c21eb2b689a8dba0b?s=64"
10
+ avatar_url: "https://secure.gravatar.com/avatar/3657d5f0e9747c1c21eb2b689a8dba0b?s=64",
11
11
  }
12
12
  u.single_access_token = SecureRandom.hex(20)
13
- u.save!(validate: false)
13
+ u.save!(validate: false) if Symphonia::User.where(login: "admin").none?
@@ -19,7 +19,7 @@ module Generators
19
19
  argument :attributes, type: :array, default: [], banner: "field:type field:type"
20
20
 
21
21
  def create_controller_files
22
- template_file = options.api? ? "api_controller.rb" : "controller.rb"
22
+ template_file = options.api? ? "api_controller.rb.tt" : "controller.rb.tt"
23
23
  template template_file, File.join("app/controllers", controller_class_path, "#{controller_file_name}_controller.rb")
24
24
  end
25
25
 
@@ -45,4 +45,4 @@ module Generators
45
45
 
46
46
  end
47
47
  end
48
- end
48
+ end