trusty-cms 7.0.1 → 7.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/Gemfile +2 -2
  4. data/Gemfile.lock +89 -102
  5. data/INSTALL.md +8 -6
  6. data/README.md +16 -11
  7. data/app/assets/stylesheets/admin/partials/_forms.scss +13 -0
  8. data/app/controllers/admin/configuration_controller.rb +1 -1
  9. data/app/controllers/admin/extensions_controller.rb +1 -0
  10. data/app/controllers/admin/layouts_controller.rb +2 -1
  11. data/app/controllers/admin/resource_controller.rb +10 -1
  12. data/app/controllers/admin/sites_controller.rb +1 -0
  13. data/app/controllers/admin/snippets_controller.rb +2 -1
  14. data/app/controllers/admin/users_controller.rb +2 -1
  15. data/app/helpers/admin/users_helper.rb +2 -1
  16. data/app/models/admins_site.rb +6 -0
  17. data/app/models/site.rb +2 -0
  18. data/app/models/trusty_cms/config.rb +2 -1
  19. data/app/models/user.rb +15 -4
  20. data/app/views/admin/layouts/_choose_site.html.haml +5 -3
  21. data/app/views/admin/layouts/_site_chooser.html.haml +2 -2
  22. data/app/views/admin/pages/_fields.html.haml +4 -3
  23. data/app/views/admin/pages/_node.html.haml +1 -1
  24. data/app/views/admin/snippets/_choose_site.html.haml +2 -1
  25. data/app/views/admin/users/_choose_site.html.haml +2 -1
  26. data/app/views/admin/users/_form.html.haml +3 -1
  27. data/bin/rails +2 -2
  28. data/config/application.rb +1 -0
  29. data/config/boot.rb +1 -1
  30. data/config/locales/en.yml +10 -8
  31. data/db/migrate/20241108172942_create_site_users.rb +8 -0
  32. data/lib/generators/extension_controller/extension_controller_generator.rb +1 -1
  33. data/lib/generators/extension_mailer/extension_mailer_generator.rb +1 -1
  34. data/lib/generators/extension_model/extension_model_generator.rb +1 -1
  35. data/lib/generators/instance/instance_generator.rb +24 -20
  36. data/lib/generators/trusty_cms/templates/boot.rb.erb +1 -1
  37. data/lib/login_system.rb +15 -15
  38. data/lib/tasks/framework.rake +3 -3
  39. data/lib/trusty_cms/available_locales.rb +1 -1
  40. data/lib/trusty_cms/task_support.rb +1 -1
  41. data/lib/trusty_cms/version.rb +1 -1
  42. data/spec/dummy/config/application.rb +2 -0
  43. data/spec/dummy/db/schema.rb +8 -1
  44. data/spec/factories/snippet.rb +10 -0
  45. data/spec/factories/user.rb +11 -11
  46. data/spec/models/snippets_spec.rb +29 -0
  47. data/spec/models/user_spec.rb +46 -0
  48. data/trusty_cms.gemspec +1 -1
  49. data/vendor/extensions/multi-site-extension/lib/multi_site/scoped_model.rb +17 -11
  50. data/vendor/extensions/multi-site-extension/lib/multi_site/site_chooser_helper.rb +10 -10
  51. metadata +12 -5
  52. data/app/users/_choose_site.html.haml +0 -4
@@ -17,7 +17,7 @@ module MultiSite
17
17
  # that is, anything without a site is considered to be shared among all sites
18
18
  # the default is false
19
19
 
20
- def is_site_scoped(options={})
20
+ def is_site_scoped(options = {})
21
21
  return if is_site_scoped?
22
22
 
23
23
  options = {
@@ -25,7 +25,7 @@ module MultiSite
25
25
  }.merge(options)
26
26
 
27
27
  class_eval <<-EO
28
- default_scope {where(site_scope_condition)}
28
+ #{ self == User ? 'default_scope { joins(user_scope_condition) }' : 'default_scope { where(site_scope_condition) }' }
29
29
  extend MultiSite::ScopedModel::ScopedClassMethods
30
30
  include MultiSite::ScopedModel::ScopedInstanceMethods
31
31
  EO
@@ -52,8 +52,7 @@ module MultiSite
52
52
 
53
53
  module ScopedClassMethods
54
54
 
55
-
56
- def paginate_with_site(options={})
55
+ def paginate_with_site(options = {})
57
56
  return paginate_without_site(options) unless sites?
58
57
  where(site_scope_condition) do
59
58
  paginate_without_site(options)
@@ -63,7 +62,7 @@ module MultiSite
63
62
  %w{count average minimum maximum sum}.each do |getter|
64
63
  define_method("#{getter}_with_site") do |*args|
65
64
  return send("#{getter}_without_site".intern, *args) unless sites?
66
- with_scope(:find => {:conditions => site_scope_condition}) do
65
+ with_scope(:find => { :conditions => site_scope_condition }) do
67
66
  send "#{getter}_without_site".intern, *args
68
67
  end
69
68
  end
@@ -73,11 +72,11 @@ module MultiSite
73
72
  # and should only be used in odd cases like migration.
74
73
  def find_without_site(*args)
75
74
  options = args.extract_options!
76
- #set_readonly_option!(options)
75
+ # set_readonly_option!(options)
77
76
 
78
77
  case args.first
79
- when :first then find_initial_without_site(options) # defined here
80
- when :all then all_without_site(options) # already defined by the alias chain
78
+ when :first then find_initial_without_site(options) # defined here
79
+ when :all then all_without_site(options) # already defined by the alias chain
81
80
  end
82
81
  end
83
82
 
@@ -110,6 +109,12 @@ module MultiSite
110
109
  condition
111
110
  end
112
111
 
112
+ def user_scope_condition
113
+ return "" unless self.current_site
114
+
115
+ "INNER JOIN `admins_sites` ON `admins_sites`.`admin_id` = `admins`.`id` AND `admins_sites`.`site_id` = #{self.current_site.id}"
116
+ end
117
+
113
118
  def plural_symbol_for_class
114
119
  self.to_s.pluralize.underscore.intern
115
120
  end
@@ -125,9 +130,10 @@ module MultiSite
125
130
 
126
131
  module ScopedInstanceMethods
127
132
  protected
128
- def set_site
129
- self.site ||= self.class.current_site! unless self.class.is_shareable?
130
- end
133
+
134
+ def set_site
135
+ self.site ||= self.class.current_site! unless self.class.is_shareable?
136
+ end
131
137
  end
132
138
  end
133
139
  end
@@ -1,14 +1,14 @@
1
1
  module MultiSite::SiteChooserHelper
2
2
 
3
- def sites_chooser_thing
4
- return "" unless current_user.admin? && defined?(Site) && defined?(controller) && controller.sited_model? && controller.template_name == 'index' && Site.several?
5
- options = Site.all.map{ |site| "<li>" + link_to( site.name, "#{request.path}?site_id=#{site.id}", :class => site == current_site ? 'fg' : '') + "</li>" }.join("")
6
- chooser = %{<div id="site_chooser">}
7
- #chooser << link_to("sites", admin_sites_url, {:id => 'show_site_list', :class => 'expandable'})
8
- chooser << %{<ul id="nav"><li>Current Site: #{current_site.name}}
9
- chooser << %{<ul class="expansion">#{options}</ul></li></ul>}
10
- chooser << %{</div>}
11
- chooser
12
- end
3
+ def sites_chooser_thing
4
+ return "" unless current_user.admin? && defined?(Site) && defined?(controller) && controller.sited_model? && controller.template_name == 'index' && Site.several?
5
+ options = Site.all.map { |site| "<li>" + link_to(site.name, "#{request.path}?site_id=#{site.id}", :class => site == current_site ? 'fg' : '') + "</li>" }.join("")
6
+ chooser = %{<div id="site_chooser">}
7
+ # chooser << link_to("sites", admin_sites_url, {:id => 'show_site_list', :class => 'expandable'})
8
+ chooser << %{<ul id="nav"><li>Current Site: #{current_site.name}}
9
+ chooser << %{<ul class="expansion">#{options}</ul></li></ul>}
10
+ chooser << %{</div>}
11
+ chooser
12
+ end
13
13
 
14
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trusty-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.1
4
+ version: 7.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - TrustyCms CMS dev team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-17 00:00:00.000000000 Z
11
+ date: 2024-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage-validator
@@ -301,7 +301,7 @@ dependencies:
301
301
  version: 2.0.1
302
302
  - - "<"
303
303
  - !ruby/object:Gem::Version
304
- version: 3.1.0
304
+ version: 3.2.0
305
305
  type: :runtime
306
306
  prerelease: false
307
307
  version_requirements: !ruby/object:Gem::Requirement
@@ -311,7 +311,7 @@ dependencies:
311
311
  version: 2.0.1
312
312
  - - "<"
313
313
  - !ruby/object:Gem::Version
314
- version: 3.1.0
314
+ version: 3.2.0
315
315
  - !ruby/object:Gem::Dependency
316
316
  name: rack-cache
317
317
  requirement: !ruby/object:Gem::Requirement
@@ -730,6 +730,7 @@ files:
730
730
  - app/mailers/application_mailer.rb
731
731
  - app/mailers/devise_mailer.rb
732
732
  - app/mailers/rad_social_mailer.rb
733
+ - app/models/admins_site.rb
733
734
  - app/models/asset.rb
734
735
  - app/models/asset_type.rb
735
736
  - app/models/file_not_found_page.rb
@@ -753,7 +754,6 @@ files:
753
754
  - app/models/trusty_cms/page_response_cache_director.rb
754
755
  - app/models/user.rb
755
756
  - app/models/user_action_observer.rb
756
- - app/users/_choose_site.html.haml
757
757
  - app/views/admin/assets/_asset.html.haml
758
758
  - app/views/admin/assets/_asset_table.html.haml
759
759
  - app/views/admin/assets/_errors.html.haml
@@ -908,6 +908,7 @@ files:
908
908
  - db/migrate/20161027141250_add_position_to_pages.rb
909
909
  - db/migrate/20200117141251_create_admin_users.rb
910
910
  - db/migrate/20210331134718_create_active_storage_tables.active_storage.rb
911
+ - db/migrate/20241108172942_create_site_users.rb
911
912
  - db/schema.rb
912
913
  - lib/active_record_extensions/active_record_extensions.rb
913
914
  - lib/annotatable.rb
@@ -1097,12 +1098,15 @@ files:
1097
1098
  - spec/factories/layout.rb
1098
1099
  - spec/factories/page.rb
1099
1100
  - spec/factories/page_part.rb
1101
+ - spec/factories/snippet.rb
1100
1102
  - spec/factories/user.rb
1101
1103
  - spec/features/config_spec.rb
1102
1104
  - spec/features/layouts_spec.rb
1103
1105
  - spec/features/pages_spec.rb
1104
1106
  - spec/fixtures/users.yml
1105
1107
  - spec/models/layout_spec.rb
1108
+ - spec/models/snippets_spec.rb
1109
+ - spec/models/user_spec.rb
1106
1110
  - spec/rails_helper.rb
1107
1111
  - spec/spec_helper.rb
1108
1112
  - spec/support/custom_actions.rb
@@ -1248,12 +1252,15 @@ test_files:
1248
1252
  - spec/factories/layout.rb
1249
1253
  - spec/factories/page.rb
1250
1254
  - spec/factories/page_part.rb
1255
+ - spec/factories/snippet.rb
1251
1256
  - spec/factories/user.rb
1252
1257
  - spec/features/config_spec.rb
1253
1258
  - spec/features/layouts_spec.rb
1254
1259
  - spec/features/pages_spec.rb
1255
1260
  - spec/fixtures/users.yml
1256
1261
  - spec/models/layout_spec.rb
1262
+ - spec/models/snippets_spec.rb
1263
+ - spec/models/user_spec.rb
1257
1264
  - spec/rails_helper.rb
1258
1265
  - spec/spec_helper.rb
1259
1266
  - spec/support/custom_actions.rb
@@ -1,4 +0,0 @@
1
- - unless current_user.site
2
- %label{:for=>"user_admin"} Can edit site
3
- = select :user, :site_id, [['<any>', '']] + Site.all.map { |s| [s.name, s.id] }
4
- .caption A user with no site is able to act (to whatever extent their status allows) on any site.