diff --git a/app/controllers/extranet/pages_controller.rb b/app/controllers/extranet/pages_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..90cfe247fb5639b56fc7516307849a3086af07d5 --- /dev/null +++ b/app/controllers/extranet/pages_controller.rb @@ -0,0 +1,12 @@ +class Extranet::PagesController < Extranet::ApplicationController + skip_before_action :authenticate_user!, :authorize_extranet_access! + + def termes_of_use + end + + def cookie_policy + end + + def privacy_policy + end +end diff --git a/app/models/communication/extranet.rb b/app/models/communication/extranet.rb index 8437a8e4de243e1083e9a209d091d2ba8e92d7f8..cd9c9bd78c090602877456946bf0c1bb34930ad8 100644 --- a/app/models/communication/extranet.rb +++ b/app/models/communication/extranet.rb @@ -33,6 +33,7 @@ # class Communication::Extranet < ApplicationRecord include WithAbouts + include WithLegal include WithSso include WithUniversity diff --git a/app/models/communication/extranet/with_legal.rb b/app/models/communication/extranet/with_legal.rb new file mode 100644 index 0000000000000000000000000000000000000000..a4420cd47ba96ef58e4b440d9f2e1a530c3ee8cb --- /dev/null +++ b/app/models/communication/extranet/with_legal.rb @@ -0,0 +1,19 @@ +module Communication::Extranet::WithLegal + extend ActiveSupport::Concern + + included do + include ActionView::Helpers::SanitizeHelper + end + + def has_terms? + strip_tags(terms).strip.present? + end + + def has_cookies_policy? + strip_tags(cookies_policy).strip.present? + end + + def has_privacy_policy? + strip_tags(privacy_policy).strip.present? + end +end diff --git a/app/views/extranet/application/_footer.html.erb b/app/views/extranet/application/_footer.html.erb index ccb9d2c5416b39c9c5576fdc447fa59a1d83bad6..4f37174adcd36bfa3f9a722dd0b46dcfccf807d7 100644 --- a/app/views/extranet/application/_footer.html.erb +++ b/app/views/extranet/application/_footer.html.erb @@ -25,17 +25,17 @@ <nav class="text-md-end col-md-6"> <%= link_to t('terms_of_service'), - t('terms_of_service_url'), + terms_of_service_path, target: '_blank', - rel: 'noreferrer' %> + rel: 'noreferrer' if current_extranet.has_terms? %> <%= link_to t('privacy_policy'), - t('privacy_policy_url'), + privacy_policy_path, target: '_blank', - rel: 'noreferrer' %> + rel: 'noreferrer' if current_extranet.has_privacy_policy? %> <%= link_to t('cookies_policy'), - t('cookies_policy_url'), + cookies_policy_path, target: '_blank', - rel: 'noreferrer' %> + rel: 'noreferrer' if current_extranet.has_cookies_policy? %> <%= link_to t('cookies_consent_choice'), '', class: 'js-gdpr__cookie_consent__display_again' %> diff --git a/app/views/extranet/application/_nav.html.erb b/app/views/extranet/application/_nav.html.erb index df6f594d50ee82f9f51db2bdcdebf1cd1bd8a01c..13e9921f628e8fb1f88b3c08bf92f2848620e1ba 100644 --- a/app/views/extranet/application/_nav.html.erb +++ b/app/views/extranet/application/_nav.html.erb @@ -3,25 +3,27 @@ <a class="navbar-brand" href="/"> <%= render 'logo' %> </a> - <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#menu" aria-controls="menu" aria-expanded="false" aria-label="Toggle menu"> - <%= t('extranet.menu') %> <span class="navbar-toggler-icon"></span> - </button> - <div class="collapse navbar-collapse" id="menu"> - <%= render_navigation context: :extranet %> - <ul class="navbar-nav navbar-nav__account"> - <li class="nav-item dropdown<%= ' active' if '/account'.in?(request.path) %>"> - <a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> - <i class="bi bi-person-circle"></i> - <%= t('extranet.account.my') %> - </a> - <ul class="dropdown-menu dropdown-menu-end text-end"> - <li><%= link_to current_user.to_s, account_path, class: "dropdown-item" %></li> - <li><%= link_to t('extranet.account.edit'), edit_account_path, class: "dropdown-item" %></li> - <li><%= link_to t('extranet.account.edit_personal_data'), edit_personal_data_path, class: "dropdown-item" %></li> - <li><%= link_to t('extranet.account.logout'), destroy_user_session_path, method: :delete, class: "dropdown-item" %></li> - </ul> - </li> - </ul> - </div> + <% if user_signed_in? %> + <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#menu" aria-controls="menu" aria-expanded="false" aria-label="Toggle menu"> + <%= t('extranet.menu') %> <span class="navbar-toggler-icon"></span> + </button> + <div class="collapse navbar-collapse" id="menu"> + <%= render_navigation context: :extranet %> + <ul class="navbar-nav navbar-nav__account"> + <li class="nav-item dropdown<%= ' active' if '/account'.in?(request.path) %>"> + <a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> + <i class="bi bi-person-circle"></i> + <%= t('extranet.account.my') %> + </a> + <ul class="dropdown-menu dropdown-menu-end text-end"> + <li><%= link_to current_user.to_s, account_path, class: "dropdown-item" %></li> + <li><%= link_to t('extranet.account.edit'), edit_account_path, class: "dropdown-item" %></li> + <li><%= link_to t('extranet.account.edit_personal_data'), edit_personal_data_path, class: "dropdown-item" %></li> + <li><%= link_to t('extranet.account.logout'), destroy_user_session_path, method: :delete, class: "dropdown-item" %></li> + </ul> + </li> + </ul> + </div> + <% end %> </div> </nav> diff --git a/app/views/extranet/gdpr/_cookie_consent.html.erb b/app/views/extranet/gdpr/_cookie_consent.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..3a1cfe18e18ad1aff4e2fffef35dbf87a7a0dfd3 --- /dev/null +++ b/app/views/extranet/gdpr/_cookie_consent.html.erb @@ -0,0 +1,10 @@ +<div class="gdpr__cookie_consent js-gdpr__cookie_consent"> + <div class="gdpr__cookie_consent__text"> + <%= t('gdpr.cookie_consent.text') %> + <%= t('gdpr.cookie_consent.learn_more_html', link: cookies_policy_path) %> + </div> + <div class="gdpr__cookie_consent__buttons"> + <button class="gdpr__cookie_consent__buttons__ok js-gdpr__cookie_consent__buttons__ok btn btn-primary btn-sm btn-xs"> <%= t('gdpr.cookie_consent.button_ok') %></button> + <button class="gdpr__cookie_consent__buttons__ko js-gdpr__cookie_consent__buttons__ko btn btn-primary btn-sm btn-xs"> <%= t('gdpr.cookie_consent.button_ko') %></button> + </div> +</div> \ No newline at end of file diff --git a/app/views/extranet/layouts/application.html.erb b/app/views/extranet/layouts/application.html.erb index 04e325e33ceb9ae95e52ba912ca92dadf4cde9d0..a887b371fe9f58a7c79be7ea5f8bc04430a6094c 100644 --- a/app/views/extranet/layouts/application.html.erb +++ b/app/views/extranet/layouts/application.html.erb @@ -17,7 +17,7 @@ <%= yield %> </main> <%= render 'extranet/application/footer' %> - <%= render 'gdpr/cookie_consent' %> + <%= render 'extranet/gdpr/cookie_consent' %> <%= render 'bugsnag' %> </body> </html> diff --git a/app/views/extranet/layouts/devise.html.erb b/app/views/extranet/layouts/devise.html.erb index dc9c6b8abb5b7f13a93a51c23e4a5097d537d1cd..c0e1e7413eb5ef1283274b724abc46e2e3dd718e 100644 --- a/app/views/extranet/layouts/devise.html.erb +++ b/app/views/extranet/layouts/devise.html.erb @@ -34,7 +34,7 @@ </div> </div> <%= render 'extranet/application/footer', hide_logo: true %> - <%= render 'gdpr/cookie_consent' %> + <%= render 'extranet/gdpr/cookie_consent' %> <%= render 'bugsnag' %> </body> </html> diff --git a/app/views/extranet/pages/cookies_policy.html.erb b/app/views/extranet/pages/cookies_policy.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..406e9d0b40467f76fe310d44aabf9347016f91af --- /dev/null +++ b/app/views/extranet/pages/cookies_policy.html.erb @@ -0,0 +1,8 @@ +<% content_for :title, Communication::Extranet.human_attribute_name('cookies_policy') %> +<% content_for :header do %> + <h1><%= Communication::Extranet.human_attribute_name('cookies_policy') %></h1> +<% end %> + +<div class="content"> + <%= sanitize current_extranet.cookies_policy %> +</div> \ No newline at end of file diff --git a/app/views/extranet/pages/privacy_policy.html.erb b/app/views/extranet/pages/privacy_policy.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..f859cb73ed1c9b4b7767bee0f7ebe9e0ee13d94a --- /dev/null +++ b/app/views/extranet/pages/privacy_policy.html.erb @@ -0,0 +1,8 @@ +<% content_for :title, Communication::Extranet.human_attribute_name('privacy_policy') %> +<% content_for :header do %> + <h1><%= Communication::Extranet.human_attribute_name('privacy_policy') %></h1> +<% end %> + +<div class="content"> + <%= sanitize current_extranet.privacy_policy %> +</div> \ No newline at end of file diff --git a/app/views/extranet/pages/terms_of_service.html.erb b/app/views/extranet/pages/terms_of_service.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..070b829790f0e08835b2b46a49acfb46bf1d5779 --- /dev/null +++ b/app/views/extranet/pages/terms_of_service.html.erb @@ -0,0 +1,8 @@ +<% content_for :title, Communication::Extranet.human_attribute_name('terms') %> +<% content_for :header do %> + <h1><%= Communication::Extranet.human_attribute_name('terms') %></h1> +<% end %> + +<div class="content"> + <%= sanitize current_extranet.terms %> +</div> \ No newline at end of file diff --git a/config/routes/extranet.rb b/config/routes/extranet.rb index 513a41e598bdd6beb6cf57492ceb8862faf4c389..3d5d9c7c720b580ae2785927bcf552ff9445d00f 100644 --- a/config/routes/extranet.rb +++ b/config/routes/extranet.rb @@ -15,4 +15,7 @@ scope :account do get 'personal_data' => 'extranet/personal_data#edit', as: :edit_personal_data patch 'personal_data' => 'extranet/personal_data#update', as: :personal_data end +get 'terms-of-service' => 'extranet/pages#terms_of_service', as: :terms_of_service +get 'privacy-policy' => 'extranet/pages#privacy_policy', as: :privacy_policy +get 'cookies-policy' => 'extranet/pages#cookies_policy', as: :cookies_policy root to: 'extranet/home#index'