biovision 0.0.200518.1 → 0.12.211124.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (345) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +105 -52
  3. data/app/assets/images/biovision/icons/back.svg +19 -0
  4. data/app/assets/images/biovision/icons/create.svg +19 -0
  5. data/app/assets/images/biovision/icons/destroy.svg +12 -0
  6. data/app/assets/images/biovision/icons/dropdown.svg +3 -0
  7. data/app/assets/images/biovision/icons/edit.svg +22 -0
  8. data/app/assets/images/biovision/icons/gear.svg +11 -0
  9. data/app/assets/images/biovision/icons/return.svg +25 -0
  10. data/app/assets/images/biovision/icons/world.svg +11 -0
  11. data/app/assets/stylesheets/biovision/admin/components/users.scss +20 -0
  12. data/app/assets/stylesheets/biovision/admin/components.scss +13 -1
  13. data/app/assets/stylesheets/biovision/admin/layout.scss +27 -12
  14. data/app/assets/stylesheets/biovision/biovision.scss +105 -26
  15. data/app/assets/stylesheets/biovision/components/breadcrumbs.scss +13 -0
  16. data/app/assets/stylesheets/biovision/components/buttons.scss +130 -0
  17. data/app/assets/stylesheets/biovision/components/filters.scss +39 -0
  18. data/app/assets/stylesheets/biovision/components/forms.scss +208 -1
  19. data/app/assets/stylesheets/biovision/components/lists.scss +6 -7
  20. data/app/assets/stylesheets/biovision/{biovision → components}/messages.scss +9 -0
  21. data/app/assets/stylesheets/biovision/components/pagination.scss +34 -0
  22. data/app/assets/stylesheets/biovision/components/quick_search.scss +24 -0
  23. data/app/assets/stylesheets/biovision/components/simple_image.scss +112 -0
  24. data/app/assets/stylesheets/biovision/components/toggleable.scss +71 -0
  25. data/app/assets/stylesheets/biovision/components.scss +7 -0
  26. data/app/assets/stylesheets/biovision/default.scss +4 -4
  27. data/app/assets/stylesheets/biovision/themes/default_theme/components/users/dashboard.scss +4 -0
  28. data/app/assets/stylesheets/biovision/themes/default_theme/components/users/form_tabs.scss +101 -0
  29. data/app/assets/stylesheets/biovision/themes/default_theme/components/users/profile.scss +77 -0
  30. data/app/assets/stylesheets/biovision/themes/default_theme/components/users.scss +3 -0
  31. data/app/assets/stylesheets/biovision/themes/default_theme/components.scss +2 -3
  32. data/app/assets/stylesheets/biovision/themes/default_theme/layout/footer.scss +3 -0
  33. data/app/assets/stylesheets/biovision/themes/default_theme/layout/header.scss +12 -0
  34. data/app/assets/stylesheets/biovision/themes/default_theme/layout.scss +8 -19
  35. data/app/assets/stylesheets/biovision/themes/default_theme.scss +0 -1
  36. data/app/assets/stylesheets/biovision/vars.scss +5 -0
  37. data/app/controllers/admin/biovision_components_controller.rb +10 -0
  38. data/app/controllers/admin/components_controller.rb +37 -97
  39. data/app/controllers/admin/dynamic_blocks_controller.rb +15 -0
  40. data/app/controllers/admin/dynamic_pages_controller.rb +15 -0
  41. data/app/controllers/admin/index_controller.rb +8 -2
  42. data/app/controllers/admin/navigation_groups_controller.rb +45 -0
  43. data/app/controllers/admin/tokens_controller.rb +15 -0
  44. data/app/controllers/admin/users_controller.rb +101 -0
  45. data/app/controllers/admin_controller.rb +2 -8
  46. data/app/controllers/authentication_controller.rb +6 -34
  47. data/app/controllers/concerns/authentication.rb +12 -12
  48. data/app/controllers/concerns/component_stories.rb +22 -0
  49. data/app/controllers/concerns/crud_entities.rb +140 -0
  50. data/app/controllers/concerns/entity_priority.rb +10 -0
  51. data/app/controllers/concerns/my_crud_entities.rb +146 -0
  52. data/app/controllers/concerns/processed_forms.rb +28 -0
  53. data/app/controllers/concerns/restricted_access.rb +37 -0
  54. data/app/controllers/concerns/toggleable_entity.rb +31 -0
  55. data/app/controllers/contact_controller.rb +49 -0
  56. data/app/controllers/errors_controller.rb +37 -0
  57. data/app/controllers/fallback_controller.rb +12 -0
  58. data/app/controllers/index_controller.rb +1 -0
  59. data/app/controllers/legal_controller.rb +14 -0
  60. data/app/controllers/my/components_controller.rb +26 -0
  61. data/app/controllers/my/confirmations_controller.rb +44 -0
  62. data/app/controllers/my/index_controller.rb +7 -1
  63. data/app/controllers/my/profiles_controller.rb +33 -16
  64. data/app/controllers/oembed_controller.rb +12 -0
  65. data/app/controllers/profile_controller.rb +14 -0
  66. data/app/controllers/users_controller.rb +63 -0
  67. data/app/helpers/biovision_components_helper.rb +7 -3
  68. data/app/helpers/biovision_helper.rb +170 -0
  69. data/app/helpers/entity_helper.rb +77 -0
  70. data/app/helpers/my_helper.rb +34 -0
  71. data/app/helpers/simple_image_helper.rb +125 -0
  72. data/app/jobs/application_job.rb +7 -0
  73. data/app/jobs/send_phone_confirmation_job.rb +16 -0
  74. data/app/lib/biovision/components/base/component_parameters.rb +55 -0
  75. data/app/lib/biovision/components/base/component_privileges.rb +75 -0
  76. data/app/lib/biovision/components/base/component_settings.rb +40 -0
  77. data/app/lib/biovision/components/base/component_stories.rb +30 -0
  78. data/app/lib/biovision/components/base/entity_links.rb +38 -0
  79. data/app/lib/biovision/components/base/image_handling.rb +33 -0
  80. data/app/lib/biovision/components/base_component.rb +63 -95
  81. data/app/lib/biovision/components/contact_component.rb +26 -0
  82. data/app/lib/biovision/components/content/oembed/receiver.rb +98 -0
  83. data/app/lib/biovision/components/content/oembed/twitter_receiver.rb +20 -0
  84. data/app/lib/biovision/components/content/oembed/vimeo_receiver.rb +20 -0
  85. data/app/lib/biovision/components/content/oembed/youtube_receiver.rb +20 -0
  86. data/app/lib/biovision/components/content_component.rb +65 -0
  87. data/app/lib/biovision/components/track_component.rb +3 -0
  88. data/app/lib/biovision/components/users/authentication.rb +15 -7
  89. data/app/lib/biovision/components/users/codes.rb +104 -0
  90. data/app/lib/biovision/components/users/flag_helpers.rb +72 -0
  91. data/app/lib/biovision/components/users/profile_handler.rb +111 -1
  92. data/app/lib/biovision/components/users/registration_handler.rb +40 -52
  93. data/app/lib/biovision/components/users/validation.rb +83 -0
  94. data/app/lib/biovision/components/users_component.rb +114 -19
  95. data/app/lib/biovision/helpers/data_helper.rb +70 -0
  96. data/app/lib/biovision/helpers/export_helper.rb +97 -0
  97. data/app/lib/biovision/migrations/component_migration.rb +56 -0
  98. data/app/lib/biovision/notifiers/base_notifier.rb +2 -2
  99. data/app/lib/biovision/notifiers/contact_notifier.rb +15 -0
  100. data/app/lib/biovision/stories/component_story.rb +55 -0
  101. data/app/lib/canonizer.rb +38 -0
  102. data/app/lib/carrier_wave/image_optim.rb +32 -0
  103. data/app/mailers/code_sender.rb +29 -0
  104. data/app/mailers/feedback_mailer.rb +14 -0
  105. data/app/models/agent.rb +4 -0
  106. data/app/models/biovision_component.rb +39 -3
  107. data/app/models/code.rb +31 -8
  108. data/app/models/concerns/checkable.rb +2 -1
  109. data/app/models/concerns/has_simple_image.rb +9 -0
  110. data/app/models/concerns/has_uploaded_file.rb +26 -0
  111. data/app/models/concerns/meta_texts.rb +25 -5
  112. data/app/models/concerns/simple_tag.rb +30 -0
  113. data/app/models/concerns/toggleable.rb +2 -1
  114. data/app/models/concerns/tree_structure.rb +75 -0
  115. data/app/models/contact_method.rb +47 -0
  116. data/app/models/contact_type.rb +27 -0
  117. data/app/models/dynamic_block.rb +43 -0
  118. data/app/models/dynamic_page.rb +73 -0
  119. data/app/models/feedback_message.rb +65 -0
  120. data/app/models/feedback_response.rb +50 -0
  121. data/app/models/group.rb +48 -0
  122. data/app/models/language.rb +4 -0
  123. data/app/models/metric.rb +4 -0
  124. data/app/models/navigation_group.rb +43 -0
  125. data/app/models/navigation_group_page.rb +23 -0
  126. data/app/models/oembed_domain.rb +25 -0
  127. data/app/models/oembed_link.rb +19 -0
  128. data/app/models/oembed_receiver.rb +15 -0
  129. data/app/models/role.rb +86 -0
  130. data/app/models/role_group.rb +13 -0
  131. data/app/models/simple_image.rb +49 -8
  132. data/app/models/simple_image_tag.rb +1 -16
  133. data/app/models/token.rb +6 -2
  134. data/app/models/uploaded_file.rb +62 -0
  135. data/app/models/uploaded_file_tag.rb +15 -0
  136. data/app/models/uploaded_file_tag_file.rb +13 -0
  137. data/app/models/user.rb +122 -29
  138. data/app/models/user_group.rb +20 -0
  139. data/app/models/user_role.rb +18 -0
  140. data/app/uploaders/simple_file_uploader.rb +23 -0
  141. data/app/uploaders/simple_image_uploader.rb +29 -20
  142. data/app/uploaders/uploaders/path_slug.rb +22 -0
  143. data/app/views/admin/agents/index.html.erb +1 -3
  144. data/app/views/admin/biovision_components/_nav_item.html.erb +6 -0
  145. data/app/views/admin/biovision_components/entity/_in_list.html.erb +12 -0
  146. data/app/views/admin/biovision_components/index.html.erb +11 -0
  147. data/app/views/admin/components/_image.jbuilder +18 -0
  148. data/app/views/admin/components/_list.html.erb +1 -1
  149. data/app/views/admin/components/entity/_links.html.erb +31 -21
  150. data/app/views/admin/components/image.jbuilder +1 -0
  151. data/app/views/admin/components/images.jbuilder +4 -0
  152. data/app/views/admin/components/links/_base.html.erb +1 -0
  153. data/app/views/admin/components/settings/_new_parameter.html.erb +4 -2
  154. data/app/views/admin/components/settings/_parameters.html.erb +8 -2
  155. data/app/views/admin/components/settings/_settings.html.erb +4 -4
  156. data/app/views/admin/components/settings.html.erb +2 -1
  157. data/app/views/admin/components/update_privileges.jbuilder +21 -0
  158. data/app/views/admin/dynamic_blocks/_form.html.erb +16 -0
  159. data/app/views/admin/dynamic_blocks/_nav_item.html.erb +6 -0
  160. data/app/views/admin/dynamic_blocks/entity/_in_list.html.erb +12 -0
  161. data/app/views/admin/dynamic_blocks/index.html.erb +17 -0
  162. data/app/views/admin/dynamic_blocks/show.html.erb +25 -0
  163. data/app/views/admin/dynamic_pages/_dynamic_page.jbuilder +18 -0
  164. data/app/views/admin/dynamic_pages/_form.html.erb +21 -0
  165. data/app/views/admin/dynamic_pages/_nav_item.html.erb +6 -0
  166. data/app/views/admin/dynamic_pages/entity/_in_list.html.erb +17 -0
  167. data/app/views/admin/dynamic_pages/entity/_in_search.html.erb +7 -0
  168. data/app/views/admin/dynamic_pages/index.html.erb +17 -0
  169. data/app/views/admin/dynamic_pages/search.jbuilder +4 -0
  170. data/app/views/admin/dynamic_pages/show.html.erb +28 -0
  171. data/app/views/admin/index/index.html.erb +7 -5
  172. data/app/views/admin/ip_addresses/index.html.erb +2 -4
  173. data/app/views/admin/navigation_group_pages/entity/_in_list.html.erb +26 -0
  174. data/app/views/admin/navigation_groups/_form.html.erb +15 -0
  175. data/app/views/admin/navigation_groups/_nav_item.html.erb +6 -0
  176. data/app/views/admin/navigation_groups/entity/_dynamic_pages.html.erb +38 -0
  177. data/app/views/admin/navigation_groups/entity/_in_list.html.erb +14 -0
  178. data/app/views/admin/navigation_groups/index.html.erb +17 -0
  179. data/app/views/admin/navigation_groups/show.html.erb +33 -0
  180. data/app/views/admin/tokens/_form.html.erb +31 -0
  181. data/app/views/admin/tokens/_nav_item.html.erb +6 -0
  182. data/app/views/admin/tokens/entity/_in_list.html.erb +27 -0
  183. data/app/views/admin/tokens/index.html.erb +11 -0
  184. data/app/views/admin/tokens/show.html.erb +26 -0
  185. data/app/views/admin/unauthorized.html.erb +2 -5
  186. data/app/views/admin/users/_form.html.erb +81 -0
  187. data/app/views/admin/users/_nav_item.html.erb +6 -0
  188. data/app/views/admin/users/_user.jbuilder +18 -0
  189. data/app/views/admin/users/entity/_fields.html.erb +53 -0
  190. data/app/views/admin/users/entity/_in_list.html.erb +38 -0
  191. data/app/views/admin/users/entity/_in_search.html.erb +18 -0
  192. data/app/views/admin/users/entity/_profile.html.erb +26 -0
  193. data/app/views/admin/users/entity/in_list/_additional_data.html.erb +0 -0
  194. data/app/views/admin/users/index.html.erb +24 -0
  195. data/app/views/admin/users/roles/_component.html.erb +22 -0
  196. data/app/views/admin/users/roles.html.erb +23 -0
  197. data/app/views/admin/users/search.jbuilder +4 -0
  198. data/app/views/admin/users/show.html.erb +62 -0
  199. data/app/views/admin/widgets/_filters.html.erb +20 -0
  200. data/app/views/admin/widgets/_quick_search.html.erb +13 -0
  201. data/app/views/admin/widgets/filters/_flag.html.erb +15 -0
  202. data/app/views/admin/widgets/filters/_text.html.erb +7 -0
  203. data/app/views/application/forbidden.html.erb +9 -0
  204. data/app/views/application/forbidden.jbuilder +4 -0
  205. data/app/views/application/not_found.html.erb +9 -0
  206. data/app/views/application/not_found.jbuilder +4 -0
  207. data/app/views/application/unauthorized.html.erb +19 -0
  208. data/app/views/application/unauthorized.jbuilder +4 -0
  209. data/app/views/authentication/new.html.erb +2 -8
  210. data/app/views/components/content/_dynamic_page.html.erb +17 -0
  211. data/app/views/components/content/_dynamic_page_content.html.erb +14 -0
  212. data/app/views/components/users/_form_tabs.html.erb +31 -0
  213. data/app/views/components/users/_join_form.html.erb +192 -0
  214. data/app/views/components/users/_login_form.html.erb +46 -0
  215. data/app/views/components/users/form/_image.html.erb +17 -0
  216. data/app/views/components/users/form/_profile_data.html.erb +54 -0
  217. data/app/views/contact/_form.html.erb +108 -0
  218. data/app/views/contact/create_feedback_message.js.erb +1 -0
  219. data/app/views/contact/feedback.html.erb +13 -0
  220. data/app/views/contact/index.html.erb +16 -0
  221. data/app/views/errors/error.html.erb +1 -0
  222. data/app/views/fallback/show.html.erb +6 -0
  223. data/app/views/feedback_mailer/new_feedback_request.html.erb +11 -0
  224. data/app/views/feedback_mailer/new_feedback_request.text.erb +6 -0
  225. data/app/views/index/index.html.erb +14 -0
  226. data/app/views/layouts/admin/_footer.html.erb +1 -1
  227. data/app/views/layouts/admin/_header.html.erb +7 -2
  228. data/app/views/layouts/admin.html.erb +0 -1
  229. data/app/views/layouts/application/_footer.html.erb +1 -1
  230. data/app/views/layouts/application/header/_authentication.html.erb +4 -1
  231. data/app/views/legal/privacy.html.erb +5 -0
  232. data/app/views/legal/tos.html.erb +5 -0
  233. data/app/views/my/components/index.html.erb +25 -0
  234. data/app/views/my/components/show.html.erb +21 -0
  235. data/app/views/my/confirmations/show.html.erb +62 -0
  236. data/app/views/my/index/_cards.html.erb +15 -0
  237. data/app/views/my/index/_email.html.erb +14 -0
  238. data/app/views/my/index/_navigation.html.erb +33 -0
  239. data/app/views/my/index/index.html.erb +12 -0
  240. data/app/views/my/profiles/_form.html.erb +10 -0
  241. data/app/views/my/profiles/check.jbuilder +4 -0
  242. data/app/views/my/profiles/edit.html.erb +14 -0
  243. data/app/views/my/profiles/form/_basic_parameters.html.erb +9 -0
  244. data/app/views/my/profiles/form/_sensitive_parameters.html.erb +68 -0
  245. data/app/views/my/profiles/new.html.erb +6 -8
  246. data/app/views/my/profiles/show.html.erb +36 -0
  247. data/app/views/my/recoveries/show.html.erb +0 -0
  248. data/app/views/shared/_flash_messages.html.erb +1 -1
  249. data/app/views/shared/_list_of_errors.html.erb +7 -0
  250. data/app/views/shared/admin/_breadcrumbs.html.erb +8 -0
  251. data/app/views/shared/admin/_list.html.erb +10 -19
  252. data/app/views/shared/admin/_list_with_priority.html.erb +10 -19
  253. data/app/views/shared/admin/_priority.html.erb +6 -0
  254. data/app/views/shared/admin/_toggle.html.erb +6 -0
  255. data/app/views/shared/entity/_date_field.html.erb +6 -0
  256. data/app/views/shared/entity/_formatted_text_field.html.erb +10 -0
  257. data/app/views/shared/entity/_image.html.erb +31 -0
  258. data/app/views/shared/entity/_language.html.erb +6 -0
  259. data/app/views/shared/entity/_linked_entity.html.erb +6 -0
  260. data/app/views/shared/entity/_list.html.erb +22 -0
  261. data/app/views/shared/entity/_list_with_priority.html.erb +22 -0
  262. data/app/views/shared/entity/_meta_texts.html.erb +16 -0
  263. data/app/views/shared/entity/_metadata.html.erb +18 -0
  264. data/app/views/shared/entity/_parent.html.erb +6 -0
  265. data/app/views/shared/entity/_priority.html.erb +4 -0
  266. data/app/views/shared/entity/_priority_icons.html.erb +8 -0
  267. data/app/views/shared/entity/_raw_text_field.html.erb +10 -0
  268. data/app/views/shared/entity/_simple_image.html.erb +10 -0
  269. data/app/views/shared/entity/_slug.html.erb +6 -0
  270. data/app/views/shared/entity/_text_field.html.erb +6 -0
  271. data/app/views/shared/entity/_text_fields.html.erb +9 -0
  272. data/app/views/shared/entity/_time_field.html.erb +6 -0
  273. data/app/views/shared/entity/_timestamps.html.erb +13 -0
  274. data/app/views/shared/entity/_toggle.html.erb +12 -0
  275. data/app/views/shared/entity/_track.html.erb +12 -0
  276. data/app/views/shared/entity/_tree_caches.html.erb +19 -0
  277. data/app/views/shared/entity/_uuid.html.erb +4 -0
  278. data/app/views/shared/entity/edit.html.erb +23 -0
  279. data/app/views/shared/entity/new.html.erb +16 -0
  280. data/app/views/shared/forms/_entity_flags.html.erb +15 -0
  281. data/app/views/shared/forms/_field.html.erb +50 -0
  282. data/app/views/shared/forms/_field_with_search.html.erb +17 -0
  283. data/app/views/shared/forms/_fields.html.erb +3 -0
  284. data/app/views/shared/forms/_language.html.erb +40 -0
  285. data/app/views/shared/forms/_meta_texts.html.erb +27 -0
  286. data/app/views/shared/forms/_priority.html.erb +13 -0
  287. data/app/views/shared/forms/_simple_entity_link.html.erb +14 -0
  288. data/app/views/shared/forms/_simple_image.html.erb +47 -0
  289. data/app/views/shared/forms/_state_container.html.erb +7 -0
  290. data/app/views/shared/forms/_text_area.html.erb +25 -0
  291. data/app/views/shared/forms/_text_field.html.erb +24 -0
  292. data/app/views/shared/forms/_text_fields.html.erb +3 -0
  293. data/app/views/shared/forms/check.jbuilder +4 -0
  294. data/app/views/shared/forms/errors.jbuilder +3 -0
  295. data/app/views/shared/forms/simple_image/_browse.html.erb +14 -0
  296. data/app/views/shared/forms/simple_image/_load_image.html.erb +38 -0
  297. data/app/views/shared/my/_list.html.erb +10 -0
  298. data/app/views/shared/my/_list_with_priority.html.erb +10 -0
  299. data/app/views/shared/my/entity/edit.html.erb +25 -0
  300. data/app/views/shared/my/entity/new.html.erb +18 -0
  301. data/app/views/simple_images/_simple_image.jbuilder +13 -0
  302. data/app/views/users/_profile.html.erb +30 -0
  303. data/app/views/users/profile/_data.html.erb +20 -0
  304. data/app/views/users/show.html.erb +21 -0
  305. data/config/locales/biovision-ru.yml +76 -1
  306. data/config/locales/components-ru.yml +55 -4
  307. data/config/locales/contact-ru.yml +110 -0
  308. data/config/locales/content-ru.yml +115 -0
  309. data/config/locales/users-ru.yml +142 -3
  310. data/config/routes.rb +99 -48
  311. data/db/migrate/20191228000000_create_biovision_components.rb +6 -5
  312. data/db/migrate/20200224000000_create_track_component.rb +9 -14
  313. data/db/migrate/20200224000010_create_users_component.rb +14 -83
  314. data/db/migrate/20200404000000_create_simple_images.rb +4 -3
  315. data/db/migrate/20210405000000_create_acl.rb +88 -0
  316. data/db/migrate/20210421000000_create_content_component.rb +80 -0
  317. data/db/migrate/20210421000010_create_contact_component.rb +74 -0
  318. data/db/migrate/20210616000000_create_uploaded_files.rb +52 -0
  319. data/db/migrate/amends/20210816060606_create_oembed_receivers.rb +21 -0
  320. data/db/migrate/amends/20210907070707_add_checksum_to_simple_images.rb +13 -0
  321. data/lib/biovision/base_methods.rb +17 -29
  322. data/lib/biovision/engine.rb +8 -13
  323. data/lib/biovision/version.rb +1 -1
  324. data/lib/tasks/components.rake +51 -0
  325. metadata +266 -27
  326. data/app/assets/images/biovision/placeholders/user.svg +0 -15
  327. data/app/helpers/users_helper.rb +0 -11
  328. data/app/lib/biovision/components/component_settings.rb +0 -30
  329. data/app/lib/biovision/components/privilege_handler.rb +0 -77
  330. data/app/lib/biovision/components/users/code_handler.rb +0 -23
  331. data/app/models/biovision_component_user.rb +0 -21
  332. data/app/models/foreign_site.rb +0 -34
  333. data/app/models/foreign_user.rb +0 -21
  334. data/app/uploaders/user_image_uploader.rb +0 -58
  335. data/app/views/admin/components/links/_track.html.erb +0 -2
  336. data/app/views/admin/components/links/_users.html.erb +0 -11
  337. data/app/views/admin/components/privileges/_component_user.html.erb +0 -17
  338. data/app/views/admin/components/privileges/_links.html.erb +0 -35
  339. data/app/views/admin/components/privileges/_privilege_flag.html.erb +0 -28
  340. data/app/views/admin/components/privileges/_users.html.erb +0 -23
  341. data/app/views/admin/components/privileges.html.erb +0 -20
  342. data/app/views/authentication/_form.html.erb +0 -40
  343. data/app/views/authentication/failed.js.erb +0 -3
  344. data/app/views/my/profiles/new/_form.html.erb +0 -147
  345. data/app/views/shared/admin/_toggleable.html.erb +0 -8
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Type of contact
4
+ #
5
+ # Attributes:
6
+ # slug [String]
7
+ class ContactType < ApplicationRecord
8
+ include Checkable
9
+ include RequiredUniqueSlug
10
+
11
+ SLUG_PATTERN = /\A[a-z][_a-z]{,16}[a-z]\z/.freeze
12
+
13
+ has_many :contact_methods, dependent: :delete_all
14
+
15
+ validates_format_of :slug, with: SLUG_PATTERN
16
+
17
+ scope :list_for_administration, -> { ordered_by_slug }
18
+
19
+ # @param [String] slug
20
+ def self.[](slug)
21
+ find_by(slug: slug)
22
+ end
23
+
24
+ def self.entity_parameters
25
+ %i[slug]
26
+ end
27
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Dynamic block
4
+ #
5
+ # Attributes:
6
+ # body [Text], optional
7
+ # created_at [DateTime]
8
+ # data [JSON]
9
+ # slug [String]
10
+ # updated_at [DateTime]
11
+ # visible [Boolean]
12
+ class DynamicBlock < ApplicationRecord
13
+ include Checkable
14
+ include RequiredUniqueSlug
15
+ include Toggleable
16
+
17
+ SLUG_LIMIT = 100
18
+
19
+ toggleable :visible
20
+
21
+ validates_length_of :slug, maximum: SLUG_LIMIT
22
+
23
+ scope :visible, -> { where(visible: true) }
24
+ scope :list_for_administration, -> { ordered_by_slug }
25
+
26
+ # Get body of visible block with given slug or empty string
27
+ #
28
+ # Can be used in views for quick output
29
+ #
30
+ # @param [String] slug
31
+ # @return [String]
32
+ def self.[](slug)
33
+ visible.find_by(slug: slug)&.body.to_s
34
+ end
35
+
36
+ def self.entity_parameters
37
+ %i[body slug visible]
38
+ end
39
+
40
+ def text_for_link
41
+ slug
42
+ end
43
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Dynamic page
4
+ #
5
+ # Attributes:
6
+ # body [text]
7
+ # created_at [DateTime]
8
+ # data [jsonb]
9
+ # language_id [Language], optional
10
+ # name [string]
11
+ # simple_image_id [SimpleImage], optional
12
+ # slug [string]
13
+ # updated_at [DateTime]
14
+ # url [string], optional
15
+ # uuid [uuid]
16
+ # visible [boolean]
17
+ class DynamicPage < ApplicationRecord
18
+ include Checkable
19
+ include HasLanguage
20
+ include HasSimpleImage
21
+ include HasUuid
22
+ include MetaTexts
23
+ include Toggleable
24
+
25
+ NAME_LIMIT = 100
26
+ SLUG_LIMIT = 100
27
+ URL_LIMIT = 100
28
+
29
+ toggleable :visible
30
+
31
+ has_many :navigation_group_pages, dependent: :destroy
32
+
33
+ validates_presence_of :slug
34
+ validates_uniqueness_of :slug, scope: :language_id
35
+ validates_length_of :name, maximum: NAME_LIMIT
36
+ validates_length_of :slug, maximum: SLUG_LIMIT
37
+ validates_length_of :url, maximum: URL_LIMIT
38
+
39
+ scope :visible, -> { where(visible: true) }
40
+ scope :list_for_administration, -> { included_image.order('slug asc, language_id asc nulls first') }
41
+ scope :search, ->(q) { where('url ilike ? or slug ilike ?', "#{q}%", "#{q}%") unless q.blank? }
42
+
43
+ # @param [String] slug
44
+ def self.[](slug)
45
+ find_by(slug: slug)
46
+ end
47
+
48
+ def self.entity_parameters
49
+ %i[body language_id name simple_image_id slug url visible]
50
+ end
51
+
52
+ def long_slug
53
+ language.nil? ? slug : "#{slug} (#{language.code})"
54
+ end
55
+
56
+ def text_for_link
57
+ long_slug
58
+ end
59
+
60
+ def world_url
61
+ url.blank? ? '/' : url
62
+ end
63
+
64
+ def meta_title
65
+ title = data.dig('meta', 'title')
66
+ title.blank? ? name : title
67
+ end
68
+
69
+ def meta_heading
70
+ heading = data.dig('meta', 'heading')
71
+ heading.blank? ? name : heading
72
+ end
73
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Message from visitor
4
+ #
5
+ # Attributes:
6
+ # agent_id [Agent], optional
7
+ # attachment [SimpleFileUploader], optional
8
+ # comment [text], optional
9
+ # created_at [DateTime]
10
+ # data [jsonb]
11
+ # email [string], optional
12
+ # ip_address_id [IpAddress], optional
13
+ # language_id [Language], optional
14
+ # name [string], optional
15
+ # phone [string], optional
16
+ # processed [boolean]
17
+ # updated_at [DateTime]
18
+ # user_id [User], optional
19
+ # uuid [uuid]
20
+ class FeedbackMessage < ApplicationRecord
21
+ include Checkable
22
+ include HasLanguage
23
+ include HasOwner
24
+ include HasTrack
25
+ include HasUuid
26
+ include Toggleable
27
+
28
+ COMMENT_LIMIT = 5000
29
+ EMAIL_LIMIT = 250
30
+ EMAIL_PATTERN = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z0-9][-a-z0-9]+)\z/i.freeze
31
+ NAME_LIMIT = 100
32
+ PHONE_LIMIT = 30
33
+
34
+ toggleable :processed
35
+
36
+ mount_uploader :attachment, SimpleFileUploader
37
+
38
+ belongs_to :user, optional: true
39
+ has_many :feedback_responses, dependent: :delete_all
40
+
41
+ validates_format_of :email, with: EMAIL_PATTERN, allow_blank: true
42
+ validates_length_of :comment, maximum: COMMENT_LIMIT
43
+ validates_length_of :email, maximum: EMAIL_LIMIT
44
+ validates_length_of :name, maximum: NAME_LIMIT
45
+ validates_length_of :phone, maximum: PHONE_LIMIT
46
+
47
+ scope :recent, -> { order('id desc') }
48
+ scope :unprocessed, -> { where(processed: false) }
49
+ scope :list_for_administration, -> { recent }
50
+
51
+ # @param [Integer] page
52
+ def self.page_for_administration(page = 1)
53
+ list_for_administration.page(page)
54
+ end
55
+
56
+ def self.entity_parameters
57
+ %i[attachment comment email language_id name phone]
58
+ end
59
+
60
+ def attachment_name
61
+ return if attachment.blank?
62
+
63
+ File.basename(attachment.path)
64
+ end
65
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Response to feedback message
4
+ #
5
+ # Attributes:
6
+ # agent_id [Agent], optional
7
+ # body [text]
8
+ # created_at [DateTime]
9
+ # data [jsonb]
10
+ # feedback_message_id [FeedbackMessage]
11
+ # ip_address_id [IpAddress], optional
12
+ # updated_at [DateTime]
13
+ # user_id [User], optional
14
+ # uuid [uuid]
15
+ # visible [boolean]
16
+ class FeedbackResponse < ApplicationRecord
17
+ include Checkable
18
+ include HasOwner
19
+ include HasTrack
20
+ include HasUuid
21
+ include Toggleable
22
+
23
+ BODY_LIMIT = 5000
24
+
25
+ toggleable :visible
26
+
27
+ belongs_to :feedback_message
28
+ belongs_to :user, optional: true
29
+
30
+ validates_presence_of :body
31
+ validates_length_of :body, maximum: BODY_LIMIT
32
+
33
+ scope :recent, -> { order('id desc') }
34
+ scope :visible, -> { where(visible: true) }
35
+ scope :list_for_administration, -> { recent }
36
+ scope :list_for_visitors, -> { visible.recent }
37
+
38
+ # @param [Integer] page
39
+ def self.page_for_administration(page = 1)
40
+ list_for_administration.page(page)
41
+ end
42
+
43
+ def self.entity_parameters
44
+ %i[body]
45
+ end
46
+
47
+ def self.creation_parameters
48
+ entity_parameters + %i[feedback_message_id]
49
+ end
50
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ # ACL group
4
+ #
5
+ # Attributes:
6
+ # biovision_component_id [BiovisionComponent]
7
+ # data [jsonb]
8
+ # children_cache [Array<integer>]
9
+ # parent_id [Group], optional
10
+ # parents_cache [string]
11
+ # slug [string]
12
+ # user_count [Integer]
13
+ # uuid [uuid]
14
+ class Group < ApplicationRecord
15
+ include Checkable
16
+ include HasUuid
17
+ include TreeStructure
18
+
19
+ SLUG_LIMIT = 50
20
+ SLUG_PATTERN = /\A[a-z][_a-z]*[a-z]\z/.freeze
21
+
22
+ belongs_to :biovision_component
23
+ has_many :user_groups, dependent: :delete_all
24
+ has_many :role_groups, dependent: :destroy
25
+
26
+ before_validation { self.slug = slug.to_s.downcase }
27
+
28
+ validates_presence_of :slug
29
+ validates_uniqueness_of :slug, scope: :biovision_component_id
30
+ validates_format_of :slug, with: SLUG_PATTERN
31
+
32
+ def roles
33
+ Role.where(id: role_groups.where(group_id: branch_ids).pluck(:role_id).uniq)
34
+ end
35
+
36
+ def users
37
+ User.where(id: user_ids)
38
+ end
39
+
40
+ def user_ids
41
+ # user_groups.where(group_id: branch_ids).pluck(:user_id).uniq
42
+ []
43
+ end
44
+
45
+ def users_changed!
46
+ roles.each(&:count_users!)
47
+ end
48
+ end
@@ -28,4 +28,8 @@ class Language < ApplicationRecord
28
28
  def self.[](code)
29
29
  find_by(code: code)
30
30
  end
31
+
32
+ def name
33
+ I18n.t("languages.#{slug}", default: slug)
34
+ end
31
35
  end
data/app/models/metric.rb CHANGED
@@ -25,6 +25,10 @@ class Metric < ApplicationRecord
25
25
 
26
26
  validates_length_of :name, maximum: NAME_LIMIT
27
27
 
28
+ # @param [String] name
29
+ def self.[](name)
30
+ find_by(name: name)
31
+ end
28
32
 
29
33
  def quantity
30
34
  metric_values.sum(:quantity)
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Navigation group
4
+ #
5
+ # Attributes:
6
+ # created_at [DateTime]
7
+ # dynamic_pages_count [integer]
8
+ # name [string]
9
+ # slug [string]
10
+ # updated_at [DateTime]
11
+ class NavigationGroup < ApplicationRecord
12
+ include Checkable
13
+ include RequiredUniqueName
14
+ include RequiredUniqueSlug
15
+
16
+ NAME_LIMIT = 100
17
+ SLUG_LIMIT = 100
18
+
19
+ has_many :navigation_group_pages, dependent: :delete_all
20
+
21
+ validates_length_of :name, maximum: NAME_LIMIT
22
+ validates_length_of :slug, maximum: SLUG_LIMIT
23
+
24
+ scope :list_for_administration, -> { ordered_by_name }
25
+
26
+ def self.entity_parameters
27
+ %i[name slug]
28
+ end
29
+
30
+ def text_for_link
31
+ name
32
+ end
33
+
34
+ # @param [DynamicPage] entity
35
+ def add_dynamic_page(entity)
36
+ navigation_group_pages.create(dynamic_page: entity)
37
+ end
38
+
39
+ # @param [DynamicPage] entity
40
+ def remove_dynamic_page(entity)
41
+ navigation_group_pages.where(dynamic_page: entity).destroy_all
42
+ end
43
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Page in navigation group
4
+ #
5
+ # Attributes:
6
+ # created_at [DateTime]
7
+ # dynamic_page_id [DynamicPage]
8
+ # navigation_group_id [NavigationGroup]
9
+ # priority [integer]
10
+ # updated_at [DateTime]
11
+ class NavigationGroupPage < ApplicationRecord
12
+ include NestedPriority
13
+
14
+ belongs_to :navigation_group, counter_cache: :dynamic_pages_count
15
+ belongs_to :dynamic_page
16
+
17
+ validates_uniqueness_of :dynamic_page_id, scope: :navigation_group_id
18
+
19
+ # @param [NavigationGroupPage] entity
20
+ def self.siblings(entity)
21
+ where(navigation_group_id: entity&.navigation_group_id)
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Domain for OEmbed receiver
4
+ #
5
+ # Attributes:
6
+ # name [String]
7
+ # oembed_receiver_id [OembedReceiver]
8
+ class OembedDomain < ApplicationRecord
9
+ include RequiredUniqueName
10
+
11
+ NAME_LIMIT = 255
12
+
13
+ belongs_to :oembed_receiver
14
+
15
+ validates_length_of :name, maximum: NAME_LIMIT
16
+
17
+ # @param [String] name
18
+ def self.[](name)
19
+ find_by(name: name.to_s.downcase)
20
+ end
21
+
22
+ def receiver_slug
23
+ oembed_receiver&.slug
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Link from oembed tag
4
+ #
5
+ # Attributes:
6
+ # code [Text], optional
7
+ # created_at [DateTime]
8
+ # updated_at [DateTime]
9
+ # url [String]
10
+ class OembedLink < ApplicationRecord
11
+ URL_LIMIT = 255
12
+
13
+ validates_presence_of :url
14
+ before_save { self.url = url.to_s[0..(URL_LIMIT - 1)] }
15
+
16
+ def self.[](url)
17
+ find_or_initialize_by(url: url)
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Receiver for OEmbed links
4
+ #
5
+ # Attributes:
6
+ # slug [String]
7
+ class OembedReceiver < ApplicationRecord
8
+ include RequiredUniqueSlug
9
+
10
+ SLUG_PATTERN = /\A[a-z]+(_?[a-z]+){2,49}\z/
11
+
12
+ has_many :oembed_domains, dependent: :delete_all
13
+
14
+ validates_format_of :slug, with: SLUG_PATTERN
15
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ # ACL role
4
+ #
5
+ # Attributes:
6
+ # biovision_component_id [BiovisionComponent]
7
+ # data [jsonb]
8
+ # slug [string]
9
+ # user_count [integer]
10
+ # uuid [uuid]
11
+ class Role < ApplicationRecord
12
+ include Checkable
13
+ include HasUuid
14
+
15
+ CACHE_KEY = 'role_cache'
16
+
17
+ belongs_to :biovision_component
18
+ has_many :role_groups, dependent: :destroy
19
+ has_many :user_roles, dependent: :destroy
20
+
21
+ before_validation { self.slug = slug.to_s.downcase }
22
+
23
+ validates_presence_of :slug
24
+ validates_uniqueness_of :slug, scope: :biovision_component_id
25
+
26
+ # @param [String] slug
27
+ def self.[](slug)
28
+ parts = slug.to_s.split('.')
29
+ criteria = {
30
+ biovision_components: { slug: parts.shift },
31
+ slug: parts.join('.')
32
+ }
33
+ joins(:biovision_component).where(criteria).first
34
+ end
35
+
36
+ def groups
37
+ # group_ids = role_groups.map(&:group).map(&:branch_ids).flatten.uniq
38
+ # Group.where(id: group_ids)
39
+ []
40
+ end
41
+
42
+ def users
43
+ User.where("data->'role_cache' @> '[?]'::jsonb", id)
44
+ end
45
+
46
+ def user_ids
47
+ (user_roles.pluck(:user_id).uniq + groups.map(&:user_ids).flatten).uniq
48
+ end
49
+
50
+ def count_users!
51
+ self.user_count = user_ids.count
52
+ save
53
+ end
54
+
55
+ # @param [User] user
56
+ def add_to_cache!(user)
57
+ return if user.nil?
58
+
59
+ ids = user.role_ids + [id]
60
+ user.data[CACHE_KEY] = ids.uniq
61
+ user.save
62
+ end
63
+
64
+ # @param [User] user
65
+ def remove_from_cache!(user)
66
+ return if user.nil?
67
+
68
+ new_ids = user.role_ids - [id]
69
+ user.data[CACHE_KEY] = new_ids
70
+ user.save
71
+ end
72
+
73
+ # @param [User] user
74
+ def add_user(user)
75
+ user_roles.create(user: user)
76
+ add_to_cache!(user)
77
+ end
78
+
79
+ # @param [User] user
80
+ def remove_user(user)
81
+ return if user.nil?
82
+
83
+ user_roles.where(user: user).destroy_all
84
+ remove_from_cache!(user)
85
+ end
86
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Role in ACL group
4
+ #
5
+ # Attributes:
6
+ # group_id [Group]
7
+ # role_id [Role]
8
+ class RoleGroup < ApplicationRecord
9
+ belongs_to :group
10
+ belongs_to :role
11
+
12
+ validates_uniqueness_of :role_id, scope: :group_id
13
+ end
@@ -6,7 +6,9 @@
6
6
  # agent_id [Agent], optional
7
7
  # biovision_component_id [BiovisionComponent]
8
8
  # caption [string], optional
9
+ # checksum [String], optional
9
10
  # created_at [DateTime]
11
+ # data [jsonb]
10
12
  # image [SimpleImageUploader]
11
13
  # image_alt_text [string]
12
14
  # ip_address_id [IpAddress], optional
@@ -16,32 +18,71 @@
16
18
  # updated_at [DateTime]
17
19
  # user_id [User], optional
18
20
  # uuid [uuid]
19
- # data [jsonb]
20
21
  class SimpleImage < ApplicationRecord
21
22
  include Checkable
22
23
  include HasOwner
23
24
  include HasTrack
24
25
  include HasUuid
25
26
 
26
- CAPTION_LIMIT = 255
27
- LINK_LIMIT = 255
28
- NAME_LIMIT = 255
29
27
  META_LIMIT = 255
28
+ ORIGINAL_CHECKSUM = 'original_checksum'
29
+
30
+ mount_uploader :image, SimpleImageUploader
30
31
 
32
+ belongs_to :agent, optional: true
31
33
  belongs_to :biovision_component
32
34
  belongs_to :user, optional: true
35
+ has_many :simple_image_tag_images, dependent: :destroy
36
+ has_many :simple_image_tags, through: :simple_image_tag_images
37
+
38
+ before_save :calculate_checksum
33
39
 
34
40
  validates_presence_of :image
35
- validates_length_of :caption, maximum: CAPTION_LIMIT
41
+ validates_length_of :caption, maximum: META_LIMIT
36
42
  validates_length_of :image_alt_text, maximum: META_LIMIT
37
- validates_length_of :source_link, maximum: LINK_LIMIT
38
- validates_length_of :source_name, maximum: NAME_LIMIT
43
+ validates_length_of :source_link, maximum: META_LIMIT
44
+ validates_length_of :source_name, maximum: META_LIMIT
45
+
46
+ scope :in_component, ->(v) { where(biovision_component: v) }
47
+ scope :filtered, ->(v) { where('image ilike ? or caption ilike ?', "%#{v}%", "%#{v}%") unless v.blank? }
48
+ scope :list_for_administration, -> { order(:image) }
49
+
50
+ # @param [String] input
51
+ def self.[](input)
52
+ case input
53
+ when /\A\h{8}-\h{4}-4\h{3}-[89ab]\h{3}-\h{12}\Z/i
54
+ find_by(uuid: input)
55
+ when /\A[a-f0-9]{64}\z/i
56
+ key = "data->>'#{ORIGINAL_CHECKSUM}'"
57
+ find_by(checksum: input) || find_by("#{key} = ?", input)
58
+ end
59
+ end
39
60
 
40
61
  def self.entity_parameters
41
62
  %i[caption image image_alt_text source_link source_name]
42
63
  end
43
64
 
65
+ def self.json_attributes
66
+ %i[caption image_alt_text source_link source_name]
67
+ end
68
+
44
69
  def name
45
- caption.blank? ? File.basename(image.path) : caption
70
+ File.basename(image.path)
71
+ end
72
+
73
+ def file_size
74
+ File.size(image.path)
75
+ end
76
+
77
+ def image_slug
78
+ "#{uuid[0..2]}/#{uuid[3..5]}/#{uuid}"
79
+ end
80
+
81
+ private
82
+
83
+ def calculate_checksum
84
+ return if image&.path.blank?
85
+
86
+ self.checksum = Digest::SHA256.file(image.path).hexdigest
46
87
  end
47
88
  end
@@ -9,22 +9,7 @@
9
9
  # updated_at [DateTime]
10
10
  class SimpleImageTag < ApplicationRecord
11
11
  include Checkable
12
- NAME_LIMIT = 100
12
+ include SimpleTag
13
13
 
14
14
  has_many :simple_image_tag_images, dependent: :delete_all
15
-
16
- before_validation :normalize_name
17
- validates_uniqueness_of :name, case_sensitive: false
18
-
19
- scope :list_for_administration, -> { order('name asc') }
20
-
21
- def self.entity_parameters
22
- %i[name]
23
- end
24
-
25
- private
26
-
27
- def normalize_name
28
- self.name = name.to_s[0..NAME_LIMIT]
29
- end
30
15
  end
data/app/models/token.rb CHANGED
@@ -64,7 +64,7 @@ class Token < ApplicationRecord
64
64
  return if input.blank?
65
65
 
66
66
  pair = input.split(':')
67
- user_by_pair(pair[0], pair[1], touch_user)
67
+ user_by_pair(pair[0].to_i, pair[1], touch_user)
68
68
  end
69
69
 
70
70
  # @param [Integer] user_id
@@ -83,11 +83,15 @@ class Token < ApplicationRecord
83
83
  "[#{id}] #{user.profile_name}"
84
84
  end
85
85
 
86
+ def text_for_link
87
+ name
88
+ end
89
+
86
90
  # @param [User] user
87
91
  def editable_by?(user)
88
92
  return true if owned_by?(user)
89
93
 
90
- Biovision::Components::UsersComponent[user].allow?('edit')
94
+ Biovision::Components::UsersComponent[user].permit?('edit', self)
91
95
  end
92
96
 
93
97
  def cookie_pair