biovision-base 0.5.170614 → 0.7.170709

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -0
  3. data/app/assets/images/biovision/base/placeholders/image.svg +1 -1
  4. data/app/assets/images/biovision/base/placeholders/region_image.svg +1 -0
  5. data/app/assets/stylesheets/biovision/base/admin.scss +226 -31
  6. data/app/assets/stylesheets/biovision/base/biovision.scss +45 -104
  7. data/app/assets/stylesheets/biovision/base/buttons.scss +3 -2
  8. data/app/assets/stylesheets/biovision/base/default.scss +66 -45
  9. data/app/assets/stylesheets/biovision/base/default_admin.scss +10 -0
  10. data/app/assets/stylesheets/biovision/base/default_application.scss +8 -0
  11. data/app/assets/stylesheets/biovision/base/filters.scss +4 -4
  12. data/app/assets/stylesheets/biovision/base/layout.scss +113 -0
  13. data/app/assets/stylesheets/biovision/base/message-box.scss +3 -3
  14. data/app/assets/stylesheets/biovision/base/regions.scss +9 -0
  15. data/app/assets/stylesheets/biovision/base/tootik.scss +6 -6
  16. data/app/assets/stylesheets/biovision/base/track.scss +7 -6
  17. data/app/assets/stylesheets/biovision/base/users.scss +64 -0
  18. data/app/controllers/admin/login_attempts_controller.rb +6 -0
  19. data/app/controllers/admin/privileges_controller.rb +37 -1
  20. data/app/controllers/admin/regions_controller.rb +37 -0
  21. data/app/controllers/admin/users_controller.rb +2 -2
  22. data/app/controllers/authentication_controller.rb +27 -26
  23. data/app/controllers/concerns/authentication.rb +20 -0
  24. data/app/controllers/my/confirmations_controller.rb +8 -3
  25. data/app/controllers/my/login_attempts_controller.rb +9 -0
  26. data/app/controllers/my/profiles_controller.rb +10 -2
  27. data/app/controllers/my/tokens_controller.rb +20 -0
  28. data/app/controllers/regions_controller.rb +73 -0
  29. data/app/helpers/biovision_regions_helper.rb +22 -0
  30. data/app/mailers/application_mailer.rb +5 -0
  31. data/app/mailers/user_mailer.rb +8 -0
  32. data/app/models/central_region.rb +49 -0
  33. data/app/models/concerns/required_unique_name.rb +1 -1
  34. data/app/models/concerns/required_unique_slug.rb +1 -1
  35. data/app/models/login_attempt.rb +24 -0
  36. data/app/models/privilege.rb +176 -1
  37. data/app/models/region.rb +100 -0
  38. data/app/models/user.rb +118 -1
  39. data/app/models/user_privilege.rb +52 -1
  40. data/app/services/code_manager/confirmation.rb +1 -1
  41. data/app/services/user_bouncer.rb +37 -0
  42. data/app/uploaders/header_image_uploader.rb +50 -0
  43. data/app/uploaders/region_image_uploader.rb +53 -0
  44. data/app/views/admin/agents/entity/_preview.jbuilder +8 -0
  45. data/app/views/admin/codes/index.html.erb +1 -1
  46. data/app/views/admin/editable_pages/index.html.erb +1 -1
  47. data/app/views/admin/index/index.html.erb +4 -0
  48. data/app/views/admin/login_attempts/_nav_item.html.erb +6 -0
  49. data/app/views/admin/login_attempts/entity/_in_list.html.erb +16 -0
  50. data/app/views/admin/login_attempts/included/_agents.jbuilder +3 -0
  51. data/app/views/admin/login_attempts/included/_users.jbuilder +3 -0
  52. data/app/views/admin/login_attempts/index.html.erb +16 -0
  53. data/app/views/admin/login_attempts/index.jbuilder +28 -0
  54. data/app/views/admin/privilege_groups/index.html.erb +1 -1
  55. data/app/views/admin/privileges/_toggleable.html.erb +7 -0
  56. data/app/views/admin/privileges/entity/_in_list.html.erb +1 -0
  57. data/app/views/admin/privileges/entity/_region.html.erb +12 -0
  58. data/app/views/admin/privileges/regions.jbuilder +10 -0
  59. data/app/views/admin/privileges/show.html.erb +2 -0
  60. data/app/views/admin/regions/_nav_item.html.erb +2 -0
  61. data/app/views/admin/regions/_toggleable.html.erb +7 -0
  62. data/app/views/admin/regions/entity/_in_list.html.erb +32 -0
  63. data/app/views/admin/regions/index.html.erb +22 -0
  64. data/app/views/admin/regions/show.html.erb +95 -0
  65. data/app/views/admin/tokens/index.html.erb +1 -1
  66. data/app/views/admin/users/_search.html.erb +1 -1
  67. data/app/views/admin/users/entity/_preview.jbuilder +12 -0
  68. data/app/views/admin/users/entity/_privilege.html.erb +23 -7
  69. data/app/views/admin/users/entity/_privilege_tree.html.erb +2 -2
  70. data/app/views/admin/users/privileges.html.erb +47 -12
  71. data/app/views/admin/users/show.html.erb +17 -1
  72. data/app/views/admin/users/tokens.html.erb +1 -1
  73. data/app/views/authentication/new.html.erb +1 -2
  74. data/app/views/layouts/admin/_footer.html.erb +8 -0
  75. data/app/views/layouts/application/_footer.html.erb +5 -0
  76. data/app/views/layouts/application/_header.html.erb +9 -0
  77. data/app/views/layouts/application/header/_authentication.html.erb +7 -0
  78. data/app/views/layouts/application/header/_logo.html.erb +3 -0
  79. data/app/views/layouts/application/header/_navigation.html.erb +0 -0
  80. data/app/views/layouts/application/header/authentication/_links.html.erb +4 -0
  81. data/app/views/layouts/application/header/authentication/_plate.html.erb +4 -0
  82. data/app/views/layouts/mailer.html.erb +13 -0
  83. data/app/views/layouts/mailer.text.erb +1 -0
  84. data/app/views/my/confirmations/show.html.erb +11 -1
  85. data/app/views/my/index/index.html.erb +6 -4
  86. data/app/views/{admin/tokens → my/login_attempts}/_list.html.erb +1 -1
  87. data/app/views/my/login_attempts/_nav_item.html.erb +6 -0
  88. data/app/views/my/login_attempts/entity/_in_list.html.erb +13 -0
  89. data/app/views/my/login_attempts/included/_agents.jbuilder +7 -0
  90. data/app/views/my/login_attempts/index.html.erb +13 -0
  91. data/app/views/my/login_attempts/index.jbuilder +22 -0
  92. data/app/views/my/profiles/_nav_item.html.erb +6 -0
  93. data/app/views/my/profiles/new/_form.html.erb +49 -23
  94. data/app/views/my/profiles/new.html.erb +2 -2
  95. data/app/views/{admin/codes → my/tokens}/_list.html.erb +1 -1
  96. data/app/views/my/tokens/_nav_item.html.erb +6 -0
  97. data/app/views/my/tokens/_toggleable.html.erb +7 -0
  98. data/app/views/my/tokens/entity/_in_list.html.erb +18 -0
  99. data/app/views/my/tokens/index.html.erb +13 -0
  100. data/app/views/privileges/_form.html.erb +7 -0
  101. data/app/views/regions/_form.html.erb +73 -0
  102. data/app/views/regions/edit.html.erb +20 -0
  103. data/app/views/regions/new.html.erb +17 -0
  104. data/app/views/shared/_counters.html.erb +0 -0
  105. data/app/views/shared/_pagination.jbuilder +9 -0
  106. data/app/views/{admin/editable_pages → shared/admin}/_list.html.erb +2 -2
  107. data/app/views/user_mailer/login_attempt.html.erb +7 -0
  108. data/config/locales/common-ru.yml +5 -0
  109. data/config/locales/editable-pages-ru.yml +1 -1
  110. data/config/locales/regions-ru.yml +62 -0
  111. data/config/locales/users-ru.yml +48 -6
  112. data/config/routes.rb +19 -2
  113. data/db/migrate/20170301000201_create_regions.rb +32 -0
  114. data/db/migrate/20170302000001_create_users.rb +1 -0
  115. data/db/migrate/20170302000101_create_privileges.rb +2 -0
  116. data/db/migrate/20170302000102_create_user_privileges.rb +1 -0
  117. data/db/migrate/20170302000103_create_privilege_groups.rb +1 -0
  118. data/db/migrate/20170302000104_create_privilege_group_privileges.rb +4 -0
  119. data/db/migrate/20170629120000_create_login_attempts.rb +19 -0
  120. data/lib/biovision/base/engine.rb +6 -0
  121. data/lib/biovision/base/privilege_methods.rb +21 -3
  122. data/lib/biovision/base/version.rb +1 -1
  123. data/lib/tasks/{biovision/agents.rake → agents.rake} +0 -0
  124. data/lib/tasks/{biovision/browsers.rake → browsers.rake} +0 -0
  125. data/lib/tasks/{biovision/codes.rake → codes.rake} +0 -0
  126. data/lib/tasks/regions.rake +70 -0
  127. data/lib/tasks/{biovision/tokens.rake → tokens.rake} +0 -0
  128. data/lib/tasks/{biovision/users.rake → users.rake} +0 -0
  129. metadata +75 -17
  130. data/app/assets/stylesheets/biovision/base/fonts.scss +0 -9
  131. data/app/controllers/concerns/biovision/admin/privileges.rb +0 -34
  132. data/app/models/concerns/biovision/privilege_base.rb +0 -143
  133. data/app/models/concerns/biovision/user_base.rb +0 -124
  134. data/app/models/concerns/biovision/user_privilege_base.rb +0 -46
  135. data/app/views/admin/privilege_groups/_list.html.erb +0 -11
  136. data/app/views/authentication/_info.html.erb +0 -8
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biovision-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.170614
4
+ version: 0.7.170709
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Khan-Magomedov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-14 00:00:00.000000000 Z
11
+ date: 2017-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -191,26 +191,33 @@ files:
191
191
  - app/assets/images/biovision/base/icons/world.svg
192
192
  - app/assets/images/biovision/base/placeholders/image.svg
193
193
  - app/assets/images/biovision/base/placeholders/photo.svg
194
+ - app/assets/images/biovision/base/placeholders/region_image.svg
194
195
  - app/assets/images/biovision/base/placeholders/user.svg
195
196
  - app/assets/javascripts/biovision/base/biovision.js
196
197
  - app/assets/stylesheets/biovision/base/admin.scss
197
198
  - app/assets/stylesheets/biovision/base/biovision.scss
198
199
  - app/assets/stylesheets/biovision/base/buttons.scss
199
200
  - app/assets/stylesheets/biovision/base/default.scss
201
+ - app/assets/stylesheets/biovision/base/default_admin.scss
202
+ - app/assets/stylesheets/biovision/base/default_application.scss
200
203
  - app/assets/stylesheets/biovision/base/filters.scss
201
- - app/assets/stylesheets/biovision/base/fonts.scss
204
+ - app/assets/stylesheets/biovision/base/layout.scss
202
205
  - app/assets/stylesheets/biovision/base/message-box.scss
203
206
  - app/assets/stylesheets/biovision/base/pagination.scss
207
+ - app/assets/stylesheets/biovision/base/regions.scss
204
208
  - app/assets/stylesheets/biovision/base/tootik.scss
205
209
  - app/assets/stylesheets/biovision/base/track.scss
210
+ - app/assets/stylesheets/biovision/base/users.scss
206
211
  - app/controllers/admin/agents_controller.rb
207
212
  - app/controllers/admin/browsers_controller.rb
208
213
  - app/controllers/admin/codes_controller.rb
209
214
  - app/controllers/admin/editable_pages_controller.rb
210
215
  - app/controllers/admin/index_controller.rb
216
+ - app/controllers/admin/login_attempts_controller.rb
211
217
  - app/controllers/admin/metrics_controller.rb
212
218
  - app/controllers/admin/privilege_groups_controller.rb
213
219
  - app/controllers/admin/privileges_controller.rb
220
+ - app/controllers/admin/regions_controller.rb
214
221
  - app/controllers/admin/tokens_controller.rb
215
222
  - app/controllers/admin/users_controller.rb
216
223
  - app/controllers/admin_controller.rb
@@ -219,7 +226,6 @@ files:
219
226
  - app/controllers/browsers_controller.rb
220
227
  - app/controllers/codes_controller.rb
221
228
  - app/controllers/concerns/authentication.rb
222
- - app/controllers/concerns/biovision/admin/privileges.rb
223
229
  - app/controllers/concerns/entity_priority.rb
224
230
  - app/controllers/concerns/lockable_entity.rb
225
231
  - app/controllers/concerns/toggleable_entity.rb
@@ -228,14 +234,18 @@ files:
228
234
  - app/controllers/metrics_controller.rb
229
235
  - app/controllers/my/confirmations_controller.rb
230
236
  - app/controllers/my/index_controller.rb
237
+ - app/controllers/my/login_attempts_controller.rb
231
238
  - app/controllers/my/profiles_controller.rb
232
239
  - app/controllers/my/recoveries_controller.rb
240
+ - app/controllers/my/tokens_controller.rb
233
241
  - app/controllers/privilege_groups_controller.rb
234
242
  - app/controllers/privileges_controller.rb
235
243
  - app/controllers/profiles_controller.rb
244
+ - app/controllers/regions_controller.rb
236
245
  - app/controllers/tokens_controller.rb
237
246
  - app/controllers/users_controller.rb
238
247
  - app/helpers/biovision_helper.rb
248
+ - app/helpers/biovision_regions_helper.rb
239
249
  - app/helpers/biovision_users_helper.rb
240
250
  - app/helpers/codes_helper.rb
241
251
  - app/helpers/editable_pages_helper.rb
@@ -243,15 +253,15 @@ files:
243
253
  - app/helpers/tracking_helper.rb
244
254
  - app/jobs/application_job.rb
245
255
  - app/jobs/clean_tokens_job.rb
256
+ - app/mailers/application_mailer.rb
246
257
  - app/mailers/code_sender.rb
258
+ - app/mailers/user_mailer.rb
247
259
  - app/models/agent.rb
248
260
  - app/models/application_record.rb
249
261
  - app/models/browser.rb
262
+ - app/models/central_region.rb
250
263
  - app/models/code.rb
251
264
  - app/models/code_type.rb
252
- - app/models/concerns/biovision/privilege_base.rb
253
- - app/models/concerns/biovision/user_base.rb
254
- - app/models/concerns/biovision/user_privilege_base.rb
255
265
  - app/models/concerns/has_owner.rb
256
266
  - app/models/concerns/required_unique_name.rb
257
267
  - app/models/concerns/required_unique_slug.rb
@@ -259,11 +269,13 @@ files:
259
269
  - app/models/editable_page.rb
260
270
  - app/models/foreign_site.rb
261
271
  - app/models/foreign_user.rb
272
+ - app/models/login_attempt.rb
262
273
  - app/models/metric.rb
263
274
  - app/models/metric_value.rb
264
275
  - app/models/privilege.rb
265
276
  - app/models/privilege_group.rb
266
277
  - app/models/privilege_group_privilege.rb
278
+ - app/models/region.rb
267
279
  - app/models/token.rb
268
280
  - app/models/user.rb
269
281
  - app/models/user_privilege.rb
@@ -272,13 +284,17 @@ files:
272
284
  - app/services/code_manager/confirmation.rb
273
285
  - app/services/code_manager/invitation.rb
274
286
  - app/services/code_manager/recovery.rb
287
+ - app/services/user_bouncer.rb
275
288
  - app/uploaders/avatar_uploader.rb
276
289
  - app/uploaders/editable_page_image_uploader.rb
290
+ - app/uploaders/header_image_uploader.rb
291
+ - app/uploaders/region_image_uploader.rb
277
292
  - app/views/admin/agents/_filter.html.erb
278
293
  - app/views/admin/agents/_list.html.erb
279
294
  - app/views/admin/agents/_nav_item.html.erb
280
295
  - app/views/admin/agents/_toggleable.html.erb
281
296
  - app/views/admin/agents/entity/_in_list.html.erb
297
+ - app/views/admin/agents/entity/_preview.jbuilder
282
298
  - app/views/admin/agents/index.html.erb
283
299
  - app/views/admin/agents/show.html.erb
284
300
  - app/views/admin/browsers/_list.html.erb
@@ -288,36 +304,46 @@ files:
288
304
  - app/views/admin/browsers/entity/_in_list.html.erb
289
305
  - app/views/admin/browsers/index.html.erb
290
306
  - app/views/admin/browsers/show.html.erb
291
- - app/views/admin/codes/_list.html.erb
292
307
  - app/views/admin/codes/_nav_item.html.erb
293
308
  - app/views/admin/codes/entity/_in_list.html.erb
294
309
  - app/views/admin/codes/index.html.erb
295
310
  - app/views/admin/codes/show.html.erb
296
- - app/views/admin/editable_pages/_list.html.erb
297
311
  - app/views/admin/editable_pages/_nav_item.html.erb
298
312
  - app/views/admin/editable_pages/entity/_in_list.html.erb
299
313
  - app/views/admin/editable_pages/index.html.erb
300
314
  - app/views/admin/editable_pages/show.html.erb
301
315
  - app/views/admin/index/index.html.erb
316
+ - app/views/admin/login_attempts/_nav_item.html.erb
317
+ - app/views/admin/login_attempts/entity/_in_list.html.erb
318
+ - app/views/admin/login_attempts/included/_agents.jbuilder
319
+ - app/views/admin/login_attempts/included/_users.jbuilder
320
+ - app/views/admin/login_attempts/index.html.erb
321
+ - app/views/admin/login_attempts/index.jbuilder
302
322
  - app/views/admin/metrics/_list.html.erb
303
323
  - app/views/admin/metrics/_nav_item.html.erb
304
324
  - app/views/admin/metrics/data.jbuilder
305
325
  - app/views/admin/metrics/index.html.erb
306
326
  - app/views/admin/metrics/show.html.erb
307
- - app/views/admin/privilege_groups/_list.html.erb
308
327
  - app/views/admin/privilege_groups/_nav_item.html.erb
309
328
  - app/views/admin/privilege_groups/entity/_in_list.html.erb
310
329
  - app/views/admin/privilege_groups/index.html.erb
311
330
  - app/views/admin/privilege_groups/show.html.erb
312
331
  - app/views/admin/privileges/_list.html.erb
313
332
  - app/views/admin/privileges/_nav_item.html.erb
333
+ - app/views/admin/privileges/_toggleable.html.erb
314
334
  - app/views/admin/privileges/entity/_groups.html.erb
315
335
  - app/views/admin/privileges/entity/_in_list.html.erb
336
+ - app/views/admin/privileges/entity/_region.html.erb
316
337
  - app/views/admin/privileges/index.html.erb
338
+ - app/views/admin/privileges/regions.jbuilder
317
339
  - app/views/admin/privileges/show.html.erb
318
340
  - app/views/admin/privileges/users.html.erb
341
+ - app/views/admin/regions/_nav_item.html.erb
342
+ - app/views/admin/regions/_toggleable.html.erb
343
+ - app/views/admin/regions/entity/_in_list.html.erb
344
+ - app/views/admin/regions/index.html.erb
345
+ - app/views/admin/regions/show.html.erb
319
346
  - app/views/admin/tokens/_filter.html.erb
320
- - app/views/admin/tokens/_list.html.erb
321
347
  - app/views/admin/tokens/_nav_item.html.erb
322
348
  - app/views/admin/tokens/_toggleable.html.erb
323
349
  - app/views/admin/tokens/entity/_in_list.html.erb
@@ -330,6 +356,7 @@ files:
330
356
  - app/views/admin/users/_toggleable.html.erb
331
357
  - app/views/admin/users/codes.html.erb
332
358
  - app/views/admin/users/entity/_in_list.html.erb
359
+ - app/views/admin/users/entity/_preview.jbuilder
333
360
  - app/views/admin/users/entity/_privilege.html.erb
334
361
  - app/views/admin/users/entity/_privilege_tree.html.erb
335
362
  - app/views/admin/users/index.html.erb
@@ -351,7 +378,6 @@ files:
351
378
  - app/views/application/unauthorized.html.erb
352
379
  - app/views/application/unauthorized.jbuilder
353
380
  - app/views/authentication/_form.html.erb
354
- - app/views/authentication/_info.html.erb
355
381
  - app/views/authentication/new.html.erb
356
382
  - app/views/browsers/_form.html.erb
357
383
  - app/views/browsers/edit.html.erb
@@ -370,18 +396,39 @@ files:
370
396
  - app/views/layouts/admin/_footer.html.erb
371
397
  - app/views/layouts/admin/_header.html.erb
372
398
  - app/views/layouts/admin/header/_logo.html.erb
399
+ - app/views/layouts/application/_footer.html.erb
400
+ - app/views/layouts/application/_header.html.erb
401
+ - app/views/layouts/application/header/_authentication.html.erb
402
+ - app/views/layouts/application/header/_logo.html.erb
403
+ - app/views/layouts/application/header/_navigation.html.erb
404
+ - app/views/layouts/application/header/authentication/_links.html.erb
405
+ - app/views/layouts/application/header/authentication/_plate.html.erb
406
+ - app/views/layouts/mailer.html.erb
407
+ - app/views/layouts/mailer.text.erb
373
408
  - app/views/metrics/_form.html.erb
374
409
  - app/views/metrics/edit.html.erb
375
410
  - app/views/metrics/index.jbuilder
376
411
  - app/views/metrics/show.jbuilder
377
412
  - app/views/my/confirmations/show.html.erb
378
413
  - app/views/my/index/index.html.erb
414
+ - app/views/my/login_attempts/_list.html.erb
415
+ - app/views/my/login_attempts/_nav_item.html.erb
416
+ - app/views/my/login_attempts/entity/_in_list.html.erb
417
+ - app/views/my/login_attempts/included/_agents.jbuilder
418
+ - app/views/my/login_attempts/index.html.erb
419
+ - app/views/my/login_attempts/index.jbuilder
420
+ - app/views/my/profiles/_nav_item.html.erb
379
421
  - app/views/my/profiles/edit.html.erb
380
422
  - app/views/my/profiles/edit/_form.html.erb
381
423
  - app/views/my/profiles/new.html.erb
382
424
  - app/views/my/profiles/new/_form.html.erb
383
425
  - app/views/my/profiles/show.html.erb
384
426
  - app/views/my/recoveries/show.html.erb
427
+ - app/views/my/tokens/_list.html.erb
428
+ - app/views/my/tokens/_nav_item.html.erb
429
+ - app/views/my/tokens/_toggleable.html.erb
430
+ - app/views/my/tokens/entity/_in_list.html.erb
431
+ - app/views/my/tokens/index.html.erb
385
432
  - app/views/privilege_groups/_form.html.erb
386
433
  - app/views/privilege_groups/edit.html.erb
387
434
  - app/views/privilege_groups/new.html.erb
@@ -390,19 +437,26 @@ files:
390
437
  - app/views/privileges/new.html.erb
391
438
  - app/views/profiles/_profile.html.erb
392
439
  - app/views/profiles/show.html.erb
440
+ - app/views/regions/_form.html.erb
441
+ - app/views/regions/edit.html.erb
442
+ - app/views/regions/new.html.erb
443
+ - app/views/shared/_counters.html.erb
393
444
  - app/views/shared/_flash_messages.html.erb
394
445
  - app/views/shared/_list_of_errors.html.erb
395
446
  - app/views/shared/_meta_texts.html.erb
396
447
  - app/views/shared/_nothing_found.html.erb
448
+ - app/views/shared/_pagination.jbuilder
397
449
  - app/views/shared/_track.html.erb
398
450
  - app/views/shared/actions/_locks.html.erb
399
451
  - app/views/shared/actions/_priority_changer.html.erb
400
452
  - app/views/shared/admin/_breadcrumbs.html.erb
453
+ - app/views/shared/admin/_list.html.erb
401
454
  - app/views/shared/editable_pages/_body.html.erb
402
455
  - app/views/shared/filter/_flag.html.erb
403
456
  - app/views/tokens/_form.html.erb
404
457
  - app/views/tokens/edit.html.erb
405
458
  - app/views/tokens/new.html.erb
459
+ - app/views/user_mailer/login_attempt.html.erb
406
460
  - app/views/users/_form.html.erb
407
461
  - app/views/users/edit.html.erb
408
462
  - app/views/users/new.html.erb
@@ -411,6 +465,7 @@ files:
411
465
  - config/locales/common-ru.yml
412
466
  - config/locales/editable-pages-ru.yml
413
467
  - config/locales/plurals.rb
468
+ - config/locales/regions-ru.yml
414
469
  - config/locales/track-ru.yml
415
470
  - config/locales/users-ru.yml
416
471
  - config/routes.rb
@@ -418,6 +473,7 @@ files:
418
473
  - db/migrate/20170301000002_create_metric_values.rb
419
474
  - db/migrate/20170301000101_create_browsers.rb
420
475
  - db/migrate/20170301000102_create_agents.rb
476
+ - db/migrate/20170301000201_create_regions.rb
421
477
  - db/migrate/20170302000001_create_users.rb
422
478
  - db/migrate/20170302000002_create_tokens.rb
423
479
  - db/migrate/20170302000003_create_code_types.rb
@@ -429,17 +485,19 @@ files:
429
485
  - db/migrate/20170320000000_create_editable_pages.rb
430
486
  - db/migrate/20170425000001_create_foreign_sites.rb
431
487
  - db/migrate/20170425000002_create_foreign_users.rb
488
+ - db/migrate/20170629120000_create_login_attempts.rb
432
489
  - lib/biovision/base.rb
433
490
  - lib/biovision/base/base_methods.rb
434
491
  - lib/biovision/base/engine.rb
435
492
  - lib/biovision/base/privilege_methods.rb
436
493
  - lib/biovision/base/version.rb
437
- - lib/tasks/biovision/agents.rake
494
+ - lib/tasks/agents.rake
438
495
  - lib/tasks/biovision/base_tasks.rake
439
- - lib/tasks/biovision/browsers.rake
440
- - lib/tasks/biovision/codes.rake
441
- - lib/tasks/biovision/tokens.rake
442
- - lib/tasks/biovision/users.rake
496
+ - lib/tasks/browsers.rake
497
+ - lib/tasks/codes.rake
498
+ - lib/tasks/regions.rake
499
+ - lib/tasks/tokens.rake
500
+ - lib/tasks/users.rake
443
501
  homepage: https://github.com/Biovision/biovision-base
444
502
  licenses:
445
503
  - MIT
@@ -1,9 +0,0 @@
1
- $huge-font-size: 4.8rem;
2
- $larger-font-size: 3.2rem;
3
- $large-font-size: 2.4rem;
4
- $increased-font-size: 1.8rem;
5
- $normal-font-size: 1.6rem;
6
- $decreased-font-size: 1.4rem;
7
- $small-font-size: 1.2rem;
8
- $smaller-font-size: 1rem;
9
- $tiny-font-size: 0.8rem;
@@ -1,34 +0,0 @@
1
- module Biovision::Admin::Privileges
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- before_action :set_entity, except: [:index]
6
- end
7
-
8
- # get /admin/privileges
9
- def index
10
- @collection = ::Privilege.for_tree
11
- end
12
-
13
- # get /admin/privileges/:id
14
- def show
15
- end
16
-
17
- # get /admin/privileges/:id/users
18
- def users
19
- @collection = @entity.users.page_for_administration(current_page)
20
- end
21
-
22
- protected
23
-
24
- def restrict_access
25
- require_privilege :administrator
26
- end
27
-
28
- def set_entity
29
- @entity = ::Privilege.find_by(id: params[:id], deleted: false)
30
- if @entity.nil?
31
- handle_http_404("Cannot find non-deleted privilege #{params[:id]}")
32
- end
33
- end
34
- end
@@ -1,143 +0,0 @@
1
- module Biovision::PrivilegeBase
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- DESCRIPTION_LIMIT = 350
6
- NAME_LIMIT = 250
7
- SLUG_LIMIT = 250
8
- PRIORITY_RANGE = (1..32767)
9
-
10
- belongs_to :parent, class_name: Privilege.to_s, optional: true
11
- has_many :children, class_name: Privilege.to_s, foreign_key: :parent_id
12
- has_many :user_privileges, dependent: :destroy
13
- has_many :users, through: :user_privileges
14
- has_many :privilege_group_privileges, dependent: :destroy
15
- has_many :privilege_groups, through: :privilege_group_privileges
16
-
17
- after_initialize :set_next_priority
18
-
19
- before_validation { self.name = name.strip unless name.nil? }
20
- before_validation { self.slug = Canonizer.transliterate(name.to_s) if slug.blank? }
21
- before_validation :normalize_priority
22
-
23
- before_save :compact_children_cache
24
-
25
- validates_presence_of :name, :slug, :priority
26
- validates :name, uniqueness: { case_sensitive: false, scope: [:parent_id] }
27
- validates :slug, uniqueness: { case_sensitive: false }
28
- validates_length_of :name, maximum: NAME_LIMIT
29
- validates_length_of :slug, maximum: SLUG_LIMIT
30
- validates_length_of :description, maximum: DESCRIPTION_LIMIT
31
-
32
- scope :ordered_by_priority, -> { order('priority asc, name asc') }
33
- scope :ordered_by_name, -> { order('name asc, slug asc') }
34
- scope :visible, -> { where(visible: true, deleted: false) }
35
- scope :for_tree, ->(parent_id = nil) { where(parent_id: parent_id).ordered_by_priority }
36
- scope :siblings, ->(item) { where(parent_id: item.parent_id) }
37
- end
38
-
39
- # @return [String]
40
- def full_title
41
- (parents.map(&:name) + [name]).join ' / '
42
- end
43
-
44
- # @return [Array<Integer>]
45
- def ids
46
- [id] + children_cache
47
- end
48
-
49
- # @return [Array<Integer>]
50
- def branch_ids
51
- parents_cache.split(',').map(&:to_i).reject { |i| i < 1 }.uniq + [id]
52
- end
53
-
54
- def parents
55
- if parents_cache.blank?
56
- []
57
- else
58
- Privilege.where(id: parents_cache.split(',').compact).order('id asc')
59
- end
60
- end
61
-
62
- def cache_parents!
63
- if parent.nil?
64
- self.parents_cache = ''
65
- else
66
- self.parents_cache = parent.parents_cache + ",#{parent_id}"
67
- end
68
- save!
69
- end
70
-
71
- def cache_children!
72
- children.order('id asc').map do |child|
73
- self.children_cache += [child.id] + child.children_cache
74
- end
75
- save!
76
- parent&.cache_children!
77
- end
78
-
79
- def can_be_deleted?
80
- children.count < 1
81
- end
82
-
83
- # @param [User] user
84
- def has_user?(user)
85
- return false if user.nil?
86
- user_privileges.exists?(user: user) || user.super_user?
87
- end
88
-
89
- # @param [User] user
90
- def grant(user)
91
- criteria = { privilege: self, user: user }
92
- UserPrivilege.create(criteria) unless UserPrivilege.exists?(criteria)
93
- end
94
-
95
- # @param [User] user
96
- def revoke(user)
97
- criteria = { privilege: self, user: user }
98
- UserPrivilege.where(criteria).destroy_all
99
- end
100
-
101
- # @param [Integer] delta
102
- def change_priority(delta)
103
- new_priority = priority + delta
104
- adjacent = Privilege.siblings(self).find_by(priority: new_priority)
105
- if adjacent.is_a?(Privilege) && (adjacent.id != id)
106
- adjacent.update!(priority: priority)
107
- end
108
- update(priority: new_priority)
109
-
110
- Privilege.for_tree(parent_id).map { |e| [e.id, e.priority] }.to_h
111
- end
112
-
113
- private
114
-
115
- def set_next_priority
116
- if id.nil? && priority == 1
117
- self.priority = Privilege.siblings(self).maximum(:priority).to_i + 1
118
- end
119
- end
120
-
121
- def normalize_priority
122
- self.priority = PRIORITY_RANGE.first if priority < PRIORITY_RANGE.first
123
- self.priority = PRIORITY_RANGE.last if priority > PRIORITY_RANGE.last
124
- end
125
-
126
- def compact_children_cache
127
- self.children_cache.uniq!
128
- end
129
-
130
- module ClassMethods
131
- def page_for_administration
132
- ordered_by_name
133
- end
134
-
135
- def entity_parameters
136
- %i(name slug priority description)
137
- end
138
-
139
- def creation_parameters
140
- entity_parameters + %i(parent_id)
141
- end
142
- end
143
- end
@@ -1,124 +0,0 @@
1
- module Biovision::UserBase
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- include Toggleable
6
-
7
- METRIC_REGISTRATION = 'users.registration.hit'
8
- METRIC_AUTHENTICATION_SUCCESS = 'users.authentication.success.hit'
9
- METRIC_AUTHENTICATION_FAILURE = 'users.authentication.failure.hit'
10
- METRIC_AUTHENTICATION_EXTERNAL = 'users.authentication.external.hit'
11
-
12
- PER_PAGE = 20
13
-
14
- SLUG_LIMIT = 250
15
- EMAIL_LIMIT = 250
16
- NAME_LIMIT = 100
17
- NOTICE_LIMIT = 255
18
- PHONE_LIMIT = 50
19
-
20
- toggleable %i(allow_login bot email_confirmed phone_confirmed allow_mail)
21
-
22
- belongs_to :agent, optional: true
23
-
24
- has_secure_password
25
-
26
- mount_uploader :image, AvatarUploader
27
-
28
- enum gender: [:female, :male]
29
-
30
- belongs_to :agent, optional: true
31
- belongs_to :inviter, class_name: User.to_s, optional: true
32
- has_many :invitees, class_name: User.to_s, foreign_key: :inviter_id, dependent: :nullify
33
- has_many :tokens, dependent: :delete_all
34
- has_many :codes, dependent: :delete_all
35
- has_many :user_privileges, dependent: :destroy
36
- has_many :privileges, through: :user_privileges
37
- has_many :foreign_users, dependent: :delete_all
38
-
39
- before_save :normalize_slug
40
-
41
- validates_presence_of :screen_name, :email
42
- validates_format_of :screen_name, with: /\A[a-z0-9_]{1,30}\z/i, if: :native_slug?
43
- validates_format_of :email, with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z0-9][-a-z0-9]+)\z/i
44
- validates :screen_name, uniqueness: { case_sensitive: false }
45
- validates :email, uniqueness: { case_sensitive: false }
46
- validates_length_of :slug, maximum: SLUG_LIMIT
47
- validates_length_of :screen_name, maximum: SLUG_LIMIT
48
- validates_length_of :name, maximum: NAME_LIMIT
49
- validates_length_of :patronymic, maximum: NAME_LIMIT
50
- validates_length_of :surname, maximum: NAME_LIMIT
51
- validates_length_of :email, maximum: EMAIL_LIMIT
52
- validates_length_of :phone, maximum: PHONE_LIMIT
53
- validates_length_of :notice, maximum: NOTICE_LIMIT
54
-
55
- scope :with_privilege, ->(privilege) { joins(:user_privileges).where(user_privileges: { privilege_id: privilege.branch_ids }) }
56
- scope :bots, ->(flag) { where(bot: flag.to_i > 0) unless flag.blank? }
57
- scope :name_like, ->(val) { where('name ilike ?', "%#{val}%") unless val.blank? }
58
- scope :email_like, ->(val) { where('email ilike ?', "%#{val}%") unless val.blank? }
59
- scope :with_email, ->(email) { where('lower(email) = lower(?)', email) }
60
- scope :screen_name_like, ->(val) { where('screen_name ilike ?', "%#{val}%") unless val.blank? }
61
- scope :search, ->(q) { where("lower(concat_ws(' ', slug, email, surname, name)) like ?", "%#{q.downcase}%") unless q.blank? }
62
- scope :filtered, ->(f) { name_like(f[:name]).email_like(f[:email]).screen_name_like(f[:screen_name]) }
63
- end
64
-
65
- module ClassMethods
66
- # @param [Integer] page
67
- # @param [Hash] filter
68
- def page_for_administration(page, filter = {})
69
- bots(filter[:bots]).filtered(filter).order('id desc').page(page).per(PER_PAGE)
70
- end
71
-
72
- def profile_parameters
73
- %i(image name patronymic surname birthday gender allow_mail)
74
- end
75
-
76
- def sensitive_parameters
77
- %i(email phone password password_confirmation)
78
- end
79
-
80
- # Параметры при регистрации
81
- def new_profile_parameters
82
- profile_parameters + sensitive_parameters + %i(screen_name)
83
- end
84
-
85
- # Параметры для администрирования
86
- def entity_parameters
87
- flags = %i(bot allow_login email_confirmed phone_confirmed foreign_slug)
88
-
89
- new_profile_parameters + flags + %i(screen_name notice)
90
- end
91
-
92
- def ids_range
93
- min = User.minimum(:id).to_i
94
- max = User.maximum(:id).to_i
95
- (min..max)
96
- end
97
- end
98
-
99
- def profile_name
100
- screen_name
101
- end
102
-
103
- def name_for_letter
104
- name || profile_name
105
- end
106
-
107
- def can_receive_letters?
108
- allow_mail? && !email.blank?
109
- end
110
-
111
- def native_slug?
112
- !foreign_slug?
113
- end
114
-
115
- private
116
-
117
- def normalize_slug
118
- if native_slug?
119
- self.slug = screen_name.downcase
120
- else
121
- self.slug = slug.downcase
122
- end
123
- end
124
- end
@@ -1,46 +0,0 @@
1
- module Biovision::UserPrivilegeBase
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- belongs_to :user
6
- belongs_to :privilege, counter_cache: :users_count
7
-
8
- validates_uniqueness_of :privilege_id, scope: [:user_id]
9
- end
10
-
11
- module ClassMethods
12
- # @param [User] user
13
- # @return [Array<Integer>]
14
- def ids(user)
15
- privileges = user&.privileges
16
- return [] if privileges.blank?
17
- privileges.map(&:ids).flatten.uniq
18
- end
19
-
20
- # @param [User] user
21
- # @param [Symbol] privilege_name
22
- def user_has_privilege?(user, privilege_name)
23
- return false if user.nil?
24
- return true if user.super_user?
25
- privilege = Privilege.find_by(slug: privilege_name.to_s)
26
- ids(user).include?(privilege&.id)
27
- end
28
-
29
- # @param [User] user
30
- def user_has_any_privilege?(user)
31
- return false if user.nil?
32
- return true if user.super_user?
33
- exists?(user: user)
34
- end
35
-
36
- # @param [User] user
37
- # @param [Symbol] group_name
38
- def user_in_group?(user, group_name)
39
- return false if user.nil?
40
- return true if user.super_user?
41
- privilege_ids = PrivilegeGroup.ids(group_name)
42
- return false if privilege_ids.blank?
43
- exists?(user: user, privilege_id: privilege_ids)
44
- end
45
- end
46
- end
@@ -1,11 +0,0 @@
1
- <% if collection.any? %>
2
- <ul class="list-of-entities">
3
- <% collection.each do |entity| %>
4
- <li data-id="<%= entity.id %>">
5
- <%= render partial: 'admin/privilege_groups/entity/in_list', locals: { entity: entity } %>
6
- </li>
7
- <% end %>
8
- </ul>
9
- <% else %>
10
- <%= render 'shared/nothing_found' %>
11
- <% end %>
@@ -1,8 +0,0 @@
1
- <div class="authentication">
2
- <div class="plate">
3
- <%= link_to current_user.profile_name, my_profile_path, class: "profile" %>
4
- <div class="logout">
5
- <%= link_to image_tag('biovision/base/icons/exit.svg', alt: t(:logout)), logout_path, method: :delete, title: t(:logout) %>
6
- </div>
7
- </div>
8
- </div>