anoubis 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +38 -0
  5. data/app/controllers/anoubis/application_controller.rb +78 -0
  6. data/app/controllers/anoubis/core/application_controller.rb +343 -0
  7. data/app/controllers/anoubis/core/data/actions.rb +962 -0
  8. data/app/controllers/anoubis/core/data/callbacks.rb +68 -0
  9. data/app/controllers/anoubis/core/data/convert.rb +407 -0
  10. data/app/controllers/anoubis/core/data/defaults.rb +217 -0
  11. data/app/controllers/anoubis/core/data/get.rb +531 -0
  12. data/app/controllers/anoubis/core/data/load.rb +89 -0
  13. data/app/controllers/anoubis/core/data/set.rb +49 -0
  14. data/app/controllers/anoubis/core/data/setup.rb +104 -0
  15. data/app/controllers/anoubis/core/data_controller.rb +28 -0
  16. data/app/controllers/anoubis/core/index/actions.rb +53 -0
  17. data/app/controllers/anoubis/core/index/callbacks.rb +23 -0
  18. data/app/controllers/anoubis/core/index_controller.rb +36 -0
  19. data/app/controllers/anoubis/etc/base.rb +52 -0
  20. data/app/controllers/anoubis/etc/data.rb +89 -0
  21. data/app/controllers/anoubis/etc/field.rb +468 -0
  22. data/app/controllers/anoubis/etc/field_options.rb +83 -0
  23. data/app/controllers/anoubis/etc/field_order.rb +51 -0
  24. data/app/controllers/anoubis/etc/filter.rb +251 -0
  25. data/app/controllers/anoubis/etc/menu.rb +101 -0
  26. data/app/controllers/anoubis/etc/model.rb +67 -0
  27. data/app/controllers/anoubis/etc/tab_item.rb +91 -0
  28. data/app/controllers/anoubis/etc.rb +8 -0
  29. data/app/controllers/anoubis/export.rb +47 -0
  30. data/app/controllers/anoubis/output/autocomplete.rb +30 -0
  31. data/app/controllers/anoubis/output/basic.rb +86 -0
  32. data/app/controllers/anoubis/output/data.rb +101 -0
  33. data/app/controllers/anoubis/output/delete.rb +41 -0
  34. data/app/controllers/anoubis/output/edit.rb +55 -0
  35. data/app/controllers/anoubis/output/frame.rb +227 -0
  36. data/app/controllers/anoubis/output/login.rb +71 -0
  37. data/app/controllers/anoubis/output/menu.rb +220 -0
  38. data/app/controllers/anoubis/output/update.rb +43 -0
  39. data/app/controllers/anoubis/sso/client/application_controller.rb +139 -0
  40. data/app/controllers/anoubis/sso/client/data/actions.rb +5 -0
  41. data/app/controllers/anoubis/sso/client/data/callbacks.rb +5 -0
  42. data/app/controllers/anoubis/sso/client/data/convert.rb +5 -0
  43. data/app/controllers/anoubis/sso/client/data/defaults.rb +5 -0
  44. data/app/controllers/anoubis/sso/client/data/get.rb +5 -0
  45. data/app/controllers/anoubis/sso/client/data/load.rb +26 -0
  46. data/app/controllers/anoubis/sso/client/data/set.rb +5 -0
  47. data/app/controllers/anoubis/sso/client/data/setup.rb +5 -0
  48. data/app/controllers/anoubis/sso/client/data_controller.rb +21 -0
  49. data/app/controllers/anoubis/sso/client/index/actions.rb +79 -0
  50. data/app/controllers/anoubis/sso/client/index/callbacks.rb +13 -0
  51. data/app/controllers/anoubis/sso/client/index_controller.rb +18 -0
  52. data/app/controllers/anoubis/sso/server/application_controller.rb +49 -0
  53. data/app/controllers/anoubis/sso/server/login_controller.rb +342 -0
  54. data/app/controllers/anoubis/sso/server/user_controller.rb +142 -0
  55. data/app/controllers/anoubis/tenant/application_controller.rb +54 -0
  56. data/app/controllers/anoubis/tenant/data/actions.rb +11 -0
  57. data/app/controllers/anoubis/tenant/data/callbacks.rb +11 -0
  58. data/app/controllers/anoubis/tenant/data/convert.rb +11 -0
  59. data/app/controllers/anoubis/tenant/data/defaults.rb +11 -0
  60. data/app/controllers/anoubis/tenant/data/get.rb +11 -0
  61. data/app/controllers/anoubis/tenant/data/load.rb +52 -0
  62. data/app/controllers/anoubis/tenant/data/set.rb +11 -0
  63. data/app/controllers/anoubis/tenant/data/setup.rb +11 -0
  64. data/app/controllers/anoubis/tenant/data_controller.rb +28 -0
  65. data/app/controllers/anoubis/tenant/index/actions.rb +191 -0
  66. data/app/controllers/anoubis/tenant/index/callbacks.rb +11 -0
  67. data/app/controllers/anoubis/tenant/index_controller.rb +38 -0
  68. data/app/controllers/anoubis/tenants_controller.rb +7 -0
  69. data/app/controllers/anoubis/users_controller.rb +7 -0
  70. data/app/jobs/anoubis/application_job.rb +6 -0
  71. data/app/mailers/anoubis/application_mailer.rb +8 -0
  72. data/app/models/anoubis/application_record.rb +45 -0
  73. data/app/models/anoubis/core/application_record.rb +250 -0
  74. data/app/models/anoubis/core/locales.rb +27 -0
  75. data/app/models/anoubis/sso/client/application_record.rb +3 -0
  76. data/app/models/anoubis/sso/client/group.rb +19 -0
  77. data/app/models/anoubis/sso/client/group_menu.rb +109 -0
  78. data/app/models/anoubis/sso/client/menu.rb +145 -0
  79. data/app/models/anoubis/sso/client/user.rb +81 -0
  80. data/app/models/anoubis/sso/client/user_group.rb +32 -0
  81. data/app/models/anoubis/sso/server/system.rb +36 -0
  82. data/app/models/anoubis/sso/server/user.rb +79 -0
  83. data/app/models/anoubis/tenant/application_record.rb +41 -0
  84. data/app/models/anoubis/tenant/group.rb +95 -0
  85. data/app/models/anoubis/tenant/group_locale.rb +19 -0
  86. data/app/models/anoubis/tenant/group_menu.rb +84 -0
  87. data/app/models/anoubis/tenant/menu.rb +156 -0
  88. data/app/models/anoubis/tenant/menu_locale.rb +27 -0
  89. data/app/models/anoubis/tenant/system.rb +127 -0
  90. data/app/models/anoubis/tenant/system_locale.rb +19 -0
  91. data/app/models/anoubis/tenant/system_menu.rb +51 -0
  92. data/app/models/anoubis/tenant/tenant.rb +107 -0
  93. data/app/models/anoubis/tenant/tenant_system.rb +19 -0
  94. data/app/models/anoubis/tenant/user.rb +225 -0
  95. data/app/models/anoubis/tenant/user_group.rb +32 -0
  96. data/app/services/anoubis/core_service.rb +16 -0
  97. data/app/services/anoubis/session_service.rb +17 -0
  98. data/app/validators/presence_in_tenant_validator.rb +20 -0
  99. data/config/initializers/mime_type.rb +1 -0
  100. data/config/locales/en.yml +120 -0
  101. data/config/locales/ru.yml +245 -0
  102. data/config/routes.rb +74 -0
  103. data/db/migrate/20181018085843_create_tenants.rb +13 -0
  104. data/db/migrate/20181018111217_create_systems.rb +10 -0
  105. data/db/migrate/20181018111713_create_tenant_systems.rb +11 -0
  106. data/db/migrate/20181018111925_create_groups.rb +13 -0
  107. data/db/migrate/20181018112151_create_users.rb +25 -0
  108. data/db/migrate/20181018115737_add_title_to_users.rb +10 -0
  109. data/db/migrate/20181022060211_create_menus.rb +18 -0
  110. data/db/migrate/20181115055245_create_group_menus.rb +12 -0
  111. data/db/migrate/20181115060830_create_system_menus.rb +11 -0
  112. data/db/migrate/20181122062131_create_user_groups.rb +11 -0
  113. data/db/migrate/20181221060727_create_menu_locales.rb +14 -0
  114. data/db/migrate/20181225062303_create_system_locales.rb +11 -0
  115. data/db/migrate/20181225062339_create_group_locales.rb +11 -0
  116. data/db/seeds.rb +268 -0
  117. data/lib/anoubis/engine.rb +13 -0
  118. data/lib/anoubis/version.rb +5 -0
  119. data/lib/anoubis.rb +213 -0
  120. data/lib/tasks/anubis_tasks.rake +10 -0
  121. data/lib/tasks/sessions/clear_sessions.rake +10 -0
  122. data/spec/anubis_spec.rb +5 -0
  123. data/spec/controllers/anoubis/index_controller_spec.rb +77 -0
  124. data/spec/dummy/Rakefile +3 -0
  125. data/spec/dummy/app/assets/config/manifest.js +2 -0
  126. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  127. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  128. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  129. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  130. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  131. data/spec/dummy/app/jobs/application_job.rb +2 -0
  132. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  133. data/spec/dummy/app/models/application_record.rb +3 -0
  134. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  135. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  136. data/spec/dummy/bin/bundle +3 -0
  137. data/spec/dummy/bin/rails +4 -0
  138. data/spec/dummy/bin/rake +4 -0
  139. data/spec/dummy/bin/setup +33 -0
  140. data/spec/dummy/bin/update +28 -0
  141. data/spec/dummy/config/application.rb +14 -0
  142. data/spec/dummy/config/boot.rb +5 -0
  143. data/spec/dummy/config/cable.yml +10 -0
  144. data/spec/dummy/config/database.yml +54 -0
  145. data/spec/dummy/config/environment.rb +5 -0
  146. data/spec/dummy/config/environments/development.rb +54 -0
  147. data/spec/dummy/config/environments/production.rb +85 -0
  148. data/spec/dummy/config/environments/test.rb +46 -0
  149. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  150. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  151. data/spec/dummy/config/initializers/cors.rb +16 -0
  152. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  153. data/spec/dummy/config/initializers/inflections.rb +16 -0
  154. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  155. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  156. data/spec/dummy/config/locales/en.yml +33 -0
  157. data/spec/dummy/config/puma.rb +34 -0
  158. data/spec/dummy/config/routes.rb +3 -0
  159. data/spec/dummy/config/spring.rb +6 -0
  160. data/spec/dummy/config/storage.yml +34 -0
  161. data/spec/dummy/config.ru +5 -0
  162. data/spec/dummy/db/schema.rb +167 -0
  163. data/spec/dummy/db/seeds.rb +1 -0
  164. data/spec/factories/anubis_group_locales.rb +7 -0
  165. data/spec/factories/anubis_group_menus.rb +7 -0
  166. data/spec/factories/anubis_groups.rb +6 -0
  167. data/spec/factories/anubis_menu_locales.rb +9 -0
  168. data/spec/factories/anubis_menus.rb +6 -0
  169. data/spec/factories/anubis_system_locales.rb +7 -0
  170. data/spec/factories/anubis_system_menus.rb +6 -0
  171. data/spec/factories/anubis_systems.rb +5 -0
  172. data/spec/factories/anubis_tenants.rb +7 -0
  173. data/spec/factories/anubis_users.rb +10 -0
  174. data/spec/integration/navigation_test.rb +7 -0
  175. data/spec/models/anoubis/group_locale_spec.rb +25 -0
  176. data/spec/models/anoubis/group_menu_spec.rb +50 -0
  177. data/spec/models/anoubis/group_spec.rb +52 -0
  178. data/spec/models/anoubis/menu_locale_spec.rb +31 -0
  179. data/spec/models/anoubis/menu_spec.rb +48 -0
  180. data/spec/models/anoubis/system_locale_spec.rb +20 -0
  181. data/spec/models/anoubis/system_menu_spec.rb +49 -0
  182. data/spec/models/anoubis/system_spec.rb +53 -0
  183. data/spec/models/anoubis/tenant_spec.rb +67 -0
  184. data/spec/models/anoubis/user_spec.rb +57 -0
  185. data/spec/rails_helper.rb +32 -0
  186. data/spec/requests/anoubis/users_request_spec.rb +5 -0
  187. data/spec/spec_helper.rb +13 -0
  188. metadata +408 -0
@@ -0,0 +1,225 @@
1
+ ##
2
+ # Main User model. Stores inforation about all users that can access to the portal.
3
+ class Anubis::Tenant::User < ApplicationRecord
4
+ # @!attribute patronymic
5
+ # @return [String] user's patronymic
6
+
7
+ # @!attribute login
8
+ # @return [String] user's full login with {Tenant#ident} suffix.
9
+
10
+ has_secure_password
11
+
12
+ # Redefines default table name
13
+ self.table_name = 'users'
14
+
15
+ before_validation :before_validation_anubis_user_on_create, on: :create
16
+ before_validation :before_validation_anubis_user_on_update, on: :update
17
+ before_save :before_save_anubis_user
18
+ before_destroy :before_destroy_anubis_user
19
+ after_destroy :after_destroy_anubis_user
20
+
21
+ # Email must be valid email address
22
+ VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
23
+
24
+ # @!attribute email
25
+ # @return [String] user's email
26
+ validates :email, presence: true, length: { maximum: 50 }, format: { with: VALID_EMAIL_REGEX }
27
+ validates :email, uniqueness: { case_sensitive: true, scope: [:tenant_id] }, if: :email_unique
28
+
29
+ # @!attribute name
30
+ # @return [String] user's name
31
+ validates :name, length: { maximum: 100 }
32
+ validates :name, presence: true, if: :name_presence
33
+
34
+ # @!attribute surname
35
+ # @return [String] user's surname
36
+ validates :surname, length: { maximum: 100 }
37
+ validates :surname, presence: true, if: :name_presence
38
+
39
+ validates :password, length: { in: 5..30 }, on: [:create]
40
+ validates :password, length: { in: 5..30 }, on: [:update], if: :password_changed?
41
+ validates :password_confirmation, length: { in: 5..30 }, on: [:create]
42
+ validates :password_confirmation, length: { in: 5..30 }, on: [:update], if: :password_changed?
43
+
44
+ # @!attribute auth_key
45
+ # @return [String] user's auth key. Variable is used for storing key to restore password or confirm email.
46
+ validates :auth_key, length: { maximum: 32 }
47
+
48
+ # @!attribute auth_key
49
+ # @return [Integer] user's session timeout. Default vaule is 3600
50
+ validates :timeout, presence: true, numericality: {only_integer: true, greater_than_or_equal_to: 0}
51
+
52
+ # @!attribute uuid_bin
53
+ # @return [Blob] user's binary representation of UUID
54
+ validates :uuid_bin, uniqueness: { case_sensitive: false, scope: [:tenant_id] }
55
+
56
+ # @!attribute status
57
+ # @return ['enabled', 'disabled'] the status of menu element.
58
+ # - 'enabled' --- user is enabled and can login to system.
59
+ # - 'disabled' --- user is disabled and can't login to system.
60
+ # - 'pending' --- user isn't confirmed.
61
+ enum status: {enabled: 0, disabled: 1, pending: 2}
62
+
63
+ # @!attribute uuid
64
+ # @return [String] user's UUID
65
+ attr_accessor :uuid
66
+
67
+ # @!attribute groups_access
68
+ # @return [Array] array of user access groups
69
+ attr_accessor :groups_access
70
+
71
+ # @!attribute tenant
72
+ # @return [Tenant] the tenant that owns this user.
73
+ belongs_to :tenant, class_name: 'Anubis::Tenant::Tenant'
74
+ has_many :user_groups, class_name: 'Anubis::Tenant::UserGroup'
75
+
76
+ has_one_attached :avatar
77
+
78
+ ##
79
+ # Is called before validation when new user is being created. Checks user parameters before create new user.
80
+ # Generates new UUID. Sets default system parameters for first user.
81
+ def before_validation_anubis_user_on_create
82
+ self.uuid = self.new_uuid
83
+ if self.id
84
+ if self.id == 1
85
+ self.password = 'admin'
86
+ self.password_confirmation = 'admin'
87
+ self.status = 0
88
+ self.tenant_id = 1
89
+ self.timeout = 3600
90
+ return true
91
+ end
92
+ end
93
+ validate_anubis_user true
94
+ end
95
+
96
+ ##
97
+ # Is called before validation when user is being updated. Checks user parameters before create new user.
98
+ # Generates new UUID. Sets default system parameters for first user.
99
+ def before_validation_anubis_user_on_update
100
+ validate_anubis_user false
101
+ end
102
+
103
+ ##
104
+ # Validates users element. Sets default missing parameters. Prevents changing tenant for existing user.
105
+ # @param is_new [Boolean] sets into true when user is being created
106
+ def validate_anubis_user(is_new)
107
+ self.locale = 'ru-RU' if !self.locale
108
+ self.timeout = 3600 if !self.timeout
109
+ self.tenant_id = self.tenant_id_was if !is_new # Can't change tenant for existing user
110
+ self.status = 0 if self.id == 1 # Can't disable Main Administrator
111
+
112
+ if !password.blank?
113
+ if password != password_confirmation
114
+ errors.add(:password, I18n.t('users.errors.different_passwords'))
115
+ errors.add(:password_confirmation, I18n.t('users.errors.different_passwords'))
116
+ return false
117
+ end
118
+ end
119
+
120
+ return true
121
+ end
122
+
123
+ ##
124
+ # Is called before user will be stored in database. Changes {#login} and {#email} values to lower case.
125
+ # Deletes user cache in Redis database when user's parameters has been changed.
126
+ def before_save_anubis_user
127
+ self.timezone = 'GMT' if !self.timezone
128
+ self.email = self.email.downcase
129
+ self.login = self.email+'.'+self.tenant.ident
130
+ self.redis.del(self.redis_prefix + 'user:' + self.uuid) if self.redis
131
+ end
132
+
133
+ ##
134
+ # Checks if password has been changed
135
+ # @return [Boolean] return true if password has been changed
136
+ def password_changed?
137
+ !password.blank?
138
+ end
139
+
140
+ ##
141
+ # Is called before delete user from database. Destroys all access groups for this user
142
+ def before_destroy_anubis_user
143
+ if self.id == 1
144
+ errors.add(:base, I18n.t('users.errors.cant_destroy_tenant_admin'))
145
+ throw(:abort, __method__)
146
+ end
147
+
148
+ Anubis::Tenant::UserGroup.where(user_id: self.id).delete_all
149
+ end
150
+
151
+ ##
152
+ # Is called after user was deleted from database. Also deletes all cache for this user from Redis database.
153
+ def after_destroy_anubis_user
154
+ if self.redis
155
+ self.redis.del self.uuid
156
+ self.redis.keys(self.uuid+'_*').each do |data|
157
+ self.redis.del data
158
+ end
159
+ end
160
+ end
161
+
162
+ ##
163
+ # UUID representations in string format
164
+ # @return [String] string representaion of user UUID
165
+ def uuid
166
+ self.bin_to_uuid self.uuid_bin
167
+ end
168
+
169
+ ##
170
+ # Sets UUID into binary format
171
+ # @param value [String] string representation of UUID
172
+ def uuid=(value)
173
+ self.uuid_bin = self.uuid_to_bin value
174
+ end
175
+
176
+ ##
177
+ # Excludes password from json output and uuid_bin from
178
+ # @param options [Hash] additional options
179
+ def to_json(options={})
180
+ options[:except] ||= [:password_digest, :uuid_bin]
181
+ super(options)
182
+ end
183
+
184
+ ##
185
+ # Returns user model system title
186
+ # @return [String] user system title
187
+ def sys_title
188
+ self.title
189
+ end
190
+
191
+ ##
192
+ # Attach groups to user json outputs
193
+ def as_json(options={})
194
+ h = super(options)
195
+ h[:groups_access] = []
196
+ self.user_groups.each do |ug|
197
+ h[:groups_access].push ug.group.full_ident
198
+ end
199
+ h
200
+ end
201
+
202
+ ##
203
+ # Array of user access group
204
+ def groups_access
205
+ @groups_access ||= get_groups_access
206
+ end
207
+
208
+ ##
209
+ # Generate user access groups
210
+ def get_groups_access
211
+ h = []
212
+ self.user_groups.each do |ug|
213
+ h[:groups_access].push ug.group.full_ident
214
+ end
215
+ h
216
+ end
217
+
218
+ def name_presence
219
+ true
220
+ end
221
+
222
+ def email_unique
223
+ true
224
+ end
225
+ end
@@ -0,0 +1,32 @@
1
+ ##
2
+ # UserGroup model. It links User and Group models.
3
+ class Anoubis::Tenant::UserGroup < ApplicationRecord
4
+ self.table_name = 'user_groups'
5
+
6
+ before_update :before_update_user_group
7
+ after_create :after_modify_user_group
8
+ after_destroy :after_modify_user_group
9
+
10
+ belongs_to :group, class_name: 'Anoubis::Tenant::Group'
11
+ validates :group, presence: true, uniqueness: { scope: [:user_id] }
12
+ belongs_to :user, class_name: 'Anoubis::Tenant::User'
13
+ validates :user, presence: true, uniqueness: { scope: [:group_id] }
14
+
15
+ ##
16
+ # Can't change elements
17
+ def before_update_user_group
18
+ self.user_id = self.user_id_was if self.user_id_changed?
19
+ self.group_id = self.group_id_was if self.group_id_changed?
20
+ end
21
+
22
+ ##
23
+ # Delete all redis keys of menu for defined user
24
+ def after_modify_user_group
25
+ if self.redis
26
+ self.redis.keys(self.redis_prefix + self.user.uuid.to_s + '_*').each do |data|
27
+ self.redis.del data
28
+ end
29
+ self.redis.del self.redis_prefix + self.user.uuid.to_s
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,16 @@
1
+ class Anoubis::CoreService
2
+ attr_accessor :redis
3
+
4
+ def initialize
5
+ self.redis = Redis.new
6
+ end
7
+
8
+ def redis_prefix
9
+ begin
10
+ value = Rails.configuration.redis_prefix
11
+ rescue
12
+ return ''
13
+ end
14
+ return value + ':'
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ class Anubis::SessionService < Anubis::CoreService
2
+ def initialize
3
+ super
4
+ end
5
+
6
+ def clear
7
+ self.redis.scan_each(:match => self.redis_prefix + 'session:*') do |key|
8
+ begin
9
+ data = JSON.parse redis.get(key), { symbolize_names: true }
10
+ rescue
11
+ data = {}
12
+ end
13
+ data[:ttl] = Time.now - 1.day unless data.key? :ttl
14
+ self.redis.del(key) if data[:ttl] < Time.now
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ class PresenceInTenantValidator < ActiveModel::EachValidator
2
+ def validate_each(record, attribute, value)
3
+ if value
4
+ if value.class.to_s.index 'ActiveRecord_Associations_CollectionProxy'
5
+ value.each do |dat|
6
+ if record.tenant_id != dat.tenant_id
7
+ record.errors.add(attribute, :not_in_tenant, message: I18n.t('activerecord.errors.models.'+record.model_name.i18n_key.to_s+'.attributes.'+attribute.to_s+'.not_in_tenant', :default => ['activerecord.errors.messages.not_in_tenant'.to_sym]))
8
+ return
9
+ end
10
+ end
11
+ else
12
+ if record.tenant_id != value.tenant_id
13
+ record.errors.add(attribute, :not_in_tenant, message: I18n.t('activerecord.errors.models.'+record.model_name.i18n_key.to_s+'.attributes.'+attribute.to_s+'.not_in_tenant', :default => ['activerecord.errors.messages.not_in_tenant'.to_sym]))
14
+ end
15
+ end
16
+ else
17
+ record.errors.add(attribute, :blank, message: I18n.t('activerecord.errors.models.'+record.model_name.i18n_key.to_s+'.attributes.'+attribute.to_s+'.blank', :default => ['activerecord.errors.messages.blank'.to_sym]))
18
+ end
19
+ end
20
+ end
@@ -0,0 +1 @@
1
+ Mime::Type.register "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", :xlsx
@@ -0,0 +1,120 @@
1
+ en:
2
+ success: Successful
3
+ errors:
4
+ no_api_version: API version not defined
5
+ invalid_locale: Invalid locale
6
+ access_not_allowed: Access not allowed
7
+ authentication_required: Authentication required
8
+ session_expired: Session expired
9
+ invalid_login_parameters: Invalid login parameters. Required 'login' and 'password'.
10
+ invalid_login_or_password: Invalid login or password
11
+ invalid_menu_output: Invalid menu output
12
+ internal_error: Internal error
13
+ update_error: Error updating data on server
14
+ delete_error: Error deleting data on server
15
+ incorrect_parameters: Incorrect request parameters
16
+ field_error: field error
17
+ install:
18
+ menu:
19
+ anoubis/admin:
20
+ title: Administration
21
+ page_title: System administration
22
+ anoubis/tenants:
23
+ title: Tenants
24
+ page_title: Tenants management
25
+ short_title: Tenants
26
+ anoubis/users:
27
+ title: Users
28
+ page_title: Users management
29
+ short_title: Users
30
+
31
+ anoubis:
32
+ default_tab: Default
33
+ default_tab_hint: This is default tab
34
+ install:
35
+ groups:
36
+ admin: Administrators
37
+ user: Users
38
+
39
+ tenant_title: System Tenant
40
+ system_title: Main System
41
+ admins_group: Administrators
42
+ admin_name: Administrator
43
+ admin_surname: Main
44
+ table:
45
+ buttons:
46
+ edit: "Edit: %{title}"
47
+ delete: "Delete: %{title}"
48
+ form:
49
+ titles:
50
+ edit: "Edit element: %{title}"
51
+ new: "Add new element"
52
+
53
+ tenants:
54
+ errors:
55
+ cant_change_ident: of system tetnant can't be changed
56
+ cant_destroy: System tetant can't be destroyed
57
+ has_childs: Tenant has child users or systems access
58
+ systems:
59
+ errors:
60
+ cant_change_ident: of main system can't be changed
61
+ cant_destroy: Main system can't be destroyed
62
+ has_childs: System has child groups
63
+ groups:
64
+ errors:
65
+ cant_change_admin_ident: of admin group can't be changed
66
+ cant_destroy_admin_group: Admin group of main system can't be destroyed
67
+ cant_destroy_group_with_users: Can't destroy group with users in it
68
+ users:
69
+ errors:
70
+ different_passwords: must be identical
71
+ cant_destroy_tenant_admin: Main Administrator can't be destroyed
72
+ menus:
73
+ errors:
74
+ has_childs: This menu has child sub menu
75
+ group_menus:
76
+ errors:
77
+ no_access: System of this group has no access to this menu
78
+
79
+ activerecord:
80
+ attributes:
81
+ anoubis/tenant/tenant:
82
+ title: Title
83
+ ident: Identifier
84
+ anoubis/tenant/system:
85
+ title: Title
86
+ ident: Identifier
87
+ anoubis/tenant/group:
88
+ title: Title
89
+ ident: Identifier
90
+ anoubis/tenant/user:
91
+ login: Login
92
+ email: Email
93
+ name: Name
94
+ surname: Surname
95
+ timezone: Timezone
96
+ password: Password
97
+ password_confirmation: Password confirmation
98
+ phone: Phone
99
+ auth_key: Authorization key
100
+ recover_key: Recovery key
101
+ status: Status
102
+ tenant: Tenant
103
+ timeout: Session timeout
104
+ anoubis/tenant/user_group:
105
+ group: Group
106
+ group_id: Group
107
+ user: User
108
+ anoubis/tenant/tenant_system:
109
+ tenant: Tenant
110
+ system: System
111
+ anoubis/tenant/menu:
112
+ mode: Path
113
+ action: Action
114
+ page_size: Page Size
115
+ position: Position
116
+ anoubis/tenant/menu_locale:
117
+ title: Title
118
+ page_title: Page Title
119
+ short_title: Short Title
120
+
@@ -0,0 +1,245 @@
1
+ ru:
2
+ all: Все
3
+ success: Успешное завершение
4
+ actions:
5
+ edit: "Редактировать: %{title}"
6
+ delete: "Удалить: %{title}"
7
+ errors:
8
+ no_api_version: Не указана версия API
9
+ invalid_locale: Некорректная версия локали
10
+ access_not_allowed: Доступ запрещен
11
+ authentication_required: Требуется авторизация пользователя
12
+ session_expired: Сессия завершена
13
+ invalid_login_parameters: Некорректные параметры входа. Требуется задать 'login' и 'password'.
14
+ invalid_login_or_password: Некорректный логин или пароль.
15
+ invalid_menu_output: Некорректный вывод меню
16
+ internal_error: Внутренняя ошибка сервера
17
+ update_error: Ошибка обновления данных на сервере
18
+ delete_error: Ошибка удаления данных на сервере
19
+ incorrect_parameters: Некорректные параметры запроса
20
+ field_error: ошибка поля
21
+ install:
22
+ menu:
23
+ anoubis/admin:
24
+ title: Управление
25
+ page_title: Управление системой
26
+ anoubis/tenants:
27
+ title: Тенанты
28
+ page_title: Управление тенантами
29
+ short_title: Тенанты
30
+ anoubis/users:
31
+ title: Пользователи
32
+ page_title: Управление пользователями
33
+ short_title: Пользователи
34
+
35
+ anoubis:
36
+ core:
37
+ success: Завершено корректно
38
+ errors:
39
+ incorrect_system: Некорректная система
40
+ incorrect_parameters: Некорректные параметры
41
+ error_changing_data: Ошибка изменения данных
42
+
43
+ default_tab: Основная
44
+ default_tab_hint: Это основная вкладка
45
+ months:
46
+ main:
47
+ - Январь
48
+ - Февраль
49
+ - Март
50
+ - Апрель
51
+ - Май
52
+ - Июнь
53
+ - Июль
54
+ - Август
55
+ - Сентябрь
56
+ - Октябрь
57
+ - Ноябрь
58
+ - Декабрь
59
+ second:
60
+ - Января
61
+ - Февраля
62
+ - Марта
63
+ - Апреля
64
+ - Мая
65
+ - Июня
66
+ - Июля
67
+ - Августа
68
+ - Сентября
69
+ - Октября
70
+ - Ноября
71
+ - Декабря
72
+ short:
73
+ - янв
74
+ - фев
75
+ - мар
76
+ - апр
77
+ - май
78
+ - июн
79
+ - июл
80
+ - авг
81
+ - сен
82
+ - окт
83
+ - ноя
84
+ - дек
85
+ install:
86
+ groups:
87
+ admin: Администраторы
88
+ user: Пользователи
89
+
90
+ tenant_title: Основной тенант
91
+ system_title: Основная система
92
+ admins_group: Администраторы
93
+ admin_name: Администратор
94
+ admin_surname: Главный
95
+ table:
96
+ buttons:
97
+ edit: "Редактировать: %{title}"
98
+ delete: "Удалить: %{title}"
99
+ form:
100
+ titles:
101
+ edit: "Редактирование элемента: %{title}"
102
+ show: "Просмотр элемента: %{title}"
103
+ new: "Добавление нового элемента"
104
+
105
+ tenants:
106
+ errors:
107
+ cant_change_ident: основного тенанта изменить нельзя
108
+ cant_destroy: Невозможно удалить основной тенант
109
+ has_childs: Тенант содержит пользователей или имеет доступ к системам
110
+ systems:
111
+ errors:
112
+ cant_change_ident: основной системы изменить нельзя
113
+ cant_destroy: Невозможно удалить основную систему
114
+ has_childs: Система содержит группы
115
+ groups:
116
+ errors:
117
+ cant_change_admin_ident: группы администрирования изменить нельзя
118
+ cant_destroy_admin_group: Группа администраторов основной системы не может быть удалена
119
+ cant_destroy_group_with_users: Нельзя удалить группу содержащую пользователей
120
+ users:
121
+ errors:
122
+ different_passwords: должен быть идентичным
123
+ cant_destroy_tenant_admin: Главный Администратор не может быть удален
124
+ menus:
125
+ errors:
126
+ has_childs: Меню имеет вложенные пункты меню
127
+ group_menus:
128
+ errors:
129
+ no_access: Система которой принадлежит группа не имеет доступа к данному пункту меню
130
+
131
+ activerecord:
132
+ options:
133
+ anoubis/locale:
134
+ ru: Русский
135
+ en: Английский
136
+ kz: Казахский
137
+ anoubis/group_menu:
138
+ access:
139
+ not: Не определен
140
+ read: Чтение
141
+ write: Запись
142
+ disabled: Блокирован
143
+ attributes:
144
+ anoubis/tenant:
145
+ title: Название
146
+ ident: Идентификатор
147
+ anoubis/system:
148
+ title: Название
149
+ ident: Идентификатор
150
+ anoubis/group:
151
+ title: Название
152
+ ident: Идентификатор
153
+ anoubis/user:
154
+ login: Логин
155
+ email: Электронный адрес
156
+ name: Имя
157
+ surname: Фамилия
158
+ timezone: Временная зона
159
+ password: Пароль
160
+ password_confirmation: Повтор пароля
161
+ phone: Телефон
162
+ auth_key: Ключ авторизации
163
+ recover_key: Ключ восстановления
164
+ status: Статус
165
+ tenant: Тенант
166
+ timeout: Время завершения сессии
167
+ anoubis/user_group:
168
+ group: Группа
169
+ group_id: Группа
170
+ user: Пользователь
171
+ anoubis/tenant_system:
172
+ tenant: Тенант
173
+ system: Система
174
+ anoubis/menu:
175
+ mode: Путь
176
+ action: Действие
177
+ page_size: Количество строк таблицы
178
+ position: Позиция
179
+ anoubis/menu_locale:
180
+ title: Название
181
+ page_title: Заголовок страницы
182
+ short_title: Короткое название
183
+
184
+ errors:
185
+ messages:
186
+ not_in_tenant: отсутсвует в тенанте
187
+ required: должен существовать
188
+ too_short:
189
+ one: "должен быть длиннее одного символа"
190
+ other: "должен быть больше %{count} символов"
191
+ too_long:
192
+ one: "должен быть длиннее одного символа"
193
+ other: "должен быть короче %{count} символов"
194
+ invalid: некорректен
195
+ record_invalid: некорректен
196
+ taken: уже существует
197
+ blank: не может быть пустым
198
+ not_an_integer: должен быть целым числом
199
+ not_a_number: должен быть вещественным числом
200
+ greater_than_or_equal_to: "должен быть больше или равен %{count}"
201
+ less_than_or_equal_to: "должен быть меньше или равен %{count}"
202
+ inclusion: "значение не попадает в список"
203
+
204
+ models:
205
+ anoubis/tenant/tenant:
206
+ attributes:
207
+ title:
208
+ too_short: "должно быть больше %{count} символов"
209
+ too_long: "должно быть короче %{count} символов"
210
+ anoubis/tenant/system:
211
+ attributes:
212
+ title:
213
+ too_short: "должно быть больше %{count} символов"
214
+ too_long: "должно быть короче %{count} символов"
215
+ anoubis/tenant/user_group:
216
+ attributes:
217
+ group:
218
+ required: должна существовать
219
+ anoubis/tenant/user:
220
+ attributes:
221
+ name:
222
+ too_long: "должно быть короче %{count} символов"
223
+ surname:
224
+ blank: не может быть пустой
225
+ too_long: "должна быть короче %{count} символов"
226
+ timeout:
227
+ not_a_number: "должно быть целым числом"
228
+ greater_than_or_equal_to: "должно быть больше или равно %{count}"
229
+
230
+ anoubis/tenant/tenant_system:
231
+ attributes:
232
+ system:
233
+ required: должна существовать
234
+ anoubis/tenant/menu:
235
+ attributes:
236
+ position:
237
+ not_a_number: должна быть целым числом
238
+ page_size:
239
+ greater_than_or_equal_to: "должно быть больше или равно %{count}"
240
+ anoubis/tenant/menu_locale:
241
+ attributes:
242
+ title:
243
+ too_short: "должно быть больше %{count} символов"
244
+ too_long: "должно быть короче %{count} символов"
245
+