biovision 0.1.210414.0 → 0.12.211128.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +50 -40
  3. data/app/assets/stylesheets/biovision/admin/components/users.scss +4 -0
  4. data/app/assets/stylesheets/biovision/admin/components.scss +10 -0
  5. data/app/assets/stylesheets/biovision/admin/layout.scss +34 -8
  6. data/app/assets/stylesheets/biovision/biovision.scss +64 -26
  7. data/app/assets/stylesheets/biovision/components/carousel.scss +24 -24
  8. data/app/assets/stylesheets/biovision/components/filters.scss +39 -0
  9. data/app/assets/stylesheets/biovision/components/forms.scss +56 -10
  10. data/app/assets/stylesheets/biovision/components/quick_search.scss +24 -0
  11. data/app/assets/stylesheets/biovision/components.scss +1 -0
  12. data/app/assets/stylesheets/biovision/default.scss +4 -4
  13. data/app/assets/stylesheets/biovision/themes/default_theme/components/users/dashboard.scss +4 -0
  14. data/app/assets/stylesheets/biovision/themes/default_theme/components/users.scss +1 -0
  15. data/app/assets/stylesheets/biovision/themes/default_theme/layout/footer.scss +3 -0
  16. data/app/assets/stylesheets/biovision/themes/default_theme/layout/header.scss +12 -0
  17. data/app/assets/stylesheets/biovision/themes/default_theme/layout.scss +6 -3
  18. data/app/assets/stylesheets/biovision/themes/default_theme.scss +0 -1
  19. data/app/assets/stylesheets/biovision/vars.scss +5 -0
  20. data/app/controllers/admin/biovision_components_controller.rb +10 -0
  21. data/app/controllers/admin/components_controller.rb +33 -83
  22. data/app/controllers/admin/dynamic_pages_controller.rb +1 -1
  23. data/app/controllers/admin/index_controller.rb +8 -2
  24. data/app/controllers/admin/navigation_groups_controller.rb +31 -0
  25. data/app/controllers/admin/tokens_controller.rb +15 -0
  26. data/app/controllers/admin/users_controller.rb +35 -4
  27. data/app/controllers/admin_controller.rb +2 -9
  28. data/app/controllers/concerns/component_stories.rb +22 -0
  29. data/app/controllers/concerns/crud_entities.rb +23 -15
  30. data/app/controllers/concerns/my_crud_entities.rb +146 -0
  31. data/app/controllers/concerns/processed_forms.rb +28 -0
  32. data/app/controllers/concerns/restricted_access.rb +37 -0
  33. data/app/controllers/contact_controller.rb +1 -1
  34. data/app/controllers/errors_controller.rb +37 -0
  35. data/app/controllers/my/components_controller.rb +21 -0
  36. data/app/controllers/my/index_controller.rb +1 -3
  37. data/app/controllers/my/profiles_controller.rb +2 -0
  38. data/app/controllers/oembed_controller.rb +12 -0
  39. data/app/controllers/profile_controller.rb +2 -0
  40. data/app/controllers/users_controller.rb +2 -0
  41. data/app/helpers/biovision_components_helper.rb +7 -3
  42. data/app/helpers/biovision_helper.rb +33 -34
  43. data/app/helpers/entity_helper.rb +77 -0
  44. data/app/helpers/my_helper.rb +34 -0
  45. data/app/lib/biovision/components/base/component_parameters.rb +13 -2
  46. data/app/lib/biovision/components/base/component_privileges.rb +28 -18
  47. data/app/lib/biovision/components/base/component_settings.rb +8 -0
  48. data/app/lib/biovision/components/base/component_stories.rb +30 -0
  49. data/app/lib/biovision/components/base/entity_links.rb +38 -0
  50. data/app/lib/biovision/components/base/image_handling.rb +33 -0
  51. data/app/lib/biovision/components/base_component.rb +20 -49
  52. data/app/lib/biovision/components/contact_component.rb +5 -1
  53. data/app/lib/biovision/components/content/oembed/receiver.rb +98 -0
  54. data/app/lib/biovision/components/content/oembed/twitter_receiver.rb +20 -0
  55. data/app/lib/biovision/components/content/oembed/vimeo_receiver.rb +20 -0
  56. data/app/lib/biovision/components/content/oembed/youtube_receiver.rb +20 -0
  57. data/app/lib/biovision/components/content_component.rb +46 -9
  58. data/app/lib/biovision/components/track_component.rb +1 -1
  59. data/app/lib/biovision/components/users_component.rb +34 -2
  60. data/app/lib/biovision/helpers/data_helper.rb +70 -0
  61. data/app/lib/biovision/helpers/export_helper.rb +97 -0
  62. data/app/lib/biovision/migrations/component_migration.rb +56 -0
  63. data/app/lib/biovision/stories/component_story.rb +55 -0
  64. data/app/mailers/feedback_mailer.rb +14 -0
  65. data/app/models/biovision_component.rb +17 -1
  66. data/app/models/browser.rb +1 -1
  67. data/app/models/code.rb +5 -5
  68. data/app/models/concerns/checkable.rb +2 -1
  69. data/app/models/concerns/has_uploaded_file.rb +26 -0
  70. data/app/models/concerns/simple_tag.rb +30 -0
  71. data/app/models/concerns/toggleable.rb +2 -1
  72. data/app/models/concerns/tree_structure.rb +4 -1
  73. data/app/models/contact_method.rb +1 -1
  74. data/app/models/contact_type.rb +1 -1
  75. data/app/models/dynamic_block.rb +1 -1
  76. data/app/models/dynamic_page.rb +3 -1
  77. data/app/models/feedback_message.rb +7 -1
  78. data/app/models/feedback_response.rb +2 -2
  79. data/app/models/metric.rb +4 -0
  80. data/app/models/navigation_group.rb +11 -1
  81. data/app/models/oembed_domain.rb +25 -0
  82. data/app/models/oembed_link.rb +19 -0
  83. data/app/models/oembed_receiver.rb +15 -0
  84. data/app/models/role.rb +42 -12
  85. data/app/models/simple_image.rb +30 -3
  86. data/app/models/simple_image_tag.rb +1 -16
  87. data/app/models/token.rb +6 -2
  88. data/app/models/uploaded_file.rb +62 -0
  89. data/app/models/uploaded_file_tag.rb +15 -0
  90. data/app/models/uploaded_file_tag_file.rb +13 -0
  91. data/app/models/user.rb +35 -10
  92. data/app/models/user_role.rb +0 -1
  93. data/app/uploaders/simple_file_uploader.rb +2 -6
  94. data/app/uploaders/simple_image_uploader.rb +10 -21
  95. data/app/uploaders/uploaders/path_slug.rb +22 -0
  96. data/app/views/admin/agents/index.html.erb +1 -1
  97. data/app/views/admin/biovision_components/_nav_item.html.erb +6 -0
  98. data/app/views/admin/biovision_components/entity/_in_list.html.erb +12 -0
  99. data/app/views/admin/biovision_components/index.html.erb +11 -0
  100. data/app/views/admin/components/_list.html.erb +1 -1
  101. data/app/views/admin/components/entity/_links.html.erb +31 -21
  102. data/app/views/admin/components/links/_base.html.erb +1 -0
  103. data/app/views/admin/components/settings/_settings.html.erb +3 -3
  104. data/app/views/admin/components/settings.html.erb +2 -1
  105. data/app/views/admin/dynamic_blocks/_form.html.erb +1 -1
  106. data/app/views/admin/dynamic_blocks/entity/_in_list.html.erb +8 -6
  107. data/app/views/admin/dynamic_blocks/index.html.erb +6 -4
  108. data/app/views/admin/dynamic_blocks/show.html.erb +9 -7
  109. data/app/views/admin/dynamic_pages/_dynamic_page.jbuilder +18 -0
  110. data/app/views/admin/dynamic_pages/entity/_in_list.html.erb +6 -4
  111. data/app/views/admin/dynamic_pages/entity/_in_search.html.erb +7 -0
  112. data/app/views/admin/dynamic_pages/index.html.erb +6 -4
  113. data/app/views/admin/dynamic_pages/search.jbuilder +4 -0
  114. data/app/views/admin/dynamic_pages/show.html.erb +2 -2
  115. data/app/views/admin/index/index.html.erb +7 -5
  116. data/app/views/admin/ip_addresses/index.html.erb +2 -2
  117. data/app/views/admin/navigation_group_pages/entity/_in_list.html.erb +26 -0
  118. data/app/views/admin/navigation_groups/entity/_dynamic_pages.html.erb +38 -0
  119. data/app/views/admin/navigation_groups/entity/_in_list.html.erb +7 -5
  120. data/app/views/admin/navigation_groups/index.html.erb +6 -4
  121. data/app/views/admin/navigation_groups/show.html.erb +16 -3
  122. data/app/views/admin/tokens/_form.html.erb +31 -0
  123. data/app/views/admin/tokens/_nav_item.html.erb +6 -0
  124. data/app/views/admin/tokens/entity/_in_list.html.erb +27 -0
  125. data/app/views/admin/tokens/index.html.erb +11 -0
  126. data/app/views/admin/tokens/show.html.erb +26 -0
  127. data/app/views/admin/users/_user.jbuilder +18 -0
  128. data/app/views/admin/users/entity/_fields.html.erb +1 -1
  129. data/app/views/admin/users/entity/_in_list.html.erb +3 -3
  130. data/app/views/admin/users/entity/_in_search.html.erb +18 -0
  131. data/app/views/admin/users/index.html.erb +13 -4
  132. data/app/views/admin/users/roles/_component.html.erb +22 -0
  133. data/app/views/admin/users/roles.html.erb +23 -0
  134. data/app/views/admin/users/search.jbuilder +4 -0
  135. data/app/views/admin/users/show.html.erb +28 -10
  136. data/app/views/admin/widgets/_filters.html.erb +20 -0
  137. data/app/views/admin/widgets/_quick_search.html.erb +13 -0
  138. data/app/views/admin/widgets/filters/_flag.html.erb +15 -0
  139. data/app/views/admin/widgets/filters/_text.html.erb +7 -0
  140. data/app/views/application/unauthorized.html.erb +4 -1
  141. data/app/views/components/content/_dynamic_page.html.erb +6 -10
  142. data/app/views/components/content/_dynamic_page_content.html.erb +14 -0
  143. data/app/views/components/users/_login_form.html.erb +1 -0
  144. data/app/views/contact/_form.html.erb +1 -1
  145. data/app/views/errors/error.html.erb +1 -0
  146. data/app/views/feedback_mailer/new_feedback_request.html.erb +11 -0
  147. data/app/views/feedback_mailer/new_feedback_request.text.erb +6 -0
  148. data/app/views/index/index.html.erb +14 -0
  149. data/app/views/layouts/admin/_header.html.erb +7 -2
  150. data/app/views/layouts/admin.html.erb +0 -1
  151. data/app/views/layouts/application/_footer.html.erb +1 -1
  152. data/app/views/layouts/application/header/_authentication.html.erb +4 -1
  153. data/app/views/my/components/index.html.erb +25 -0
  154. data/app/views/my/components/show.html.erb +21 -0
  155. data/app/views/my/index/_cards.html.erb +15 -0
  156. data/app/views/my/index/_email.html.erb +14 -0
  157. data/app/views/my/index/_navigation.html.erb +33 -0
  158. data/app/views/my/index/index.html.erb +7 -26
  159. data/app/views/my/profiles/show.html.erb +13 -0
  160. data/app/views/{admin/components/links/extra/_content.html.erb → my/recoveries/show.html.erb} +0 -0
  161. data/app/views/shared/admin/_list.html.erb +10 -19
  162. data/app/views/shared/admin/_list_with_priority.html.erb +10 -19
  163. data/app/views/shared/admin/_priority.html.erb +6 -5
  164. data/app/views/shared/admin/_toggle.html.erb +5 -10
  165. data/app/views/shared/entity/_date_field.html.erb +6 -0
  166. data/app/views/shared/entity/_linked_entity.html.erb +2 -2
  167. data/app/views/shared/entity/_list.html.erb +22 -0
  168. data/app/views/shared/entity/_list_with_priority.html.erb +22 -0
  169. data/app/views/shared/entity/_parent.html.erb +1 -1
  170. data/app/views/shared/entity/_priority_icons.html.erb +8 -0
  171. data/app/views/shared/entity/_time_field.html.erb +6 -0
  172. data/app/views/shared/entity/_toggle.html.erb +12 -0
  173. data/app/views/shared/entity/_track.html.erb +12 -0
  174. data/app/views/shared/entity/_tree_caches.html.erb +8 -1
  175. data/app/views/shared/entity/edit.html.erb +10 -6
  176. data/app/views/shared/entity/new.html.erb +4 -2
  177. data/app/views/shared/forms/_field.html.erb +6 -2
  178. data/app/views/shared/forms/_field_with_search.html.erb +17 -0
  179. data/app/views/shared/forms/_meta_texts.html.erb +1 -1
  180. data/app/views/shared/forms/_simple_entity_link.html.erb +14 -0
  181. data/app/views/shared/forms/_simple_image.html.erb +12 -4
  182. data/app/views/shared/forms/_text_area.html.erb +1 -1
  183. data/app/views/shared/forms/_text_field.html.erb +1 -1
  184. data/app/views/shared/my/_list.html.erb +10 -19
  185. data/app/views/shared/my/_list_with_priority.html.erb +10 -19
  186. data/app/views/shared/my/entity/edit.html.erb +25 -0
  187. data/app/views/shared/my/entity/new.html.erb +18 -0
  188. data/app/views/simple_images/_simple_image.jbuilder +13 -0
  189. data/config/locales/biovision-ru.yml +18 -1
  190. data/config/locales/components-ru.yml +27 -4
  191. data/config/locales/contact-ru.yml +4 -0
  192. data/config/locales/content-ru.yml +12 -0
  193. data/config/locales/users-ru.yml +31 -6
  194. data/config/routes.rb +35 -4
  195. data/db/migrate/20191228000000_create_biovision_components.rb +2 -0
  196. data/db/migrate/20200224000000_create_track_component.rb +8 -12
  197. data/db/migrate/20200224000010_create_users_component.rb +8 -49
  198. data/db/migrate/20200404000000_create_simple_images.rb +1 -0
  199. data/db/migrate/20210405000000_create_acl.rb +15 -1
  200. data/db/migrate/{20200529000000_create_content_component.rb → 20210421000000_create_content_component.rb} +24 -18
  201. data/db/migrate/{20210401000000_create_contact_component.rb → 20210421000010_create_contact_component.rb} +1 -22
  202. data/db/migrate/20210616000000_create_uploaded_files.rb +52 -0
  203. data/db/migrate/amends/20210816060606_create_oembed_receivers.rb +21 -0
  204. data/db/migrate/amends/20210907070707_add_checksum_to_simple_images.rb +13 -0
  205. data/lib/biovision/base_methods.rb +8 -28
  206. data/lib/biovision/version.rb +1 -1
  207. data/lib/tasks/components.rake +51 -0
  208. metadata +90 -17
  209. data/app/lib/biovision/components/base/privilege_handler.rb +0 -79
  210. data/app/models/biovision_component_user.rb +0 -21
  211. data/app/views/admin/components/links/_content.html.erb +0 -9
  212. data/app/views/admin/components/links/_track.html.erb +0 -2
  213. data/app/views/admin/components/links/_users.html.erb +0 -4
  214. data/app/views/admin/components/privileges/_component_user.html.erb +0 -17
  215. data/app/views/admin/components/privileges/_links.html.erb +0 -17
  216. data/app/views/admin/components/privileges/_users.html.erb +0 -23
  217. data/app/views/admin/components/privileges.html.erb +0 -20
data/config/routes.rb CHANGED
@@ -13,6 +13,14 @@ Rails.application.routes.draw do
13
13
  post :toggle, on: :member, defaults: { format: :json }
14
14
  end
15
15
 
16
+ concern :search do
17
+ get :search, on: :collection
18
+ end
19
+
20
+ concern :stories do
21
+ post 'stories/:slug' => :story, on: :collection, as: :story
22
+ end
23
+
16
24
  # Handling errors
17
25
  match '/400' => 'errors#bad_request', via: :all
18
26
  match '/401' => 'errors#unauthorized', via: :all
@@ -51,6 +59,8 @@ Rails.application.routes.draw do
51
59
  namespace :admin do
52
60
  get '/' => 'index#index'
53
61
 
62
+ resources :biovision_components, only: :index, concerns: %i[priority toggle]
63
+
54
64
  scope :components, controller: :components do
55
65
  get '/' => :index, as: :components
56
66
  scope ':slug' do
@@ -58,8 +68,6 @@ Rails.application.routes.draw do
58
68
  get 'settings' => :settings, as: :component_settings
59
69
  patch 'settings' => :update_settings, as: nil
60
70
  patch 'parameters' => :update_parameter, as: :component_parameters
61
- get 'privileges' => :privileges, as: :component_privileges
62
- patch 'privileges' => :update_privileges, as: nil
63
71
  put 'administrators/:user_id' => :add_administrator, as: :component_administrators
64
72
  delete 'administrators/:user_id' => :remove_administrator, as: nil
65
73
  get 'images' => :images, as: :component_images
@@ -72,7 +80,7 @@ Rails.application.routes.draw do
72
80
  resources :agents, :ip_addresses, only: :index
73
81
 
74
82
  # Content component
75
- resources :dynamic_pages, :dynamic_blocks, concerns: %i[check toggle]
83
+ resources :dynamic_pages, :dynamic_blocks, concerns: %i[check search toggle]
76
84
  resources :navigation_groups, concerns: :check do
77
85
  member do
78
86
  put 'dynamic_pages/:page_id' => :add_page, as: :dynamic_page
@@ -81,7 +89,16 @@ Rails.application.routes.draw do
81
89
  end
82
90
  end
83
91
 
84
- resources :users, concerns: %i[check toggle]
92
+ # Users component
93
+ resources :users, concerns: %i[check search toggle] do
94
+ member do
95
+ get 'roles'
96
+ put 'roles/:role_id' => :add_role, as: :role
97
+ delete 'roles/:role_id' => :remove_role
98
+ post 'authenticate'
99
+ end
100
+ end
101
+ resources :tokens, concerns: %i[toggle]
85
102
  end
86
103
 
87
104
  namespace :my do
@@ -89,7 +106,21 @@ Rails.application.routes.draw do
89
106
 
90
107
  resource :profile, except: :destroy, concerns: :check
91
108
  resource :confirmation, :recovery, only: %i[show create update]
109
+
110
+ scope :components, controller: :components do
111
+ get '/' => :index, as: :components
112
+ scope ':slug' do
113
+ get '/' => :show, as: :component
114
+ get 'images' => :images, as: :component_images
115
+ post 'images' => :create_image, as: nil
116
+ post 'ckeditor'
117
+ end
118
+ end
119
+ get 'dashboard' => 'components#index'
120
+ get 'dashboard/:slug' => 'components#show', as: :component_dashboard
92
121
  end
93
122
 
123
+ post 'oembed' => 'oembed#code'
124
+
94
125
  get ':slug' => 'fallback#show', constraints: { slug: /.+/ }
95
126
  end
@@ -7,6 +7,8 @@ class CreateBiovisionComponents < ActiveRecord::Migration[6.0]
7
7
  create_metrics unless Metric.table_exists?
8
8
  create_metric_values unless MetricValue.table_exists?
9
9
  create_languages unless Language.table_exists?
10
+
11
+ Biovision::Components::BaseComponent.create
10
12
  end
11
13
 
12
14
  def down
@@ -1,21 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Create entry and tables for track component
4
- class CreateTrackComponent < ActiveRecord::Migration[6.0]
5
- def up
6
- BiovisionComponent.create(slug: Biovision::Components::TrackComponent.slug)
4
+ class CreateTrackComponent < ActiveRecord::Migration[6.1]
5
+ include Biovision::Migrations::ComponentMigration
7
6
 
8
- create_browsers unless Browser.table_exists?
9
- create_agents unless Agent.table_exists?
10
- create_ip_addresses unless IpAddress.table_exists?
11
- end
7
+ def up
8
+ component.create
9
+ component.dependent_models.each do |model|
10
+ next if model.table_exists?
12
11
 
13
- def down
14
- Biovision::Components::TrackComponent.dependent_models.each do |model|
15
- drop_table model.table_name if model.table_exists?
12
+ message = "create_#{model.table_name}".to_sym
13
+ send(message) if respond_to?(message, true)
16
14
  end
17
-
18
- BiovisionComponent[Biovision::Components::TrackComponent]&.destroy
19
15
  end
20
16
 
21
17
  private
@@ -1,50 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Create tables for Users component
4
- class CreateUsersComponent < ActiveRecord::Migration[6.0]
4
+ class CreateUsersComponent < ActiveRecord::Migration[6.1]
5
+ include Biovision::Migrations::ComponentMigration
6
+
5
7
  def up
6
- create_component
7
- create_users unless User.table_exists?
8
- create_tokens unless Token.table_exists?
9
- create_login_attempts unless LoginAttempt.table_exists?
10
- create_user_languages unless UserLanguage.table_exists?
11
- create_component_links unless BiovisionComponentUser.table_exists?
12
- create_codes unless Code.table_exists?
13
- create_notifications unless Notification.table_exists?
14
- end
8
+ component.create
9
+ component.dependent_models.each do |model|
10
+ next if model.table_exists?
15
11
 
16
- def down
17
- Biovision::Components::UsersComponent.dependent_models.each do |model|
18
- drop_table model.table_name if model.table_exists?
12
+ message = "create_#{model.table_name}".to_sym
13
+ send(message) if respond_to?(message, true)
19
14
  end
20
-
21
- BiovisionComponent[Biovision::Components::UsersComponent]&.destroy
22
15
  end
23
16
 
24
17
  private
25
18
 
26
- def create_component
27
- slug = Biovision::Components::UsersComponent.slug
28
-
29
- settings = {
30
- registration_open: true,
31
- email_as_login: false,
32
- phone_as_login: false,
33
- confirm_email: false,
34
- require_email: false,
35
- confirm_phone: false,
36
- require_phone: false,
37
- invite_only: false,
38
- use_invites: false,
39
- invite_count: 5,
40
- bounce_count: 10,
41
- bounce_timeout: 3,
42
- use_phone: false
43
- }
44
-
45
- BiovisionComponent.create(slug: slug, settings: settings)
46
- end
47
-
48
19
  def create_users
49
20
  create_table :users, comment: 'Users' do |t|
50
21
  t.uuid :uuid, null: false
@@ -117,18 +88,6 @@ class CreateUsersComponent < ActiveRecord::Migration[6.0]
117
88
  end
118
89
  end
119
90
 
120
- def create_component_links
121
- create_table :biovision_component_users, comment: 'Privileges and settings for users in components' do |t|
122
- t.references :biovision_component, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
123
- t.references :user, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
124
- t.boolean :administrator, default: false, null: false
125
- t.timestamps
126
- t.jsonb :data, default: {}, null: false
127
- end
128
-
129
- add_index :biovision_component_users, :data, using: :gin
130
- end
131
-
132
91
  def create_codes
133
92
  create_table :codes, comment: 'Codes for different purposes' do |t|
134
93
  t.references :biovision_component, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
@@ -30,6 +30,7 @@ class CreateSimpleImages < ActiveRecord::Migration[6.0]
30
30
  t.string :caption
31
31
  t.string :source_name
32
32
  t.string :source_link
33
+ t.string :checksum, index: true
33
34
  t.jsonb :data, default: {}, null: false
34
35
  end
35
36
 
@@ -8,6 +8,8 @@ class CreateAcl < ActiveRecord::Migration[6.1]
8
8
  create_role_groups unless RoleGroup.table_exists?
9
9
  create_user_groups unless UserGroup.table_exists?
10
10
  create_user_roles unless UserRole.table_exists?
11
+
12
+ create_component_roles
11
13
  end
12
14
 
13
15
  def down
@@ -67,8 +69,20 @@ class CreateAcl < ActiveRecord::Migration[6.1]
67
69
  create_table :user_roles, comment: 'Users with (and without) ACL roles' do |t|
68
70
  t.references :user, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
69
71
  t.references :role, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
70
- t.boolean :inclusive, default: true, null: false
71
72
  t.timestamps
72
73
  end
73
74
  end
75
+
76
+ def create_component_roles
77
+ BiovisionComponent.pluck(:slug).each do |component|
78
+ next if component == Biovision::Components::BaseComponent.slug
79
+
80
+ Biovision::Components::BaseComponent.handler(component).create_roles
81
+ end
82
+
83
+ base_component = BiovisionComponent[Biovision::Components::BaseComponent]
84
+ %w[admin components.view].each do |role|
85
+ Role.create(biovision_component: base_component, slug: role)
86
+ end
87
+ end
74
88
  end
@@ -1,23 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Create Content component and tables
4
- class CreateContentComponent < ActiveRecord::Migration[6.0]
5
- def up
6
- BiovisionComponent.create(slug: Biovision::Components::ContentComponent.slug)
7
-
8
- create_dynamic_pages unless DynamicPage.table_exists?
9
- create_navigation_groups unless NavigationGroup.table_exists?
10
- create_pages_in_groups unless NavigationGroupPage.table_exists?
11
- create_dynamic_blocks unless DynamicBlock.table_exists?
12
- end
13
-
14
- def down
15
- Biovision::Components::ContentComponent.dependent_models.each do |model|
16
- drop_table model.table_name if model.table_exists?
17
- end
18
-
19
- BiovisionComponent[Biovision::Components::ContentComponent]&.destroy
20
- end
4
+ class CreateContentComponent < ActiveRecord::Migration[6.1]
5
+ include Biovision::Migrations::ComponentMigration
21
6
 
22
7
  private
23
8
 
@@ -50,7 +35,7 @@ class CreateContentComponent < ActiveRecord::Migration[6.0]
50
35
  add_index :dynamic_pages, :data, using: :gin
51
36
  end
52
37
 
53
- def create_pages_in_groups
38
+ def create_navigation_group_pages
54
39
  create_table :navigation_group_pages, comment: 'Dynamic pages in navigation groups' do |t|
55
40
  t.references :navigation_group, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
56
41
  t.references :dynamic_page, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
@@ -71,4 +56,25 @@ class CreateContentComponent < ActiveRecord::Migration[6.0]
71
56
  add_index :dynamic_blocks, :slug, unique: true
72
57
  add_index :dynamic_blocks, :data, using: :gin
73
58
  end
59
+
60
+ def create_oembed_receivers
61
+ create_table :oembed_receivers, comment: 'Receivers for OEmbed content' do |t|
62
+ t.string :slug, null: false, index: true
63
+ end
64
+ end
65
+
66
+ def create_oembed_domains
67
+ create_table :oembed_domains, comment: 'Supported domains for OEmbed' do |t|
68
+ t.references :oembed_receiver, foreign_key: { on_update: :cascade, on_delete: :nullify }
69
+ t.string :name, null: false, index: true
70
+ end
71
+ end
72
+
73
+ def create_oembed_links
74
+ create_table :oembed_links, comment: 'Embedded links' do |t|
75
+ t.string :url, null: false
76
+ t.text :code
77
+ t.timestamps
78
+ end
79
+ end
74
80
  end
@@ -2,31 +2,10 @@
2
2
 
3
3
  # Create tables for contact component
4
4
  class CreateContactComponent < ActiveRecord::Migration[6.1]
5
- def up
6
- create_component
7
- create_feedback_messages unless FeedbackMessage.table_exists?
8
- create_feedback_responses unless FeedbackResponse.table_exists?
9
- create_contact_types unless ContactType.table_exists?
10
- create_contact_methods unless ContactMethod.table_exists?
11
- end
12
-
13
- def down
14
- Biovision::Components::ContactComponent.dependent_models.each do |model|
15
- drop_table model.table_name if model.table_exists?
16
- end
17
-
18
- BiovisionComponent[Biovision::Components::ContactComponent]&.destroy
19
- end
5
+ include Biovision::Migrations::ComponentMigration
20
6
 
21
7
  private
22
8
 
23
- def create_component
24
- settings = { feedback_email: '' }
25
- slug = Biovision::Components::ContactComponent.slug
26
-
27
- BiovisionComponent.create(slug: slug, settings: settings)
28
- end
29
-
30
9
  def create_feedback_messages
31
10
  create_table :feedback_messages, comment: 'Feedback messages from visitors' do |t|
32
11
  t.uuid :uuid, null: false
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Create tables for storing uploaded files
4
+ class CreateUploadedFiles < ActiveRecord::Migration[6.1]
5
+ def up
6
+ create_uploaded_files unless UploadedFile.table_exists?
7
+ create_uploaded_file_tags unless UploadedFileTag.table_exists?
8
+ create_uploaded_file_tag_files unless UploadedFileTagFile.table_exists?
9
+ end
10
+
11
+ def down
12
+ [UploadedFileTagFile, UploadedFileTag, UploadedFile].each do |model|
13
+ drop_table model.table_name if model.table_exists?
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def create_uploaded_files
20
+ create_table :uploaded_files, comment: 'Uploaded files' do |t|
21
+ t.uuid :uuid, null: false
22
+ t.references :biovision_component, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
23
+ t.references :user, foreign_key: { on_update: :cascade, on_delete: :nullify }
24
+ t.references :agent, foreign_key: { on_update: :cascade, on_delete: :nullify }
25
+ t.references :ip_address, foreign_key: { on_update: :cascade, on_delete: :nullify }
26
+ t.integer :object_count, default: 0, null: false
27
+ t.timestamps
28
+ t.string :attachment
29
+ t.string :description
30
+ t.string :checksum, index: true
31
+ t.jsonb :data, default: {}, null: false
32
+ end
33
+
34
+ add_index :uploaded_files, :uuid, unique: true
35
+ add_index :uploaded_files, :data, using: :gin
36
+ end
37
+
38
+ def create_uploaded_file_tags
39
+ create_table :uploaded_file_tags, comment: 'Tags for uploaded files' do |t|
40
+ t.string :name, null: false, index: true
41
+ t.integer :uploaded_files_count, default: 0, null: false
42
+ t.timestamps
43
+ end
44
+ end
45
+
46
+ def create_uploaded_file_tag_files
47
+ create_table :uploaded_file_tag_files, comment: 'Links between uploaded files and tags' do |t|
48
+ t.references :uploaded_file_tag, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
49
+ t.references :uploaded_file, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Create tables for OEmbed
4
+ class CreateOembedReceivers < ActiveRecord::Migration[6.1]
5
+ def change
6
+ # create_table :oembed_receivers, comment: 'Receivers for OEmbed content' do |t|
7
+ # t.string :slug, null: false, index: true
8
+ # end
9
+ #
10
+ # create_table :oembed_domains, comment: 'Supported domains for OEmbed' do |t|
11
+ # t.references :oembed_receiver, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
12
+ # t.string :name, null: false, index: true
13
+ # end
14
+ #
15
+ # create_table :oembed_links, comment: 'Embedded links' do |t|
16
+ # t.string :url, null: false
17
+ # t.text :code
18
+ # t.timestamps
19
+ # end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add checksum field to simple images
4
+ class AddChecksumToSimpleImages < ActiveRecord::Migration[6.1]
5
+ def up
6
+ # add_column :simple_images, :checksum, :string, index: true
7
+ # SimpleImage.order(:id).each(&:save)
8
+ end
9
+
10
+ def down
11
+ # remove_column :simple_images, :checksum
12
+ end
13
+ end
@@ -11,7 +11,7 @@ module Biovision
11
11
  helper_method :component_handler
12
12
  helper_method :current_page, :param_from_request
13
13
  helper_method :current_user, :current_language
14
- helper_method :content_component
14
+ helper_method :content_component, :users_component
15
15
  end
16
16
 
17
17
  # Get current page number from request
@@ -53,6 +53,13 @@ module Biovision
53
53
  @content_component ||= Biovision::Components::ContentComponent[current_user]
54
54
  end
55
55
 
56
+ # Get users component handler
57
+ #
58
+ # @return [Biovision::Components::UsersComponent]
59
+ def users_component
60
+ @users_component ||= Biovision::Components::UsersComponent[current_user]
61
+ end
62
+
56
63
  # @return [Agent]
57
64
  def agent
58
65
  @agent ||= Agent[request.user_agent || 'n/a']
@@ -116,13 +123,6 @@ module Biovision
116
123
  handle_http_error(:service_unavailable, message, view)
117
124
  end
118
125
 
119
- # Restrict access for anonymous users
120
- def restrict_anonymous_access
121
- return unless current_user.nil?
122
-
123
- handle_http_401(t('application.errors.restricted_access'))
124
- end
125
-
126
126
  # Owner information for entity
127
127
  #
128
128
  # @param [TrueClass|FalseClass] track
@@ -144,26 +144,6 @@ module Biovision
144
144
  @remote_ip ||= (request.env['HTTP_X_REAL_IP'] || request.remote_ip)
145
145
  end
146
146
 
147
- # @param [String] next_page
148
- def form_processed_ok(next_page)
149
- respond_to do |format|
150
- format.js { render(js: "document.location.href = '#{next_page}'") }
151
- format.json { render(json: { links: { next: next_page } }) }
152
- format.html { redirect_to(next_page) }
153
- end
154
- end
155
-
156
- # @param [Symbol|String] view_to_render
157
- # @param [Array] errors
158
- def form_processed_with_error(view_to_render, errors = [])
159
- @errors = errors
160
- respond_to do |format|
161
- format.js { render('shared/forms/errors', status: :bad_request) }
162
- format.json { render('shared/forms/errors', status: :bad_request) }
163
- format.html { render(view_to_render, status: :bad_request) }
164
- end
165
- end
166
-
167
147
  def component_class
168
148
  Biovision::Components::BaseComponent
169
149
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Biovision
4
- VERSION = '0.1.210414.0'
4
+ VERSION = '0.12.211128.0'
5
5
  end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :components do
4
+ desc 'Reset role list for all components'
5
+ task reset_role_list: :environment do
6
+ BiovisionComponent.pluck(:slug).each do |component|
7
+ next if component == Biovision::Components::BaseComponent.slug
8
+
9
+ handler = Biovision::Components::BaseComponent.handler(component)
10
+ valid_roles = []
11
+ handler.role_tree.each do |prefix, postfixes|
12
+ postfixes.each do |postfix|
13
+ slug = prefix.blank? ? postfix : "#{prefix}.#{postfix}"
14
+ valid_roles << slug
15
+ Role.create(biovision_component: handler.component, slug: slug)
16
+ end
17
+ end
18
+
19
+ handler.component.roles.each do |role|
20
+ role.destroy unless valid_roles.include?(role.slug)
21
+ end
22
+ end
23
+
24
+ base_component = BiovisionComponent[Biovision::Components::BaseComponent]
25
+ base_roles = %w[admin components.view]
26
+ base_roles.each do |role|
27
+ Role.create(biovision_component: base_component, slug: role)
28
+ end
29
+ base_component.roles.each do |role|
30
+ role.destroy unless base_roles.include?(role.slug)
31
+ end
32
+ end
33
+
34
+ desc 'Export all data from each component'
35
+ task export_all: :environment do
36
+ helper = Biovision::Helpers::ExportHelper.new
37
+ [
38
+ Language, MetricValue, Metric, BiovisionComponent, SimpleImageTagImage,
39
+ SimpleImageTag, SimpleImage, UploadedFileTagFile, UploadedFileTag,
40
+ UploadedFile, UserRole, UserGroup, RoleGroup, Role, Group
41
+ ].each do |model|
42
+ helper.export_model(model)
43
+ end
44
+ BiovisionComponent.order(:id).pluck(:slug).each do |slug|
45
+ handler = Biovision::Components::BaseComponent.handler_class(slug)
46
+ handler.dependent_models.each do |model|
47
+ helper.export_model(model)
48
+ end
49
+ end
50
+ end
51
+ end