anoubis 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/anoubis/application_controller.rb +18 -6
  3. data/app/controllers/anoubis/core/application_controller.rb +6 -6
  4. data/app/controllers/anoubis/core/data/actions.rb +15 -15
  5. data/app/controllers/anoubis/core/data/callbacks.rb +5 -5
  6. data/app/controllers/anoubis/core/data/convert.rb +33 -33
  7. data/app/controllers/anoubis/core/data/defaults.rb +8 -8
  8. data/app/controllers/anoubis/core/data/get.rb +14 -14
  9. data/app/controllers/anoubis/core/data/load.rb +3 -3
  10. data/app/controllers/anoubis/core/data/set.rb +2 -2
  11. data/app/controllers/anoubis/core/data/setup.rb +5 -5
  12. data/app/controllers/anoubis/core/data_controller.rb +10 -10
  13. data/app/controllers/anoubis/core/index/actions.rb +2 -2
  14. data/app/controllers/anoubis/core/index/callbacks.rb +1 -1
  15. data/app/controllers/anoubis/core/index_controller.rb +4 -4
  16. data/app/controllers/anoubis/etc/base.rb +16 -11
  17. data/app/controllers/anoubis/etc/data.rb +1 -1
  18. data/app/controllers/anoubis/etc/field.rb +10 -10
  19. data/app/controllers/anoubis/etc/field_options.rb +1 -1
  20. data/app/controllers/anoubis/etc/field_order.rb +1 -1
  21. data/app/controllers/anoubis/etc/filter.rb +2 -2
  22. data/app/controllers/anoubis/etc/menu.rb +2 -2
  23. data/app/controllers/anoubis/etc/model.rb +1 -1
  24. data/app/controllers/anoubis/etc/tab_item.rb +1 -1
  25. data/app/controllers/anoubis/etc.rb +1 -1
  26. data/app/controllers/anoubis/export.rb +1 -1
  27. data/app/controllers/anoubis/output/autocomplete.rb +1 -1
  28. data/app/controllers/anoubis/output/basic.rb +1 -1
  29. data/app/controllers/anoubis/output/data.rb +1 -1
  30. data/app/controllers/anoubis/output/delete.rb +1 -1
  31. data/app/controllers/anoubis/output/edit.rb +1 -1
  32. data/app/controllers/anoubis/output/frame.rb +5 -5
  33. data/app/controllers/anoubis/output/login.rb +1 -1
  34. data/app/controllers/anoubis/output/menu.rb +3 -3
  35. data/app/controllers/anoubis/output/update.rb +1 -1
  36. data/app/controllers/anoubis/sso/client/application_controller.rb +2 -2
  37. data/app/controllers/anoubis/sso/client/data/actions.rb +2 -2
  38. data/app/controllers/anoubis/sso/client/data/callbacks.rb +2 -2
  39. data/app/controllers/anoubis/sso/client/data/convert.rb +2 -2
  40. data/app/controllers/anoubis/sso/client/data/defaults.rb +2 -2
  41. data/app/controllers/anoubis/sso/client/data/get.rb +2 -2
  42. data/app/controllers/anoubis/sso/client/data/load.rb +6 -6
  43. data/app/controllers/anoubis/sso/client/data/set.rb +2 -2
  44. data/app/controllers/anoubis/sso/client/data/setup.rb +2 -2
  45. data/app/controllers/anoubis/sso/client/data_controller.rb +9 -9
  46. data/app/controllers/anoubis/sso/client/index/actions.rb +6 -6
  47. data/app/controllers/anoubis/sso/client/index/callbacks.rb +1 -1
  48. data/app/controllers/anoubis/sso/client/index_controller.rb +3 -3
  49. data/app/controllers/anoubis/sso/server/application_controller.rb +2 -2
  50. data/app/controllers/anoubis/sso/server/login_controller.rb +1 -1
  51. data/app/controllers/anoubis/sso/server/user_controller.rb +1 -1
  52. data/app/controllers/anoubis/tenant/application_controller.rb +4 -4
  53. data/app/controllers/anoubis/tenant/data/actions.rb +2 -2
  54. data/app/controllers/anoubis/tenant/data/callbacks.rb +2 -2
  55. data/app/controllers/anoubis/tenant/data/convert.rb +2 -2
  56. data/app/controllers/anoubis/tenant/data/defaults.rb +2 -2
  57. data/app/controllers/anoubis/tenant/data/get.rb +2 -2
  58. data/app/controllers/anoubis/tenant/data/load.rb +5 -5
  59. data/app/controllers/anoubis/tenant/data/set.rb +2 -2
  60. data/app/controllers/anoubis/tenant/data/setup.rb +2 -2
  61. data/app/controllers/anoubis/tenant/data_controller.rb +10 -10
  62. data/app/controllers/anoubis/tenant/index/actions.rb +15 -15
  63. data/app/controllers/anoubis/tenant/index/callbacks.rb +2 -2
  64. data/app/controllers/anoubis/tenant/index_controller.rb +4 -4
  65. data/app/controllers/anoubis/tenants_controller.rb +1 -1
  66. data/app/controllers/anoubis/users_controller.rb +1 -1
  67. data/app/models/anoubis/application_record.rb +2 -2
  68. data/app/models/anoubis/core/application_record.rb +3 -3
  69. data/app/models/anoubis/sso/client/group_menu.rb +6 -6
  70. data/app/models/anoubis/sso/client/menu.rb +8 -8
  71. data/app/models/anoubis/sso/client/user.rb +3 -3
  72. data/app/models/anoubis/sso/server/user.rb +1 -1
  73. data/app/models/anoubis/tenant/group_menu.rb +5 -5
  74. data/app/models/anoubis/tenant/menu.rb +13 -13
  75. data/app/models/anoubis/tenant/system.rb +5 -5
  76. data/app/models/anoubis/tenant/user.rb +4 -4
  77. data/app/services/anoubis/session_service.rb +1 -1
  78. data/config/locales/en.yml +17 -2
  79. data/config/locales/ru.yml +18 -3
  80. data/db/seeds.rb +30 -30
  81. data/lib/anoubis/version.rb +1 -1
  82. data/lib/anoubis.rb +1 -1
  83. data/spec/controllers/anoubis/index_controller_spec.rb +1 -1
  84. data/spec/dummy/log/development.log +0 -0
  85. data/spec/dummy/log/test.log +0 -0
  86. data/spec/dummy/tmp/development_secret.txt +1 -0
  87. data/spec/models/anoubis/group_locale_spec.rb +1 -1
  88. data/spec/models/anoubis/group_menu_spec.rb +6 -6
  89. data/spec/models/anoubis/group_spec.rb +3 -3
  90. data/spec/models/anoubis/menu_locale_spec.rb +1 -1
  91. data/spec/models/anoubis/menu_spec.rb +1 -1
  92. data/spec/models/anoubis/system_locale_spec.rb +1 -1
  93. data/spec/models/anoubis/system_menu_spec.rb +5 -5
  94. data/spec/models/anoubis/system_spec.rb +4 -4
  95. data/spec/models/anoubis/tenant_spec.rb +4 -4
  96. data/spec/models/anoubis/user_spec.rb +2 -2
  97. metadata +62 -56
@@ -1,9 +1,9 @@
1
- class Anubis::Tenant::ApplicationController < Anubis::Core::ApplicationController
1
+ class Anoubis::Tenant::ApplicationController < Anoubis::Core::ApplicationController
2
2
  ##
3
3
  # Get current user model
4
4
  # @return [ActiveRecord] defined user model. It is used for get current user data. May be redefined when user model is changed
5
5
  def get_user_model
6
- Anubis::Tenant::User
6
+ Anoubis::Tenant::User
7
7
  end
8
8
 
9
9
  ##
@@ -20,7 +20,7 @@ class Anubis::Tenant::ApplicationController < Anubis::Core::ApplicationControlle
20
20
  menu_access_status = redis.get self.redis_prefix + self.current_user.uuid+'_'+controller
21
21
 
22
22
  if !menu_access_status
23
- access = Anubis::Tenant::GroupMenu.accesses[:read].to_s+','+Anubis::Tenant::GroupMenu.accesses[:write].to_s
23
+ access = Anoubis::Tenant::GroupMenu.accesses[:read].to_s+','+Anoubis::Tenant::GroupMenu.accesses[:write].to_s
24
24
  query = <<-SQL
25
25
  SELECT `t`.* FROM
26
26
  (SELECT `menus`.`id`, `menus`.`mode`, `menus`.`action`, `menus`.`menu_id`,
@@ -33,7 +33,7 @@ class Anubis::Tenant::ApplicationController < Anubis::Core::ApplicationControlle
33
33
  WHERE `t`.`access` IN (#{access})
34
34
  ORDER BY `t`.`menu_id`
35
35
  SQL
36
- menu = Anubis::Tenant::GroupMenu.find_by_sql(query).first
36
+ menu = Anoubis::Tenant::GroupMenu.find_by_sql(query).first
37
37
  if (!menu)
38
38
  redis.set self.redis_prefix + self.current_user.uuid+'_'+controller, 'not'
39
39
  self.error_exit({ error: I18n.t('errors.access_not_allowed') }) if exit
@@ -1,10 +1,10 @@
1
- module Anubis
1
+ module Anoubis
2
2
  module Tenant
3
3
  module Data
4
4
  ##
5
5
  # Module presents all default actions for for {DataController}.
6
6
  module Actions
7
- include Anubis::Core::Data::Actions
7
+ include Anoubis::Core::Data::Actions
8
8
  end
9
9
  end
10
10
  end
@@ -1,10 +1,10 @@
1
- module Anubis
1
+ module Anoubis
2
2
  module Tenant
3
3
  module Data
4
4
  ##
5
5
  # Module presents all callbacks called in actions.
6
6
  module Callbacks
7
- include Anubis::Core::Data::Callbacks
7
+ include Anoubis::Core::Data::Callbacks
8
8
  end
9
9
  end
10
10
  end
@@ -1,10 +1,10 @@
1
- module Anubis
1
+ module Anoubis
2
2
  module Tenant
3
3
  module Data
4
4
  ##
5
5
  # Data conversion moule between database and human representation
6
6
  module Convert
7
- include Anubis::Core::Data::Convert
7
+ include Anoubis::Core::Data::Convert
8
8
  end
9
9
  end
10
10
  end
@@ -1,10 +1,10 @@
1
- module Anubis
1
+ module Anoubis
2
2
  module Tenant
3
3
  module Data
4
4
  ##
5
5
  # Module sets default parameters for {DataController}.
6
6
  module Defaults
7
- include Anubis::Core::Data::Defaults
7
+ include Anoubis::Core::Data::Defaults
8
8
  end
9
9
  end
10
10
  end
@@ -1,10 +1,10 @@
1
- module Anubis
1
+ module Anoubis
2
2
  module Tenant
3
3
  module Data
4
4
  ##
5
5
  # Module gets system data for {DataController}
6
6
  module Get
7
- include Anubis::Core::Data::Get
7
+ include Anoubis::Core::Data::Get
8
8
  end
9
9
  end
10
10
  end
@@ -1,19 +1,19 @@
1
- module Anubis
1
+ module Anoubis
2
2
  module Tenant
3
3
  module Data
4
4
  ##
5
5
  # Module loads data from external sources for {DataController}
6
6
  module Load
7
- include Anubis::Core::Data::Load
7
+ include Anoubis::Core::Data::Load
8
8
 
9
9
  ##
10
10
  # Loads current menu data. Procedure loads menu data from MySQL database or from Redis cache and places it in
11
- # self.etc.menu {Anubis::Etc#menu}
11
+ # self.etc.menu {Anoubis::Etc#menu}
12
12
  def load_menu_data
13
13
  menu_json = self.redis.get(self.redis_prefix + 'menu_' + params[:controller])
14
14
  menu_locale_json = self.redis.get(self.redis_prefix + 'menu_'+params[:controller]+'_'+self.locale)
15
15
  if !menu_json || !menu_locale_json
16
- menu = Anubis::Tenant::MenuLocale.eager_load(menu: :menu).where(locale: Anubis::Tenant::MenuLocale.locales[self.locale.to_sym]).where(['menus.mode = ? AND menus.status = 0', params[:controller]]).first
16
+ menu = Anoubis::Tenant::MenuLocale.eager_load(menu: :menu).where(locale: Anoubis::Tenant::MenuLocale.locales[self.locale.to_sym]).where(['menus.mode = ? AND menus.status = 0', params[:controller]]).first
17
17
  if menu
18
18
  menu_json = {
19
19
  mode: menu.menu.mode,
@@ -38,7 +38,7 @@ module Anubis
38
38
  end
39
39
  end
40
40
  if menu_json && menu_locale_json
41
- self.etc.menu = Anubis::Etc::Menu.new JSON.parse(menu_json, {:symbolize_names => true}).merge(JSON.parse(menu_locale_json, {:symbolize_names => true}))
41
+ self.etc.menu = Anoubis::Etc::Menu.new JSON.parse(menu_json, {:symbolize_names => true}).merge(JSON.parse(menu_locale_json, {:symbolize_names => true}))
42
42
  if self.writer
43
43
  self.etc.menu.access = 'write'
44
44
  else
@@ -1,10 +1,10 @@
1
- module Anubis
1
+ module Anoubis
2
2
  module Tenant
3
3
  module Data
4
4
  ##
5
5
  # Module sets system data for {DataController}
6
6
  module Set
7
- include Anubis::Core::Data::Set
7
+ include Anoubis::Core::Data::Set
8
8
  end
9
9
  end
10
10
  end
@@ -1,10 +1,10 @@
1
- module Anubis
1
+ module Anoubis
2
2
  module Tenant
3
3
  module Data
4
4
  ##
5
5
  # Module setups system parameters for {DataController}
6
6
  module Setup
7
- include Anubis::Core::Data::Setup
7
+ include Anoubis::Core::Data::Setup
8
8
  end
9
9
  end
10
10
  end
@@ -8,21 +8,21 @@ require_dependency "anubis/tenant/data/defaults"
8
8
  require_dependency "anubis/tenant/data/convert"
9
9
  require_dependency "anubis/tenant/data/callbacks"
10
10
 
11
- module Anubis
11
+ module Anoubis
12
12
  ##
13
13
  # Module presents all core functions for Anubis Library
14
14
  module Tenant
15
15
  ##
16
16
  # Controller consists all procedures and function for presents and modify models data.
17
- class DataController < Anubis::Tenant::ApplicationController
18
- include Anubis::Tenant::Data::Actions
19
- include Anubis::Tenant::Data::Load
20
- include Anubis::Tenant::Data::Get
21
- include Anubis::Tenant::Data::Set
22
- include Anubis::Tenant::Data::Setup
23
- include Anubis::Tenant::Data::Defaults
24
- include Anubis::Tenant::Data::Convert
25
- include Anubis::Tenant::Data::Callbacks
17
+ class DataController < Anoubis::Tenant::ApplicationController
18
+ include Anoubis::Tenant::Data::Actions
19
+ include Anoubis::Tenant::Data::Load
20
+ include Anoubis::Tenant::Data::Get
21
+ include Anoubis::Tenant::Data::Set
22
+ include Anoubis::Tenant::Data::Setup
23
+ include Anoubis::Tenant::Data::Defaults
24
+ include Anoubis::Tenant::Data::Convert
25
+ include Anoubis::Tenant::Data::Callbacks
26
26
  end
27
27
  end
28
28
  end
@@ -1,10 +1,10 @@
1
- module Anubis
1
+ module Anoubis
2
2
  module Tenant
3
3
  module Index
4
4
  ##
5
5
  # Module contains all basic actions for {IndexController}.
6
6
  module Actions
7
- include Anubis::Core::Index::Actions
7
+ include Anoubis::Core::Index::Actions
8
8
 
9
9
  ##
10
10
  # <i>Login</i> action of index controller. Procedure checks user credential. If credentials are correct than user enters
@@ -28,7 +28,7 @@ module Anubis
28
28
  #
29
29
  # <b>Results:</b><br>
30
30
  #
31
- # Resulting data is placed in self.output({Anubis::OutputLogin}) class and returns in JSON format.
31
+ # Resulting data is placed in self.output({Anoubis::OutputLogin}) class and returns in JSON format.
32
32
  #
33
33
  # <b>Examples:</b>
34
34
  #
@@ -48,18 +48,18 @@ module Anubis
48
48
  # "message": "Incorrect user login or password"
49
49
  # }
50
50
  def login
51
- self.output = Anubis::Output::Login.new
51
+ self.output = Anoubis::Output::Login.new
52
52
  if params.has_key?(:login) && params.has_key?(:password)
53
- user = Anubis::Tenant::User.where(login: params[:login].downcase, status: 0).first
53
+ user = Anoubis::Tenant::User.where(login: params[:login].downcase, status: 0).first
54
54
 
55
55
  if !user
56
- tenant = Anubis::Tenant::Tenant.where(state: Anubis::Tenant::Tenant.states[:default]).first
57
- user = Anubis::Tenant::User.where(login: (params[:login]+'.'+tenant.ident).downcase, status: 0).first
56
+ tenant = Anoubis::Tenant::Tenant.where(state: Anoubis::Tenant::Tenant.states[:default]).first
57
+ user = Anoubis::Tenant::User.where(login: (params[:login]+'.'+tenant.ident).downcase, status: 0).first
58
58
  end
59
59
 
60
60
  if !user
61
- tenant = Anubis::Tenant::Tenant.find(1)
62
- user = Anubis::Tenant::User.where(login: (params[:login]+'.'+tenant.ident).downcase, status: 0).first
61
+ tenant = Anoubis::Tenant::Tenant.find(1)
62
+ user = Anoubis::Tenant::User.where(login: (params[:login]+'.'+tenant.ident).downcase, status: 0).first
63
63
  end
64
64
 
65
65
  if user && user.authenticate(params[:password])
@@ -108,7 +108,7 @@ module Anubis
108
108
  #
109
109
  # <b>Results:</b><br>
110
110
  #
111
- # Resulting data is placed in self.output({Anubis::Output::Menu}) variable and returns in JSON format.
111
+ # Resulting data is placed in self.output({Anoubis::Output::Menu}) variable and returns in JSON format.
112
112
  #
113
113
  # <b>Examples:</b>
114
114
  #
@@ -138,9 +138,9 @@ module Anubis
138
138
  # "message": "Session expired"
139
139
  # }
140
140
  def menu
141
- self.output = Anubis::Output::Menu.new
142
- access = Anubis::Tenant::GroupMenu.accesses[:read].to_s+','+Anubis::Tenant::GroupMenu.accesses[:write].to_s
143
- locale = Anubis::Tenant::MenuLocale.locales[self.locale.to_s.to_sym]
141
+ self.output = Anoubis::Output::Menu.new
142
+ access = Anoubis::Tenant::GroupMenu.accesses[:read].to_s+','+Anoubis::Tenant::GroupMenu.accesses[:write].to_s
143
+ locale = Anoubis::Tenant::MenuLocale.locales[self.locale.to_s.to_sym]
144
144
  query = <<-SQL
145
145
  SELECT `t`.* FROM
146
146
  (
@@ -163,7 +163,7 @@ module Anubis
163
163
  )
164
164
  ORDER BY `t`.`menu_id`, `t`.`position`
165
165
  SQL
166
- Anubis::Tenant::GroupMenu.find_by_sql(query).each do |data|
166
+ Anoubis::Tenant::GroupMenu.find_by_sql(query).each do |data|
167
167
  self.output.addElement({
168
168
  mode: data.mode,
169
169
  title: data.title,
@@ -173,7 +173,7 @@ module Anubis
173
173
  tab: data.tab,
174
174
  action: data.action,
175
175
  access: data.access,
176
- state: Anubis::Tenant::Menu.states.invert[data.state],
176
+ state: Anoubis::Tenant::Menu.states.invert[data.state],
177
177
  parent: data.parent_mode
178
178
  })
179
179
  #self.output[:data].push menu_id[data.id.to_s.to_sym]
@@ -1,10 +1,10 @@
1
- module Anubis
1
+ module Anoubis
2
2
  module Tenant
3
3
  module Index
4
4
  ##
5
5
  # Module contains all callbacks {IndexController}.
6
6
  module Callbacks
7
- include Anubis::Core::Index::Callbacks
7
+ include Anoubis::Core::Index::Callbacks
8
8
  end
9
9
  end
10
10
  end
@@ -2,15 +2,15 @@ require_dependency "anubis/tenant/application_controller"
2
2
  require_dependency "anubis/tenant/index/actions"
3
3
  require_dependency "anubis/tenant/index/callbacks"
4
4
 
5
- module Anubis
5
+ module Anoubis
6
6
  ##
7
7
  # Module presents all tenant functions for Anubis Library
8
8
  module Tenant
9
9
  ##
10
10
  # Controller processes main system functions. Authenticates user, checks user access, outputs main menu and etc.
11
- class IndexController < Anubis::Tenant::ApplicationController
12
- include Anubis::Tenant::Index::Actions
13
- include Anubis::Tenant::Index::Callbacks
11
+ class IndexController < Anoubis::Tenant::ApplicationController
12
+ include Anoubis::Tenant::Index::Actions
13
+ include Anoubis::Tenant::Index::Callbacks
14
14
 
15
15
  ##
16
16
  # Check if authentication required
@@ -1,4 +1,4 @@
1
- module Anubis
1
+ module Anoubis
2
2
  ##
3
3
  # Controller that shows and proccesses {Tenant} data
4
4
  class TenantsController < DataController
@@ -1,6 +1,6 @@
1
1
  require_dependency "anoubis/application_controller"
2
2
 
3
- module Anubis
3
+ module Anoubis
4
4
  class UsersController < DataController
5
5
 
6
6
  end
@@ -24,7 +24,7 @@ class Anoubis::ApplicationRecord < ActiveRecord::Base
24
24
  # @return [String] {https://github.com/redis/redis-rb Redis} prefix
25
25
  def redis_prefix
26
26
  begin
27
- value = Rails.configuration.redis_prefix
27
+ value = Rails.configuration.anoubis_redis_prefix
28
28
  rescue
29
29
  return ''
30
30
  end
@@ -36,7 +36,7 @@ class Anoubis::ApplicationRecord < ActiveRecord::Base
36
36
  # @return [String] {https://github.com/redis/redis-rb Redis} prefix
37
37
  def self.redis_prefix
38
38
  begin
39
- value = Rails.configuration.redis_prefix
39
+ value = Rails.configuration.anoubis_redis_prefix
40
40
  rescue
41
41
  return ''
42
42
  end
@@ -1,6 +1,6 @@
1
1
  ##
2
- # Default ApplicationRecord for Anubis::Core library.
3
- class Anubis::Core::ApplicationRecord < ActiveRecord::Base
2
+ # Default ApplicationRecord for Anoubis::Core library.
3
+ class Anoubis::Core::ApplicationRecord < ActiveRecord::Base
4
4
  self.abstract_class = true
5
5
 
6
6
  # @!attribute created_at
@@ -39,7 +39,7 @@ class Anubis::Core::ApplicationRecord < ActiveRecord::Base
39
39
  public
40
40
 
41
41
  ##
42
- # Is called after initialization Anubis::Core ActiveRecord. Sets default parameters.
42
+ # Is called after initialization Anoubis::Core ActiveRecord. Sets default parameters.
43
43
  def after_initialize_core_anubis_model
44
44
  self.need_refresh = false
45
45
  self.redis = Redis.new
@@ -1,6 +1,6 @@
1
1
  ##
2
2
  # Model links {Menu} and {Group}. Describes group access to menu.
3
- class Anubis::Sso::Client::GroupMenu < Anubis::Sso::Client::ApplicationRecord
3
+ class Anoubis::Sso::Client::GroupMenu < Anoubis::Sso::Client::ApplicationRecord
4
4
  # Redefines default table name
5
5
  self.table_name = 'group_menus'
6
6
 
@@ -12,12 +12,12 @@ class Anubis::Sso::Client::GroupMenu < Anubis::Sso::Client::ApplicationRecord
12
12
 
13
13
  # @!attribute group
14
14
  # @return [Group] reference to the {Group} model
15
- belongs_to :group, :class_name => 'Anubis::Sso::Client::Group'
15
+ belongs_to :group, :class_name => 'Anoubis::Sso::Client::Group'
16
16
  validates :group, presence: true, uniqueness: { scope: [:menu_id] }
17
17
 
18
18
  # @!attribute menu
19
19
  # @return [Menu] reference to the {Menu} model
20
- belongs_to :menu, :class_name => 'Anubis::Sso::Client::Menu'
20
+ belongs_to :menu, :class_name => 'Anoubis::Sso::Client::Menu'
21
21
  validates :menu, presence: true, uniqueness: { scope: [:group_id] }
22
22
 
23
23
  # @!attribute access
@@ -41,7 +41,7 @@ class Anubis::Sso::Client::GroupMenu < Anubis::Sso::Client::ApplicationRecord
41
41
  # doesn't present in database then adds this link to database with {#access} defined as 'read'.
42
42
  def after_create_sso_client_group_menu
43
43
  if self.menu.menu_id != nil
44
- Anubis::Sso::Client::GroupMenu.find_or_create_by(menu_id: self.menu.menu_id, group_id: self.group_id) do |menu|
44
+ Anoubis::Sso::Client::GroupMenu.find_or_create_by(menu_id: self.menu.menu_id, group_id: self.group_id) do |menu|
45
45
  menu.access = 'read'
46
46
  end
47
47
  end
@@ -60,8 +60,8 @@ class Anubis::Sso::Client::GroupMenu < Anubis::Sso::Client::ApplicationRecord
60
60
  ##
61
61
  # Is called after link between menu and group had been deleted from database. It also deletes all child links.
62
62
  def after_destroy_sso_client_group_menu
63
- Anubis::Sso::Client::Menu.select(:id).where(menu_id: self.menu_id).each do |menu|
64
- Anubis::Sso::Client::GroupMenu.where(menu_id: menu.id, group_id: self.group_id).each do |group_menu|
63
+ Anoubis::Sso::Client::Menu.select(:id).where(menu_id: self.menu_id).each do |menu|
64
+ Anoubis::Sso::Client::GroupMenu.where(menu_id: menu.id, group_id: self.group_id).each do |group_menu|
65
65
  group_menu.destroy
66
66
  end
67
67
  end
@@ -1,4 +1,4 @@
1
- class Anubis::Sso::Client::Menu < Anubis::Sso::Client::ApplicationRecord
1
+ class Anoubis::Sso::Client::Menu < Anoubis::Sso::Client::ApplicationRecord
2
2
  self.table_name = 'menus'
3
3
 
4
4
  before_create :before_create_sso_client_menu
@@ -31,8 +31,8 @@ class Anubis::Sso::Client::Menu < Anubis::Sso::Client::ApplicationRecord
31
31
 
32
32
  # @!attribute menu
33
33
  # @return [Menu, nil] the parent menu for element menu (if exists).
34
- belongs_to :menu, class_name: 'Anubis::Sso::Client::Menu', optional: true
35
- has_many :menus, class_name: 'Anubis::Sso::Client::Menu'
34
+ belongs_to :menu, class_name: 'Anoubis::Sso::Client::Menu', optional: true
35
+ has_many :menus, class_name: 'Anoubis::Sso::Client::Menu'
36
36
 
37
37
  # @!attribute title
38
38
  # @return [String] the menu's localized title.
@@ -82,13 +82,13 @@ class Anubis::Sso::Client::Menu < Anubis::Sso::Client::ApplicationRecord
82
82
  # - 'hidden' --- element is hidden.
83
83
  enum state: { visible: 0, hidden: 1 }
84
84
 
85
- has_many :group_menus, class_name: 'Anubis::Sso::Client::GroupMenu'
85
+ has_many :group_menus, class_name: 'Anoubis::Sso::Client::GroupMenu'
86
86
 
87
87
  ##
88
88
  # Is called before menu will be created in database. Sets {#position} as last {#position} + 1 on current {#tab}.
89
89
  # After this calls {#before_update_menu} for additional modification.
90
90
  def before_create_sso_client_menu
91
- data = Anubis::Sso::Client::Menu.where(menu_id: self.menu_id).maximum(:position)
91
+ data = Anoubis::Sso::Client::Menu.where(menu_id: self.menu_id).maximum(:position)
92
92
  self.position = if data then data + 1 else 0 end
93
93
 
94
94
  self.before_update_sso_client_menu
@@ -104,7 +104,7 @@ class Anubis::Sso::Client::Menu < Anubis::Sso::Client::ApplicationRecord
104
104
  self.page_size = 20 if self.page_size == 0
105
105
  self.page_size = self.page_size.to_i
106
106
 
107
- parent_menu = Anubis::Sso::Client::Menu.where(id: self.menu_id).first
107
+ parent_menu = Anoubis::Sso::Client::Menu.where(id: self.menu_id).first
108
108
  if parent_menu
109
109
  self.tab = parent_menu.tab + 1
110
110
  else
@@ -137,8 +137,8 @@ class Anubis::Sso::Client::Menu < Anubis::Sso::Client::ApplicationRecord
137
137
  SET menus.position = menus.position - 1
138
138
  WHERE menus.tab = #{self.tab} AND menus.position > #{self.position}
139
139
  SQL
140
- Anubis::Sso::Client::Menu.connection.execute query
141
- Anubis::Sso::Client::Menu.where(menu_id: self.id).find_each do |menu|
140
+ Anoubis::Sso::Client::Menu.connection.execute query
141
+ Anoubis::Sso::Client::Menu.where(menu_id: self.id).find_each do |menu|
142
142
  menu.destroy
143
143
  end
144
144
  end
@@ -1,4 +1,4 @@
1
- class Anubis::Sso::Client::User < Anubis::Sso::Client::ApplicationRecord
1
+ class Anoubis::Sso::Client::User < Anoubis::Sso::Client::ApplicationRecord
2
2
  self.table_name = 'users'
3
3
 
4
4
  after_destroy :after_destroy_anubis_sso_client_user
@@ -64,7 +64,7 @@ class Anubis::Sso::Client::User < Anubis::Sso::Client::ApplicationRecord
64
64
 
65
65
  def get_menus
66
66
  self.menus = {}
67
- access = Anubis::Sso::Client::GroupMenu.accesses[:read].to_s+','+Anubis::Sso::Client::GroupMenu.accesses[:write].to_s
67
+ access = Anoubis::Sso::Client::GroupMenu.accesses[:read].to_s+','+Anoubis::Sso::Client::GroupMenu.accesses[:write].to_s
68
68
  query = <<-SQL
69
69
  SELECT `menus`.`id`, `menus`.`mode`, MAX(`group_menus`.`access`) AS `access`
70
70
  FROM (`menus`, `group_menus`, `groups`, `user_groups`)
@@ -72,7 +72,7 @@ class Anubis::Sso::Client::User < Anubis::Sso::Client::ApplicationRecord
72
72
  `groups`.`id` = `user_groups`.`group_id` AND `user_groups`.`user_id` = #{self.id}
73
73
  GROUP BY `menus`.`id`, `menus`.`mode`
74
74
  SQL
75
- Anubis::Sso::Client::GroupMenu.find_by_sql(query).each do |data|
75
+ Anoubis::Sso::Client::GroupMenu.find_by_sql(query).each do |data|
76
76
  self.menus[data[:mode]] = data.access
77
77
  end
78
78
 
@@ -1,4 +1,4 @@
1
- class Anubis::Sso::Server::User < Anubis::Core::ApplicationRecord
1
+ class Anoubis::Sso::Server::User < Anoubis::Core::ApplicationRecord
2
2
  has_secure_password
3
3
 
4
4
  self.table_name = 'users'
@@ -37,7 +37,7 @@ class Anoubis::Tenant::GroupMenu < Anoubis::Core::ApplicationRecord
37
37
  errors.add(:base, I18n.t('anubis.group_menus.errors.no_access'))
38
38
  throw(:abort, __method__)
39
39
  end
40
- self.access = Anubis::Tenant::GroupMenu.accesses[:read] if !self.access
40
+ self.access = Anoubis::Tenant::GroupMenu.accesses[:read] if !self.access
41
41
  end
42
42
 
43
43
  ##
@@ -45,8 +45,8 @@ class Anoubis::Tenant::GroupMenu < Anoubis::Core::ApplicationRecord
45
45
  # doesn't present in database then adds this link to database with {#access} defined as 'read'.
46
46
  def after_create_group_menu
47
47
  if self.menu.menu_id != nil
48
- Anubis::Tenant::GroupMenu.find_or_create_by(menu_id: self.menu.menu_id, group_id: self.group_id) do |menu|
49
- menu.access = Anubis::Tenant::GroupMenu.accesses[:read]
48
+ Anoubis::Tenant::GroupMenu.find_or_create_by(menu_id: self.menu.menu_id, group_id: self.group_id) do |menu|
49
+ menu.access = Anoubis::Tenant::GroupMenu.accesses[:read]
50
50
  end
51
51
  end
52
52
  self.after_modify_group_menu
@@ -64,8 +64,8 @@ class Anoubis::Tenant::GroupMenu < Anoubis::Core::ApplicationRecord
64
64
  ##
65
65
  # Is called after link between menu and group had been deleted from database. It also deletes all child links.
66
66
  def after_destroy_group_menu
67
- Anubis::Tenant::Menu.select(:id).where(menu_id: self.menu_id).each do |menu|
68
- Anubis::Tenant::GroupMenu.where(menu_id: menu.id, group_id: self.group_id).each do |group_menu|
67
+ Anoubis::Tenant::Menu.select(:id).where(menu_id: self.menu_id).each do |menu|
68
+ Anoubis::Tenant::GroupMenu.where(menu_id: menu.id, group_id: self.group_id).each do |group_menu|
69
69
  group_menu.destroy
70
70
  end
71
71
  end
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  # Menu model. Stores information about all menu elements of the portal. Menu model defines the dependence
3
3
  # between controller and user access.
4
- class Anubis::Tenant::Menu < ApplicationRecord
4
+ class Anoubis::Tenant::Menu < ApplicationRecord
5
5
  # Redefines default table name
6
6
  self.table_name = 'menus'
7
7
 
@@ -33,12 +33,12 @@ class Anubis::Tenant::Menu < ApplicationRecord
33
33
 
34
34
  # @!attribute menu
35
35
  # @return [Menu, nil] the parent menu for element menu (if exists).
36
- belongs_to :menu, class_name: 'Anubis::Tenant::Menu', optional: true
37
- has_many :menus, class_name: 'Anubis::Tenant::Menu'
36
+ belongs_to :menu, class_name: 'Anoubis::Tenant::Menu', optional: true
37
+ has_many :menus, class_name: 'Anoubis::Tenant::Menu'
38
38
 
39
- has_many :group_menus, class_name: 'Anubis::Tenant::GroupMenu'
40
- has_many :system_menus, class_name: 'Anubis::Tenant::SystemMenu'
41
- has_many :menu_locales, class_name: 'Anubis::Tenant::MenuLocale'
39
+ has_many :group_menus, class_name: 'Anoubis::Tenant::GroupMenu'
40
+ has_many :system_menus, class_name: 'Anoubis::Tenant::SystemMenu'
41
+ has_many :menu_locales, class_name: 'Anoubis::Tenant::MenuLocale'
42
42
 
43
43
  # @!attribute status
44
44
  # @return ['enabled', 'disabled'] the status of menu element.
@@ -56,7 +56,7 @@ class Anubis::Tenant::Menu < ApplicationRecord
56
56
  # Is called before menu will be created in database. Sets {#position} as last {#position} + 1 on current {#tab}.
57
57
  # After this calls {#before_update_menu} for additional modification.
58
58
  def before_create_menu
59
- data = Anubis::Tenant::Menu.where(menu_id: self.menu_id).maximum(:position)
59
+ data = Anoubis::Tenant::Menu.where(menu_id: self.menu_id).maximum(:position)
60
60
  self.position = if data then data + 1 else 0 end
61
61
 
62
62
  self.before_update_menu
@@ -72,7 +72,7 @@ class Anubis::Tenant::Menu < ApplicationRecord
72
72
  self.page_size = 20 if !self.page_size
73
73
  self.page_size = self.page_size.to_i
74
74
 
75
- parent_menu = Anubis::Tenant::Menu.where(id: self.menu_id).first
75
+ parent_menu = Anoubis::Tenant::Menu.where(id: self.menu_id).first
76
76
  if parent_menu
77
77
  self.tab = parent_menu.tab + 1
78
78
  else
@@ -91,7 +91,7 @@ class Anubis::Tenant::Menu < ApplicationRecord
91
91
  # Is called before menu will be deleted from database. Checks the ability to destroy a menu. Delete
92
92
  # all translations for menu model from {MenuLocale}.
93
93
  def before_destroy_menu
94
- Anubis::Tenant::MenuLocale.where(menu_id: self.id).each do |menu_locale|
94
+ Anoubis::Tenant::MenuLocale.where(menu_id: self.id).each do |menu_locale|
95
95
  menu_locale.destroy
96
96
  end
97
97
 
@@ -117,14 +117,14 @@ class Anubis::Tenant::Menu < ApplicationRecord
117
117
  SET menus.position = menus.position - 1
118
118
  WHERE menus.tab = #{self.tab} AND menus.position > #{self.position}
119
119
  SQL
120
- Anubis::Tenant::Menu.connection.execute query
120
+ Anoubis::Tenant::Menu.connection.execute query
121
121
  #i = self.position
122
- #Anubis::Tenant::Menu.where(menu_id: self.menu_id, position: (self.position+1..Float::INFINITY)).find_each do |menu|
122
+ #Anoubis::Tenant::Menu.where(menu_id: self.menu_id, position: (self.position+1..Float::INFINITY)).find_each do |menu|
123
123
  # menu.position = i
124
124
  # menu.save
125
125
  # i += 1
126
126
  # end
127
- Anubis::Tenant::Menu.where(menu_id: self.id).find_each do |menu|
127
+ Anoubis::Tenant::Menu.where(menu_id: self.id).find_each do |menu|
128
128
  menu.destroy
129
129
  end
130
130
  end
@@ -133,7 +133,7 @@ class Anubis::Tenant::Menu < ApplicationRecord
133
133
  # Returns model localization data from {MenuLocale}.
134
134
  # @return [MenuLocale] localization for current menu
135
135
  def model_locale
136
- @model_locale ||= self.menu_locales.where(locale: Anubis::Tenant::MenuLocale.locales[self.current_locale.to_sym]).first
136
+ @model_locale ||= self.menu_locales.where(locale: Anoubis::Tenant::MenuLocale.locales[self.current_locale.to_sym]).first
137
137
  end
138
138
 
139
139
  # @!attribute title
@@ -60,7 +60,7 @@ class Anoubis::Tenant::System < Anoubis::Core::ApplicationRecord
60
60
  data = Anoubis::Tenant::Group.find_or_create_by(ident: 'admin', system_id: self.id)
61
61
  I18n.available_locales.each do |locale|
62
62
  I18n.locale = locale
63
- Anubis::Tenant::GroupLocale.find_or_create_by(group_id: data.id, locale: Anubis::Tenant::MenuLocale.locales[locale.to_s.to_sym]) do |system_locale|
63
+ Anoubis::Tenant::GroupLocale.find_or_create_by(group_id: data.id, locale: Anoubis::Tenant::MenuLocale.locales[locale.to_s.to_sym]) do |system_locale|
64
64
  system_locale.title = I18n.t('anubis.install.admins_group')
65
65
  end
66
66
  end
@@ -75,7 +75,7 @@ class Anoubis::Tenant::System < Anoubis::Core::ApplicationRecord
75
75
 
76
76
  ##
77
77
  # Is called after system had been updated. If {#ident} value had been changed then procedure updates
78
- # every {Anubis::Group#full_ident} value.
78
+ # every {Anoubis::Group#full_ident} value.
79
79
  def after_update_system
80
80
  if self.ident_was != self.ident
81
81
  update_groups_full_ident self.id, self.ident
@@ -91,7 +91,7 @@ class Anoubis::Tenant::System < Anoubis::Core::ApplicationRecord
91
91
  throw(:abort, __method__)
92
92
  end
93
93
 
94
- Anubis::Tenant::SystemLocale.where(system_id: self.id).each do |system_locale|
94
+ Anoubis::Tenant::SystemLocale.where(system_id: self.id).each do |system_locale|
95
95
  system_locale.destroy
96
96
  end
97
97
 
@@ -109,14 +109,14 @@ class Anoubis::Tenant::System < Anoubis::Core::ApplicationRecord
109
109
  query = <<-SQL
110
110
  UPDATE groups SET groups.full_ident = CONCAT('#{ident}.', groups.ident) WHERE groups.system_id = #{id}
111
111
  SQL
112
- Anubis::Tenant::Group.connection.execute query
112
+ Anoubis::Tenant::Group.connection.execute query
113
113
  end
114
114
 
115
115
  ##
116
116
  # Returns model localization data from {SystemLocale}.
117
117
  # @return [SystemLocale] localization for current system
118
118
  def model_locale
119
- @model_locale ||= self.system_locales.where(locale: Anubis::Tenant::SystemLocale.locales[self.current_locale.to_sym]).first
119
+ @model_locale ||= self.system_locales.where(locale: Anoubis::Tenant::SystemLocale.locales[self.current_locale.to_sym]).first
120
120
  end
121
121
 
122
122
  # @!attribute title