biovision 0.1.210414.0 → 0.3.210504.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 +43 -34
- data/app/assets/stylesheets/biovision/admin/components.scss +10 -0
- data/app/assets/stylesheets/biovision/admin/components/users.scss +4 -0
- data/app/assets/stylesheets/biovision/admin/layout.scss +0 -8
- data/app/assets/stylesheets/biovision/biovision.scss +8 -0
- data/app/assets/stylesheets/biovision/components.scss +1 -0
- data/app/assets/stylesheets/biovision/components/filters.scss +41 -0
- data/app/assets/stylesheets/biovision/components/forms.scss +16 -0
- data/app/assets/stylesheets/biovision/components/quick_search.scss +24 -0
- data/app/assets/stylesheets/biovision/default.scss +4 -4
- data/app/assets/stylesheets/biovision/themes/default_theme.scss +0 -1
- data/app/assets/stylesheets/biovision/themes/default_theme/layout.scss +6 -3
- data/app/assets/stylesheets/biovision/themes/default_theme/layout/footer.scss +3 -0
- data/app/assets/stylesheets/biovision/themes/default_theme/layout/header.scss +2 -0
- data/app/assets/stylesheets/biovision/vars.scss +5 -0
- data/app/controllers/admin/components_controller.rb +25 -79
- 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 +33 -3
- data/app/controllers/admin_controller.rb +15 -2
- data/app/controllers/concerns/crud_entities.rb +13 -13
- data/app/controllers/contact_controller.rb +1 -1
- data/app/helpers/biovision_components_helper.rb +7 -3
- data/app/lib/biovision/components/base/component_parameters.rb +8 -0
- data/app/lib/biovision/components/base/component_privileges.rb +26 -17
- data/app/lib/biovision/components/base/component_settings.rb +8 -0
- data/app/lib/biovision/components/base_component.rb +20 -23
- data/app/lib/biovision/components/contact_component.rb +5 -1
- data/app/lib/biovision/components/content_component.rb +36 -10
- data/app/lib/biovision/components/track_component.rb +1 -1
- data/app/lib/biovision/components/users_component.rb +28 -2
- data/app/lib/biovision/helpers/data_helper.rb +43 -0
- data/app/lib/biovision/migrations/component_migration.rb +54 -0
- data/app/mailers/feedback_mailer.rb +14 -0
- data/app/models/biovision_component.rb +3 -0
- data/app/models/browser.rb +1 -1
- data/app/models/code.rb +2 -2
- data/app/models/concerns/tree_structure.rb +2 -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/navigation_group.rb +11 -1
- data/app/models/role.rb +44 -6
- data/app/models/simple_image.rb +1 -1
- data/app/models/simple_image_tag.rb +1 -1
- data/app/models/token.rb +6 -2
- data/app/models/user.rb +25 -10
- data/app/uploaders/simple_file_uploader.rb +1 -1
- 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.html.erb +2 -1
- data/app/views/admin/components/settings/_settings.html.erb +3 -3
- data/app/views/admin/dynamic_blocks/entity/_in_list.html.erb +6 -4
- data/app/views/admin/dynamic_blocks/index.html.erb +5 -3
- data/app/views/admin/dynamic_blocks/show.html.erb +6 -4
- data/app/views/admin/dynamic_pages/_dynamic_page.jbuilder +18 -0
- data/app/views/admin/dynamic_pages/entity/_in_list.html.erb +4 -2
- data/app/views/admin/dynamic_pages/entity/_in_search.html.erb +7 -0
- data/app/views/admin/dynamic_pages/index.html.erb +11 -4
- data/app/views/admin/dynamic_pages/search.jbuilder +4 -0
- data/app/views/admin/dynamic_pages/show.html.erb +1 -1
- data/app/views/admin/index/index.html.erb +7 -5
- 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 +6 -4
- data/app/views/admin/navigation_groups/index.html.erb +11 -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 +16 -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/_in_list.html.erb +3 -1
- 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.html.erb +23 -0
- data/app/views/admin/users/roles/_component.html.erb +22 -0
- data/app/views/admin/users/search.jbuilder +4 -0
- data/app/views/admin/users/show.html.erb +14 -2
- data/app/views/admin/widgets/_filters.html.erb +15 -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/components/content/_dynamic_page.html.erb +6 -10
- data/app/views/components/content/_dynamic_page_content.html.erb +14 -0
- data/app/views/contact/_form.html.erb +1 -1
- 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.html.erb +0 -1
- data/app/views/layouts/application/_footer.html.erb +1 -1
- data/app/views/my/index/index.html.erb +26 -0
- data/app/views/shared/entity/_time_field.html.erb +6 -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 +5 -3
- data/app/views/shared/forms/_simple_image.html.erb +12 -4
- data/config/locales/biovision-ru.yml +14 -1
- data/config/locales/components-ru.yml +4 -2
- data/config/locales/contact-ru.yml +4 -0
- data/config/locales/content-ru.yml +4 -0
- data/config/locales/users-ru.yml +27 -5
- data/config/routes.rb +14 -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 +10 -40
- data/db/migrate/20210405000000_create_acl.rb +15 -0
- data/db/migrate/{20200529000000_create_content_component.rb → 20210421000000_create_content_component.rb} +3 -18
- data/db/migrate/{20210401000000_create_contact_component.rb → 20210421000010_create_contact_component.rb} +1 -22
- data/lib/biovision/version.rb +1 -1
- metadata +34 -13
- data/app/lib/biovision/components/base/privilege_handler.rb +0 -79
- 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/links/extra/_content.html.erb +0 -0
- data/app/views/admin/components/privileges.html.erb +0 -20
- 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
@@ -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,12 @@
|
|
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
7
|
include ToggleableEntity
|
8
8
|
|
9
|
-
before_action :set_entity, except: %i[check create index new]
|
9
|
+
before_action :set_entity, except: %i[check create index new search]
|
10
10
|
|
11
11
|
# post /admin/users
|
12
12
|
def create
|
@@ -42,6 +42,35 @@ class Admin::UsersController < AdminController
|
|
42
42
|
redirect_to my_path
|
43
43
|
end
|
44
44
|
|
45
|
+
# get /admin/users/:id/roles
|
46
|
+
def roles
|
47
|
+
if current_user&.super_user?
|
48
|
+
@components = BiovisionComponent.list_for_administration
|
49
|
+
else
|
50
|
+
handle_http_401
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# put /admin/users/:id/roles/:role_id
|
55
|
+
def add_role
|
56
|
+
if current_user&.super_user?
|
57
|
+
role = Role.find_by(id: params[:role_id])
|
58
|
+
@entity.add_role(role)
|
59
|
+
end
|
60
|
+
|
61
|
+
head :no_content
|
62
|
+
end
|
63
|
+
|
64
|
+
# delete /admin/users/:id/roles/:role_id
|
65
|
+
def remove_role
|
66
|
+
if current_user&.super_user?
|
67
|
+
role = Role.find_by(id: params[:role_id])
|
68
|
+
@entity.remove_role(role)
|
69
|
+
end
|
70
|
+
|
71
|
+
head :no_content
|
72
|
+
end
|
73
|
+
|
45
74
|
private
|
46
75
|
|
47
76
|
def component_class
|
@@ -55,7 +84,8 @@ class Admin::UsersController < AdminController
|
|
55
84
|
end
|
56
85
|
|
57
86
|
def creation_parameters
|
58
|
-
|
87
|
+
permitted = User.entity_parameters
|
88
|
+
parameters = params.require(:user).permit(permitted)
|
59
89
|
parameters.merge(tracking_for_entity)
|
60
90
|
end
|
61
91
|
|
@@ -7,9 +7,22 @@ class AdminController < ApplicationController
|
|
7
7
|
private
|
8
8
|
|
9
9
|
def restrict_access
|
10
|
-
user_action = "#{controller_name}
|
11
|
-
|
10
|
+
user_action = "#{controller_name}.#{role_end_from_action}"
|
11
|
+
role_name = "#{component_handler.slug}.#{user_action}"
|
12
|
+
error = t('admin.errors.unauthorized.missing_role', role: role_name)
|
12
13
|
|
13
14
|
handle_http_401(error) unless component_handler.permit?(user_action)
|
14
15
|
end
|
16
|
+
|
17
|
+
def role_end_from_action
|
18
|
+
role = action_to_role_map.select { |k| k.include?(action_name) }.values.last
|
19
|
+
role || 'default'
|
20
|
+
end
|
21
|
+
|
22
|
+
def action_to_role_map
|
23
|
+
{
|
24
|
+
%w[index show search] => 'view',
|
25
|
+
%w[create destroy edit new priority toggle update] => 'edit'
|
26
|
+
}
|
27
|
+
end
|
15
28
|
end
|
@@ -4,13 +4,17 @@
|
|
4
4
|
module CrudEntities
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
|
+
# get [scope]/[table_name]/search?q=
|
8
|
+
def search
|
9
|
+
q = param_from_request(:q)
|
10
|
+
@collection = model_class.search(q).list_for_administration.page(current_page)
|
11
|
+
end
|
12
|
+
|
7
13
|
# get [scope]/[table_name]
|
8
14
|
def index
|
9
|
-
@
|
10
|
-
|
11
|
-
|
12
|
-
model_class.list_for_administration
|
13
|
-
end
|
15
|
+
@filter = params[:filter]&.permit!.to_h
|
16
|
+
data_helper = Biovision::Helpers::DataHelper.new(model_class)
|
17
|
+
@collection = data_helper.administrative_collection(current_page, @filter)
|
14
18
|
end
|
15
19
|
|
16
20
|
# get [scope]/[table_name]/:id
|
@@ -32,7 +36,7 @@ module CrudEntities
|
|
32
36
|
|
33
37
|
# post [scope]/[table_name]
|
34
38
|
def create
|
35
|
-
@entity =
|
39
|
+
@entity = component_handler.new_entity(model_class, creation_parameters)
|
36
40
|
apply_meta if @entity.respond_to?(:meta=)
|
37
41
|
if @entity.save
|
38
42
|
form_processed_ok(path_after_save)
|
@@ -50,7 +54,7 @@ module CrudEntities
|
|
50
54
|
def update
|
51
55
|
apply_meta if @entity.respond_to?(:meta=)
|
52
56
|
|
53
|
-
if @entity
|
57
|
+
if component_handler.update_entity(@entity, entity_parameters)
|
54
58
|
form_processed_ok(path_after_save)
|
55
59
|
else
|
56
60
|
form_processed_with_error(view_for_edit)
|
@@ -95,10 +99,6 @@ module CrudEntities
|
|
95
99
|
"#{prefix}/#{model_class.table_name}"
|
96
100
|
end
|
97
101
|
|
98
|
-
def paginate_entities?
|
99
|
-
model_class.respond_to?(:page_for_administration)
|
100
|
-
end
|
101
|
-
|
102
102
|
def set_entity
|
103
103
|
@entity = model_class.find_by(id: params[:id])
|
104
104
|
handle_http_404("Cannot find #{model_class.model_name}") if @entity.nil?
|
@@ -113,7 +113,7 @@ module CrudEntities
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def explicit_creation_parameters
|
116
|
-
permitted = model_class.creation_parameters
|
116
|
+
permitted = model_class.creation_parameters
|
117
117
|
parameters = params.require(model_key).permit(permitted)
|
118
118
|
parameters.merge!(tracking_for_entity) if model_class.include?(HasTrack)
|
119
119
|
parameters.merge!(owner_for_entity) if model_class.include?(HasOwner)
|
@@ -121,7 +121,7 @@ module CrudEntities
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def entity_parameters
|
124
|
-
permitted = model_class.entity_parameters
|
124
|
+
permitted = model_class.entity_parameters
|
125
125
|
params.require(model_key).permit(permitted)
|
126
126
|
end
|
127
127
|
|
@@ -27,7 +27,7 @@ class ContactController < ApplicationController
|
|
27
27
|
def save_entity
|
28
28
|
if @entity.save
|
29
29
|
show_result
|
30
|
-
|
30
|
+
FeedbackMailer.new_feedback_request(@entity.id).deliver_later
|
31
31
|
else
|
32
32
|
redirect_to root_path
|
33
33
|
end
|
@@ -6,9 +6,13 @@ module BiovisionComponentsHelper
|
|
6
6
|
# @param [String] text
|
7
7
|
# @param [Hash] options
|
8
8
|
def admin_biovision_component_link(entity, text = nil, options = {})
|
9
|
-
|
10
|
-
text = t("biovision.components.#{entity.slug}.name", default: entity.slug)
|
11
|
-
end
|
9
|
+
text ||= component_name(entity.slug)
|
12
10
|
link_to(text, admin_component_path(slug: entity.slug), options)
|
13
11
|
end
|
12
|
+
|
13
|
+
# @param [String|BiovisionComponent] slug
|
14
|
+
def component_name(slug)
|
15
|
+
slug = slug.respond_to?(:slug) ? slug.slug : slug
|
16
|
+
t("biovision.components.#{slug}.name", default: slug)
|
17
|
+
end
|
14
18
|
end
|
@@ -9,6 +9,14 @@ module Biovision
|
|
9
9
|
false
|
10
10
|
end
|
11
11
|
|
12
|
+
def use_images?
|
13
|
+
false
|
14
|
+
end
|
15
|
+
|
16
|
+
def manage_settings?
|
17
|
+
use_parameters? || component.settings.any?
|
18
|
+
end
|
19
|
+
|
12
20
|
# Receive parameter value with default
|
13
21
|
#
|
14
22
|
# Returns value of component's parameter or default value
|
@@ -5,18 +5,12 @@ module Biovision
|
|
5
5
|
module Base
|
6
6
|
# Handling component privileges
|
7
7
|
module ComponentPrivileges
|
8
|
-
# @param [String|Array] privileges
|
9
|
-
# @deprecated use #role? or #permit?
|
10
|
-
def allow?(*privileges)
|
11
|
-
permit?(*privileges)
|
12
|
-
end
|
13
|
-
|
14
8
|
# @param [String] action
|
15
9
|
# @param [Object] context
|
16
10
|
def permit?(action = 'default', context = nil)
|
17
11
|
return false if user.nil?
|
18
12
|
|
19
|
-
parts = []
|
13
|
+
parts = [slug]
|
20
14
|
model = model_from_context(context)
|
21
15
|
parts << model.table_name if model.respond_to?(:table_name)
|
22
16
|
parts << action
|
@@ -33,12 +27,12 @@ module Biovision
|
|
33
27
|
# @param [String] role_name
|
34
28
|
def role?(role_name)
|
35
29
|
return false if user.nil?
|
36
|
-
return true if user.super_user?
|
30
|
+
return true if user.super_user?
|
37
31
|
|
38
32
|
role = Role[role_name]
|
39
33
|
return false if role.nil?
|
40
34
|
|
41
|
-
|
35
|
+
user.role_ids.include?(role.id)
|
42
36
|
end
|
43
37
|
|
44
38
|
# @param [Class|Object] context
|
@@ -47,18 +41,33 @@ module Biovision
|
|
47
41
|
context.is_a?(Class) ? context : context.class
|
48
42
|
end
|
49
43
|
|
50
|
-
def
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
44
|
+
def crud_table_names
|
45
|
+
tables = self.class.dependent_models.map(&:table_name)
|
46
|
+
tables << 'simple_images' if use_images?
|
47
|
+
tables
|
48
|
+
end
|
49
|
+
|
50
|
+
def role_tree
|
51
|
+
tree = { nil => %w[default view] }
|
52
|
+
tree['settings'] = %w[view edit] if use_settings?
|
53
|
+
crud_table_names.each do |table_name|
|
54
|
+
tree[table_name] = %w[view edit]
|
56
55
|
end
|
56
|
+
tree
|
57
|
+
end
|
57
58
|
|
58
|
-
|
59
|
-
|
59
|
+
def create_roles
|
60
|
+
role_tree.each do |prefix, postfixes|
|
61
|
+
postfixes.each do |postfix|
|
62
|
+
slug = prefix.blank? ? postfix : "#{prefix}.#{postfix}"
|
63
|
+
Role.create(biovision_component: component, slug: slug)
|
64
|
+
end
|
60
65
|
end
|
61
66
|
end
|
67
|
+
|
68
|
+
def administrative_parts
|
69
|
+
self.class.dependent_models.map(&:table_name)
|
70
|
+
end
|
62
71
|
end
|
63
72
|
end
|
64
73
|
end
|
@@ -64,16 +64,8 @@ module Biovision
|
|
64
64
|
[]
|
65
65
|
end
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
return false if user.nil? || user.banned?
|
70
|
-
return true if user.super_user?
|
71
|
-
|
72
|
-
BiovisionComponentUser.owned_by(user).each do |link|
|
73
|
-
return true if link.administrator? || !link.data['privileges'].blank?
|
74
|
-
end
|
75
|
-
|
76
|
-
false
|
67
|
+
def self.create
|
68
|
+
BiovisionComponent.create(slug: slug, settings: default_settings)
|
77
69
|
end
|
78
70
|
|
79
71
|
# @param [ApplicationRecord] entity
|
@@ -93,9 +85,12 @@ module Biovision
|
|
93
85
|
def user=(user)
|
94
86
|
@user = user
|
95
87
|
|
96
|
-
|
97
|
-
|
98
|
-
|
88
|
+
if @user.nil?
|
89
|
+
@user_link = nil
|
90
|
+
else
|
91
|
+
criteria = { biovision_component: @component, user: user }
|
92
|
+
@user_link = BiovisionComponentUser.find_by(criteria)
|
93
|
+
end
|
99
94
|
end
|
100
95
|
|
101
96
|
def user_link!(force_create = false)
|
@@ -112,12 +107,6 @@ module Biovision
|
|
112
107
|
use_parameters? || @component.settings.any?
|
113
108
|
end
|
114
109
|
|
115
|
-
def administrator?
|
116
|
-
return false if user.nil?
|
117
|
-
|
118
|
-
user.super_user? || @user_link&.administrator?
|
119
|
-
end
|
120
|
-
|
121
110
|
# @param [Hash] data
|
122
111
|
def settings=(data)
|
123
112
|
@component.settings.merge!(self.class.normalize_settings(data))
|
@@ -144,10 +133,6 @@ module Biovision
|
|
144
133
|
metric << quantity
|
145
134
|
end
|
146
135
|
|
147
|
-
def privilege_handler
|
148
|
-
@privilege_handler ||= Base::PrivilegeHandler.new(self)
|
149
|
-
end
|
150
|
-
|
151
136
|
# @param [User] user
|
152
137
|
# @param [String] code_type
|
153
138
|
# @param [Integer] quantity
|
@@ -169,6 +154,18 @@ module Biovision
|
|
169
154
|
data[key.to_s] = new_value
|
170
155
|
user.new_component_data(data)
|
171
156
|
end
|
157
|
+
|
158
|
+
# @param [ApplicationRecord] entity
|
159
|
+
# @param [Hash] new_attributes
|
160
|
+
def update_entity(entity, new_attributes)
|
161
|
+
entity.update(new_attributes)
|
162
|
+
end
|
163
|
+
|
164
|
+
# @param [Class] model_class
|
165
|
+
# @param [Hash] parameters
|
166
|
+
def new_entity(model_class, parameters)
|
167
|
+
model_class.new(parameters)
|
168
|
+
end
|
172
169
|
end
|
173
170
|
end
|
174
171
|
end
|