biovision 0.0.200518.1 → 0.1.210414.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 +60 -18
- data/app/assets/images/biovision/icons/back.svg +19 -0
- data/app/assets/images/biovision/icons/create.svg +19 -0
- data/app/assets/images/biovision/icons/destroy.svg +12 -0
- data/app/assets/images/biovision/icons/dropdown.svg +3 -0
- data/app/assets/images/biovision/icons/edit.svg +22 -0
- data/app/assets/images/biovision/icons/gear.svg +11 -0
- data/app/assets/images/biovision/icons/return.svg +25 -0
- data/app/assets/images/biovision/icons/world.svg +11 -0
- data/app/assets/stylesheets/biovision/admin/components.scss +3 -1
- data/app/assets/stylesheets/biovision/admin/components/users.scss +16 -0
- data/app/assets/stylesheets/biovision/admin/layout.scss +6 -17
- data/app/assets/stylesheets/biovision/biovision.scss +42 -1
- data/app/assets/stylesheets/biovision/components.scss +6 -0
- data/app/assets/stylesheets/biovision/components/breadcrumbs.scss +13 -0
- data/app/assets/stylesheets/biovision/components/buttons.scss +130 -0
- data/app/assets/stylesheets/biovision/components/forms.scss +162 -1
- data/app/assets/stylesheets/biovision/components/lists.scss +6 -7
- data/app/assets/stylesheets/biovision/{biovision → components}/messages.scss +9 -0
- data/app/assets/stylesheets/biovision/components/pagination.scss +34 -0
- data/app/assets/stylesheets/biovision/components/simple_image.scss +112 -0
- data/app/assets/stylesheets/biovision/components/toggleable.scss +71 -0
- data/app/assets/stylesheets/biovision/themes/default_theme/components.scss +2 -3
- data/app/assets/stylesheets/biovision/themes/default_theme/components/users.scss +2 -0
- data/app/assets/stylesheets/biovision/themes/default_theme/components/users/form_tabs.scss +101 -0
- data/app/assets/stylesheets/biovision/themes/default_theme/components/users/profile.scss +77 -0
- data/app/assets/stylesheets/biovision/themes/default_theme/layout.scss +2 -16
- data/app/controllers/admin/components_controller.rb +9 -19
- data/app/controllers/admin/dynamic_blocks_controller.rb +15 -0
- data/app/controllers/admin/dynamic_pages_controller.rb +15 -0
- data/app/controllers/admin/navigation_groups_controller.rb +14 -0
- data/app/controllers/admin/users_controller.rb +70 -0
- data/app/controllers/admin_controller.rb +3 -2
- data/app/controllers/authentication_controller.rb +6 -34
- data/app/controllers/concerns/authentication.rb +12 -12
- data/app/controllers/concerns/crud_entities.rb +132 -0
- data/app/controllers/concerns/entity_priority.rb +10 -0
- data/app/controllers/concerns/toggleable_entity.rb +31 -0
- data/app/controllers/contact_controller.rb +49 -0
- data/app/controllers/fallback_controller.rb +12 -0
- data/app/controllers/index_controller.rb +1 -0
- data/app/controllers/legal_controller.rb +14 -0
- data/app/controllers/my/components_controller.rb +5 -0
- data/app/controllers/my/confirmations_controller.rb +44 -0
- data/app/controllers/my/index_controller.rb +8 -0
- data/app/controllers/my/profiles_controller.rb +31 -16
- data/app/controllers/profile_controller.rb +12 -0
- data/app/controllers/users_controller.rb +61 -0
- data/app/helpers/biovision_helper.rb +171 -0
- data/app/helpers/simple_image_helper.rb +125 -0
- data/app/jobs/application_job.rb +7 -0
- data/app/jobs/send_phone_confirmation_job.rb +16 -0
- data/app/lib/biovision/components/base/component_parameters.rb +44 -0
- data/app/lib/biovision/components/base/component_privileges.rb +65 -0
- data/app/lib/biovision/components/base/component_settings.rb +32 -0
- data/app/lib/biovision/components/base/privilege_handler.rb +79 -0
- data/app/lib/biovision/components/base_component.rb +51 -54
- data/app/lib/biovision/components/contact_component.rb +22 -0
- data/app/lib/biovision/components/content_component.rb +28 -0
- data/app/lib/biovision/components/track_component.rb +3 -0
- data/app/lib/biovision/components/users/authentication.rb +15 -7
- data/app/lib/biovision/components/users/codes.rb +104 -0
- data/app/lib/biovision/components/users/flag_helpers.rb +72 -0
- data/app/lib/biovision/components/users/profile_handler.rb +111 -1
- data/app/lib/biovision/components/users/registration_handler.rb +40 -52
- data/app/lib/biovision/components/users/validation.rb +83 -0
- data/app/lib/biovision/components/users_component.rb +82 -19
- data/app/lib/biovision/notifiers/base_notifier.rb +2 -2
- data/app/lib/biovision/notifiers/contact_notifier.rb +15 -0
- data/app/lib/canonizer.rb +38 -0
- data/app/lib/carrier_wave/image_optim.rb +32 -0
- data/app/mailers/code_sender.rb +29 -0
- data/app/models/agent.rb +4 -0
- data/app/models/biovision_component.rb +22 -2
- data/app/models/browser.rb +1 -1
- data/app/models/code.rb +32 -9
- data/app/models/concerns/has_simple_image.rb +9 -0
- data/app/models/concerns/meta_texts.rb +25 -5
- data/app/models/concerns/tree_structure.rb +72 -0
- data/app/models/contact_method.rb +47 -0
- data/app/models/contact_type.rb +27 -0
- data/app/models/dynamic_block.rb +43 -0
- data/app/models/dynamic_page.rb +71 -0
- data/app/models/feedback_message.rb +59 -0
- data/app/models/feedback_response.rb +50 -0
- data/app/models/group.rb +48 -0
- data/app/models/language.rb +4 -0
- data/app/models/navigation_group.rb +33 -0
- data/app/models/navigation_group_page.rb +23 -0
- data/app/models/role.rb +56 -0
- data/app/models/role_group.rb +13 -0
- data/app/models/simple_image.rb +22 -8
- data/app/models/simple_image_tag.rb +1 -1
- data/app/models/token.rb +4 -4
- data/app/models/user.rb +94 -26
- data/app/models/user_group.rb +20 -0
- data/app/models/user_role.rb +19 -0
- data/app/uploaders/simple_file_uploader.rb +27 -0
- data/app/uploaders/simple_image_uploader.rb +20 -0
- data/app/views/admin/agents/index.html.erb +0 -2
- data/app/views/admin/components/_image.jbuilder +18 -0
- data/app/views/admin/components/_list.html.erb +1 -1
- data/app/views/admin/components/entity/_links.html.erb +1 -1
- data/app/views/admin/components/image.jbuilder +1 -0
- data/app/views/admin/components/images.jbuilder +4 -0
- data/app/views/admin/components/links/_content.html.erb +9 -0
- data/app/views/admin/components/links/_users.html.erb +1 -8
- data/app/views/admin/components/links/extra/_content.html.erb +0 -0
- data/app/views/admin/components/privileges/_links.html.erb +0 -18
- data/app/views/admin/components/settings/_new_parameter.html.erb +4 -2
- data/app/views/admin/components/settings/_parameters.html.erb +8 -2
- data/app/views/admin/components/settings/_settings.html.erb +1 -1
- data/app/views/admin/components/update_privileges.jbuilder +21 -0
- data/app/views/admin/dynamic_blocks/_form.html.erb +16 -0
- data/app/views/admin/dynamic_blocks/_nav_item.html.erb +6 -0
- data/app/views/admin/dynamic_blocks/entity/_in_list.html.erb +10 -0
- data/app/views/admin/dynamic_blocks/index.html.erb +15 -0
- data/app/views/admin/dynamic_blocks/show.html.erb +23 -0
- data/app/views/admin/dynamic_pages/_form.html.erb +21 -0
- data/app/views/admin/dynamic_pages/_nav_item.html.erb +6 -0
- data/app/views/admin/dynamic_pages/entity/_in_list.html.erb +15 -0
- data/app/views/admin/dynamic_pages/index.html.erb +15 -0
- data/app/views/admin/dynamic_pages/show.html.erb +28 -0
- data/app/views/admin/ip_addresses/index.html.erb +0 -2
- data/app/views/admin/navigation_groups/_form.html.erb +15 -0
- data/app/views/admin/navigation_groups/_nav_item.html.erb +6 -0
- data/app/views/admin/navigation_groups/entity/_in_list.html.erb +12 -0
- data/app/views/admin/navigation_groups/index.html.erb +15 -0
- data/app/views/admin/navigation_groups/show.html.erb +20 -0
- data/app/views/admin/unauthorized.html.erb +2 -5
- data/app/views/admin/users/_form.html.erb +81 -0
- data/app/views/admin/users/_nav_item.html.erb +6 -0
- data/app/views/admin/users/entity/_fields.html.erb +53 -0
- data/app/views/admin/users/entity/_in_list.html.erb +38 -0
- data/app/views/admin/users/entity/_profile.html.erb +26 -0
- data/app/views/admin/users/entity/in_list/_additional_data.html.erb +0 -0
- data/app/views/admin/users/index.html.erb +15 -0
- data/app/views/admin/users/show.html.erb +44 -0
- data/app/views/application/forbidden.html.erb +9 -0
- data/app/views/application/forbidden.jbuilder +4 -0
- data/app/views/application/not_found.html.erb +9 -0
- data/app/views/application/not_found.jbuilder +4 -0
- data/app/views/application/unauthorized.html.erb +16 -0
- data/app/views/application/unauthorized.jbuilder +4 -0
- data/app/views/authentication/new.html.erb +2 -8
- data/app/views/components/content/_dynamic_page.html.erb +21 -0
- data/app/views/components/users/_form_tabs.html.erb +31 -0
- data/app/views/components/users/_join_form.html.erb +192 -0
- data/app/views/components/users/_login_form.html.erb +45 -0
- data/app/views/components/users/form/_image.html.erb +17 -0
- data/app/views/components/users/form/_profile_data.html.erb +54 -0
- data/app/views/contact/_form.html.erb +108 -0
- data/app/views/contact/create_feedback_message.js.erb +1 -0
- data/app/views/contact/feedback.html.erb +13 -0
- data/app/views/contact/index.html.erb +16 -0
- data/app/views/fallback/show.html.erb +6 -0
- data/app/views/layouts/admin.html.erb +1 -1
- data/app/views/layouts/admin/_footer.html.erb +1 -1
- data/app/views/layouts/application/header/_authentication.html.erb +1 -1
- data/app/views/legal/privacy.html.erb +5 -0
- data/app/views/legal/tos.html.erb +5 -0
- data/app/views/my/confirmations/show.html.erb +62 -0
- data/app/views/my/index/index.html.erb +33 -0
- data/app/views/my/profiles/_form.html.erb +10 -0
- data/app/views/my/profiles/check.jbuilder +4 -0
- data/app/views/my/profiles/edit.html.erb +14 -0
- data/app/views/my/profiles/form/_basic_parameters.html.erb +9 -0
- data/app/views/my/profiles/form/_sensitive_parameters.html.erb +68 -0
- data/app/views/my/profiles/new.html.erb +6 -8
- data/app/views/my/profiles/show.html.erb +23 -0
- data/app/views/shared/_flash_messages.html.erb +1 -1
- data/app/views/shared/_list_of_errors.html.erb +7 -0
- data/app/views/shared/admin/_breadcrumbs.html.erb +8 -0
- data/app/views/shared/admin/_list.html.erb +4 -4
- data/app/views/shared/admin/_list_with_priority.html.erb +4 -4
- data/app/views/shared/admin/_priority.html.erb +5 -0
- data/app/views/shared/admin/_toggle.html.erb +11 -0
- data/app/views/shared/entity/_formatted_text_field.html.erb +10 -0
- data/app/views/shared/entity/_image.html.erb +31 -0
- data/app/views/shared/entity/_language.html.erb +6 -0
- data/app/views/shared/entity/_linked_entity.html.erb +6 -0
- data/app/views/shared/entity/_meta_texts.html.erb +16 -0
- data/app/views/shared/entity/_metadata.html.erb +18 -0
- data/app/views/shared/entity/_parent.html.erb +6 -0
- data/app/views/shared/entity/_priority.html.erb +4 -0
- data/app/views/shared/entity/_raw_text_field.html.erb +10 -0
- data/app/views/shared/entity/_simple_image.html.erb +10 -0
- data/app/views/shared/entity/_slug.html.erb +6 -0
- data/app/views/shared/entity/_text_field.html.erb +6 -0
- data/app/views/shared/entity/_text_fields.html.erb +9 -0
- data/app/views/shared/entity/_timestamps.html.erb +13 -0
- data/app/views/shared/entity/_tree_caches.html.erb +12 -0
- data/app/views/shared/entity/_uuid.html.erb +4 -0
- data/app/views/shared/entity/edit.html.erb +21 -0
- data/app/views/shared/entity/new.html.erb +16 -0
- data/app/views/shared/forms/_entity_flags.html.erb +15 -0
- data/app/views/shared/forms/_field.html.erb +46 -0
- data/app/views/shared/forms/_fields.html.erb +3 -0
- data/app/views/shared/forms/_language.html.erb +40 -0
- data/app/views/shared/forms/_meta_texts.html.erb +27 -0
- data/app/views/shared/forms/_priority.html.erb +13 -0
- data/app/views/shared/forms/_simple_image.html.erb +39 -0
- data/app/views/shared/forms/_state_container.html.erb +7 -0
- data/app/views/shared/forms/_text_area.html.erb +25 -0
- data/app/views/shared/forms/_text_field.html.erb +24 -0
- data/app/views/shared/forms/_text_fields.html.erb +3 -0
- data/app/views/shared/forms/check.jbuilder +4 -0
- data/app/views/shared/forms/errors.jbuilder +3 -0
- data/app/views/shared/forms/simple_image/_browse.html.erb +14 -0
- data/app/views/shared/forms/simple_image/_load_image.html.erb +38 -0
- data/app/views/shared/my/_list.html.erb +19 -0
- data/app/views/shared/my/_list_with_priority.html.erb +19 -0
- data/app/views/users/_profile.html.erb +30 -0
- data/app/views/users/profile/_data.html.erb +20 -0
- data/app/views/users/show.html.erb +21 -0
- data/config/locales/biovision-ru.yml +58 -0
- data/config/locales/components-ru.yml +30 -2
- data/config/locales/contact-ru.yml +106 -0
- data/config/locales/content-ru.yml +103 -0
- data/config/locales/users-ru.yml +117 -3
- data/config/routes.rb +70 -50
- data/db/migrate/20191228000000_create_biovision_components.rb +4 -5
- data/db/migrate/20200224000000_create_track_component.rb +7 -8
- data/db/migrate/20200224000010_create_users_component.rb +15 -43
- data/db/migrate/20200404000000_create_simple_images.rb +3 -3
- data/db/migrate/20200529000000_create_content_component.rb +74 -0
- data/db/migrate/20210401000000_create_contact_component.rb +95 -0
- data/db/migrate/20210405000000_create_acl.rb +74 -0
- data/lib/biovision/base_methods.rb +18 -10
- data/lib/biovision/engine.rb +8 -13
- data/lib/biovision/version.rb +1 -1
- metadata +186 -20
- data/app/assets/images/biovision/placeholders/user.svg +0 -15
- data/app/helpers/users_helper.rb +0 -11
- data/app/lib/biovision/components/component_settings.rb +0 -30
- data/app/lib/biovision/components/privilege_handler.rb +0 -77
- data/app/lib/biovision/components/users/code_handler.rb +0 -23
- data/app/models/foreign_site.rb +0 -34
- data/app/models/foreign_user.rb +0 -21
- data/app/uploaders/user_image_uploader.rb +0 -58
- data/app/views/admin/components/privileges/_privilege_flag.html.erb +0 -28
- data/app/views/authentication/_form.html.erb +0 -40
- data/app/views/authentication/failed.js.erb +0 -3
- data/app/views/my/profiles/new/_form.html.erb +0 -147
- data/app/views/shared/admin/_toggleable.html.erb +0 -8
@@ -8,24 +8,17 @@ class CreateUsersComponent < ActiveRecord::Migration[6.0]
|
|
8
8
|
create_tokens unless Token.table_exists?
|
9
9
|
create_login_attempts unless LoginAttempt.table_exists?
|
10
10
|
create_user_languages unless UserLanguage.table_exists?
|
11
|
-
create_foreign_sites unless ForeignSite.table_exists?
|
12
|
-
create_foreign_users unless ForeignUser.table_exists?
|
13
11
|
create_component_links unless BiovisionComponentUser.table_exists?
|
14
12
|
create_codes unless Code.table_exists?
|
15
13
|
create_notifications unless Notification.table_exists?
|
16
14
|
end
|
17
15
|
|
18
16
|
def down
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
drop_table :user_languages if UserLanguage.table_exists?
|
25
|
-
drop_table :login_attempts if LoginAttempt.table_exists?
|
26
|
-
drop_table :tokens if Token.table_exists?
|
27
|
-
drop_table :users if User.table_exists?
|
28
|
-
BiovisionComponent[Biovision::Components::UsersComponent.slug]&.destroy
|
17
|
+
Biovision::Components::UsersComponent.dependent_models.each do |model|
|
18
|
+
drop_table model.table_name if model.table_exists?
|
19
|
+
end
|
20
|
+
|
21
|
+
BiovisionComponent[Biovision::Components::UsersComponent]&.destroy
|
29
22
|
end
|
30
23
|
|
31
24
|
private
|
@@ -36,13 +29,17 @@ class CreateUsersComponent < ActiveRecord::Migration[6.0]
|
|
36
29
|
settings = {
|
37
30
|
registration_open: true,
|
38
31
|
email_as_login: false,
|
32
|
+
phone_as_login: false,
|
39
33
|
confirm_email: false,
|
40
34
|
require_email: false,
|
35
|
+
confirm_phone: false,
|
36
|
+
require_phone: false,
|
41
37
|
invite_only: false,
|
42
38
|
use_invites: false,
|
43
39
|
invite_count: 5,
|
44
40
|
bounce_count: 10,
|
45
|
-
bounce_timeout:
|
41
|
+
bounce_timeout: 3,
|
42
|
+
use_phone: false
|
46
43
|
}
|
47
44
|
|
48
45
|
BiovisionComponent.create(slug: slug, settings: settings)
|
@@ -57,12 +54,10 @@ class CreateUsersComponent < ActiveRecord::Migration[6.0]
|
|
57
54
|
t.timestamps
|
58
55
|
t.integer :primary_id, index: true
|
59
56
|
t.integer :inviter_id, index: true
|
60
|
-
t.integer :balance, default: 0, null: false
|
61
57
|
t.boolean :super_user, default: false, null: false
|
62
58
|
t.boolean :banned, default: false, null: false
|
63
59
|
t.boolean :bot, default: false, null: false
|
64
60
|
t.boolean :deleted, default: false, null: false
|
65
|
-
t.boolean :consent, default: false, null: false
|
66
61
|
t.boolean :email_confirmed, default: false, null: false
|
67
62
|
t.boolean :phone_confirmed, default: false, null: false
|
68
63
|
t.boolean :allow_mail, default: true, null: false
|
@@ -76,7 +71,8 @@ class CreateUsersComponent < ActiveRecord::Migration[6.0]
|
|
76
71
|
t.string :image
|
77
72
|
t.string :notice
|
78
73
|
t.string :referral_link
|
79
|
-
t.jsonb :data, default: {
|
74
|
+
t.jsonb :data, default: {}, null: false
|
75
|
+
t.jsonb :profile, default: {}, null: false
|
80
76
|
end
|
81
77
|
|
82
78
|
add_foreign_key :users, :users, column: :inviter_id, on_update: :cascade, on_delete: :nullify
|
@@ -85,6 +81,7 @@ class CreateUsersComponent < ActiveRecord::Migration[6.0]
|
|
85
81
|
add_index :users, :uuid, unique: true
|
86
82
|
add_index :users, :slug, unique: true
|
87
83
|
add_index :users, :data, using: :gin
|
84
|
+
add_index :users, :profile, using: :gin
|
88
85
|
add_index :users, :referral_link, unique: true
|
89
86
|
end
|
90
87
|
|
@@ -120,30 +117,6 @@ class CreateUsersComponent < ActiveRecord::Migration[6.0]
|
|
120
117
|
end
|
121
118
|
end
|
122
119
|
|
123
|
-
def create_foreign_sites
|
124
|
-
create_table :foreign_sites, comment: 'Sites for external authentication' do |t|
|
125
|
-
t.string :slug, null: false
|
126
|
-
t.string :name, null: false
|
127
|
-
t.integer :foreign_users_count, default: 0, null: false
|
128
|
-
end
|
129
|
-
|
130
|
-
add_index :foreign_sites, :slug, unique: true
|
131
|
-
end
|
132
|
-
|
133
|
-
def create_foreign_users
|
134
|
-
create_table :foreign_users, comment: 'Users from external sites' do |t|
|
135
|
-
t.references :foreign_site, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
136
|
-
t.references :user, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
137
|
-
t.references :agent, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
138
|
-
t.references :ip_address, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
139
|
-
t.string :slug, null: false
|
140
|
-
t.timestamps
|
141
|
-
t.jsonb :data, default: {}, null: false
|
142
|
-
end
|
143
|
-
|
144
|
-
add_index :foreign_users, :data, using: :gin
|
145
|
-
end
|
146
|
-
|
147
120
|
def create_component_links
|
148
121
|
create_table :biovision_component_users, comment: 'Privileges and settings for users in components' do |t|
|
149
122
|
t.references :biovision_component, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
@@ -159,16 +132,15 @@ class CreateUsersComponent < ActiveRecord::Migration[6.0]
|
|
159
132
|
def create_codes
|
160
133
|
create_table :codes, comment: 'Codes for different purposes' do |t|
|
161
134
|
t.references :biovision_component, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
162
|
-
t.references :user,
|
135
|
+
t.references :user, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
163
136
|
t.references :agent, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
164
137
|
t.references :ip_address, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
165
138
|
t.integer :quantity, default: 1, null: false
|
166
|
-
t.string :body, null: false
|
139
|
+
t.string :body, index: true, null: false
|
167
140
|
t.timestamps
|
168
141
|
t.jsonb :data, default: {}, null: false
|
169
142
|
end
|
170
143
|
|
171
|
-
add_index :codes, :body, unique: true
|
172
144
|
add_index :codes, :data, using: :gin
|
173
145
|
end
|
174
146
|
|
@@ -9,9 +9,9 @@ class CreateSimpleImages < ActiveRecord::Migration[6.0]
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def down
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
[SimpleImageTagImage, SimpleImageTag, SimpleImage].each do |model|
|
13
|
+
drop_table model.table_name if model.table_exists?
|
14
|
+
end
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
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
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def create_navigation_groups
|
25
|
+
create_table :navigation_groups, comment: 'Navigation groups' do |t|
|
26
|
+
t.timestamps
|
27
|
+
t.integer :dynamic_pages_count, default: 0, null: false
|
28
|
+
t.string :slug, null: false
|
29
|
+
t.string :name, null: false
|
30
|
+
end
|
31
|
+
|
32
|
+
add_index :navigation_groups, :slug, unique: true
|
33
|
+
end
|
34
|
+
|
35
|
+
def create_dynamic_pages
|
36
|
+
create_table :dynamic_pages, comment: 'Dynamic pages' do |t|
|
37
|
+
t.uuid :uuid, null: false
|
38
|
+
t.references :simple_image, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
39
|
+
t.references :language, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
40
|
+
t.timestamps
|
41
|
+
t.boolean :visible, default: true, null: false
|
42
|
+
t.string :slug, null: false
|
43
|
+
t.string :url, index: true
|
44
|
+
t.string :name
|
45
|
+
t.text :body, default: '', null: false
|
46
|
+
t.jsonb :data, default: {}, null: false
|
47
|
+
end
|
48
|
+
|
49
|
+
add_index :dynamic_pages, :uuid, unique: true
|
50
|
+
add_index :dynamic_pages, :data, using: :gin
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_pages_in_groups
|
54
|
+
create_table :navigation_group_pages, comment: 'Dynamic pages in navigation groups' do |t|
|
55
|
+
t.references :navigation_group, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
56
|
+
t.references :dynamic_page, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
57
|
+
t.integer :priority, limit: 2, default: 1, null: false
|
58
|
+
t.timestamps
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def create_dynamic_blocks
|
63
|
+
create_table :dynamic_blocks, comment: 'Dynamic blocks' do |t|
|
64
|
+
t.string :slug, null: false
|
65
|
+
t.boolean :visible, default: true, null: false
|
66
|
+
t.timestamps
|
67
|
+
t.text :body
|
68
|
+
t.jsonb :data, default: {}, null: false
|
69
|
+
end
|
70
|
+
|
71
|
+
add_index :dynamic_blocks, :slug, unique: true
|
72
|
+
add_index :dynamic_blocks, :data, using: :gin
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Create tables for contact component
|
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
|
20
|
+
|
21
|
+
private
|
22
|
+
|
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
|
+
def create_feedback_messages
|
31
|
+
create_table :feedback_messages, comment: 'Feedback messages from visitors' do |t|
|
32
|
+
t.uuid :uuid, null: false
|
33
|
+
t.references :language, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
34
|
+
t.references :user, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
35
|
+
t.references :ip_address, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
36
|
+
t.references :agent, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
37
|
+
t.timestamps
|
38
|
+
t.boolean :visible, default: false, null: false
|
39
|
+
t.boolean :processed, default: false, null: false
|
40
|
+
t.string :attachment
|
41
|
+
t.string :name
|
42
|
+
t.string :email
|
43
|
+
t.string :phone
|
44
|
+
t.text :comment
|
45
|
+
t.jsonb :data, default: {}, null: false
|
46
|
+
end
|
47
|
+
|
48
|
+
add_index :feedback_messages, :uuid, unique: true
|
49
|
+
add_index :feedback_messages, :data, using: :gin
|
50
|
+
end
|
51
|
+
|
52
|
+
def create_feedback_responses
|
53
|
+
create_table :feedback_responses, comment: 'Responses to feedback messages' do |t|
|
54
|
+
t.uuid :uuid, null: false
|
55
|
+
t.references :feedback_message, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
56
|
+
t.references :user, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
57
|
+
t.references :agent, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
58
|
+
t.references :ip_address, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
59
|
+
t.timestamps
|
60
|
+
t.boolean :visible, default: true, null: false
|
61
|
+
t.text :body
|
62
|
+
t.jsonb :data, default: {}, null: false
|
63
|
+
end
|
64
|
+
|
65
|
+
add_index :feedback_responses, :uuid, unique: true
|
66
|
+
add_index :feedback_responses, :data, using: :gin
|
67
|
+
end
|
68
|
+
|
69
|
+
def create_contact_types
|
70
|
+
create_table :contact_types, comment: 'Types of contact methods' do |t|
|
71
|
+
t.string :slug, null: false
|
72
|
+
end
|
73
|
+
|
74
|
+
add_index :contact_types, :slug, unique: true
|
75
|
+
|
76
|
+
%w[email phone address].each { |slug| ContactType.create(slug: slug) }
|
77
|
+
end
|
78
|
+
|
79
|
+
def create_contact_methods
|
80
|
+
create_table :contact_methods, comment: 'Contact methods for visitors' do |t|
|
81
|
+
t.uuid :uuid, null: false
|
82
|
+
t.references :language, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
83
|
+
t.references :contact_type, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
84
|
+
t.timestamps
|
85
|
+
t.boolean :visible, default: true, null: false
|
86
|
+
t.integer :priority, limit: 2, default: 1, null: false
|
87
|
+
t.string :name
|
88
|
+
t.string :value
|
89
|
+
t.jsonb :data, default: {}, null: false
|
90
|
+
end
|
91
|
+
|
92
|
+
add_index :contact_methods, :uuid, unique: true
|
93
|
+
add_index :contact_methods, :data, using: :gin
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Create tables for access control
|
4
|
+
class CreateAcl < ActiveRecord::Migration[6.1]
|
5
|
+
def up
|
6
|
+
create_groups unless Group.table_exists?
|
7
|
+
create_roles unless Role.table_exists?
|
8
|
+
create_role_groups unless RoleGroup.table_exists?
|
9
|
+
create_user_groups unless UserGroup.table_exists?
|
10
|
+
create_user_roles unless UserRole.table_exists?
|
11
|
+
end
|
12
|
+
|
13
|
+
def down
|
14
|
+
[UserRole, UserGroup, RoleGroup, Role, Group].each do |model|
|
15
|
+
drop_table model.table_name if model.table_exists?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def create_groups
|
22
|
+
create_table :groups, comment: 'ACL groups' do |t|
|
23
|
+
t.uuid :uuid, null: false
|
24
|
+
t.references :biovision_component, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
25
|
+
t.integer :parent_id
|
26
|
+
t.integer :user_count, default: 0, null: false
|
27
|
+
t.string :slug, index: true, null: false
|
28
|
+
t.string :parents_cache, default: '', null: false
|
29
|
+
t.integer :children_cache, array: true, default: [], null: false
|
30
|
+
t.jsonb :data, default: {}, null: false
|
31
|
+
end
|
32
|
+
|
33
|
+
add_foreign_key :groups, :groups, column: :parent_id, on_update: :cascade, on_delete: :cascade
|
34
|
+
add_index :groups, :uuid, unique: true
|
35
|
+
add_index :groups, :data, using: :gin
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_roles
|
39
|
+
create_table :roles, comment: 'ACL roles' do |t|
|
40
|
+
t.uuid :uuid, null: false
|
41
|
+
t.references :biovision_component, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
42
|
+
t.integer :user_count, default: 0, null: false
|
43
|
+
t.string :slug, index: true, null: false
|
44
|
+
t.jsonb :data, default: {}, null: false
|
45
|
+
end
|
46
|
+
|
47
|
+
add_index :roles, :uuid, unique: true
|
48
|
+
add_index :roles, :data, using: :gin
|
49
|
+
end
|
50
|
+
|
51
|
+
def create_role_groups
|
52
|
+
create_table :role_groups, comment: 'ACL: roles in groups' do |t|
|
53
|
+
t.references :role, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
54
|
+
t.references :group, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def create_user_groups
|
59
|
+
create_table :user_groups, comment: 'Users in ACL groups' do |t|
|
60
|
+
t.references :user, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
61
|
+
t.references :group, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
62
|
+
t.timestamps
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def create_user_roles
|
67
|
+
create_table :user_roles, comment: 'Users with (and without) ACL roles' do |t|
|
68
|
+
t.references :user, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
69
|
+
t.references :role, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
70
|
+
t.boolean :inclusive, default: true, null: false
|
71
|
+
t.timestamps
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -2,16 +2,16 @@
|
|
2
2
|
|
3
3
|
# Useful helper methods for application
|
4
4
|
module Biovision
|
5
|
+
# Base additional methods for application controller
|
5
6
|
module BaseMethods
|
6
7
|
extend ActiveSupport::Concern
|
7
8
|
|
8
9
|
included do
|
9
|
-
before_action :set_locale
|
10
|
-
|
11
10
|
helper_method :visitor_slug
|
12
11
|
helper_method :component_handler
|
13
12
|
helper_method :current_page, :param_from_request
|
14
13
|
helper_method :current_user, :current_language
|
14
|
+
helper_method :content_component
|
15
15
|
end
|
16
16
|
|
17
17
|
# Get current page number from request
|
@@ -46,6 +46,13 @@ module Biovision
|
|
46
46
|
@current_language ||= Language[locale]
|
47
47
|
end
|
48
48
|
|
49
|
+
# Get content component handler
|
50
|
+
#
|
51
|
+
# @return [Biovision::Components::ContentComponent]
|
52
|
+
def content_component
|
53
|
+
@content_component ||= Biovision::Components::ContentComponent[current_user]
|
54
|
+
end
|
55
|
+
|
49
56
|
# @return [Agent]
|
50
57
|
def agent
|
51
58
|
@agent ||= Agent[request.user_agent || 'n/a']
|
@@ -60,11 +67,7 @@ module Biovision
|
|
60
67
|
end
|
61
68
|
end
|
62
69
|
|
63
|
-
|
64
|
-
I18n.locale = params[:locale] || I18n.default_locale
|
65
|
-
end
|
66
|
-
|
67
|
-
protected
|
70
|
+
private
|
68
71
|
|
69
72
|
# Handle generic HTTP error without raising exception
|
70
73
|
#
|
@@ -115,8 +118,9 @@ module Biovision
|
|
115
118
|
|
116
119
|
# Restrict access for anonymous users
|
117
120
|
def restrict_anonymous_access
|
118
|
-
|
119
|
-
|
121
|
+
return unless current_user.nil?
|
122
|
+
|
123
|
+
handle_http_401(t('application.errors.restricted_access'))
|
120
124
|
end
|
121
125
|
|
122
126
|
# Owner information for entity
|
@@ -144,14 +148,18 @@ module Biovision
|
|
144
148
|
def form_processed_ok(next_page)
|
145
149
|
respond_to do |format|
|
146
150
|
format.js { render(js: "document.location.href = '#{next_page}'") }
|
151
|
+
format.json { render(json: { links: { next: next_page } }) }
|
147
152
|
format.html { redirect_to(next_page) }
|
148
153
|
end
|
149
154
|
end
|
150
155
|
|
151
156
|
# @param [Symbol|String] view_to_render
|
152
|
-
|
157
|
+
# @param [Array] errors
|
158
|
+
def form_processed_with_error(view_to_render, errors = [])
|
159
|
+
@errors = errors
|
153
160
|
respond_to do |format|
|
154
161
|
format.js { render('shared/forms/errors', status: :bad_request) }
|
162
|
+
format.json { render('shared/forms/errors', status: :bad_request) }
|
155
163
|
format.html { render(view_to_render, status: :bad_request) }
|
156
164
|
end
|
157
165
|
end
|