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
@@ -1,104 +0,0 @@
1
- module Anubis
2
- ##
3
- # Module consists all procedures and functons of {DataController}
4
- module Core
5
- module Data
6
- ##
7
- # Module setups system parameters for {DataController}
8
- module Setup
9
- ##
10
- # Setups frame data information. It loads menu data, sets titles and tabs of the frame.
11
- def setup_frame
12
- self.load_menu_data
13
- if self.etc.menu
14
- self.get_parent_data
15
- if self.etc.data.parent
16
- self.output.title = self.etc.menu.page_title.sub '%{title}', self.etc.data.parent.sys_title.to_s
17
- else
18
- self.output.title = self.etc.menu.page_title
19
- end
20
- self.output.short = self.etc.menu.short_title
21
- self.output.mode = self.etc.menu.mode
22
- self.output.access = self.etc.menu.access
23
- end
24
- tabs = self.tabs
25
- tabs.each do |key, item|
26
- item = self.get_tab key, item
27
- self.output.addTab(item)
28
- end
29
- end
30
-
31
- ##
32
- # Setups order for current tab. Parameters is set into {Anubis::Etc::TabItem#sort self.etc.tab.sort} and
33
- # {Anubis::Etc::TabItem#order self.etc.tab.order} attributes.
34
- def setup_order
35
- sort = nil
36
- first = nil
37
- self.etc.data.fields.each do |key, field|
38
- if field.order
39
- first = key if !first
40
- first = key if field.order.default
41
- if params.key? :sort
42
- sort = key if params[:sort] == key.to_s
43
- end
44
- end
45
- end
46
- sort = first if !sort
47
- if sort
48
- self.etc.tab.sort = sort.to_s
49
- self.etc.tab.order = self.etc.data.fields[sort].order.order
50
- if params.key? :order
51
- self.etc.tab.order = :desc if params[:order] == 'desc'
52
- self.etc.tab.order = :asc if params[:order] == 'asc'
53
- end
54
- end
55
- end
56
-
57
- ##
58
- # @!group Block of fields setup functions
59
-
60
- ##
61
- # Setups defined fields and places it into attribute {Anubis::Etc::Data#fields self.etc.data.fields}
62
- def setup_fields
63
- if !self.etc.data.fields
64
- self.etc.data.fields = {}
65
-
66
- fields = self.fields
67
-
68
- fields.each_key do |key|
69
- if fields[key].key? :edit
70
- if self.menu_access fields[key][:edit], false
71
- fields[key][:editable] = fields[key][:edit]
72
- end
73
- end
74
- self.etc.data.fields[key] = Anubis::Etc::Field.new(key, self.get_model, fields[key].merge(action: self.etc.action))
75
- end
76
- self.setup_order if %w[index export].include? self.etc.action
77
- end
78
- end
79
-
80
- ##
81
- # Setups additional parameters for table field with type 'datetime'
82
- # Resulting data placed in {Etc::Data#fields self.etc.data.fields} (Hash)
83
- # @param key [Symbol] key of table field.
84
- def setup_fields_datetime (key)
85
- self.etc.data.fields[key][:format] = 'full' if !self.etc.data.fields[key].has_key? :format
86
- self.etc.data.fields[key][:format] = 'full' if !['full', 'month', 'date', 'datetime'].include? self.etc.data.fields[key][:format]
87
- end
88
-
89
-
90
-
91
- ##
92
- # Setups additional parameters for table field with type 'float'
93
- # Resulting data placed in {Etc::Data#fields self.etc.data.fields} (Hash)
94
- # @param key [Symbol] key of table field.
95
- def setup_fields_float (key)
96
- self.etc.data.fields[key][:precision] = 2 if !self.etc.data.fields[key][:precision]
97
- self.etc.data.fields[key][:point] = ',' if !self.etc.data.fields[key][:point]
98
- self.etc.data.fields[key][:separator] = '' if !self.etc.data.fields[key][:separator]
99
- end
100
- # @!endgroup
101
- end
102
- end
103
- end
104
- end
@@ -1,28 +0,0 @@
1
- require_dependency "anubis/core/application_controller"
2
- require_dependency "anubis/core/data/actions"
3
- require_dependency "anubis/core/data/load"
4
- require_dependency "anubis/core/data/get"
5
- require_dependency "anubis/core/data/set"
6
- require_dependency "anubis/core/data/setup"
7
- require_dependency "anubis/core/data/defaults"
8
- require_dependency "anubis/core/data/convert"
9
- require_dependency "anubis/core/data/callbacks"
10
-
11
- module Anubis
12
- ##
13
- # Module presents all core functions for Anubis Library
14
- module Core
15
- ##
16
- # Controller consists all procedures and function for presents and modify models data.
17
- class DataController < Anubis::Core::ApplicationController
18
- include Anubis::Core::Data::Actions
19
- include Anubis::Core::Data::Load
20
- include Anubis::Core::Data::Get
21
- include Anubis::Core::Data::Set
22
- include Anubis::Core::Data::Setup
23
- include Anubis::Core::Data::Defaults
24
- include Anubis::Core::Data::Convert
25
- include Anubis::Core::Data::Callbacks
26
- end
27
- end
28
- end
@@ -1,5 +0,0 @@
1
- ##
2
- # Module presents all default actions for for {DataController}.
3
- module Anubis::Sso::Client::Data::Actions
4
- include Anubis::Core::Data::Actions
5
- end
@@ -1,5 +0,0 @@
1
- ##
2
- # Module presents all callbacks called in actions.
3
- module Anubis::Sso::Client::Data::Callbacks
4
- include Anubis::Core::Data::Callbacks
5
- end
@@ -1,5 +0,0 @@
1
- ##
2
- # Data conversion moule between database and human representation
3
- module Anubis::Sso::Client::Data::Convert
4
- include Anubis::Core::Data::Convert
5
- end
@@ -1,5 +0,0 @@
1
- ##
2
- # Module sets default parameters for {DataController}.
3
- module Anubis::Sso::Client::Data::Defaults
4
- include Anubis::Core::Data::Defaults
5
- end
@@ -1,5 +0,0 @@
1
- ##
2
- # Module gets system data for {DataController}
3
- module Anubis::Sso::Client::Data::Get
4
- include Anubis::Core::Data::Get
5
- end
@@ -1,26 +0,0 @@
1
- ##
2
- # Module loads data from external sources for {Anubis::Sso::Client::DataController}
3
- module Anubis::Sso::Client::Data::Load
4
- include Anubis::Core::Data::Load
5
-
6
- def load_menu_data
7
- menu_json = self.redis.get(self.redis_prefix + 'menu:' + params[:controller])
8
-
9
- unless menu_json
10
- menu = Anubis::Sso::Client::Menu.where(mode: params[:controller], status: 'enabled').first
11
- self.redis.set(self.redis_prefix + 'menu:'+ params[:controller], menu.to_json) if menu
12
- else
13
- menu = Anubis::Sso::Client::Menu.new(JSON.parse(menu_json, { :symbolize_names => true }))
14
- end
15
-
16
- if menu
17
- self.etc.menu = Anubis::Etc::Menu.new menu
18
-
19
- if self.writer
20
- self.etc.menu.access = 'write'
21
- else
22
- self.etc.menu.access = 'read'
23
- end
24
- end
25
- end
26
- end
@@ -1,5 +0,0 @@
1
- ##
2
- # Module sets system data for {DataController}
3
- module Anubis::Sso::Client::Data::Set
4
- include Anubis::Core::Data::Set
5
- end
@@ -1,5 +0,0 @@
1
- ##
2
- # Module setups system parameters for {DataController}
3
- module Anubis::Sso::Client::Data::Setup
4
- include Anubis::Core::Data::Setup
5
- end
@@ -1,21 +0,0 @@
1
- require_dependency "anubis/sso/client/application_controller"
2
- require_dependency "anubis/sso/client/data/actions"
3
- require_dependency "anubis/sso/client/data/load"
4
- require_dependency "anubis/sso/client/data/get"
5
- require_dependency "anubis/sso/client/data/set"
6
- require_dependency "anubis/sso/client/data/setup"
7
- require_dependency "anubis/sso/client/data/defaults"
8
- require_dependency "anubis/sso/client/data/convert"
9
- require_dependency "anubis/sso/client/data/callbacks"
10
-
11
- # Controller consists all procedures and function for presents and modify models data.
12
- class Anubis::Sso::Client::DataController < Anubis::Sso::Client::ApplicationController
13
- include Anubis::Sso::Client::Data::Actions
14
- include Anubis::Sso::Client::Data::Load
15
- include Anubis::Sso::Client::Data::Get
16
- include Anubis::Sso::Client::Data::Set
17
- include Anubis::Sso::Client::Data::Setup
18
- include Anubis::Sso::Client::Data::Defaults
19
- include Anubis::Sso::Client::Data::Convert
20
- include Anubis::Sso::Client::Data::Callbacks
21
- end
@@ -1,11 +0,0 @@
1
- module Anubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Module presents all default actions for for {DataController}.
6
- module Actions
7
- include Anubis::Core::Data::Actions
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Anubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Module presents all callbacks called in actions.
6
- module Callbacks
7
- include Anubis::Core::Data::Callbacks
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Anubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Data conversion moule between database and human representation
6
- module Convert
7
- include Anubis::Core::Data::Convert
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Anubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Module sets default parameters for {DataController}.
6
- module Defaults
7
- include Anubis::Core::Data::Defaults
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Anubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Module gets system data for {DataController}
6
- module Get
7
- include Anubis::Core::Data::Get
8
- end
9
- end
10
- end
11
- end
@@ -1,52 +0,0 @@
1
- module Anubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Module loads data from external sources for {DataController}
6
- module Load
7
- include Anubis::Core::Data::Load
8
-
9
- ##
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}
12
- def load_menu_data
13
- menu_json = self.redis.get(self.redis_prefix + 'menu_' + params[:controller])
14
- menu_locale_json = self.redis.get(self.redis_prefix + 'menu_'+params[:controller]+'_'+self.locale)
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
17
- if menu
18
- menu_json = {
19
- mode: menu.menu.mode,
20
- menu_id: menu.menu_id,
21
- parent_menu_id: menu.menu.menu_id,
22
- action: menu.menu.action,
23
- tab: menu.menu.tab,
24
- position: menu.menu.position,
25
- state: menu.menu.state
26
- }
27
- if menu.menu.menu
28
- menu_json[:parent_mode] = menu.menu.menu.mode
29
- end
30
- menu_json = menu_json.to_json
31
- self.redis.set(self.redis_prefix + 'menu_'+params[:controller], menu_json)
32
- menu_locale_json = {
33
- title: menu.title,
34
- page_title: menu.page_title,
35
- short_title: menu.short_title
36
- }.to_json
37
- self.redis.set(self.redis_prefix + 'menu_'+params[:controller]+'_'+self.locale, menu_locale_json)
38
- end
39
- end
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}))
42
- if self.writer
43
- self.etc.menu.access = 'write'
44
- else
45
- self.etc.menu.access = 'read'
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,11 +0,0 @@
1
- module Anubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Module sets system data for {DataController}
6
- module Set
7
- include Anubis::Core::Data::Set
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Anubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Module setups system parameters for {DataController}
6
- module Setup
7
- include Anubis::Core::Data::Setup
8
- end
9
- end
10
- end
11
- end
@@ -1,28 +0,0 @@
1
- require_dependency "anubis/tenant/application_controller"
2
- require_dependency "anubis/tenant/data/actions"
3
- require_dependency "anubis/tenant/data/load"
4
- require_dependency "anubis/tenant/data/get"
5
- require_dependency "anubis/tenant/data/set"
6
- require_dependency "anubis/tenant/data/setup"
7
- require_dependency "anubis/tenant/data/defaults"
8
- require_dependency "anubis/tenant/data/convert"
9
- require_dependency "anubis/tenant/data/callbacks"
10
-
11
- module Anubis
12
- ##
13
- # Module presents all core functions for Anubis Library
14
- module Tenant
15
- ##
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
26
- end
27
- end
28
- end
@@ -1,7 +0,0 @@
1
- module Anubis
2
- ##
3
- # Controller that shows and proccesses {Tenant} data
4
- class TenantsController < DataController
5
-
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- require_dependency "anoubis/application_controller"
2
-
3
- module Anubis
4
- class UsersController < DataController
5
-
6
- end
7
- end
@@ -1,8 +0,0 @@
1
- module Anoubis
2
- ##
3
- # Default mailer for Anoubis library
4
- class ApplicationMailer < ActionMailer::Base
5
- default from: 'from@example.com'
6
- layout 'mailer'
7
- end
8
- end