biovision-base 0.14.180326 → 0.15.180415

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/biovision/base/biovision-sliders.js +22 -1
  3. data/app/assets/javascripts/biovision/base/biovision.js +27 -1
  4. data/app/assets/stylesheets/biovision/base/biovision.scss +6 -1
  5. data/app/controllers/about_controller.rb +9 -2
  6. data/app/controllers/my/profiles_controller.rb +7 -6
  7. data/app/controllers/users_controller.rb +2 -2
  8. data/app/models/user.rb +2 -1
  9. data/app/views/admin/index/_biovision_base.html.erb +1 -0
  10. data/app/views/admin/privileges/entity/_in_list.html.erb +1 -1
  11. data/app/views/editable_pages/_form.html.erb +5 -4
  12. data/app/views/my/confirmations/show.html.erb +1 -1
  13. data/app/views/my/index/index.html.erb +1 -1
  14. data/app/views/my/index/index/_custom_sidebar.html.erb +0 -0
  15. data/app/views/my/index/index/_sidebar.html.erb +2 -0
  16. data/app/views/my/login_attempts/index.html.erb +1 -1
  17. data/app/views/my/profiles/edit/_form.html.erb +1 -1
  18. data/app/views/my/profiles/new.html.erb +1 -1
  19. data/app/views/my/profiles/new/_form.html.erb +1 -1
  20. data/app/views/my/tokens/index.html.erb +1 -1
  21. data/app/views/users/_form.html.erb +1 -0
  22. data/config/locales/users-en.yml +1 -0
  23. data/config/locales/users-ru.yml +1 -0
  24. data/config/routes.rb +1 -0
  25. data/db/migrate/20170302000001_create_users.rb +1 -0
  26. data/db/migrate/20170320000000_create_editable_pages.rb +1 -0
  27. data/db/migrate/20180405000000_add_consent_to_users.rb +13 -0
  28. data/lib/biovision/base/version.rb +1 -1
  29. metadata +9 -9
  30. data/app/views/my/profiles/edit.js.erb +0 -1
  31. data/app/views/my/profiles/new.js.erb +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1353161eefdcb8571b2b56a451e83333d79bf82583127c2d561e9ffdb1859953
4
- data.tar.gz: 42f4e3dcab70faf1e77dc46ff68a2c248d7952c434eb85ee66228e5ad5092168
3
+ metadata.gz: b32ca23796647159d2a821d53b9b83ece30a748e846c666b55aa8d24579c8fc7
4
+ data.tar.gz: f00de9e1ea2772e8863b66f96f1fea59c0d5675f0062dd87ce015eba7b3bfa0f
5
5
  SHA512:
6
- metadata.gz: c4242e909f0fdf4760ce0e131469cb8a92b976e02bb731166ace8a28b48ad30e6927c04118274374f694c2d43da3770dba23f7edccaedcd8a102a3e03375e37e
7
- data.tar.gz: 43f83f5678b7705c21a54a548d19a0bcddca133f57d53a910b29e701d6b734e876344fd7c2a41d1186ea899f88952d8e70b190b7347d27216c3920c032ca6687
6
+ metadata.gz: 5ebdb6a0c58f56706b1b93fdaa2fe23e17f801c53aca06bd018e5e1b2fcff96eafd8aa3e0a99dfc4c16f00d522c44e2ff6432df42843278becff5920ce3adf84
7
+ data.tar.gz: 7af837c64015a5694ed8b917b7b1ee9e8579c1943318ffdae4d3f73a797d7ca61bcb653f27181b07c1359adbfea1a374da1f18a4165a067e17018c879dd2f75d
@@ -43,9 +43,30 @@ Biovision.sliders = {
43
43
  Biovision.sliders.behavior[type].left(list, delay);
44
44
  };
45
45
 
46
+ const handle_gesture = function () {
47
+ const x0 = Biovision.sliders.touch_state.x0;
48
+ const x1 = Biovision.sliders.touch_state.x1;
49
+
50
+ if (x0 < x1) {
51
+ slide_left();
52
+ } else if (x0 > x1) {
53
+ slide_right();
54
+ }
55
+ };
56
+
46
57
  slider.querySelector('button.prev').addEventListener('click', slide_left);
47
58
  slider.querySelector('button.next').addEventListener('click', slide_right);
48
- }
59
+ slider.addEventListener('touchstart', function (event) {
60
+ Biovision.sliders.touch_state.x0 = event.changedTouches[0].pageX;
61
+ Biovision.sliders.touch_state.y0 = event.changedTouches[0].pageY;
62
+ }, false);
63
+ slider.addEventListener('touchend', function (event) {
64
+ Biovision.sliders.touch_state.x1 = event.changedTouches[0].pageX;
65
+ Biovision.sliders.touch_state.y1 = event.changedTouches[0].pageY;
66
+ handle_gesture();
67
+ }, false);
68
+ },
69
+ touch_state: {x0: 0, y0: 0, x1: 0, y1: 0}
49
70
  };
50
71
 
51
72
  document.addEventListener('DOMContentLoaded', function () {
@@ -205,7 +205,7 @@ const Biovision = {
205
205
  element.addEventListener('blur', perform_check);
206
206
  });
207
207
  },
208
- show_list_of_errors: function(entity_name, list) {
208
+ show_list_of_errors: function (entity_name, list) {
209
209
  const form = document.getElementById(entity_name + '-form');
210
210
  if (form) {
211
211
  let errors = form.querySelector('ol.errors');
@@ -471,6 +471,32 @@ function handle_ajax_failure(response) {
471
471
  }
472
472
  }
473
473
 
474
+ /**
475
+ * Workaround for defective Safari behaviour with empty files
476
+ * @see https://github.com/rails/rails/issues/32440
477
+ */
478
+ document.addEventListener('ajax:beforeSend', function (e) {
479
+ const formData = e.detail[1].data;
480
+
481
+ if (!(formData instanceof window.FormData) || !formData.keys) {
482
+ return;
483
+ }
484
+
485
+ const newFormData = new window.FormData();
486
+
487
+ Array.from(formData.entries()).forEach(function (entry) {
488
+ const value = entry[1];
489
+
490
+ if (value instanceof window.File && value.name === '' && value.size === 0) {
491
+ newFormData.append(entry[0], new window.Blob([]), '');
492
+ } else {
493
+ newFormData.append(entry[0], value);
494
+ }
495
+ });
496
+
497
+ e.detail[1].data = newFormData
498
+ });
499
+
474
500
  /*
475
501
  *************
476
502
  * Polyfills *
@@ -11,7 +11,12 @@ html {
11
11
  -ms-text-size-adjust: none;
12
12
  }
13
13
 
14
- h1, h2, h3, h4, h6, h6 {
14
+ h1,
15
+ h2,
16
+ h3,
17
+ h4,
18
+ h5,
19
+ h6 {
15
20
  font-family: $font-family-heading;
16
21
  font-weight: 500;
17
22
  margin: 0;
@@ -1,14 +1,21 @@
1
1
  class AboutController < ApplicationController
2
2
  # get /about
3
3
  def index
4
- @editable_page = EditablePage.find_by(slug: 'about')
4
+ @editable_page = EditablePage.find_localized('about', locale)
5
5
 
6
6
  render :editable
7
7
  end
8
8
 
9
9
  # get /tos
10
10
  def tos
11
- @editable_page = EditablePage.find_by(slug: 'tos')
11
+ @editable_page = EditablePage.find_localized('tos', locale)
12
+
13
+ render :editable
14
+ end
15
+
16
+ # get /privacy
17
+ def privacy
18
+ @editable_page = EditablePage.find_localized('privacy', locale)
12
19
 
13
20
  render :editable
14
21
  end
@@ -6,7 +6,7 @@ class My::ProfilesController < ApplicationController
6
6
 
7
7
  # get /my/profile/new
8
8
  def new
9
- @user = User.new
9
+ @entity = User.new
10
10
  end
11
11
 
12
12
  # post /my/profile
@@ -28,9 +28,10 @@ class My::ProfilesController < ApplicationController
28
28
 
29
29
  # patch /my/profile
30
30
  def update
31
- if current_user.update(user_parameters)
31
+ @entity = current_user
32
+ if @entity.update(user_parameters)
32
33
  flash[:notice] = t('my.profiles.update.success')
33
- form_processed_ok(my_profile_path)
34
+ form_processed_ok(my_path)
34
35
  else
35
36
  form_processed_with_error(:edit)
36
37
  end
@@ -43,10 +44,10 @@ class My::ProfilesController < ApplicationController
43
44
  end
44
45
 
45
46
  def create_user
46
- @user = User.new creation_parameters
47
- if @user.save
47
+ @entity = User.new creation_parameters
48
+ if @entity.save
48
49
  Metric.register(User::METRIC_REGISTRATION)
49
- create_token_for_user(@user)
50
+ create_token_for_user(@entity)
50
51
  redirect_after_creation
51
52
  else
52
53
  form_processed_with_error(:new)
@@ -11,7 +11,7 @@ class UsersController < ApplicationController
11
11
 
12
12
  # get /users/new
13
13
  def new
14
- @entity = User.new
14
+ @entity = User.new(consent: true)
15
15
  end
16
16
 
17
17
  # post /users
@@ -64,7 +64,7 @@ class UsersController < ApplicationController
64
64
  end
65
65
 
66
66
  def creation_parameters
67
- entity_parameters.merge(tracking_for_entity)
67
+ entity_parameters.merge(tracking_for_entity).merge(consent: true)
68
68
  end
69
69
 
70
70
  def profile_parameters
data/app/models/user.rb CHANGED
@@ -39,6 +39,7 @@ class User < ApplicationRecord
39
39
  before_save :normalize_slug
40
40
  before_save :prepare_search_string
41
41
 
42
+ validates_acceptance_of :consent
42
43
  validates_presence_of :screen_name, :email
43
44
  validates_format_of :screen_name, with: SCREEN_NAME_PATTERN, if: :native_slug?
44
45
  validates_format_of :email, with: EMAIL_PATTERN
@@ -66,7 +67,7 @@ class User < ApplicationRecord
66
67
  end
67
68
 
68
69
  def self.profile_parameters
69
- %i(image allow_mail birthday)
70
+ %i(image allow_mail birthday consent)
70
71
  end
71
72
 
72
73
  def self.sensitive_parameters
@@ -4,5 +4,6 @@
4
4
  <%= render 'admin/index/dashboard/biovision_user' %>
5
5
  <%= render 'admin/index/dashboard/editorial' %>
6
6
  <%= render 'admin/index/dashboard/biovision_post' if Gem.loaded_specs.key?('biovision-post') %>
7
+ <%= render 'admin/index/dashboard/biovision_poll' if Gem.loaded_specs.key?('biovision-poll') %>
7
8
  <%= render 'admin/index/dashboard/biovision_courses' if Gem.loaded_specs.key?('biovision-courses') %>
8
9
  <%= render 'admin/index/dashboard/biovision_feedback' %>
@@ -12,7 +12,7 @@
12
12
 
13
13
  <ul class="actions">
14
14
  <li class="lockable <%= entity.locked? ? 'hidden' : '' %>">
15
- <%= edit_icon(edit_privilege_path(entity.id)) %>
15
+ <%= edit_icon(edit_privilege_path(id: entity.id)) %>
16
16
  </li>
17
17
  <%= render partial: 'shared/actions/priority_changer', locals: { path: priority_admin_privilege_path(id: entity.id) } %>
18
18
  <%= render partial: 'shared/actions/locks', locals: { entity: entity, path: lock_admin_privilege_path(id: entity.id) } %>
@@ -1,4 +1,5 @@
1
- <%= form_with(model: entity, html: { id: "#{entity.class.to_s.underscore}-form" }) do |f| %>
1
+ <% entity_name = entity.class.to_s.underscore %>
2
+ <%= form_with(model: entity, html: { id: "#{entity_name}-form" }) do |f| %>
2
3
  <%= render partial: 'shared/list_of_errors', locals: { entity: entity } %>
3
4
 
4
5
  <dl>
@@ -21,7 +22,7 @@
21
22
 
22
23
  <dt><%= f.label :image %></dt>
23
24
  <dd>
24
- <figure class="preview" role="group" id="editable_page-image">
25
+ <figure class="preview" role="group" id="<%= entity_name %>-image">
25
26
  <% if entity.image.blank? %>
26
27
  <%= f.label :image, image_tag('biovision/base/placeholders/image.svg') %>
27
28
  <% else %>
@@ -31,9 +32,9 @@
31
32
  <%=
32
33
  f.file_field(
33
34
  :image,
34
- id: :editable_page_image,
35
+ id: "#{entity_name}_image",
35
36
  accept: 'image/jpeg,image/png',
36
- data: { image: 'editable_page-image' }
37
+ data: { image: "#{entity_name}-image" }
37
38
  )
38
39
  %>
39
40
  </figcaption>
@@ -1,6 +1,6 @@
1
1
  <% content_for :meta_title, t('.title') %>
2
2
 
3
- <article class="my-confirmation">
3
+ <article class="profile-content my-confirmation">
4
4
  <h1><%= t('.title') %></h1>
5
5
  <% if current_user&.email_confirmed? %>
6
6
  <div class="message-box-notice"><%= t('activerecord.attributes.user.email_confirmed') %></div>
@@ -3,7 +3,7 @@
3
3
  <span><%= t('.heading') %></span>
4
4
  <% end %>
5
5
 
6
- <article id="my-index">
6
+ <article id="my-index" class="profile-content">
7
7
  <div class="sidebar dashboard">
8
8
  <%= render 'my/index/index/sidebar' %>
9
9
  </div>
File without changes
@@ -3,6 +3,8 @@
3
3
  <li><%= render 'my/profiles/nav_item' %></li>
4
4
  <li><%= render 'my/tokens/nav_item' %></li>
5
5
  <li><%= render 'my/login_attempts/nav_item' %></li>
6
+ <%= render 'my/index/sidebar/biovision_courses' if Gem.loaded_specs.key?('biovision-courses') %>
7
+ <%= render 'my/index/index/custom_sidebar' %>
6
8
  <% if UserPrivilege.user_has_any_privilege?(current_user) %>
7
9
  <li><%= link_to t('admin.index.index.heading'), admin_path %></li>
8
10
  <% end %>
@@ -4,7 +4,7 @@
4
4
  <span><%= t('my.login_attempts.nav_item.text') %></span>
5
5
  <% end %>
6
6
 
7
- <article>
7
+ <article class="profile-content">
8
8
  <h1><%= t('.heading') %></h1>
9
9
 
10
10
  <%= paginate @collection %>
@@ -3,7 +3,7 @@
3
3
  url: my_profile_path,
4
4
  method: :patch,
5
5
  multipart: true,
6
- id: 'my-profile-form'
6
+ id: 'user-form'
7
7
  ) do
8
8
  %>
9
9
  <%= render partial: 'shared/list_of_errors', locals: { entity: entity } %>
@@ -3,5 +3,5 @@
3
3
  <article class="my-profile-new">
4
4
  <h1><%= t('.heading') %></h1>
5
5
 
6
- <%= render partial: 'my/profiles/new/form', locals: { entity: @user } %>
6
+ <%= render partial: 'my/profiles/new/form', locals: { entity: @entity } %>
7
7
  </article>
@@ -4,7 +4,7 @@
4
4
  scope: 'user',
5
5
  url: my_profile_path,
6
6
  class: 'new-my-profile',
7
- id: 'new-profile-form',
7
+ id: 'user-form',
8
8
  data: { check_url: check_users_path }
9
9
  ) do |f|
10
10
  %>
@@ -4,7 +4,7 @@
4
4
  <span><%= t('my.tokens.nav_item.text') %></span>
5
5
  <% end %>
6
6
 
7
- <article>
7
+ <article class="profile-content">
8
8
  <h1><%= t('.heading') %></h1>
9
9
 
10
10
  <%= paginate @collection %>
@@ -142,6 +142,7 @@
142
142
  </dl>
143
143
 
144
144
  <div class="buttons">
145
+ <%= f.hidden_field :consent if entity.id.nil? %>
145
146
  <%= f.button t(:save), type: :submit, class: 'button-save' %>
146
147
  </div>
147
148
  <% end %>
@@ -51,6 +51,7 @@ en:
51
51
  allow_mail: "Allow email notifications"
52
52
  birthday: "Birthday"
53
53
  bot: "It is bot"
54
+ consent: "Consent for processing of personal data and acceptance of terms of service"
54
55
  email: "Email"
55
56
  email_confirmed: "Email is confirmed"
56
57
  foreign_slug: "Foreign slug"
@@ -51,6 +51,7 @@ ru:
51
51
  allow_mail: "Разрешить email-уведомления"
52
52
  birthday: "Дата рождения"
53
53
  bot: "Это бот"
54
+ consent: "Согласие на обработку персональных данных и принятие пользовательского соглашения"
54
55
  email: "Email"
55
56
  email_confirmed: "Email подтверждён"
56
57
  foreign_slug: "Идентификатор пришёл извне"
data/config/routes.rb CHANGED
@@ -36,6 +36,7 @@ Rails.application.routes.draw do
36
36
  controller :about do
37
37
  get 'about' => :index
38
38
  get 'tos' => :tos
39
+ get 'privacy' => :privacy
39
40
  end
40
41
 
41
42
  scope 'u/:slug', controller: :profiles, constraints: { slug: /[^\/]+/ } do
@@ -25,6 +25,7 @@ class CreateUsers < ActiveRecord::Migration[5.1]
25
25
  t.boolean :phone_confirmed, default: false, null: false
26
26
  t.boolean :allow_mail, default: true, null: false
27
27
  t.boolean :foreign_slug, default: false, null: false
28
+ t.boolean :consent, default: false, null: false
28
29
  t.datetime :last_seen
29
30
  t.date :birthday
30
31
  t.string :slug, null: false
@@ -20,6 +20,7 @@ class CreateEditablePages < ActiveRecord::Migration[5.1]
20
20
  index: { ru: 'Главная страница', en: 'Main page' },
21
21
  about: { ru: 'О проекте', en: 'About' },
22
22
  tos: { ru: 'Пользовательское соглашение', en: 'Terms of service' },
23
+ privacy: { ru: 'Соглашение о конфиденциальности', en: 'Privacy' }
23
24
  }
24
25
 
25
26
  pages.each do |slug, names|
@@ -0,0 +1,13 @@
1
+ class AddConsentToUsers < ActiveRecord::Migration[5.1]
2
+ def up
3
+ unless column_exists? :users, :consent
4
+ add_column :users, :consent, :boolean, default: false, null: false
5
+
6
+ User.all.each { |user| user.update! consent: true }
7
+ end
8
+ end
9
+
10
+ def down
11
+ # No rollback needed
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  module Biovision
2
2
  module Base
3
- VERSION = '0.14.180326'
3
+ VERSION = '0.15.180415'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biovision-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.180326
4
+ version: 0.15.180415
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Khan-Magomedov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-26 00:00:00.000000000 Z
11
+ date: 2018-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -140,16 +140,16 @@ dependencies:
140
140
  name: pg
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - "~>"
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: '0.18'
145
+ version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - "~>"
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: '0.18'
152
+ version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rspec-rails
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -474,6 +474,7 @@ files:
474
474
  - app/views/metrics/show.jbuilder
475
475
  - app/views/my/confirmations/show.html.erb
476
476
  - app/views/my/index/index.html.erb
477
+ - app/views/my/index/index/_custom_sidebar.html.erb
477
478
  - app/views/my/index/index/_dashboard.html.erb
478
479
  - app/views/my/index/index/_sidebar.html.erb
479
480
  - app/views/my/login_attempts/_list.html.erb
@@ -484,11 +485,9 @@ files:
484
485
  - app/views/my/login_attempts/index.jbuilder
485
486
  - app/views/my/profiles/_nav_item.html.erb
486
487
  - app/views/my/profiles/edit.html.erb
487
- - app/views/my/profiles/edit.js.erb
488
488
  - app/views/my/profiles/edit/_form.html.erb
489
489
  - app/views/my/profiles/edit/form/_profile_data.html.erb
490
490
  - app/views/my/profiles/new.html.erb
491
- - app/views/my/profiles/new.js.erb
492
491
  - app/views/my/profiles/new/_form.html.erb
493
492
  - app/views/my/profiles/show.html.erb
494
493
  - app/views/my/recoveries/show.html.erb
@@ -579,6 +578,7 @@ files:
579
578
  - db/migrate/20180117151515_add_language_to_models.rb
580
579
  - db/migrate/20180117160000_create_user_languages.rb
581
580
  - db/migrate/20180321000000_add_profile_data_to_users.rb
581
+ - db/migrate/20180405000000_add_consent_to_users.rb
582
582
  - lib/biovision/base.rb
583
583
  - lib/biovision/base/base_methods.rb
584
584
  - lib/biovision/base/engine.rb
@@ -610,7 +610,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
610
610
  version: '0'
611
611
  requirements: []
612
612
  rubyforge_project:
613
- rubygems_version: 2.7.3
613
+ rubygems_version: 2.7.6
614
614
  signing_key:
615
615
  specification_version: 4
616
616
  summary: Base components for Biovision applications
@@ -1 +0,0 @@
1
- <%= render partial: 'shared/forms/list_of_errors', locals: { entity: current_user, form_id: 'my-profile-form' } %>
@@ -1 +0,0 @@
1
- <%= render partial: 'shared/forms/list_of_errors', locals: { entity: @user, form_id: 'new-profile-form' } %>