anoubis 1.0.0 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -0
  3. data/app/controllers/anoubis/application_controller.rb +22 -6
  4. data/app/controllers/anoubis/core/application_controller.rb +6 -6
  5. data/app/controllers/anoubis/core/index/actions.rb +3 -3
  6. data/app/controllers/anoubis/core/index/callbacks.rb +1 -1
  7. data/app/controllers/anoubis/core/index_controller.rb +7 -7
  8. data/app/controllers/anoubis/data/actions.rb +956 -0
  9. data/app/controllers/anoubis/data/callbacks.rb +66 -0
  10. data/app/controllers/anoubis/data/convert.rb +405 -0
  11. data/app/controllers/anoubis/data/defaults.rb +215 -0
  12. data/app/controllers/anoubis/data/get.rb +529 -0
  13. data/app/controllers/anoubis/data/load.rb +87 -0
  14. data/app/controllers/anoubis/data/set.rb +47 -0
  15. data/app/controllers/anoubis/data/setup.rb +102 -0
  16. data/app/controllers/anoubis/data_controller.rb +21 -0
  17. data/app/controllers/anoubis/etc/base.rb +16 -11
  18. data/app/controllers/anoubis/etc/data.rb +1 -1
  19. data/app/controllers/anoubis/etc/field.rb +10 -10
  20. data/app/controllers/anoubis/etc/field_options.rb +1 -1
  21. data/app/controllers/anoubis/etc/field_order.rb +1 -1
  22. data/app/controllers/anoubis/etc/filter.rb +2 -2
  23. data/app/controllers/anoubis/etc/menu.rb +2 -2
  24. data/app/controllers/anoubis/etc/model.rb +1 -1
  25. data/app/controllers/anoubis/etc/tab_item.rb +1 -1
  26. data/app/controllers/anoubis/etc.rb +1 -1
  27. data/app/controllers/anoubis/export.rb +1 -1
  28. data/app/controllers/anoubis/output/autocomplete.rb +1 -1
  29. data/app/controllers/anoubis/output/basic.rb +2 -2
  30. data/app/controllers/anoubis/output/data.rb +1 -1
  31. data/app/controllers/anoubis/output/delete.rb +1 -1
  32. data/app/controllers/anoubis/output/edit.rb +1 -1
  33. data/app/controllers/anoubis/output/frame.rb +5 -5
  34. data/app/controllers/anoubis/output/login.rb +1 -1
  35. data/app/controllers/anoubis/output/menu.rb +3 -3
  36. data/app/controllers/anoubis/output/update.rb +1 -1
  37. data/app/controllers/anoubis/sso/client/application_controller.rb +2 -2
  38. data/app/controllers/anoubis/sso/client/index/actions.rb +6 -6
  39. data/app/controllers/anoubis/sso/client/index/callbacks.rb +1 -1
  40. data/app/controllers/anoubis/sso/client/index_controller.rb +5 -5
  41. data/app/controllers/anoubis/sso/server/application_controller.rb +2 -2
  42. data/app/controllers/anoubis/sso/server/login_controller.rb +6 -6
  43. data/app/controllers/anoubis/sso/server/user_controller.rb +3 -3
  44. data/app/controllers/anoubis/tenant/application_controller.rb +4 -4
  45. data/app/controllers/anoubis/tenant/index/actions.rb +15 -15
  46. data/app/controllers/anoubis/tenant/index/callbacks.rb +2 -2
  47. data/app/controllers/anoubis/tenant/index_controller.rb +7 -7
  48. data/app/models/anoubis/application_record.rb +90 -2
  49. data/app/models/anoubis/core/application_record.rb +3 -3
  50. data/app/models/anoubis/sso/client/group_menu.rb +6 -6
  51. data/app/models/anoubis/sso/client/menu.rb +8 -8
  52. data/app/models/anoubis/sso/client/user.rb +3 -3
  53. data/app/models/anoubis/sso/server/user.rb +1 -1
  54. data/app/models/anoubis/tenant/group_menu.rb +5 -5
  55. data/app/models/anoubis/tenant/menu.rb +13 -13
  56. data/app/models/anoubis/tenant/system.rb +5 -5
  57. data/app/models/anoubis/tenant/user.rb +4 -4
  58. data/app/services/anoubis/log_service.rb +97 -0
  59. data/app/services/anoubis/request_service.rb +134 -0
  60. data/app/services/anoubis/session_service.rb +1 -1
  61. data/config/locales/en.yml +31 -2
  62. data/config/locales/ru.yml +32 -5
  63. data/config/routes.rb +19 -19
  64. data/db/seeds.rb +30 -30
  65. data/lib/anoubis/version.rb +1 -1
  66. data/lib/anoubis.rb +1 -1
  67. data/spec/controllers/anoubis/index_controller_spec.rb +1 -1
  68. data/spec/dummy/log/development.log +0 -0
  69. data/spec/dummy/log/test.log +0 -0
  70. data/spec/dummy/tmp/development_secret.txt +1 -0
  71. data/spec/models/anoubis/group_locale_spec.rb +1 -1
  72. data/spec/models/anoubis/group_menu_spec.rb +6 -6
  73. data/spec/models/anoubis/group_spec.rb +3 -3
  74. data/spec/models/anoubis/menu_locale_spec.rb +1 -1
  75. data/spec/models/anoubis/menu_spec.rb +1 -1
  76. data/spec/models/anoubis/system_locale_spec.rb +1 -1
  77. data/spec/models/anoubis/system_menu_spec.rb +5 -5
  78. data/spec/models/anoubis/system_spec.rb +4 -4
  79. data/spec/models/anoubis/tenant_spec.rb +4 -4
  80. data/spec/models/anoubis/user_spec.rb +2 -2
  81. metadata +92 -87
  82. data/app/controllers/anoubis/core/data/actions.rb +0 -962
  83. data/app/controllers/anoubis/core/data/callbacks.rb +0 -68
  84. data/app/controllers/anoubis/core/data/convert.rb +0 -407
  85. data/app/controllers/anoubis/core/data/defaults.rb +0 -217
  86. data/app/controllers/anoubis/core/data/get.rb +0 -531
  87. data/app/controllers/anoubis/core/data/load.rb +0 -89
  88. data/app/controllers/anoubis/core/data/set.rb +0 -49
  89. data/app/controllers/anoubis/core/data/setup.rb +0 -104
  90. data/app/controllers/anoubis/core/data_controller.rb +0 -28
  91. data/app/controllers/anoubis/sso/client/data/actions.rb +0 -5
  92. data/app/controllers/anoubis/sso/client/data/callbacks.rb +0 -5
  93. data/app/controllers/anoubis/sso/client/data/convert.rb +0 -5
  94. data/app/controllers/anoubis/sso/client/data/defaults.rb +0 -5
  95. data/app/controllers/anoubis/sso/client/data/get.rb +0 -5
  96. data/app/controllers/anoubis/sso/client/data/load.rb +0 -26
  97. data/app/controllers/anoubis/sso/client/data/set.rb +0 -5
  98. data/app/controllers/anoubis/sso/client/data/setup.rb +0 -5
  99. data/app/controllers/anoubis/sso/client/data_controller.rb +0 -21
  100. data/app/controllers/anoubis/tenant/data/actions.rb +0 -11
  101. data/app/controllers/anoubis/tenant/data/callbacks.rb +0 -11
  102. data/app/controllers/anoubis/tenant/data/convert.rb +0 -11
  103. data/app/controllers/anoubis/tenant/data/defaults.rb +0 -11
  104. data/app/controllers/anoubis/tenant/data/get.rb +0 -11
  105. data/app/controllers/anoubis/tenant/data/load.rb +0 -52
  106. data/app/controllers/anoubis/tenant/data/set.rb +0 -11
  107. data/app/controllers/anoubis/tenant/data/setup.rb +0 -11
  108. data/app/controllers/anoubis/tenant/data_controller.rb +0 -28
  109. data/app/controllers/anoubis/tenants_controller.rb +0 -7
  110. data/app/controllers/anoubis/users_controller.rb +0 -7
  111. data/app/mailers/anoubis/application_mailer.rb +0 -8
@@ -0,0 +1,97 @@
1
+ ##
2
+ # Graylog logging service
3
+ class Anoubis::LogService
4
+ # {https://www.rubydoc.info/gems/gelf/GELF/Notifier GELF::Notifier} service
5
+ attr_accessor :logger
6
+ # Hash of permanent parameters that added before sending data to Graylog server
7
+ attr_accessor :perm
8
+
9
+ ##
10
+ # Returns Graylog server URL
11
+ # @return [String] Graylog server URL
12
+ def url
13
+ begin
14
+ value = Rails.configuration.graylog_server
15
+ rescue StandardError
16
+ value = '127.0.0.1'
17
+ end
18
+
19
+ value
20
+ end
21
+
22
+ ##
23
+ # Returns Graylog server port
24
+ # @return [String] Graylog server port
25
+ def port
26
+ begin
27
+ value = Rails.configuration.graylog_port
28
+ rescue StandardError
29
+ value = 12201
30
+ end
31
+
32
+ value
33
+ end
34
+
35
+ ##
36
+ # Returns Graylog facility identifier in input source
37
+ # @return [String] Graylog facility identifier
38
+ def facility
39
+ begin
40
+ value = Rails.configuration.graylog_facility
41
+ rescue StandardError
42
+ value = 'Graylog'
43
+ end
44
+
45
+ value
46
+ end
47
+
48
+ ##
49
+ # Setups basic initialization parameters.
50
+ def initialize
51
+ self.logger = GELF::Notifier.new(url, port, 'WAN', { facility: facility })
52
+ logger.collect_file_and_line = false
53
+ logger.rescue_network_errors = true
54
+ self.perm = {}
55
+ end
56
+
57
+ ##
58
+ # Send data to Graylog server
59
+ # @param text [String] Logged text data
60
+ # @param type [String] Log level ('debug', 'error', 'info', 'warn')
61
+ # @param object [Hash] Additional parameters for logged data
62
+ def log(text, type = 'info', object = nil)
63
+ type = 'info' unless %w[info warn error].include? type.downcase
64
+ loc = caller_locations(1, 1).first
65
+
66
+ data = {
67
+ short_message: text,
68
+ level: level(type),
69
+ line: loc.lineno,
70
+ file: loc.path
71
+ }
72
+
73
+ data.merge!(object) if object
74
+ data.merge!(self.perm)
75
+ logger.notify data
76
+ nil
77
+ end
78
+
79
+ ##
80
+ # Returns {https://www.rubydoc.info/github/graylog-labs/gelf-rb/GELF/Levels GELF::Levels} according by type
81
+ # @param type [String] Log level ('debug', 'error', 'info', 'warn')
82
+ # @return [GELF::Levels] GELF::Levels
83
+ def level(type)
84
+ case type
85
+ when 'debug'
86
+ return GELF::DEBUG
87
+ when 'info'
88
+ return GELF::INFO
89
+ when 'warn'
90
+ return GELF::WARN
91
+ when 'error'
92
+ return GELF::ERROR
93
+ end
94
+
95
+ GELF::UNKNOWN
96
+ end
97
+ end
@@ -0,0 +1,134 @@
1
+ ##
2
+ # Request service
3
+ class Anoubis::RequestService
4
+ ## Redis database variable
5
+ attr_accessor :redis
6
+
7
+ ## Returns {https://github.com/redis/redis-rb Redis} prefix for storing cache data
8
+ attr_accessor :redis_prefix
9
+
10
+ ## Log service {Anoubis::LogService}
11
+ attr_accessor :log
12
+
13
+ ## Cookies data for current session
14
+ attr_accessor :cookies
15
+
16
+ ##
17
+ # Setups basic initialization parameters.
18
+ # @param log [Anoubis::LogService] Log service
19
+ def initialize(log = nil)
20
+ self.redis = Redis.new
21
+ @cookies = nil
22
+ self.log = log ? log : Anoubis::LogService.new
23
+ end
24
+
25
+ ##
26
+ # Returns cookies data for current session
27
+ # @return [Hash] Cookies data
28
+ def cookies
29
+ return @cookies if @cookies
30
+
31
+ @cookies = redis.get cookie_path
32
+ if @cookies
33
+ begin
34
+ @cookies = JSON.parse(self.cookies, { symbolize_names: true })
35
+ rescue
36
+ @cookies = {}
37
+ end
38
+ else
39
+ @cookies = {}
40
+ end
41
+
42
+ @cookies
43
+ end
44
+
45
+ ##
46
+ # Setups cookies data for current session
47
+ # @param data [Hash] Defined cookies parameters
48
+ def cookies=(data)
49
+ @cookies = data
50
+ store_cookies
51
+ end
52
+
53
+ ##
54
+ # Returns redis path for storing cookies data
55
+ # @return [String] Redis storing path
56
+ def cookie_path
57
+ redis_prefix + 'cookies'
58
+ end
59
+
60
+ ##
61
+ # Store current cookies to {https://github.com/redis/redis-rb Redis} cache
62
+ def store_cookies
63
+ redis.set cookie_path, @cookies.to_json
64
+ end
65
+
66
+ ##
67
+ # Unzip {https://www.rubydoc.info/gems/rest-client/RestClient RestClient} response data if returned data is GZipped
68
+ # @param response [RestClient::RawResponse] Received {https://www.rubydoc.info/gems/rest-client/RestClient/RawResponse RestClient::RawResponse}
69
+ # @return [String] Unzipped string
70
+ def unzip(response)
71
+ result = response.body
72
+ begin
73
+ if response.headers.key? :content_encoding
74
+ if response.headers[:content_encoding] == 'gzip'
75
+ sio = StringIO.new( response.body )
76
+ gz = Zlib::GzipReader.new( sio )
77
+ result = gz.read()
78
+ end
79
+ end
80
+ rescue => e
81
+ self.log 'Error was received when page encoded. ' + e.to_s, 'debug'
82
+ result = nil
83
+ end
84
+
85
+ result
86
+ end
87
+
88
+ ##
89
+ # Store data to file
90
+ # @param file_name [String] Name of file
91
+ # @param text [String] Saved text
92
+ def store(file_name, text)
93
+ file = File.open(file_name, "w")
94
+ file.write(text)
95
+ file.close
96
+ end
97
+
98
+ ##
99
+ # Transform cookies string to hash
100
+ # @param str [String] Cookies string
101
+ # @return [Hash] Cookies data
102
+ def parse_cookie(str)
103
+ cookies = { }
104
+
105
+ arr = str.split('; ')
106
+ arr.each do |line|
107
+ index = line.index '='
108
+ if index
109
+ key = line[0..(index - 1)]
110
+ value = line[(index + 1)..(line.length - 1)]
111
+ end
112
+ cookies[key.to_s.to_sym] = value.to_s
113
+ end
114
+
115
+ cookies
116
+ end
117
+
118
+ ##
119
+ # Returns {https://github.com/redis/redis-rb Redis} prefix for storing cache data. Prefix can be set in Rails.configuration.anoubis_redis_prefix configuration parameter.
120
+ # @return [String] {https://github.com/redis/redis-rb Redis} prefix
121
+ def redis_prefix
122
+ @redis_prefix ||= get_redis_prefix
123
+ end
124
+
125
+ private def get_redis_prefix
126
+ begin
127
+ value = Rails.configuration.anoubis_redis_prefix
128
+ rescue
129
+ return ''
130
+ end
131
+
132
+ value + ':'
133
+ end
134
+ end
@@ -1,4 +1,4 @@
1
- class Anubis::SessionService < Anubis::CoreService
1
+ class Anoubis::SessionService < Anoubis::CoreService
2
2
  def initialize
3
3
  super
4
4
  end
@@ -1,5 +1,4 @@
1
1
  en:
2
- success: Successful
3
2
  errors:
4
3
  no_api_version: API version not defined
5
4
  invalid_locale: Invalid locale
@@ -28,10 +27,40 @@ en:
28
27
  page_title: Users management
29
28
  short_title: Users
30
29
 
30
+
31
+
32
+
33
+
34
+
35
+
31
36
  anoubis:
37
+ all: "All"
38
+ success: "Successful"
39
+ error: "Error"
40
+ errors:
41
+ incorrect_login: "Incorrect login or password"
42
+ incorrect_user: "Incorrect user"
43
+ access_not_allowed: "Access not allowed"
44
+ session_expired: "Session expired"
45
+ install:
46
+ menu:
47
+ dashboard:
48
+ title: "Dashboard"
49
+ page_title: "Dashboard"
50
+ short_title: "Dashboard"
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
32
61
  default_tab: Default
33
62
  default_tab_hint: This is default tab
34
- install:
63
+ install2:
35
64
  groups:
36
65
  admin: Administrators
37
66
  user: Users
@@ -1,6 +1,4 @@
1
1
  ru:
2
- all: Все
3
- success: Успешное завершение
4
2
  actions:
5
3
  edit: "Редактировать: %{title}"
6
4
  delete: "Удалить: %{title}"
@@ -32,7 +30,37 @@ ru:
32
30
  page_title: Управление пользователями
33
31
  short_title: Пользователи
34
32
 
33
+
34
+
35
+
36
+
37
+
35
38
  anoubis:
39
+ all: "Все"
40
+ success: "Успешное завершение"
41
+ error: "Ошибка"
42
+ default_tab: "Основная"
43
+ default_tab_hint: "Это основная вкладка"
44
+ errors:
45
+ incorrect_login: "Некорректный логин или пароль"
46
+ session_expired: "Сессия завершена"
47
+ incorrect_user: "Некорректный пользователь"
48
+ access_not_allowed: "Доступ запрещен"
49
+ install:
50
+ menu:
51
+ dashboard:
52
+ title: "Дашборд"
53
+ page_title: "Дашборд"
54
+ short_title: "Дашборд"
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
36
64
  core:
37
65
  success: Завершено корректно
38
66
  errors:
@@ -40,8 +68,7 @@ ru:
40
68
  incorrect_parameters: Некорректные параметры
41
69
  error_changing_data: Ошибка изменения данных
42
70
 
43
- default_tab: Основная
44
- default_tab_hint: Это основная вкладка
71
+
45
72
  months:
46
73
  main:
47
74
  - Январь
@@ -82,7 +109,7 @@ ru:
82
109
  - окт
83
110
  - ноя
84
111
  - дек
85
- install:
112
+ install2:
86
113
  groups:
87
114
  admin: Администраторы
88
115
  user: Пользователи
data/config/routes.rb CHANGED
@@ -8,13 +8,13 @@ Anoubis::Engine.routes.draw do
8
8
 
9
9
 
10
10
  if lib_type == 'tenant'
11
- match 'api/:version/*path', { controller: 'anubis/tenant/index', action: 'options', constraints: { method: 'OPTIONS' }, via: [:options] }
11
+ match 'api/:version/*path', { controller: 'anoubis/tenant/index', action: 'options', constraints: { method: 'OPTIONS' }, via: [:options] }
12
12
 
13
- post 'api/:version/login', to: 'anubis/tenant/index#login', :defaults => { :format => 'json' }
14
- post 'api/:version/validate', to: 'anubis/tenant/index#validate', :defaults => { :format => 'json' }
15
- post 'api/:version/recover', to: 'anubis/tenant/index#recover', :defaults => { :format => 'json' }
16
- post 'api/:version/logout', to: 'anubis/tenant/index#logout', :defaults => { :format => 'json' }
17
- get 'api/:version/menu', to: 'anubis/tenant/index#menu', :defaults => { :format => 'json' }
13
+ post 'api/:version/login', to: 'anoubis/tenant/index#login', :defaults => { :format => 'json' }
14
+ post 'api/:version/validate', to: 'anoubis/tenant/index#validate', :defaults => { :format => 'json' }
15
+ post 'api/:version/recover', to: 'anoubis/tenant/index#recover', :defaults => { :format => 'json' }
16
+ post 'api/:version/logout', to: 'anoubis/tenant/index#logout', :defaults => { :format => 'json' }
17
+ get 'api/:version/menu', to: 'anoubis/tenant/index#menu', :defaults => { :format => 'json' }
18
18
 
19
19
  scope path: 'api', :defaults => { :format => 'json' } do
20
20
  scope path: ':version' do
@@ -35,18 +35,18 @@ Anoubis::Engine.routes.draw do
35
35
  if lib_type == 'sso-server'
36
36
  scope path: 'api', defaults: { format: 'json' } do
37
37
  scope path: ':version' do
38
- match '*path', { controller: 'anubis/sso/server/login', action: 'options', constraints: { method: 'OPTIONS' }, via: [:options] }
38
+ match '*path', { controller: 'anoubis/sso/server/login', action: 'options', constraints: { method: 'OPTIONS' }, via: [:options] }
39
39
 
40
- get 'login', to: 'anubis/sso/server/login#index'
41
- post 'login', to: 'anubis/sso/server/login#create'
42
- get 'login/:session', to: 'anubis/sso/server/login#show'
43
- put 'login/:session', to: 'anubis/sso/server/login#update'
44
- delete 'login/:session', to: 'anubis/sso/server/login#destroy'
40
+ get 'login', to: 'anoubis/sso/server/login#index'
41
+ post 'login', to: 'anoubis/sso/server/login#create'
42
+ get 'login/:session', to: 'anoubis/sso/server/login#show'
43
+ put 'login/:session', to: 'anoubis/sso/server/login#update'
44
+ delete 'login/:session', to: 'anoubis/sso/server/login#destroy'
45
45
 
46
- get 'user/current', to: 'anubis/sso/server/user#show_current'
47
- get 'user/:uuid', to: 'anubis/sso/server/user#show'
48
- put 'user/current', to: 'anubis/sso/server/user#update_current'
49
- put 'user/:uuid', to: 'anubis/sso/server/user#update'
46
+ get 'user/current', to: 'anoubis/sso/server/user#show_current'
47
+ get 'user/:uuid', to: 'anoubis/sso/server/user#show'
48
+ put 'user/current', to: 'anoubis/sso/server/user#update_current'
49
+ put 'user/:uuid', to: 'anoubis/sso/server/user#update'
50
50
  end
51
51
  end
52
52
  end
@@ -54,10 +54,10 @@ Anoubis::Engine.routes.draw do
54
54
  if lib_type == 'sso-client'
55
55
  scope path: 'api', defaults: { format: 'json' } do
56
56
  scope path: ':version' do
57
- match '*path', { controller: 'anubis/sso/server/login', action: 'options', constraints: { method: 'OPTIONS' }, via: [:options] }
57
+ match '*path', { controller: 'anoubis/sso/server/login', action: 'options', constraints: { method: 'OPTIONS' }, via: [:options] }
58
58
 
59
- get 'menu', to: 'anubis/sso/client/index#menu'
60
- post 'logout', to: 'anubis/sso/client/index#logout'
59
+ get 'menu', to: 'anoubis/sso/client/index#menu'
60
+ post 'logout', to: 'anoubis/sso/client/index#logout'
61
61
  #get 'login', to: 'anubis/sso/server/login#index'
62
62
  #post 'login', to: 'anubis/sso/server/login#create'
63
63
  #put 'login/:session', to: 'anubis/sso/server/login#update'
data/db/seeds.rb CHANGED
@@ -5,16 +5,16 @@ def create_tenant(params = {})
5
5
  return nil if !params.has_key? :ident
6
6
  return nil if !params.has_key? :title
7
7
 
8
- tenant = Anubis::Tenant::Tenant.find_or_create_by ident: params[:ident]
8
+ tenant = Anoubis::Tenant::Tenant.find_or_create_by ident: params[:ident]
9
9
  tenant.title = params[:title]
10
10
  if params.has_key? :default
11
11
  if params[:default]
12
- tenant.state = Anubis::Tenant::Tenant.states[:default]
12
+ tenant.state = Anoubis::Tenant::Tenant.states[:default]
13
13
  end
14
14
  end
15
15
  tenant.save
16
16
 
17
- Anubis::Tenant::TenantSystem.find_or_create_by tenant: tenant, system_id: 1
17
+ Anoubis::Tenant::TenantSystem.find_or_create_by tenant: tenant, system_id: 1
18
18
 
19
19
  return tenant
20
20
  end
@@ -31,7 +31,7 @@ def create_menu(params = {})
31
31
  prefix = 'install.menu.'+params[:mode].to_s
32
32
 
33
33
  if get_anubis_type == 'tenant'
34
- data = Anubis::Tenant::Menu.find_or_create_by(mode: params[:mode]) do |menu|
34
+ data = Anoubis::Tenant::Menu.find_or_create_by(mode: params[:mode]) do |menu|
35
35
  menu.action = params[:action]
36
36
  menu.menu = params[:parent] if params.key? :parent
37
37
  menu.page_size = params[:page_size] if params.key? :page_size
@@ -40,7 +40,7 @@ def create_menu(params = {})
40
40
 
41
41
  I18n.available_locales.each do |locale|
42
42
  I18n.locale = locale
43
- Anubis::Tenant::MenuLocale.find_or_create_by(menu_id: data.id, locale: Anubis::Tenant::MenuLocale.locales[locale.to_s.to_sym]) do |menu_locale|
43
+ Anoubis::Tenant::MenuLocale.find_or_create_by(menu_id: data.id, locale: Anoubis::Tenant::MenuLocale.locales[locale.to_s.to_sym]) do |menu_locale|
44
44
  menu_locale.title = I18n.t(prefix+'.title')
45
45
  menu_locale.page_title = I18n.t(prefix+'.page_title')
46
46
  menu_locale.short_title = I18n.t(prefix+'.short_title', default: [(prefix+'.title').to_sym])
@@ -50,10 +50,10 @@ def create_menu(params = {})
50
50
  if params.has_key?(:group) && params.has_key?(:system)
51
51
  if params[:system].is_a? Array
52
52
  params[:system].each do |system|
53
- Anubis::Tenant::SystemMenu.find_or_create_by system: system, menu: data
53
+ Anoubis::Tenant::SystemMenu.find_or_create_by system: system, menu: data
54
54
  end
55
55
  else
56
- Anubis::Tenant::SystemMenu.find_or_create_by system: params[:system], menu: data
56
+ Anoubis::Tenant::SystemMenu.find_or_create_by system: params[:system], menu: data
57
57
  end
58
58
 
59
59
  if params[:group].is_a? Array
@@ -67,7 +67,7 @@ def create_menu(params = {})
67
67
  end
68
68
 
69
69
  if get_anubis_type == 'sso-client'
70
- data = Anubis::Sso::Client::Menu.find_or_create_by(mode: params[:mode])
70
+ data = Anoubis::Sso::Client::Menu.find_or_create_by(mode: params[:mode])
71
71
 
72
72
  #puts data.to_json
73
73
 
@@ -117,11 +117,11 @@ def create_system(params = {})
117
117
  return nil if !params.has_key? :ident
118
118
  return nil if !params.has_key? :translate
119
119
 
120
- system = Anubis::Tenant::System.find_or_create_by ident: params[:ident]
120
+ system = Anoubis::Tenant::System.find_or_create_by ident: params[:ident]
121
121
  if system
122
122
  I18n.available_locales.each do |locale|
123
123
  I18n.locale = locale
124
- Anubis::Tenant::SystemLocale.find_or_create_by(system: system, locale: Anubis::Tenant::SystemLocale.locales[locale.to_s.to_sym]) do |system_locale|
124
+ Anoubis::Tenant::SystemLocale.find_or_create_by(system: system, locale: Anoubis::Tenant::SystemLocale.locales[locale.to_s.to_sym]) do |system_locale|
125
125
  system_locale.title = I18n.t(params[:translate])
126
126
  end
127
127
  end
@@ -130,10 +130,10 @@ def create_system(params = {})
130
130
  if params.has_key? :tenant
131
131
  if params[:tenant].is_a? Array
132
132
  params[:tenant].each do |tenant|
133
- Anubis::Tenant::TenantSystem.find_or_create_by tenant: tenant, system: system
133
+ Anoubis::Tenant::TenantSystem.find_or_create_by tenant: tenant, system: system
134
134
  end
135
135
  else
136
- Anubis::Tenant::TenantSystem.find_or_create_by tenant: params[:tenant], system: system
136
+ Anoubis::Tenant::TenantSystem.find_or_create_by tenant: params[:tenant], system: system
137
137
  end
138
138
  end
139
139
 
@@ -149,11 +149,11 @@ def create_group(params = {})
149
149
  if get_anubis_type == 'tenant'
150
150
  return nil if !params.has_key? :system
151
151
 
152
- group = Anubis::Tenant::Group.find_or_create_by ident: params[:ident], system: params[:system]
152
+ group = Anoubis::Tenant::Group.find_or_create_by ident: params[:ident], system: params[:system]
153
153
  if group
154
154
  I18n.available_locales.each do |locale|
155
155
  I18n.locale = locale
156
- Anubis::Tenant::GroupLocale.find_or_create_by(group: group, locale: Anubis::Tenant::GroupLocale.locales[locale.to_s.to_sym]) do |group_locale|
156
+ Anoubis::Tenant::GroupLocale.find_or_create_by(group: group, locale: Anoubis::Tenant::GroupLocale.locales[locale.to_s.to_sym]) do |group_locale|
157
157
  group_locale.title = I18n.t(params[:translate])
158
158
  end
159
159
  end
@@ -162,16 +162,16 @@ def create_group(params = {})
162
162
  if params.has_key? :user
163
163
  if params[:user].is_a? Array
164
164
  params[:user].each do |user|
165
- Anubis::Tenant::UserGroup.find_or_create_by group: group, user: user
165
+ Anoubis::Tenant::UserGroup.find_or_create_by group: group, user: user
166
166
  end
167
167
  else
168
- Anubis::Tenant::UserGroup.find_or_create_by group: group, user: params[:user]
168
+ Anoubis::Tenant::UserGroup.find_or_create_by group: group, user: params[:user]
169
169
  end
170
170
  end
171
171
  end
172
172
 
173
173
  if get_anubis_type == 'sso-client'
174
- group = Anubis::Sso::Client::Group.find_or_create_by ident: params[:ident]
174
+ group = Anoubis::Sso::Client::Group.find_or_create_by ident: params[:ident]
175
175
 
176
176
  if group
177
177
  I18n.available_locales.each do |locale|
@@ -192,8 +192,8 @@ def add_access_menu(params = {})
192
192
  params[:access] = 'read' if !params.has_key? :access
193
193
 
194
194
  if %w[tenant sso-client].include? get_anubis_type
195
- group_menu_model = Anubis::Tenant::GroupMenu if get_anubis_type == 'tenant'
196
- group_menu_model = Anubis::Sso::Client::GroupMenu if get_anubis_type == 'sso-client'
195
+ group_menu_model = Anoubis::Tenant::GroupMenu if get_anubis_type == 'tenant'
196
+ group_menu_model = Anoubis::Sso::Client::GroupMenu if get_anubis_type == 'sso-client'
197
197
 
198
198
  if params[:group].class == Array
199
199
  params[:group].each do |group|
@@ -227,40 +227,40 @@ end
227
227
  if get_anubis_type == 'tenant'
228
228
  ##
229
229
  # Create default system with id 1
230
- system = Anubis::Tenant::System.find_by_id(1)
230
+ system = Anoubis::Tenant::System.find_by_id(1)
231
231
  if !system
232
- system = Anubis::Tenant::System.create(id: 1)
232
+ system = Anoubis::Tenant::System.create(id: 1)
233
233
  end
234
234
  I18n.available_locales.each do |locale|
235
235
  I18n.locale = locale
236
- Anubis::Tenant::SystemLocale.find_or_create_by(system_id: system.id, locale: Anubis::Tenant::SystemLocale.locales[locale.to_s.to_sym]) do |system_locale|
236
+ Anoubis::Tenant::SystemLocale.find_or_create_by(system_id: system.id, locale: Anoubis::Tenant::SystemLocale.locales[locale.to_s.to_sym]) do |system_locale|
237
237
  system_locale.title = I18n.t('anubis.install.system_title')
238
238
  end
239
239
  end
240
240
 
241
241
  ##
242
242
  # Create default tenant with id 1
243
- tenant = Anubis::Tenant::Tenant.find_by_id(1)
244
- tenant = Anubis::Tenant::Tenant.create(id: 1, title: I18n.t('anubis.install.tenant_title'), state: Anubis::Tenant::Tenant.states[:default]) if !tenant
243
+ tenant = Anoubis::Tenant::Tenant.find_by_id(1)
244
+ tenant = Anoubis::Tenant::Tenant.create(id: 1, title: I18n.t('anubis.install.tenant_title'), state: Anoubis::Tenant::Tenant.states[:default]) if !tenant
245
245
 
246
- Anubis::Tenant::TenantSystem.find_or_create_by tenant: tenant, system: system
246
+ Anoubis::Tenant::TenantSystem.find_or_create_by tenant: tenant, system: system
247
247
 
248
248
  ##
249
249
  # Load Administrator group of Main System
250
- admin_group = Anubis::Tenant::Group.where(system: system, ident: 'admin').first
250
+ admin_group = Anoubis::Tenant::Group.where(system: system, ident: 'admin').first
251
251
  I18n.available_locales.each do |locale|
252
252
  I18n.locale = locale
253
- Anubis::Tenant::GroupLocale.find_or_create_by(group_id: admin_group.id, locale: Anubis::Tenant::GroupLocale.locales[locale.to_s.to_sym]) do |group_locale|
253
+ Anoubis::Tenant::GroupLocale.find_or_create_by(group_id: admin_group.id, locale: Anoubis::Tenant::GroupLocale.locales[locale.to_s.to_sym]) do |group_locale|
254
254
  group_locale.title = I18n.t('anubis.install.admins_group')
255
255
  end
256
256
  end
257
257
 
258
258
  ##
259
259
  # Create main administrator with id 1
260
- admin_user = Anubis::Tenant::User.find_by_id(1)
261
- admin_user = Anubis::Tenant::User.create(id: 1, email: 'admin@local.local', name: I18n.t('anubis.install.admin_name'), surname: I18n.t('anubis.install.admin_surname'), timezone: 'GMT', status: 0, tenant: tenant) if !admin_user
260
+ admin_user = Anoubis::Tenant::User.find_by_id(1)
261
+ admin_user = Anoubis::Tenant::User.create(id: 1, email: 'admin@local.local', name: I18n.t('anubis.install.admin_name'), surname: I18n.t('anubis.install.admin_surname'), timezone: 'GMT', status: 0, tenant: tenant) if !admin_user
262
262
 
263
- Anubis::Tenant::UserGroup.find_or_create_by(user_id: admin_user.id, group_id: admin_group.id)
263
+ Anoubis::Tenant::UserGroup.find_or_create_by(user_id: admin_user.id, group_id: admin_group.id)
264
264
 
265
265
  menu_0 = create_menu({ mode: 'anubis/admin', action: 'menu' })
266
266
  menu_1 = create_menu({ mode: 'anubis/tenants', action: 'data', parent: menu_0, system: system, group: admin_group, access: 'write' })
@@ -1,5 +1,5 @@
1
1
  module Anoubis
2
2
  ##
3
3
  # Anoubis current version
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.8'
5
5
  end
data/lib/anoubis.rb CHANGED
@@ -19,7 +19,7 @@ module Anoubis
19
19
  send :after_destroy, :manual_order_after_destroy
20
20
 
21
21
  self.manual_order_options = params if params.is_a?(Hash)
22
- include Anubis::HasManualOrder::LocalInstanceMethods
22
+ include Anoubis::HasManualOrder::LocalInstanceMethods
23
23
  end
24
24
  end
25
25
 
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- module Anubis
3
+ module Anoubis
4
4
  RSpec.describe IndexController, type: :controller do
5
5
  render_views
6
6
 
File without changes
File without changes
@@ -0,0 +1 @@
1
+ b714976384f5d8e128e9d5c58df9222bcc4080b2f24285167f4ded45cac2aa0dbc2fdb53441fb6cd83176c54a5a98dbe0c4c7e02e85188f571fb930abe770dac
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- module Anubis
3
+ module Anoubis
4
4
  RSpec.describe GroupLocale, type: :model do
5
5
  it "has short title" do
6
6
  expect(build_stubbed(:group_locale, title: 'T'*2)).to be_invalid
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- module Anubis
3
+ module Anoubis
4
4
  RSpec.describe GroupMenu, type: :model do
5
5
  before(:all) do
6
6
  @system = create :system, ident: 'test'
@@ -21,7 +21,7 @@ module Anubis
21
21
 
22
22
  it "check created tree" do
23
23
  create :group_menu, group: @group, menu: @menu3
24
- expect(Anubis::GroupMenu.where(group: @group).count(:id)).to eq 3
24
+ expect(Anoubis::GroupMenu.where(group: @group).count(:id)).to eq 3
25
25
  end
26
26
 
27
27
  it "can destroy" do
@@ -32,16 +32,16 @@ module Anubis
32
32
 
33
33
  it "can destroy tree" do
34
34
  create :group_menu, group: @group, menu: @menu3
35
- Anubis::GroupMenu.where(group: @group, menu: @menu1).first.destroy
36
- expect(Anubis::GroupMenu.where(group: @group).count(:id)).to eq 0
35
+ Anoubis::GroupMenu.where(group: @group, menu: @menu1).first.destroy
36
+ expect(Anoubis::GroupMenu.where(group: @group).count(:id)).to eq 0
37
37
  end
38
38
 
39
39
  after(:all) do
40
- Anubis::SystemMenu.where(system: @system, menu: @menu1).first.destroy
40
+ Anoubis::SystemMenu.where(system: @system, menu: @menu1).first.destroy
41
41
  @menu3.destroy
42
42
  @menu2.destroy
43
43
  @menu1.destroy
44
- Anubis::Group.where(system_id: @system.id).each do |item|
44
+ Anoubis::Group.where(system_id: @system.id).each do |item|
45
45
  item.destroy
46
46
  end
47
47
  @system.destroy