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
@@ -41,10 +41,10 @@ $border-color-secondary: rgb(230, 230, 230) !default;
|
|
41
41
|
$border-primary: .1rem solid $border-color-primary !default;
|
42
42
|
$border-secondary: .1rem solid $border-color-secondary !default;
|
43
43
|
|
44
|
-
$
|
45
|
-
$
|
46
|
-
$
|
47
|
-
$
|
44
|
+
$layout-bg-body: #f4f4f4 linear-gradient(to top, #f4f4f4, #dfdedc) no-repeat center / cover !default;
|
45
|
+
$layout-bg-header: #fff !default;
|
46
|
+
$layout-bg-main: #fff !default;
|
47
|
+
$layout-bg-footer: #fff !default;
|
48
48
|
|
49
49
|
$link-color: rgb(20, 127, 255) !default;
|
50
50
|
$link-color-visited: rgb(20, 77, 250) !default;
|
@@ -1,4 +1,6 @@
|
|
1
1
|
.main-header {
|
2
|
+
background: var(--layout-bg-header);
|
3
|
+
|
2
4
|
.content-wrapper {
|
3
5
|
align-items: center;
|
4
6
|
display: flex;
|
@@ -23,11 +25,13 @@
|
|
23
25
|
.header-authentication {
|
24
26
|
align-items: center;
|
25
27
|
display: flex;
|
28
|
+
gap: var(--spacer-xxs);
|
26
29
|
margin: 0 0 0 auto;
|
27
30
|
|
28
31
|
.avatar {
|
29
32
|
display: inline-block;
|
30
33
|
height: 2.4rem;
|
34
|
+
overflow: hidden;
|
31
35
|
width: 2.4rem;
|
32
36
|
|
33
37
|
img {
|
@@ -36,4 +40,12 @@
|
|
36
40
|
width: 100%;
|
37
41
|
}
|
38
42
|
}
|
43
|
+
|
44
|
+
.current-user {
|
45
|
+
align-items: center;
|
46
|
+
color: inherit;
|
47
|
+
display: flex;
|
48
|
+
font-size: var(--font-size-decreased);
|
49
|
+
gap: var(--spacer-xs);
|
50
|
+
}
|
39
51
|
}
|
@@ -1,6 +1,3 @@
|
|
1
|
-
@import "biovision/themes/default_theme/components";
|
2
|
-
@import "biovision/themes/default_theme/layout/header";
|
3
|
-
|
4
1
|
//* { outline: solid pink 1px }
|
5
2
|
|
6
3
|
html {
|
@@ -8,12 +5,14 @@ html {
|
|
8
5
|
}
|
9
6
|
|
10
7
|
body {
|
8
|
+
background: var(--layout-bg-body);
|
11
9
|
display: flex;
|
12
10
|
flex-direction: column;
|
13
11
|
//height: 100%;
|
14
12
|
}
|
15
13
|
|
16
14
|
#main {
|
15
|
+
background: var(--layout-bg-main);
|
17
16
|
flex: 1;
|
18
17
|
}
|
19
18
|
|
@@ -28,3 +27,7 @@ body {
|
|
28
27
|
width: 100%;
|
29
28
|
z-index: 5;
|
30
29
|
}
|
30
|
+
|
31
|
+
@import "biovision/themes/default_theme/components";
|
32
|
+
@import "biovision/themes/default_theme/layout/header";
|
33
|
+
@import "biovision/themes/default_theme/layout/footer";
|
@@ -50,4 +50,9 @@
|
|
50
50
|
--input-border-focus: #{$input-border-focus};
|
51
51
|
--input-border-invalid: #{$input-border-invalid};
|
52
52
|
--input-border-invalid-focus: #{$input-border-invalid-focus};
|
53
|
+
|
54
|
+
--layout-bg-body: #{$layout-bg-body};
|
55
|
+
--layout-bg-footer: #{$layout-bg-footer};
|
56
|
+
--layout-bg-header: #{$layout-bg-header};
|
57
|
+
--layout-bg-main: #{$layout-bg-main};
|
53
58
|
}
|
@@ -2,12 +2,14 @@
|
|
2
2
|
|
3
3
|
# Handling components
|
4
4
|
class Admin::ComponentsController < AdminController
|
5
|
-
|
5
|
+
include ProcessedForms
|
6
|
+
|
7
|
+
# skip_before_action :restrict_access, only: :index
|
6
8
|
skip_before_action :verify_authenticity_token, only: :ckeditor
|
7
9
|
|
8
10
|
# get /admin/components
|
9
11
|
def index
|
10
|
-
@collection = BiovisionComponent.list_for_administration
|
12
|
+
@collection = BiovisionComponent.active.list_for_administration
|
11
13
|
end
|
12
14
|
|
13
15
|
# get /admin/components/:slug
|
@@ -18,105 +20,45 @@ class Admin::ComponentsController < AdminController
|
|
18
20
|
|
19
21
|
# get /admin/components/:slug/settings
|
20
22
|
def settings
|
21
|
-
error = 'Viewing settings is not allowed'
|
22
|
-
handle_http_401(error) unless @handler.permit?('settings.view')
|
23
23
|
end
|
24
24
|
|
25
25
|
# patch /admin/components/:slug/settings
|
26
26
|
def update_settings
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
redirect_to(admin_component_settings_path(slug: params[:slug]))
|
32
|
-
else
|
33
|
-
handle_http_401('Changing settings is not allowed')
|
34
|
-
end
|
27
|
+
new_settings = params.dig(:component, :settings).permit!
|
28
|
+
@handler.settings = new_settings.to_h
|
29
|
+
flash[:success] = t('.success')
|
30
|
+
redirect_to(admin_component_settings_path(slug: params[:slug]))
|
35
31
|
end
|
36
32
|
|
37
33
|
# patch /admin/components/:slug/parameters
|
38
34
|
def update_parameter
|
39
|
-
|
40
|
-
|
41
|
-
value = param_from_request(:key, :value)
|
35
|
+
slug = param_from_request(:key, :slug).downcase
|
36
|
+
value = param_from_request(:key, :value)
|
42
37
|
|
43
|
-
|
44
|
-
end
|
38
|
+
@handler[slug] = value
|
45
39
|
|
46
40
|
head :no_content
|
47
41
|
end
|
48
42
|
|
49
43
|
# delete /admin/components/:slug/parameters/:parameter_slug
|
50
44
|
def delete_parameter
|
51
|
-
|
52
|
-
|
53
|
-
@handler.component.save
|
54
|
-
end
|
55
|
-
|
56
|
-
head :no_content
|
57
|
-
end
|
58
|
-
|
59
|
-
# get /admin/components/:slug/privileges
|
60
|
-
def privileges
|
61
|
-
error = 'Viewing privileges is not allowed'
|
62
|
-
handle_http_401(error) unless @handler.administrator?
|
63
|
-
end
|
64
|
-
|
65
|
-
# patch /admin/components/:slug/privileges
|
66
|
-
def update_privileges
|
67
|
-
if @handler.administrator?
|
68
|
-
user = User.find_by(id: params[:user_id])
|
69
|
-
|
70
|
-
if user.nil?
|
71
|
-
handle_http_404('Cannot find user') if user.nil?
|
72
|
-
else
|
73
|
-
@entity = @handler.user_link!(true)
|
74
|
-
end
|
75
|
-
else
|
76
|
-
handle_http_401('Updating privileges is not allowed')
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# put /admin/components/:slug/administrators/:user_id
|
81
|
-
def add_administrator
|
82
|
-
if @handler.administrator?
|
83
|
-
@handler.user = User.find_by(id: params[:user_id])
|
84
|
-
@handler.privilege_handler.administrator!
|
85
|
-
end
|
86
|
-
|
87
|
-
head :no_content
|
88
|
-
end
|
89
|
-
|
90
|
-
# put /admin/components/:slug/administrators/:user_id
|
91
|
-
def remove_administrator
|
92
|
-
if @handler.administrator?
|
93
|
-
@handler.user = User.find_by(id: params[:user_id])
|
94
|
-
@handler.privilege_handler.not_administrator!
|
95
|
-
end
|
96
|
-
|
97
|
-
head :no_content
|
98
|
-
end
|
45
|
+
@handler.component.parameters.delete(params[:parameter_slug])
|
46
|
+
@handler.component.save
|
99
47
|
|
100
|
-
# put /admin/components/:slug/users/:user_id/privileges/:privilege_slug
|
101
|
-
def add_privilege
|
102
|
-
head :no_content
|
103
|
-
end
|
104
|
-
|
105
|
-
# put /admin/components/:slug/users/:user_id/privileges/:privilege_slug
|
106
|
-
def remove_privilege
|
107
48
|
head :no_content
|
108
49
|
end
|
109
50
|
|
110
51
|
# get /admin/components/:slug/images
|
111
52
|
def images
|
112
53
|
list = SimpleImage.in_component(@handler.component).list_for_administration
|
113
|
-
@collection =
|
54
|
+
@collection = list.page(current_page)
|
114
55
|
end
|
115
56
|
|
57
|
+
# post /admin/components/:slug/images
|
116
58
|
def create_image
|
117
59
|
if @handler.permit?('simple_images.create')
|
118
|
-
@entity = @handler.
|
119
|
-
if @entity
|
60
|
+
@entity = @handler.upload_image(image_parameters)
|
61
|
+
if @entity
|
120
62
|
render 'image', formats: :json
|
121
63
|
else
|
122
64
|
form_processed_with_error(:new_image)
|
@@ -133,7 +75,7 @@ class Admin::ComponentsController < AdminController
|
|
133
75
|
biovision_component: @handler.component
|
134
76
|
}.merge(owner_for_entity(true))
|
135
77
|
|
136
|
-
@entity =
|
78
|
+
@entity = @handler.upload_image(parameters)
|
137
79
|
|
138
80
|
render json: {
|
139
81
|
uploaded: 1,
|
@@ -144,16 +86,14 @@ class Admin::ComponentsController < AdminController
|
|
144
86
|
|
145
87
|
private
|
146
88
|
|
147
|
-
def
|
89
|
+
def restrict_access
|
148
90
|
slug = params[:slug]
|
149
91
|
@handler = Biovision::Components::BaseComponent.handler(slug, current_user)
|
150
|
-
|
92
|
+
role = action_name == 'index' ? 'components.view' : role_end_from_action
|
93
|
+
role_name = "#{@handler.slug}.#{role}"
|
94
|
+
error = t('admin.errors.unauthorized.missing_role', role: role_name)
|
151
95
|
|
152
|
-
|
153
|
-
return if current_user&.super_user?
|
154
|
-
|
155
|
-
links_exist = BiovisionComponentUser.where(user: current_user).exists?
|
156
|
-
handle_http_401('User has no component privileges') unless links_exist
|
96
|
+
handle_http_401(error) unless @handler.permit?(role)
|
157
97
|
end
|
158
98
|
|
159
99
|
def image_parameters
|
@@ -161,4 +101,14 @@ class Admin::ComponentsController < AdminController
|
|
161
101
|
parameters = params.require(:simple_image).permit(permitted)
|
162
102
|
parameters.merge(owner_for_entity(true))
|
163
103
|
end
|
104
|
+
|
105
|
+
def action_to_role_map
|
106
|
+
super.merge(
|
107
|
+
%w[images] => 'simple_images.view',
|
108
|
+
%w[create_image ckeditor] => 'simple_images.create',
|
109
|
+
%w[settings] => 'settings.view',
|
110
|
+
%w[update_settings update_parameter delete_parameter] => 'settings.edit',
|
111
|
+
%w[show] => 'view'
|
112
|
+
)
|
113
|
+
end
|
164
114
|
end
|
@@ -4,8 +4,14 @@
|
|
4
4
|
class Admin::IndexController < AdminController
|
5
5
|
# get /admin
|
6
6
|
def index
|
7
|
-
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def restrict_access
|
12
|
+
role_name = "#{component_handler.slug}.admin"
|
13
|
+
error = t('admin.errors.unauthorized.missing_role', role: role_name)
|
8
14
|
|
9
|
-
handle_http_401
|
15
|
+
handle_http_401(error) unless component_handler.permit?('admin')
|
10
16
|
end
|
11
17
|
end
|
@@ -6,9 +6,40 @@ class Admin::NavigationGroupsController < AdminController
|
|
6
6
|
|
7
7
|
before_action :set_entity, except: %i[check create index new]
|
8
8
|
|
9
|
+
# put /admin/navigation_groups/:id/dynamic_pages/:page_id
|
10
|
+
def add_page
|
11
|
+
@entity.add_dynamic_page(DynamicPage.find_by(id: params[:page_id]))
|
12
|
+
|
13
|
+
head :no_content
|
14
|
+
end
|
15
|
+
|
16
|
+
# delete /admin/navigation_groups/:id/dynamic_pages/:page_id
|
17
|
+
def remove_page
|
18
|
+
@entity.remove_dynamic_page(DynamicPage.find_by(id: params[:page_id]))
|
19
|
+
|
20
|
+
head :no_content
|
21
|
+
end
|
22
|
+
|
23
|
+
# post /admin/navigation_groups/:id/dynamic_pages/:page_id/priority
|
24
|
+
def page_priority
|
25
|
+
link = @entity.navigation_group_pages.find_by(id: params[:page_id])
|
26
|
+
|
27
|
+
if link.nil?
|
28
|
+
handle_http_404
|
29
|
+
else
|
30
|
+
render json: { data: link.change_priority(params[:delta].to_s.to_i) }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
9
34
|
private
|
10
35
|
|
11
36
|
def component_class
|
12
37
|
Biovision::Components::ContentComponent
|
13
38
|
end
|
39
|
+
|
40
|
+
def action_to_role_map
|
41
|
+
super.merge(
|
42
|
+
%w[add_page page_priority remove_page] => 'navigation_groups.edit',
|
43
|
+
)
|
44
|
+
end
|
14
45
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Handling user tokens
|
4
|
+
class Admin::TokensController < AdminController
|
5
|
+
include CrudEntities
|
6
|
+
include ToggleableEntity
|
7
|
+
|
8
|
+
before_action :set_entity, except: %i[check create index new search]
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def component_class
|
13
|
+
Biovision::Components::UsersComponent
|
14
|
+
end
|
15
|
+
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Administrative part for handling
|
3
|
+
# Administrative part for handling users
|
4
4
|
class Admin::UsersController < AdminController
|
5
5
|
include Authentication
|
6
6
|
include CrudEntities
|
7
|
+
include ProcessedForms
|
7
8
|
include ToggleableEntity
|
8
9
|
|
9
|
-
before_action :set_entity, except: %i[check create index new]
|
10
|
+
before_action :set_entity, except: %i[check create index new search]
|
10
11
|
|
11
12
|
# post /admin/users
|
12
13
|
def create
|
@@ -29,7 +30,7 @@ class Admin::UsersController < AdminController
|
|
29
30
|
|
30
31
|
# post /admin/users/:id/authenticate
|
31
32
|
def authenticate
|
32
|
-
|
33
|
+
if component_handler.permit?('log_in', @entity) && !@entity.super_user?
|
33
34
|
cookies['pt'] = {
|
34
35
|
value: cookies['token'],
|
35
36
|
expires: 1.year.from_now,
|
@@ -42,6 +43,35 @@ class Admin::UsersController < AdminController
|
|
42
43
|
redirect_to my_path
|
43
44
|
end
|
44
45
|
|
46
|
+
# get /admin/users/:id/roles
|
47
|
+
def roles
|
48
|
+
if current_user&.super_user?
|
49
|
+
@components = BiovisionComponent.list_for_administration
|
50
|
+
else
|
51
|
+
handle_http_401
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# put /admin/users/:id/roles/:role_id
|
56
|
+
def add_role
|
57
|
+
if current_user&.super_user?
|
58
|
+
role = Role.find_by(id: params[:role_id])
|
59
|
+
@entity.add_role(role)
|
60
|
+
end
|
61
|
+
|
62
|
+
head :no_content
|
63
|
+
end
|
64
|
+
|
65
|
+
# delete /admin/users/:id/roles/:role_id
|
66
|
+
def remove_role
|
67
|
+
if current_user&.super_user?
|
68
|
+
role = Role.find_by(id: params[:role_id])
|
69
|
+
@entity.remove_role(role)
|
70
|
+
end
|
71
|
+
|
72
|
+
head :no_content
|
73
|
+
end
|
74
|
+
|
45
75
|
private
|
46
76
|
|
47
77
|
def component_class
|
@@ -55,7 +85,8 @@ class Admin::UsersController < AdminController
|
|
55
85
|
end
|
56
86
|
|
57
87
|
def creation_parameters
|
58
|
-
|
88
|
+
permitted = User.entity_parameters
|
89
|
+
parameters = params.require(:user).permit(permitted)
|
59
90
|
parameters.merge(tracking_for_entity)
|
60
91
|
end
|
61
92
|
|
@@ -2,14 +2,7 @@
|
|
2
2
|
|
3
3
|
# Common administrative controller
|
4
4
|
class AdminController < ApplicationController
|
5
|
-
|
6
|
-
|
7
|
-
private
|
5
|
+
include RestrictedAccess
|
8
6
|
|
9
|
-
|
10
|
-
user_action = "#{controller_name}.default"
|
11
|
-
error = t('admin.errors.unauthorized.message')
|
12
|
-
|
13
|
-
handle_http_401(error) unless component_handler.permit?(user_action)
|
14
|
-
end
|
7
|
+
before_action :restrict_access
|
15
8
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Adds method for working with component stories
|
4
|
+
module ComponentStories
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
# Perform story
|
8
|
+
#
|
9
|
+
# Parameters:
|
10
|
+
# slug: story slug app/lib/biovision/components/.../stories/<slug>_story.rb
|
11
|
+
# entity_id: optional parameter for setting entity context
|
12
|
+
#
|
13
|
+
# post [...]/stories/:slug
|
14
|
+
def story
|
15
|
+
story_parameters = params[:parameters]&.permit!.to_h
|
16
|
+
entity_id = param_from_request(:entity_id)
|
17
|
+
story_handler = component_handler.story(params[:slug], entity_id)
|
18
|
+
result = story_handler.perform(story_parameters)
|
19
|
+
|
20
|
+
render json: { meta: { result: result } }
|
21
|
+
end
|
22
|
+
end
|
@@ -3,14 +3,19 @@
|
|
3
3
|
# Adds method for CRUD
|
4
4
|
module CrudEntities
|
5
5
|
extend ActiveSupport::Concern
|
6
|
+
include ProcessedForms
|
7
|
+
|
8
|
+
# get [scope]/[table_name]/search?q=
|
9
|
+
def search
|
10
|
+
q = param_from_request(:q)
|
11
|
+
@collection = model_class.search(q).list_for_administration.page(current_page)
|
12
|
+
end
|
6
13
|
|
7
14
|
# get [scope]/[table_name]
|
8
15
|
def index
|
9
|
-
@
|
10
|
-
|
11
|
-
|
12
|
-
model_class.list_for_administration
|
13
|
-
end
|
16
|
+
@filter = params[:filter]&.permit!.to_h
|
17
|
+
data_helper = Biovision::Helpers::DataHelper.new(model_class, @filter)
|
18
|
+
@collection = data_helper.administrative_collection(current_page)
|
14
19
|
end
|
15
20
|
|
16
21
|
# get [scope]/[table_name]/:id
|
@@ -32,7 +37,7 @@ module CrudEntities
|
|
32
37
|
|
33
38
|
# post [scope]/[table_name]
|
34
39
|
def create
|
35
|
-
@entity =
|
40
|
+
@entity = component_handler.new_entity(model_class, creation_parameters)
|
36
41
|
apply_meta if @entity.respond_to?(:meta=)
|
37
42
|
if @entity.save
|
38
43
|
form_processed_ok(path_after_save)
|
@@ -50,7 +55,7 @@ module CrudEntities
|
|
50
55
|
def update
|
51
56
|
apply_meta if @entity.respond_to?(:meta=)
|
52
57
|
|
53
|
-
if @entity
|
58
|
+
if component_handler.update_entity(@entity, entity_parameters)
|
54
59
|
form_processed_ok(path_after_save)
|
55
60
|
else
|
56
61
|
form_processed_with_error(view_for_edit)
|
@@ -95,10 +100,6 @@ module CrudEntities
|
|
95
100
|
"#{prefix}/#{model_class.table_name}"
|
96
101
|
end
|
97
102
|
|
98
|
-
def paginate_entities?
|
99
|
-
model_class.respond_to?(:page_for_administration)
|
100
|
-
end
|
101
|
-
|
102
103
|
def set_entity
|
103
104
|
@entity = model_class.find_by(id: params[:id])
|
104
105
|
handle_http_404("Cannot find #{model_class.model_name}") if @entity.nil?
|
@@ -108,25 +109,32 @@ module CrudEntities
|
|
108
109
|
if model_class.respond_to?(:creation_parameters)
|
109
110
|
explicit_creation_parameters
|
110
111
|
else
|
111
|
-
|
112
|
+
implicit_creation_parameters
|
112
113
|
end
|
113
114
|
end
|
114
115
|
|
115
116
|
def explicit_creation_parameters
|
116
|
-
permitted = model_class.creation_parameters
|
117
|
+
permitted = model_class.creation_parameters
|
117
118
|
parameters = params.require(model_key).permit(permitted)
|
118
119
|
parameters.merge!(tracking_for_entity) if model_class.include?(HasTrack)
|
119
120
|
parameters.merge!(owner_for_entity) if model_class.include?(HasOwner)
|
120
121
|
parameters
|
121
122
|
end
|
122
123
|
|
124
|
+
def implicit_creation_parameters
|
125
|
+
parameters = entity_parameters
|
126
|
+
parameters.merge!(tracking_for_entity) if model_class.include?(HasTrack)
|
127
|
+
parameters.merge!(owner_for_entity) if model_class.include?(HasOwner)
|
128
|
+
parameters
|
129
|
+
end
|
130
|
+
|
123
131
|
def entity_parameters
|
124
|
-
permitted = model_class.entity_parameters
|
132
|
+
permitted = model_class.entity_parameters
|
125
133
|
params.require(model_key).permit(permitted)
|
126
134
|
end
|
127
135
|
|
128
136
|
def apply_meta
|
129
|
-
new_data = params[:meta]
|
137
|
+
new_data = params[:meta]&.permit!.to_h
|
130
138
|
@entity.meta = new_data
|
131
139
|
end
|
132
140
|
end
|