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
data/app/models/simple_image.rb
CHANGED
@@ -43,7 +43,7 @@ class SimpleImage < ApplicationRecord
|
|
43
43
|
scope :filtered, ->(v) { where('image ilike ? or caption ilike ?', "%#{v}%", "%#{v}%") unless v.blank? }
|
44
44
|
scope :list_for_administration, -> { order('image asc') }
|
45
45
|
|
46
|
-
def self.entity_parameters
|
46
|
+
def self.entity_parameters
|
47
47
|
%i[caption image image_alt_text source_link source_name]
|
48
48
|
end
|
49
49
|
|
data/app/models/token.rb
CHANGED
@@ -45,11 +45,11 @@ class Token < ApplicationRecord
|
|
45
45
|
list_for_owner(user).page(page)
|
46
46
|
end
|
47
47
|
|
48
|
-
def self.entity_parameters
|
48
|
+
def self.entity_parameters
|
49
49
|
%i[active]
|
50
50
|
end
|
51
51
|
|
52
|
-
def self.creation_parameters
|
52
|
+
def self.creation_parameters
|
53
53
|
entity_parameters + %i[user_id]
|
54
54
|
end
|
55
55
|
|
@@ -83,6 +83,10 @@ class Token < ApplicationRecord
|
|
83
83
|
"[#{id}] #{user.profile_name}"
|
84
84
|
end
|
85
85
|
|
86
|
+
def text_for_link
|
87
|
+
name
|
88
|
+
end
|
89
|
+
|
86
90
|
# @param [User] user
|
87
91
|
def editable_by?(user)
|
88
92
|
return true if owned_by?(user)
|
data/app/models/user.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# User
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# Attributes:
|
6
6
|
# agent_id [Agent], optional
|
7
7
|
# allow_mail [boolean]
|
@@ -20,14 +20,14 @@
|
|
20
20
|
# last_seen [datetime], optional
|
21
21
|
# notice [string], optional
|
22
22
|
# password_digest [string]
|
23
|
+
# phone [string], optional
|
23
24
|
# phone_confirmed [boolean]
|
24
25
|
# primary_id [User], optional
|
25
26
|
# profile [Jsonb]
|
27
|
+
# referral_link [string]
|
26
28
|
# screen_name [string]
|
27
29
|
# slug [string]
|
28
30
|
# super_user [boolean]
|
29
|
-
# phone [string], optional
|
30
|
-
# referral_link [string]
|
31
31
|
# updated_at [DateTime]
|
32
32
|
# uuid [uuid]
|
33
33
|
class User < ApplicationRecord
|
@@ -60,6 +60,8 @@ class User < ApplicationRecord
|
|
60
60
|
has_many :foreign_users, dependent: :delete_all if Gem.loaded_specs.key?('biovision-oauth')
|
61
61
|
has_many :login_attempts, dependent: :delete_all
|
62
62
|
has_many :user_languages, dependent: :delete_all
|
63
|
+
has_many :user_roles, dependent: :destroy
|
64
|
+
has_many :user_groups, dependent: :destroy
|
63
65
|
|
64
66
|
after_initialize :prepare_referral_link
|
65
67
|
|
@@ -71,7 +73,6 @@ class User < ApplicationRecord
|
|
71
73
|
Biovision::Components::UsersComponent[entity].validate
|
72
74
|
end
|
73
75
|
|
74
|
-
validates_acceptance_of :consent
|
75
76
|
validates :screen_name, presence: true, uniqueness: { case_sensitive: false }
|
76
77
|
validates :email, uniqueness: { case_sensitive: false }, allow_nil: true
|
77
78
|
validates :phone, uniqueness: { case_sensitive: false }, allow_nil: true
|
@@ -82,6 +83,7 @@ class User < ApplicationRecord
|
|
82
83
|
scope :email_like, ->(v) { where('email ilike ?', "%#{v}%") unless v.blank? }
|
83
84
|
scope :with_email, ->(v) { where('lower(email) = lower(?)', v.to_s) }
|
84
85
|
scope :list_for_administration, -> { order('id desc') }
|
86
|
+
scope :search, ->(q) { where('screen_name ilike ?', "%#{q}%") unless q.blank? }
|
85
87
|
|
86
88
|
def self.[](login)
|
87
89
|
find_by(slug: login) || find_by_contact(login)
|
@@ -93,7 +95,7 @@ class User < ApplicationRecord
|
|
93
95
|
end
|
94
96
|
|
95
97
|
def self.profile_parameters
|
96
|
-
%i[image allow_mail birthday
|
98
|
+
%i[image allow_mail birthday]
|
97
99
|
end
|
98
100
|
|
99
101
|
def self.sensitive_parameters
|
@@ -110,12 +112,12 @@ class User < ApplicationRecord
|
|
110
112
|
end
|
111
113
|
|
112
114
|
# Parameters for registration
|
113
|
-
def self.new_profile_parameters
|
115
|
+
def self.new_profile_parameters
|
114
116
|
profile_parameters + sensitive_parameters + %i[screen_name]
|
115
117
|
end
|
116
118
|
|
117
119
|
# Administrative parameters
|
118
|
-
def self.entity_parameters
|
120
|
+
def self.entity_parameters
|
119
121
|
flags = %i[banned bot email_confirmed phone_confirmed]
|
120
122
|
|
121
123
|
new_profile_parameters + flags + %i[notice screen_name slug]
|
@@ -131,9 +133,22 @@ class User < ApplicationRecord
|
|
131
133
|
def role?(role_name)
|
132
134
|
return true if super_user?
|
133
135
|
|
134
|
-
|
135
|
-
|
136
|
-
|
136
|
+
role = Role[role_name]
|
137
|
+
role_ids.include?(role&.id)
|
138
|
+
end
|
139
|
+
|
140
|
+
def role_ids
|
141
|
+
Array(data[Role::CACHE_KEY]).map(&:to_i)
|
142
|
+
end
|
143
|
+
|
144
|
+
# @param [Role] role
|
145
|
+
def add_role(role)
|
146
|
+
role&.add_user(self)
|
147
|
+
end
|
148
|
+
|
149
|
+
# @param [Role] role
|
150
|
+
def remove_role(role)
|
151
|
+
role&.remove_user(self)
|
137
152
|
end
|
138
153
|
|
139
154
|
# Name to be shown as profile
|
@@ -1,35 +1,45 @@
|
|
1
1
|
<nav class="biovision-component-nav">
|
2
|
-
<% if handler.permit?('settings') %>
|
3
|
-
<% if handler.use_parameters? || handler.component.settings.any? %>
|
4
|
-
<%=
|
5
|
-
link_to(
|
6
|
-
t('admin.components.settings.nav_text'),
|
7
|
-
admin_component_settings_path(slug: handler.slug),
|
8
|
-
class: 'settings'
|
9
|
-
)
|
10
|
-
%>
|
11
|
-
<% end %>
|
12
|
-
<% end %>
|
13
|
-
|
14
|
-
<% if handler.administrator? %>
|
2
|
+
<% if handler.manage_settings? && handler.permit?('settings.view') %>
|
15
3
|
<%=
|
16
4
|
link_to(
|
17
|
-
|
18
|
-
|
19
|
-
|
5
|
+
t('admin.components.settings.nav_text'),
|
6
|
+
admin_component_settings_path(slug: handler.slug),
|
7
|
+
class: 'settings'
|
20
8
|
)
|
21
9
|
%>
|
22
10
|
<% end %>
|
23
11
|
|
24
12
|
<% prefix = 'admin/components/links/' %>
|
25
|
-
|
26
|
-
|
13
|
+
<ul class="biovision-component-links">
|
14
|
+
<% if lookup_context.exists?("#{prefix}_#{handler.slug}") %>
|
15
|
+
<%=
|
16
|
+
render(
|
17
|
+
partial: "#{prefix}#{handler.slug}",
|
18
|
+
locals: { handler: handler }
|
19
|
+
)
|
20
|
+
%>
|
21
|
+
<% else %>
|
22
|
+
<% handler.administrative_parts.each do |part| %>
|
23
|
+
<% context = "admin/#{part}/_nav_item" %>
|
24
|
+
<% if handler.permit?("#{part}.view") && lookup_context.exists?(context) %>
|
25
|
+
<li>
|
26
|
+
<%=
|
27
|
+
render(
|
28
|
+
partial: "admin/#{part}/nav_item",
|
29
|
+
locals: { handler: handler }
|
30
|
+
)
|
31
|
+
%>
|
32
|
+
</li>
|
33
|
+
<% end %>
|
34
|
+
<% end %>
|
35
|
+
<% end %>
|
36
|
+
<% if lookup_context.exists?("admin/components/links/extra/_#{handler.slug}") %>
|
27
37
|
<%=
|
28
38
|
render(
|
29
|
-
|
30
|
-
|
39
|
+
partial: "admin/components/links/extra/#{handler.slug}",
|
40
|
+
locals: { handler: handler }
|
31
41
|
)
|
32
42
|
%>
|
33
|
-
</ul>
|
34
43
|
<% end %>
|
44
|
+
</ul>
|
35
45
|
</nav>
|
@@ -0,0 +1 @@
|
|
1
|
+
<li>:)</li>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if
|
1
|
+
<% if keys.any? %>
|
2
2
|
<section class="biovision-component-settings">
|
3
3
|
<h2><%= t('.heading') %></h2>
|
4
4
|
|
@@ -10,14 +10,14 @@
|
|
10
10
|
) do
|
11
11
|
%>
|
12
12
|
<div class="fields">
|
13
|
-
<%
|
13
|
+
<% keys.each do |key| %>
|
14
14
|
<%=
|
15
15
|
render(
|
16
16
|
partial: 'admin/components/settings/setting',
|
17
17
|
locals: {
|
18
18
|
slug: handler.slug,
|
19
19
|
key: key,
|
20
|
-
value:
|
20
|
+
value: settings[key.to_s]
|
21
21
|
}
|
22
22
|
)
|
23
23
|
%>
|
@@ -3,8 +3,10 @@
|
|
3
3
|
|
4
4
|
<%= render(partial: 'shared/admin/toggle', locals: { entity: entity }) %>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
<% if local_assigns[:handler] && handler.permit?('edit', entity) %>
|
7
|
+
<div class="entity-actions">
|
8
|
+
<%= edit_icon(entity) %>
|
9
|
+
<%= destroy_icon(entity) %>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
10
12
|
</div>
|
@@ -7,9 +7,11 @@
|
|
7
7
|
<article>
|
8
8
|
<h1><%= t('.heading') %></h1>
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
<% if component_handler.permit?("#{controller_name}.create") %>
|
11
|
+
<nav class="entity-actions">
|
12
|
+
<%= create_icon(new_admin_dynamic_block_path) %>
|
13
|
+
</nav>
|
14
|
+
<% end %>
|
13
15
|
|
14
16
|
<%= render partial: 'shared/admin/list', locals: { collection: @collection } %>
|
15
17
|
</article>
|
@@ -8,10 +8,12 @@
|
|
8
8
|
<article>
|
9
9
|
<h1><%= @entity.class.model_name.human %> <q><%= @entity.slug %></q></h1>
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
<% if component_handler.permit?('edit', @entity) %>
|
12
|
+
<nav class="entity-actions">
|
13
|
+
<%= edit_icon(@entity) %>
|
14
|
+
<%= destroy_icon(@entity) %>
|
15
|
+
</nav>
|
16
|
+
<% end %>
|
15
17
|
|
16
18
|
<dl class="fields">
|
17
19
|
<%= render partial: 'shared/entity/slug', locals: { entity: @entity } %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
json.id dynamic_page.id
|
2
|
+
json.type dynamic_page.class.table_name
|
3
|
+
json.attributes do
|
4
|
+
json.call(dynamic_page, :slug, :url)
|
5
|
+
end
|
6
|
+
json.meta do
|
7
|
+
json.text_for_link dynamic_page.text_for_link
|
8
|
+
json.html(
|
9
|
+
render(
|
10
|
+
partial: 'admin/dynamic_pages/entity/in_search',
|
11
|
+
locals: { entity: dynamic_page },
|
12
|
+
formats: [:html]
|
13
|
+
)
|
14
|
+
)
|
15
|
+
end
|
16
|
+
json.links do
|
17
|
+
json.self admin_dynamic_page_path(id: dynamic_page.id)
|
18
|
+
end
|
@@ -9,7 +9,9 @@
|
|
9
9
|
|
10
10
|
<div class="entity-actions">
|
11
11
|
<%= world_icon(entity) unless entity.url.blank? %>
|
12
|
-
|
13
|
-
|
12
|
+
<% if local_assigns[:handler] && handler.permit?('edit', entity) %>
|
13
|
+
<%= edit_icon(entity) %>
|
14
|
+
<%= destroy_icon(entity) %>
|
15
|
+
<% end %>
|
14
16
|
</div>
|
15
17
|
</div>
|
@@ -7,9 +7,16 @@
|
|
7
7
|
<article>
|
8
8
|
<h1><%= t('.heading') %></h1>
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
<% if component_handler.permit?("#{controller_name}.edit") %>
|
11
|
+
<nav class="entity-actions">
|
12
|
+
<%= create_icon(new_admin_dynamic_page_path) %>
|
13
|
+
</nav>
|
14
|
+
<% end %>
|
13
15
|
|
14
|
-
<%=
|
16
|
+
<%=
|
17
|
+
render(
|
18
|
+
partial: 'shared/admin/list',
|
19
|
+
locals: { collection: @collection, handler: component_handler }
|
20
|
+
)
|
21
|
+
%>
|
15
22
|
</article>
|
@@ -3,12 +3,14 @@
|
|
3
3
|
<article>
|
4
4
|
<h1><%= t('.heading') %></h1>
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
<% if component_handler.permit?('components.view') %>
|
7
|
+
<%=
|
8
|
+
render(
|
8
9
|
partial: 'admin/components/list',
|
9
10
|
locals: {
|
10
|
-
|
11
|
+
collection: BiovisionComponent.list_for_administration
|
11
12
|
}
|
12
|
-
|
13
|
-
|
13
|
+
)
|
14
|
+
%>
|
15
|
+
<% end %>
|
14
16
|
</article>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<div class="data">
|
2
|
+
<div><%= admin_entity_link(entity.dynamic_page) %></div>
|
3
|
+
<div class="info"><%= entity.dynamic_page.url %></div>
|
4
|
+
<div class="secondary info"><%= entity.dynamic_page.name %></div>
|
5
|
+
|
6
|
+
<% if local_assigns[:handler] && handler.permit?('edit', entity.navigation_group) %>
|
7
|
+
<div class="entity-actions">
|
8
|
+
<% url = page_priority_admin_navigation_group_path(id: entity.navigation_group_id, page_id: entity.id) %>
|
9
|
+
<div class="priority-changer" data-url="<%= url %>">
|
10
|
+
<button data-delta="-1" type="button">↑</button>
|
11
|
+
<button data-delta="1" type="button">↓</button>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<%=
|
15
|
+
button_tag(
|
16
|
+
'',
|
17
|
+
class: 'danger destroy',
|
18
|
+
data: {
|
19
|
+
url: dynamic_page_admin_navigation_group_path(id: entity.navigation_group_id, page_id: entity.id)
|
20
|
+
},
|
21
|
+
type: 'button'
|
22
|
+
)
|
23
|
+
%>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
</div>
|