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.
- checksums.yaml +4 -4
- data/README.md +50 -40
- data/app/assets/stylesheets/biovision/admin/components/users.scss +4 -0
- data/app/assets/stylesheets/biovision/admin/components.scss +10 -0
- data/app/assets/stylesheets/biovision/admin/layout.scss +34 -8
- data/app/assets/stylesheets/biovision/biovision.scss +64 -26
- data/app/assets/stylesheets/biovision/components/carousel.scss +24 -24
- data/app/assets/stylesheets/biovision/components/filters.scss +39 -0
- data/app/assets/stylesheets/biovision/components/forms.scss +56 -10
- data/app/assets/stylesheets/biovision/components/quick_search.scss +24 -0
- data/app/assets/stylesheets/biovision/components.scss +1 -0
- data/app/assets/stylesheets/biovision/default.scss +4 -4
- data/app/assets/stylesheets/biovision/themes/default_theme/components/users/dashboard.scss +4 -0
- data/app/assets/stylesheets/biovision/themes/default_theme/components/users.scss +1 -0
- data/app/assets/stylesheets/biovision/themes/default_theme/layout/footer.scss +3 -0
- data/app/assets/stylesheets/biovision/themes/default_theme/layout/header.scss +12 -0
- data/app/assets/stylesheets/biovision/themes/default_theme/layout.scss +6 -3
- data/app/assets/stylesheets/biovision/themes/default_theme.scss +0 -1
- data/app/assets/stylesheets/biovision/vars.scss +5 -0
- data/app/controllers/admin/biovision_components_controller.rb +10 -0
- data/app/controllers/admin/components_controller.rb +33 -83
- data/app/controllers/admin/dynamic_pages_controller.rb +1 -1
- data/app/controllers/admin/index_controller.rb +8 -2
- data/app/controllers/admin/navigation_groups_controller.rb +31 -0
- data/app/controllers/admin/tokens_controller.rb +15 -0
- data/app/controllers/admin/users_controller.rb +35 -4
- data/app/controllers/admin_controller.rb +2 -9
- data/app/controllers/concerns/component_stories.rb +22 -0
- data/app/controllers/concerns/crud_entities.rb +23 -15
- data/app/controllers/concerns/my_crud_entities.rb +146 -0
- data/app/controllers/concerns/processed_forms.rb +28 -0
- data/app/controllers/concerns/restricted_access.rb +37 -0
- data/app/controllers/contact_controller.rb +1 -1
- data/app/controllers/errors_controller.rb +37 -0
- data/app/controllers/my/components_controller.rb +21 -0
- data/app/controllers/my/index_controller.rb +1 -3
- data/app/controllers/my/profiles_controller.rb +2 -0
- data/app/controllers/oembed_controller.rb +12 -0
- data/app/controllers/profile_controller.rb +2 -0
- data/app/controllers/users_controller.rb +2 -0
- data/app/helpers/biovision_components_helper.rb +7 -3
- data/app/helpers/biovision_helper.rb +33 -34
- data/app/helpers/entity_helper.rb +77 -0
- data/app/helpers/my_helper.rb +34 -0
- data/app/lib/biovision/components/base/component_parameters.rb +13 -2
- data/app/lib/biovision/components/base/component_privileges.rb +28 -18
- data/app/lib/biovision/components/base/component_settings.rb +8 -0
- data/app/lib/biovision/components/base/component_stories.rb +30 -0
- data/app/lib/biovision/components/base/entity_links.rb +38 -0
- data/app/lib/biovision/components/base/image_handling.rb +33 -0
- data/app/lib/biovision/components/base_component.rb +20 -49
- data/app/lib/biovision/components/contact_component.rb +5 -1
- data/app/lib/biovision/components/content/oembed/receiver.rb +98 -0
- data/app/lib/biovision/components/content/oembed/twitter_receiver.rb +20 -0
- data/app/lib/biovision/components/content/oembed/vimeo_receiver.rb +20 -0
- data/app/lib/biovision/components/content/oembed/youtube_receiver.rb +20 -0
- data/app/lib/biovision/components/content_component.rb +46 -9
- data/app/lib/biovision/components/track_component.rb +1 -1
- data/app/lib/biovision/components/users_component.rb +34 -2
- data/app/lib/biovision/helpers/data_helper.rb +70 -0
- data/app/lib/biovision/helpers/export_helper.rb +97 -0
- data/app/lib/biovision/migrations/component_migration.rb +56 -0
- data/app/lib/biovision/stories/component_story.rb +55 -0
- data/app/mailers/feedback_mailer.rb +14 -0
- data/app/models/biovision_component.rb +17 -1
- data/app/models/browser.rb +1 -1
- data/app/models/code.rb +5 -5
- data/app/models/concerns/checkable.rb +2 -1
- data/app/models/concerns/has_uploaded_file.rb +26 -0
- data/app/models/concerns/simple_tag.rb +30 -0
- data/app/models/concerns/toggleable.rb +2 -1
- data/app/models/concerns/tree_structure.rb +4 -1
- data/app/models/contact_method.rb +1 -1
- data/app/models/contact_type.rb +1 -1
- data/app/models/dynamic_block.rb +1 -1
- data/app/models/dynamic_page.rb +3 -1
- data/app/models/feedback_message.rb +7 -1
- data/app/models/feedback_response.rb +2 -2
- data/app/models/metric.rb +4 -0
- data/app/models/navigation_group.rb +11 -1
- data/app/models/oembed_domain.rb +25 -0
- data/app/models/oembed_link.rb +19 -0
- data/app/models/oembed_receiver.rb +15 -0
- data/app/models/role.rb +42 -12
- data/app/models/simple_image.rb +30 -3
- data/app/models/simple_image_tag.rb +1 -16
- data/app/models/token.rb +6 -2
- data/app/models/uploaded_file.rb +62 -0
- data/app/models/uploaded_file_tag.rb +15 -0
- data/app/models/uploaded_file_tag_file.rb +13 -0
- data/app/models/user.rb +35 -10
- data/app/models/user_role.rb +0 -1
- data/app/uploaders/simple_file_uploader.rb +2 -6
- data/app/uploaders/simple_image_uploader.rb +10 -21
- data/app/uploaders/uploaders/path_slug.rb +22 -0
- data/app/views/admin/agents/index.html.erb +1 -1
- data/app/views/admin/biovision_components/_nav_item.html.erb +6 -0
- data/app/views/admin/biovision_components/entity/_in_list.html.erb +12 -0
- data/app/views/admin/biovision_components/index.html.erb +11 -0
- data/app/views/admin/components/_list.html.erb +1 -1
- data/app/views/admin/components/entity/_links.html.erb +31 -21
- data/app/views/admin/components/links/_base.html.erb +1 -0
- data/app/views/admin/components/settings/_settings.html.erb +3 -3
- data/app/views/admin/components/settings.html.erb +2 -1
- data/app/views/admin/dynamic_blocks/_form.html.erb +1 -1
- data/app/views/admin/dynamic_blocks/entity/_in_list.html.erb +8 -6
- data/app/views/admin/dynamic_blocks/index.html.erb +6 -4
- data/app/views/admin/dynamic_blocks/show.html.erb +9 -7
- data/app/views/admin/dynamic_pages/_dynamic_page.jbuilder +18 -0
- data/app/views/admin/dynamic_pages/entity/_in_list.html.erb +6 -4
- data/app/views/admin/dynamic_pages/entity/_in_search.html.erb +7 -0
- data/app/views/admin/dynamic_pages/index.html.erb +6 -4
- data/app/views/admin/dynamic_pages/search.jbuilder +4 -0
- data/app/views/admin/dynamic_pages/show.html.erb +2 -2
- data/app/views/admin/index/index.html.erb +7 -5
- data/app/views/admin/ip_addresses/index.html.erb +2 -2
- data/app/views/admin/navigation_group_pages/entity/_in_list.html.erb +26 -0
- data/app/views/admin/navigation_groups/entity/_dynamic_pages.html.erb +38 -0
- data/app/views/admin/navigation_groups/entity/_in_list.html.erb +7 -5
- data/app/views/admin/navigation_groups/index.html.erb +6 -4
- data/app/views/admin/navigation_groups/show.html.erb +16 -3
- data/app/views/admin/tokens/_form.html.erb +31 -0
- data/app/views/admin/tokens/_nav_item.html.erb +6 -0
- data/app/views/admin/tokens/entity/_in_list.html.erb +27 -0
- data/app/views/admin/tokens/index.html.erb +11 -0
- data/app/views/admin/tokens/show.html.erb +26 -0
- data/app/views/admin/users/_user.jbuilder +18 -0
- data/app/views/admin/users/entity/_fields.html.erb +1 -1
- data/app/views/admin/users/entity/_in_list.html.erb +3 -3
- data/app/views/admin/users/entity/_in_search.html.erb +18 -0
- data/app/views/admin/users/index.html.erb +13 -4
- data/app/views/admin/users/roles/_component.html.erb +22 -0
- data/app/views/admin/users/roles.html.erb +23 -0
- data/app/views/admin/users/search.jbuilder +4 -0
- data/app/views/admin/users/show.html.erb +28 -10
- data/app/views/admin/widgets/_filters.html.erb +20 -0
- data/app/views/admin/widgets/_quick_search.html.erb +13 -0
- data/app/views/admin/widgets/filters/_flag.html.erb +15 -0
- data/app/views/admin/widgets/filters/_text.html.erb +7 -0
- data/app/views/application/unauthorized.html.erb +4 -1
- data/app/views/components/content/_dynamic_page.html.erb +6 -10
- data/app/views/components/content/_dynamic_page_content.html.erb +14 -0
- data/app/views/components/users/_login_form.html.erb +1 -0
- data/app/views/contact/_form.html.erb +1 -1
- data/app/views/errors/error.html.erb +1 -0
- data/app/views/feedback_mailer/new_feedback_request.html.erb +11 -0
- data/app/views/feedback_mailer/new_feedback_request.text.erb +6 -0
- data/app/views/index/index.html.erb +14 -0
- data/app/views/layouts/admin/_header.html.erb +7 -2
- data/app/views/layouts/admin.html.erb +0 -1
- data/app/views/layouts/application/_footer.html.erb +1 -1
- data/app/views/layouts/application/header/_authentication.html.erb +4 -1
- data/app/views/my/components/index.html.erb +25 -0
- data/app/views/my/components/show.html.erb +21 -0
- data/app/views/my/index/_cards.html.erb +15 -0
- data/app/views/my/index/_email.html.erb +14 -0
- data/app/views/my/index/_navigation.html.erb +33 -0
- data/app/views/my/index/index.html.erb +7 -26
- data/app/views/my/profiles/show.html.erb +13 -0
- data/app/views/{admin/components/links/extra/_content.html.erb → my/recoveries/show.html.erb} +0 -0
- data/app/views/shared/admin/_list.html.erb +10 -19
- data/app/views/shared/admin/_list_with_priority.html.erb +10 -19
- data/app/views/shared/admin/_priority.html.erb +6 -5
- data/app/views/shared/admin/_toggle.html.erb +5 -10
- data/app/views/shared/entity/_date_field.html.erb +6 -0
- data/app/views/shared/entity/_linked_entity.html.erb +2 -2
- data/app/views/shared/entity/_list.html.erb +22 -0
- data/app/views/shared/entity/_list_with_priority.html.erb +22 -0
- data/app/views/shared/entity/_parent.html.erb +1 -1
- data/app/views/shared/entity/_priority_icons.html.erb +8 -0
- data/app/views/shared/entity/_time_field.html.erb +6 -0
- data/app/views/shared/entity/_toggle.html.erb +12 -0
- data/app/views/shared/entity/_track.html.erb +12 -0
- data/app/views/shared/entity/_tree_caches.html.erb +8 -1
- data/app/views/shared/entity/edit.html.erb +10 -6
- data/app/views/shared/entity/new.html.erb +4 -2
- data/app/views/shared/forms/_field.html.erb +6 -2
- data/app/views/shared/forms/_field_with_search.html.erb +17 -0
- data/app/views/shared/forms/_meta_texts.html.erb +1 -1
- data/app/views/shared/forms/_simple_entity_link.html.erb +14 -0
- data/app/views/shared/forms/_simple_image.html.erb +12 -4
- data/app/views/shared/forms/_text_area.html.erb +1 -1
- data/app/views/shared/forms/_text_field.html.erb +1 -1
- data/app/views/shared/my/_list.html.erb +10 -19
- data/app/views/shared/my/_list_with_priority.html.erb +10 -19
- data/app/views/shared/my/entity/edit.html.erb +25 -0
- data/app/views/shared/my/entity/new.html.erb +18 -0
- data/app/views/simple_images/_simple_image.jbuilder +13 -0
- data/config/locales/biovision-ru.yml +18 -1
- data/config/locales/components-ru.yml +27 -4
- data/config/locales/contact-ru.yml +4 -0
- data/config/locales/content-ru.yml +12 -0
- data/config/locales/users-ru.yml +31 -6
- data/config/routes.rb +35 -4
- data/db/migrate/20191228000000_create_biovision_components.rb +2 -0
- data/db/migrate/20200224000000_create_track_component.rb +8 -12
- data/db/migrate/20200224000010_create_users_component.rb +8 -49
- data/db/migrate/20200404000000_create_simple_images.rb +1 -0
- data/db/migrate/20210405000000_create_acl.rb +15 -1
- data/db/migrate/{20200529000000_create_content_component.rb → 20210421000000_create_content_component.rb} +24 -18
- data/db/migrate/{20210401000000_create_contact_component.rb → 20210421000010_create_contact_component.rb} +1 -22
- data/db/migrate/20210616000000_create_uploaded_files.rb +52 -0
- data/db/migrate/amends/20210816060606_create_oembed_receivers.rb +21 -0
- data/db/migrate/amends/20210907070707_add_checksum_to_simple_images.rb +13 -0
- data/lib/biovision/base_methods.rb +8 -28
- data/lib/biovision/version.rb +1 -1
- data/lib/tasks/components.rake +51 -0
- metadata +90 -17
- data/app/lib/biovision/components/base/privilege_handler.rb +0 -79
- data/app/models/biovision_component_user.rb +0 -21
- data/app/views/admin/components/links/_content.html.erb +0 -9
- data/app/views/admin/components/links/_track.html.erb +0 -2
- data/app/views/admin/components/links/_users.html.erb +0 -4
- data/app/views/admin/components/privileges/_component_user.html.erb +0 -17
- data/app/views/admin/components/privileges/_links.html.erb +0 -17
- data/app/views/admin/components/privileges/_users.html.erb +0 -23
- 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
|
-
|
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.
|
5
|
-
|
6
|
-
BiovisionComponent.create(slug: Biovision::Components::TrackComponent.slug)
|
4
|
+
class CreateTrackComponent < ActiveRecord::Migration[6.1]
|
5
|
+
include Biovision::Migrations::ComponentMigration
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
def up
|
8
|
+
component.create
|
9
|
+
component.dependent_models.each do |model|
|
10
|
+
next if model.table_exists?
|
12
11
|
|
13
|
-
|
14
|
-
|
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.
|
4
|
+
class CreateUsersComponent < ActiveRecord::Migration[6.1]
|
5
|
+
include Biovision::Migrations::ComponentMigration
|
6
|
+
|
5
7
|
def up
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
17
|
-
|
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 }
|
@@ -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.
|
5
|
-
|
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
|
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
|
-
|
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
|
data/lib/biovision/version.rb
CHANGED
@@ -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
|