diff --git a/Gemfile b/Gemfile index 2ba0ccf6973a7c30d1e4a6dd2c964e13108707d2..4563b472786745f9eede8517a6ec878d6e4dce01 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,7 @@ gem "enum_help" gem "faceted_search"#, path: "../../noesya/faceted_search" gem "font-awesome-sass" gem "front_matter_parser" -gem "gdpr" +gem "gdpr", "~> 1.2.5" gem "geocoder", "~> 1.8" gem "geo_point" gem "gitlab" diff --git a/Gemfile.lock b/Gemfile.lock index 5ace75a6610f1dbc53c84b0dd39bf5cc5fdf3353..0e9871c0f06fe9521de550c740743bea2411e847 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -100,16 +100,16 @@ GEM annotate (3.2.0) activerecord (>= 3.2, < 8.0) rake (>= 10.4, < 14.0) - autoprefixer-rails (10.4.7.0) + autoprefixer-rails (10.4.13.0) execjs (~> 2) aws-eventstream (1.2.0) - aws-partitions (1.711.0) + aws-partitions (1.725.0) aws-sdk-core (3.170.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.5) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.62.0) + aws-sdk-kms (1.63.0) aws-sdk-core (~> 3, >= 3.165.0) aws-sigv4 (~> 1.1) aws-sdk-s3 (1.119.1) @@ -154,7 +154,7 @@ GEM actionpack (>= 3.1) caxlsx (>= 3.0) cocoon (1.2.15) - concurrent-ruby (1.2.0) + concurrent-ruby (1.2.2) countries (5.3.1) unaccent (~> 0.3) country_select (8.0.1) @@ -177,14 +177,14 @@ GEM delayed_job (> 2.0.3) rack-protection (>= 1.5.5) sinatra (>= 1.4.4) - devise (4.8.1) + devise (4.9.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - devise-i18n (1.10.2) - devise (>= 4.8.0) + devise-i18n (1.11.0) + devise (>= 4.9.0) docile (1.4.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) @@ -195,7 +195,7 @@ GEM ethon (0.16.0) ffi (>= 1.15.0) execjs (2.8.1) - faceted_search (3.6.0) + faceted_search (3.6.1) font-awesome-sass rails (>= 5.2.0) faraday (2.7.4) @@ -208,7 +208,7 @@ GEM faraday faraday-follow_redirects (0.3.0) faraday (>= 1, < 3) - faraday-gzip (0.1.0) + faraday-gzip (1.0.0) faraday (>= 1.0) zlib (~> 2.1) faraday-http-cache (2.4.1) @@ -216,7 +216,7 @@ GEM faraday-multipart (1.0.4) multipart-post (~> 2) faraday-net_http (3.0.2) - faraday-retry (2.0.0) + faraday-retry (2.1.0) faraday (~> 2.0) fastimage (2.2.6) ffi (1.15.5) @@ -314,13 +314,13 @@ GEM net-smtp marcel (1.0.2) matrix (0.4.2) - metainspector (5.13.1) + metainspector (5.14.0) addressable (~> 2.8) faraday (~> 2.5) faraday-cookie_jar (~> 0.0) faraday-encoding (~> 0.0) faraday-follow_redirects (~> 0.3) - faraday-gzip (~> 0.1) + faraday-gzip (>= 0.1, < 2.0) faraday-http-cache (~> 2.4) faraday-retry (~> 2.0) fastimage (~> 2.2) @@ -329,8 +329,8 @@ GEM method_source (1.0.0) mini_magick (4.12.0) mini_mime (1.1.2) - minitest (5.17.0) - msgpack (1.6.0) + minitest (5.18.0) + msgpack (1.6.1) multi_xml (0.6.0) multipart-post (2.3.0) mustermann (3.0.0) @@ -361,7 +361,7 @@ GEM rack (>= 1.2, < 4) snaky_hash (~> 2.0) version_gem (~> 1.1) - octokit (6.0.1) + octokit (6.1.0) faraday (>= 1, < 3) sawyer (~> 0.9) omniauth (2.1.1) @@ -381,13 +381,13 @@ GEM orm_adapter (0.5.0) pexels (0.5.0) requests (~> 1.0.2) - pg (1.4.5) + pg (1.4.6) popper_js (2.11.6) public_suffix (5.0.1) - puma (6.1.0) + puma (6.1.1) nio4r (~> 2.0) racc (1.6.2) - rack (2.2.6.2) + rack (2.2.6.3) rack-mini-profiler (2.3.4) rack (>= 1.2.0) rack-protection (3.0.5) @@ -462,7 +462,7 @@ GEM sawyer (0.9.2) addressable (>= 2.3.5) faraday (>= 0.17.3, < 3) - selenium-webdriver (4.8.0) + selenium-webdriver (4.8.1) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) @@ -511,10 +511,10 @@ GEM terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) thor (1.2.1) - tilt (2.0.11) + tilt (2.1.0) time (0.2.1) date - timeout (0.3.1) + timeout (0.3.2) typhoeus (1.4.0) ethon (>= 0.9.0) tzinfo (2.0.6) @@ -589,7 +589,7 @@ DEPENDENCIES figaro font-awesome-sass front_matter_parser - gdpr + gdpr (~> 1.2.5) geo_point geocoder (~> 1.8) gitlab diff --git a/app/controllers/admin/communication/extranets/documents/application_controller.rb b/app/controllers/admin/communication/extranets/documents/application_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..7491d21833e9f378fa47ca1492d77a8762748e36 --- /dev/null +++ b/app/controllers/admin/communication/extranets/documents/application_controller.rb @@ -0,0 +1,8 @@ +class Admin::Communication::Extranets::Documents::ApplicationController < Admin::Communication::Extranets::ApplicationController + protected + + def breadcrumb + super + add_breadcrumb Communication::Extranet.human_attribute_name(:feature_library), admin_communication_extranet_documents_path + end +end \ No newline at end of file diff --git a/app/controllers/admin/communication/extranets/documents/categories_controller.rb b/app/controllers/admin/communication/extranets/documents/categories_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..5e265cb29c8f9fcd760884edda1a6c98a87cf963 --- /dev/null +++ b/app/controllers/admin/communication/extranets/documents/categories_controller.rb @@ -0,0 +1,67 @@ +class Admin::Communication::Extranets::Documents::CategoriesController < Admin::Communication::Extranets::ApplicationController + load_and_authorize_resource class: Communication::Extranet::Document::Category, through: :extranet, through_association: :document_categories + + def index + @categories = @categories.ordered + breadcrumb + end + + def show + @documents = @category.documents.ordered.page params[:page] + breadcrumb + end + + def new + breadcrumb + end + + def edit + breadcrumb + add_breadcrumb t('edit') + end + + def create + if @category.save + redirect_to admin_communication_extranet_document_category_path(@category), notice: t('admin.successfully_created_html', model: @category.to_s) + else + breadcrumb + render :new, status: :unprocessable_entity + end + end + + def update + if @category.update(category_params) + redirect_to admin_communication_extranet_document_category_path(@category), notice: t('admin.successfully_updated_html', model: @category.to_s) + else + breadcrumb + add_breadcrumb t('edit') + render :edit, status: :unprocessable_entity + end + end + + def destroy + @category.destroy + redirect_to admin_communication_extranet_document_categories_url, notice: t('admin.successfully_destroyed_html', model: @category.to_s) + end + + protected + + def breadcrumb + super + add_breadcrumb Communication::Extranet.human_attribute_name(:feature_library), admin_communication_extranet_documents_path + add_breadcrumb Communication::Extranet::Document::Category.model_name.human(count: 2), admin_communication_extranet_document_categories_path + breadcrumb_for @category + end + + def category_params + params.require(:communication_extranet_document_category) + .permit( + :name, + :slug, + ) + .merge( + university_id: current_university.id + ) + end + +end \ No newline at end of file diff --git a/app/controllers/admin/communication/extranets/documents/kinds_controller.rb b/app/controllers/admin/communication/extranets/documents/kinds_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..45245939632cf869612bd2da00eb14599ebab4df --- /dev/null +++ b/app/controllers/admin/communication/extranets/documents/kinds_controller.rb @@ -0,0 +1,66 @@ +class Admin::Communication::Extranets::Documents::KindsController < Admin::Communication::Extranets::Documents::ApplicationController + load_and_authorize_resource class: Communication::Extranet::Document::Kind, through: :extranet, through_association: :document_kinds + + def index + @kinds = @kinds.ordered + breadcrumb + end + + def show + @documents = @kind.documents.ordered.page params[:page] + breadcrumb + end + + def new + breadcrumb + end + + def edit + breadcrumb + add_breadcrumb t('edit') + end + + def create + if @kind.save + redirect_to admin_communication_extranet_document_kind_path(@kind), notice: t('admin.successfully_created_html', model: @kind.to_s) + else + breadcrumb + render :new, status: :unprocessable_entity + end + end + + def update + if @kind.update(kind_params) + redirect_to admin_communication_extranet_document_kind_path(@kind), notice: t('admin.successfully_updated_html', model: @kind.to_s) + else + breadcrumb + add_breadcrumb t('edit') + render :edit, status: :unprocessable_entity + end + end + + def destroy + @kind.destroy + redirect_to admin_communication_extranet_document_kinds_url, notice: t('admin.successfully_destroyed_html', model: @kind.to_s) + end + + protected + + def breadcrumb + super + add_breadcrumb Communication::Extranet::Document::Kind.model_name.human(count: 2), admin_communication_extranet_document_kinds_path + breadcrumb_for @kind + end + + def kind_params + params.require(:communication_extranet_document_kind) + .permit( + :name, + :slug, + ) + .merge( + university_id: current_university.id + ) + end + +end \ No newline at end of file diff --git a/app/controllers/admin/communication/extranets/documents_controller.rb b/app/controllers/admin/communication/extranets/documents_controller.rb index 124981dd684b81afdf566884f6881d8355930625..3bcfdddfd0f94cf9b5e7a332e4ad98ddf7093cb9 100644 --- a/app/controllers/admin/communication/extranets/documents_controller.rb +++ b/app/controllers/admin/communication/extranets/documents_controller.rb @@ -3,6 +3,8 @@ class Admin::Communication::Extranets::DocumentsController < Admin::Communicatio def index @documents = @documents.ordered.page params[:page] + @categories = @extranet.document_categories.ordered + @kinds = @extranet.document_kinds.ordered breadcrumb end @@ -55,7 +57,8 @@ class Admin::Communication::Extranets::DocumentsController < Admin::Communicatio params.require(:communication_extranet_document) .permit( :name, :published, :published_at, :slug, - :file, :file_delete + :file, :file_delete, + :category_id, :kind_id ) .merge( university_id: current_university.id diff --git a/app/controllers/extranet/library/documents_controller.rb b/app/controllers/extranet/library/documents_controller.rb index e4dd569db1e66b7502f4a818a145105ab32bbce8..7a2e43ca15b6cf0b57fe629400110576ca8eeab3 100644 --- a/app/controllers/extranet/library/documents_controller.rb +++ b/app/controllers/extranet/library/documents_controller.rb @@ -1,10 +1,11 @@ class Extranet::Library::DocumentsController < Extranet::Library::ApplicationController def index - @documents = current_extranet.documents - .published - .ordered - .page(params[:page]) + @facets = Communication::Extranet::Document::Facets.new params[:facets], current_extranet + @documents = @facets.results + .published + .ordered + .page params[:page] breadcrumb end diff --git a/app/models/ability.rb b/app/models/ability.rb index bb1ea2a5b78dc2771f7825c6f5fb0c7a3943009c..8f9c9fe4380930fadbb2fbecaf13cba0d956fa75 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -101,8 +101,8 @@ class Ability can :manage, Communication::Extranet::Post, university_id: @user.university_id can :manage, Communication::Extranet::Post::Category, university_id: @user.university_id can :manage, Communication::Extranet::Document, university_id: @user.university_id - # can :manage, Communication::Extranet::Document::Category, university_id: @user.university_id - # can :manage, Communication::Extranet::Document::Kind, university_id: @user.university_id + can :manage, Communication::Extranet::Document::Category, university_id: @user.university_id + can :manage, Communication::Extranet::Document::Kind, university_id: @user.university_id can :manage, Communication::Extranet::Connection, university_id: @user.university_id can :manage, Education::AcademicYear, university_id: @user.university_id can :manage, Education::Cohort, university_id: @user.university_id diff --git a/app/models/communication/extranet.rb b/app/models/communication/extranet.rb index efd6e6f0ae57398ed1b712c54477a77afdc4bc84..c99daf122abc88d0f162d495cacdae7a82b36e3b 100644 --- a/app/models/communication/extranet.rb +++ b/app/models/communication/extranet.rb @@ -2,35 +2,34 @@ # # Table name: communication_extranets # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# allow_experiences_modification :boolean default(TRUE) -# color :string -# cookies_policy :text -# css :text -# feature_alumni :boolean default(FALSE) -# feature_contacts :boolean default(FALSE) -# feature_jobs :boolean default(FALSE) -# feature_library :boolean default(FALSE) -# feature_posts :boolean default(FALSE) -# has_sso :boolean default(FALSE) -# home_sentence :text -# host :string -# name :string -# privacy_policy :text -# registration_contact :string -# sass :text -# sso_button_label :string -# sso_cert :text -# sso_mapping :jsonb -# sso_name_identifier_format :string -# sso_provider :integer default("saml") -# sso_target_url :string -# terms :text -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# color :string +# cookies_policy :text +# css :text +# feature_alumni :boolean default(FALSE) +# feature_contacts :boolean default(FALSE) +# feature_jobs :boolean default(FALSE) +# feature_library :boolean default(FALSE) +# feature_posts :boolean default(FALSE) +# has_sso :boolean default(FALSE) +# home_sentence :text +# host :string +# name :string +# privacy_policy :text +# registration_contact :string +# sass :text +# sso_button_label :string +# sso_cert :text +# sso_mapping :jsonb +# sso_name_identifier_format :string +# sso_provider :integer default("saml") +# sso_target_url :string +# terms :text +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# university_id :uuid not null, indexed # # Indexes # @@ -61,6 +60,8 @@ class Communication::Extranet < ApplicationRecord has_many :posts has_many :post_categories, class_name: 'Communication::Extranet::Post::Category' has_many :documents + has_many :document_categories, class_name: 'Communication::Extranet::Document::Category' + has_many :document_kinds, class_name: 'Communication::Extranet::Document::Kind' validates_presence_of :name, :host validates :logo, size: { less_than: 1.megabytes } diff --git a/app/models/communication/extranet/document.rb b/app/models/communication/extranet/document.rb index 081f39cbb290caf496bc1cac72d3051b878208c4..9b332be81ebbaf763b0c4202fc428b07a1b3a046 100644 --- a/app/models/communication/extranet/document.rb +++ b/app/models/communication/extranet/document.rb @@ -8,18 +8,24 @@ # published_at :datetime # created_at :datetime not null # updated_at :datetime not null +# category_id :uuid indexed # extranet_id :uuid not null, indexed +# kind_id :uuid indexed # university_id :uuid not null, indexed # # Indexes # +# extranet_document_categories (category_id) # index_communication_extranet_documents_on_extranet_id (extranet_id) # index_communication_extranet_documents_on_university_id (university_id) +# index_extranet_document_kinds (kind_id) # # Foreign Keys # # fk_rails_1272fd263c (extranet_id => communication_extranets.id) +# fk_rails_51f7db2f66 (kind_id => communication_extranet_document_kinds.id) # fk_rails_af877a8c0c (university_id => universities.id) +# fk_rails_eb351dc444 (category_id => communication_extranet_document_categories.id) # class Communication::Extranet::Document < ApplicationRecord include Sanitizable @@ -27,6 +33,8 @@ class Communication::Extranet::Document < ApplicationRecord include WithUniversity belongs_to :extranet, class_name: 'Communication::Extranet' + belongs_to :category + belongs_to :kind has_one_attached_deletable :file diff --git a/app/models/communication/extranet/document/category.rb b/app/models/communication/extranet/document/category.rb new file mode 100644 index 0000000000000000000000000000000000000000..91f8d0214a7c43a1855d10d939a118d9cb68f77a --- /dev/null +++ b/app/models/communication/extranet/document/category.rb @@ -0,0 +1,47 @@ +# == Schema Information +# +# Table name: communication_extranet_document_categories +# +# id :uuid not null, primary key +# name :string +# slug :string +# created_at :datetime not null +# updated_at :datetime not null +# extranet_id :uuid not null, indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# extranet_document_categories_universities (university_id) +# index_communication_extranet_document_categories_on_extranet_id (extranet_id) +# +# Foreign Keys +# +# fk_rails_6f2232d9f8 (university_id => universities.id) +# fk_rails_76e327b90f (extranet_id => communication_extranets.id) +# +class Communication::Extranet::Document::Category < ApplicationRecord + include WithSlug + include WithUniversity + + belongs_to :extranet, class_name: 'Communication::Extranet' + + has_many :documents + + validates :name, presence: true + + scope :ordered, -> { order(:name) } + + def to_s + "#{name}" + end + + protected + + def slug_unavailable?(slug) + self.class.unscoped + .where(extranet_id: self.extranet_id, slug: slug) + .where.not(id: self.id) + .exists? + end +end diff --git a/app/models/communication/extranet/document/facets.rb b/app/models/communication/extranet/document/facets.rb new file mode 100644 index 0000000000000000000000000000000000000000..cb8ef4f220c73004b7691b5b73cf5ff2be0d7731 --- /dev/null +++ b/app/models/communication/extranet/document/facets.rb @@ -0,0 +1,19 @@ +class Communication::Extranet::Document::Facets < FacetedSearch::Facets + def initialize(params, extranet) + super(params) + @model = extranet.documents.published + filter_with_text :name, { + title: Communication::Extranet::Document.human_attribute_name('name') + } + filter_with_list :category, { + title: Communication::Extranet::Document::Category.model_name.human(count: 2), + source: extranet.document_categories, + habtm: false + } + filter_with_list :kind, { + title: Communication::Extranet::Document::Kind.model_name.human(count: 2), + source: extranet.document_kinds, + habtm: false + } + end +end \ No newline at end of file diff --git a/app/models/communication/extranet/document/kind.rb b/app/models/communication/extranet/document/kind.rb new file mode 100644 index 0000000000000000000000000000000000000000..7f3afa35591e32ab62a3f2e4c046eac1e3a8aa71 --- /dev/null +++ b/app/models/communication/extranet/document/kind.rb @@ -0,0 +1,47 @@ +# == Schema Information +# +# Table name: communication_extranet_document_kinds +# +# id :uuid not null, primary key +# name :string +# slug :string +# created_at :datetime not null +# updated_at :datetime not null +# extranet_id :uuid not null, indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# extranet_document_kinds_universities (university_id) +# index_communication_extranet_document_kinds_on_extranet_id (extranet_id) +# +# Foreign Keys +# +# fk_rails_27a9b91ed8 (extranet_id => communication_extranets.id) +# fk_rails_2a55cf899a (university_id => universities.id) +# +class Communication::Extranet::Document::Kind < ApplicationRecord + include WithSlug + include WithUniversity + + belongs_to :extranet, class_name: 'Communication::Extranet' + + has_many :documents + + validates :name, presence: true + + scope :ordered, -> { order(:name) } + + def to_s + "#{name}" + end + + protected + + def slug_unavailable?(slug) + self.class.unscoped + .where(extranet_id: self.extranet_id, slug: slug) + .where.not(id: self.id) + .exists? + end +end diff --git a/app/views/admin/communication/blocks/templates/files/_preview.html.erb b/app/views/admin/communication/blocks/templates/files/_preview.html.erb index 54f32745652572c91bccae0cb1f3a9c0493b7812..71babf1330e454429ff6e415b3dd88ec13029b12 100644 --- a/app/views/admin/communication/blocks/templates/files/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/files/_preview.html.erb @@ -27,10 +27,14 @@ end <li> <figure> <a href="<%= element.blob.url %>" target="_blank" title="<%= element.title %>"><%= element.title %></a> - <figcaption> - <abbr title="">TODO : EXTENSION</abbr> - - <abbr title="">TODO : TAILLE FICHIER</abbr> - </figcaption> + <% if document.file.attached? %> + <% file = document.file %> + <figcaption> + <abbr title=""><%= file.filename.extension.upcase %></abbr> + - <abbr title=""><%= number_to_human_size file.byte_size %></abbr> + </figcaption> + <% end %> + </figure> </a> </li> diff --git a/app/views/admin/communication/extranets/documents/_form.html.erb b/app/views/admin/communication/extranets/documents/_form.html.erb index 063aa8dc6bfef2611428dd28009d2e95cb9c0cd2..3f04d4e9f6bb4f4850766f9c53916df37f7d1ba7 100644 --- a/app/views/admin/communication/extranets/documents/_form.html.erb +++ b/app/views/admin/communication/extranets/documents/_form.html.erb @@ -12,13 +12,11 @@ <div class="col-md-4"> <%= osuny_panel t('metadata') do %> <% if can? :publish, document %> - <div class="row pure__row--small"> - <div class="col-6"> - <%= f.input :published %> - </div> - </div> + <%= f.input :published %> <%= f.input :published_at, html5: true, as: :date %> <% end %> + <%= f.association :kind, collection: @extranet.document_kinds.ordered, include_blank: false %> + <%= f.association :category, collection: @extranet.document_categories.ordered, include_blank: false %> <% end %> </div> </div> diff --git a/app/views/admin/communication/extranets/documents/categories/_form.html.erb b/app/views/admin/communication/extranets/documents/categories/_form.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..1dd744a49671ffd31d4c5f43f83c4129a48eed2b --- /dev/null +++ b/app/views/admin/communication/extranets/documents/categories/_form.html.erb @@ -0,0 +1,25 @@ +<%= simple_form_for [:admin, category] do |f| %> + <%= f.error_notification %> + <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> + + <div class="row"> + <div class="col-md-8"> + <%= osuny_panel t('content') do %> + <%= f.input :name %> + <% end %> + </div> + <div class="col-md-4"> + <%= osuny_panel t('metadata') do %> + <%= f.input :slug, + as: :string, + input_html: category.persisted? ? {} : { + class: 'js-slug-input', + data: { source: '#communication_extranet_document_category_name' } + } %> + <% end %> + </div> + </div> + <% content_for :action_bar_right do %> + <%= submit f %> + <% end %> +<% end %> diff --git a/app/views/admin/communication/extranets/documents/categories/_list.html.erb b/app/views/admin/communication/extranets/documents/categories/_list.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..45650a1d6d713384834a443c7657890c57ebbed3 --- /dev/null +++ b/app/views/admin/communication/extranets/documents/categories/_list.html.erb @@ -0,0 +1,31 @@ +<div class="table-responsive"> + <table class="<%= table_classes %>"> + <thead> + <tr> + <th class="ps-0" width="60%"><%= Communication::Extranet::Document::Category.human_attribute_name('name') %></th> + <th><%= Communication::Extranet::Document::Category.human_attribute_name('quantity') %></th> + <th></th> + </tr> + </thead> + <tbody> + <% categories.each do |category| %> + <tr> + <td class="ps-0"><%= link_to category, admin_communication_extranet_document_category_path(extranet_id: category.extranet.id, id: category.id) %></td> + <td><%= category.documents.count %></td> + <td> + <div class="btn-group" role="group"> + <%= link_to t('edit'), + edit_admin_communication_extranet_document_category_path(extranet_id: category.extranet.id, id: category.id), + class: button_classes if can?(:update, category) %> + <%= link_to t('delete'), + admin_communication_extranet_document_category_path(extranet_id: category.extranet.id, id: category.id), + method: :delete, + data: { confirm: t('please_confirm') }, + class: button_classes_danger if can?(:destroy, category) %> + </div> + </td> + </tr> + <% end %> + </tbody> + </table> +</div> diff --git a/app/views/admin/communication/extranets/documents/categories/edit.html.erb b/app/views/admin/communication/extranets/documents/categories/edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..213c0056b51e4ccbfb3ed8619a16bf3b0af53ef7 --- /dev/null +++ b/app/views/admin/communication/extranets/documents/categories/edit.html.erb @@ -0,0 +1,5 @@ +<% content_for :title, @category %> + +<%= render 'admin/communication/extranets/sidebar' do %> + <%= render 'form', category: @category %> +<% end %> diff --git a/app/views/admin/communication/extranets/documents/categories/index.html.erb b/app/views/admin/communication/extranets/documents/categories/index.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..7cd4d3774dd5d3382d98bf7ab013c7e185333701 --- /dev/null +++ b/app/views/admin/communication/extranets/documents/categories/index.html.erb @@ -0,0 +1,9 @@ +<% content_for :title, Communication::Extranet::Document::Category.model_name.human(count: 2) %> + +<%= render 'admin/communication/extranets/sidebar' do %> + <%= render 'admin/communication/extranets/documents/categories/list', categories: @categories %> +<% end %> + +<% content_for :action_bar_right do %> + <%= create_link Communication::Extranet::Document::Category %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/communication/extranets/documents/categories/new.html.erb b/app/views/admin/communication/extranets/documents/categories/new.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..04037310c7f30d0d8441899965092973963bdc4b --- /dev/null +++ b/app/views/admin/communication/extranets/documents/categories/new.html.erb @@ -0,0 +1,5 @@ +<% content_for :title, Communication::Extranet::Document::Category.model_name.human %> + +<%= render 'admin/communication/extranets/sidebar' do %> + <%= render 'form', category: @category %> +<% end %> diff --git a/app/views/admin/communication/extranets/documents/categories/show.html.erb b/app/views/admin/communication/extranets/documents/categories/show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..535fe68ca87b8ef5e1507faf1d2797d040fe013e --- /dev/null +++ b/app/views/admin/communication/extranets/documents/categories/show.html.erb @@ -0,0 +1,16 @@ +<% content_for :title, @category %> + +<%= render 'admin/communication/extranets/sidebar' do %> + <%= osuny_panel Communication::Extranet::Document.model_name.human(count: 2) do %> + <%= render 'admin/communication/extranets/documents/list', documents: @documents %> + <%= paginate @documents, theme: 'bootstrap-5' %> + <% end %> +<% end %> + +<% content_for :action_bar_left do %> + <%= destroy_link @category %> +<% end %> + +<% content_for :action_bar_right do %> + <%= edit_link @category %> +<% end %> diff --git a/app/views/admin/communication/extranets/documents/index.html.erb b/app/views/admin/communication/extranets/documents/index.html.erb index 40ec6ed9a75ee524b5dd85ef886ebdcdd295b875..8e93fb2198d4c623f6112c8970a37b41abdf1697 100644 --- a/app/views/admin/communication/extranets/documents/index.html.erb +++ b/app/views/admin/communication/extranets/documents/index.html.erb @@ -1,8 +1,22 @@ <% content_for :title, Communication::Extranet.human_attribute_name(:feature_library) %> <%= render 'admin/communication/extranets/sidebar' do %> - <%= render 'admin/communication/extranets/documents/list', documents: @documents %> - <%= paginate @documents, theme: 'bootstrap-5' %> + <% action = create_link Communication::Extranet::Document %> + <%= osuny_panel Communication::Extranet::Document.model_name.human(count: 2), action: action do %> + <%= render 'admin/communication/extranets/documents/list', documents: @documents %> + <%= paginate @documents, theme: 'bootstrap-5' %> + <% end %> + + <% action = link_to t('create'), new_admin_communication_extranet_document_category_path, class: button_classes %> + <%= osuny_panel Communication::Extranet::Document::Category.model_name.human(count: 2), action: action do %> + <%= render 'admin/communication/extranets/documents/categories/list', categories: @categories %> + <% end %> + + <% action = link_to t('create'), new_admin_communication_extranet_document_kind_path, class: button_classes %> + <%= osuny_panel Communication::Extranet::Document::Kind.model_name.human(count: 2), action: action do %> + <%= render 'admin/communication/extranets/documents/kinds/list', kinds: @kinds %> + <% end %> + <% end %> <% content_for :action_bar_right do %> diff --git a/app/views/admin/communication/extranets/documents/kinds/_form.html.erb b/app/views/admin/communication/extranets/documents/kinds/_form.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..bfb75b8b56c062f9553f167c988e856abf834528 --- /dev/null +++ b/app/views/admin/communication/extranets/documents/kinds/_form.html.erb @@ -0,0 +1,25 @@ +<%= simple_form_for [:admin, kind] do |f| %> + <%= f.error_notification %> + <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> + + <div class="row"> + <div class="col-md-8"> + <%= osuny_panel t('content') do %> + <%= f.input :name %> + <% end %> + </div> + <div class="col-md-4"> + <%= osuny_panel t('metadata') do %> + <%= f.input :slug, + as: :string, + input_html: kind.persisted? ? {} : { + class: 'js-slug-input', + data: { source: '#communication_extranet_document_kind_name' } + } %> + <% end %> + </div> + </div> + <% content_for :action_bar_right do %> + <%= submit f %> + <% end %> +<% end %> diff --git a/app/views/admin/communication/extranets/documents/kinds/_list.html.erb b/app/views/admin/communication/extranets/documents/kinds/_list.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..0cb30d55f5f0b1ed66229e1a66427a420583ac74 --- /dev/null +++ b/app/views/admin/communication/extranets/documents/kinds/_list.html.erb @@ -0,0 +1,31 @@ +<div class="table-responsive"> + <table class="<%= table_classes %>"> + <thead> + <tr> + <th class="ps-0" width="60%"><%= Communication::Extranet::Document::Kind.human_attribute_name('name') %></th> + <th><%= Communication::Extranet::Document::Kind.human_attribute_name('quantity') %></th> + <th></th> + </tr> + </thead> + <tbody> + <% kinds.each do |kind| %> + <tr> + <td class="ps-0"><%= link_to kind, admin_communication_extranet_document_kind_path(extranet_id: kind.extranet.id, id: kind.id) %></td> + <td><%= kind.documents.count %></td> + <td> + <div class="btn-group" role="group"> + <%= link_to t('edit'), + edit_admin_communication_extranet_document_kind_path(extranet_id: kind.extranet.id, id: kind.id), + class: button_classes if can?(:update, kind) %> + <%= link_to t('delete'), + admin_communication_extranet_document_kind_path(extranet_id: kind.extranet.id, id: kind.id), + method: :delete, + data: { confirm: t('please_confirm') }, + class: button_classes_danger if can?(:destroy, kind) %> + </div> + </td> + </tr> + <% end %> + </tbody> + </table> +</div> diff --git a/app/views/admin/communication/extranets/documents/kinds/edit.html.erb b/app/views/admin/communication/extranets/documents/kinds/edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..6a33b3912c1e57e0337b0ef8ff0b202e5e09595e --- /dev/null +++ b/app/views/admin/communication/extranets/documents/kinds/edit.html.erb @@ -0,0 +1,5 @@ +<% content_for :title, @kind %> + +<%= render 'admin/communication/extranets/sidebar' do %> + <%= render 'form', kind: @kind %> +<% end %> diff --git a/app/views/admin/communication/extranets/documents/kinds/index.html.erb b/app/views/admin/communication/extranets/documents/kinds/index.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..c10c021d7b3b1ec146b83f22e2389bdf7561c33d --- /dev/null +++ b/app/views/admin/communication/extranets/documents/kinds/index.html.erb @@ -0,0 +1,9 @@ +<% content_for :title, Communication::Extranet::Document::Kind.model_name.human(count: 2) %> + +<%= render 'admin/communication/extranets/sidebar' do %> + <%= render 'admin/communication/extranets/documents/kinds/list', kinds: @kinds %> +<% end %> + +<% content_for :action_bar_right do %> + <%= create_link Communication::Extranet::Document::Kind %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/communication/extranets/documents/kinds/new.html.erb b/app/views/admin/communication/extranets/documents/kinds/new.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..c7b31afd7a099e13ffd44860b148f0c3392f5e7a --- /dev/null +++ b/app/views/admin/communication/extranets/documents/kinds/new.html.erb @@ -0,0 +1,5 @@ +<% content_for :title, Communication::Extranet::Document::Kind.model_name.human %> + +<%= render 'admin/communication/extranets/sidebar' do %> + <%= render 'form', kind: @kind %> +<% end %> diff --git a/app/views/admin/communication/extranets/documents/kinds/show.html.erb b/app/views/admin/communication/extranets/documents/kinds/show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e510fd64acb77bcc591cb4bb1995c1d23afe27a1 --- /dev/null +++ b/app/views/admin/communication/extranets/documents/kinds/show.html.erb @@ -0,0 +1,16 @@ +<% content_for :title, @kind %> + +<%= render 'admin/communication/extranets/sidebar' do %> + <%= osuny_panel Communication::Extranet::Document.model_name.human(count: 2) do %> + <%= render 'admin/communication/extranets/documents/list', documents: @documents %> + <%= paginate @documents, theme: 'bootstrap-5' %> + <% end %> +<% end %> + +<% content_for :action_bar_left do %> + <%= destroy_link @kind %> +<% end %> + +<% content_for :action_bar_right do %> + <%= edit_link @kind %> +<% end %> diff --git a/app/views/admin/communication/extranets/documents/show.html.erb b/app/views/admin/communication/extranets/documents/show.html.erb index fbc17175fb3036454f659d82484f6048cda21576..5a1494f7532a8eba7be06c1dd4f41ef7bb5e7c9f 100644 --- a/app/views/admin/communication/extranets/documents/show.html.erb +++ b/app/views/admin/communication/extranets/documents/show.html.erb @@ -9,16 +9,20 @@ </div> <div class="col-xl-4"> <%= osuny_panel t('metadata') do %> - <div class="row pure__row--small"> - <div class="col-6"> - <%= osuny_label Communication::Extranet::Document.human_attribute_name('published') %> - <p> - <%= t @document.published %><% if @document.published %>, - <%= l @document.published_at.to_date, format: :long %> - <% end %> - </p> - </div> - </div> + <%= osuny_label Communication::Extranet::Document.human_attribute_name('published') %> + <p> + <%= t @document.published %><% if @document.published %>, + <%= l @document.published_at.to_date, format: :long %> + <% end %> + </p> + <% if @document.category %> + <%= osuny_label Communication::Extranet::Document::Category.model_name.human %> + <p><%= link_to @document.category, [:admin, @document.category] %></p> + <% end %> + <% if @document.kind %> + <%= osuny_label Communication::Extranet::Document::Kind.model_name.human %> + <p><%= link_to @document.kind, [:admin, @document.kind] %></p> + <% end %> <% end %> </div> </div> diff --git a/app/views/admin/communication/extranets/posts/categories/_list.html.erb b/app/views/admin/communication/extranets/posts/categories/_list.html.erb index e553d2d004b953398e638b9bd1ff4a7b67a2efa5..e865a434c7b7eff49c79ac3a5b71ed64fe997e4c 100644 --- a/app/views/admin/communication/extranets/posts/categories/_list.html.erb +++ b/app/views/admin/communication/extranets/posts/categories/_list.html.erb @@ -3,6 +3,7 @@ <thead> <tr> <th class="ps-0" width="60%"><%= Communication::Extranet::Post::Category.human_attribute_name('name') %></th> + <th><%= Communication::Extranet::Post::Category.human_attribute_name('quantity') %></th> <th></th> </tr> </thead> @@ -10,7 +11,7 @@ <% categories.each do |category| %> <tr> <td class="ps-0"><%= link_to category, admin_communication_extranet_post_category_path(extranet_id: category.extranet.id, id: category.id) %></td> - + <td><%= category.posts.count %></td> <td> <div class="btn-group" role="group"> <%= link_to t('edit'), diff --git a/app/views/admin/communication/extranets/posts/categories/show.html.erb b/app/views/admin/communication/extranets/posts/categories/show.html.erb index 30f2bd037402f50911dbb153e9453cbcd7dcdfb9..b564c8234c32559f70c1c8aef46fef455b0a73e9 100644 --- a/app/views/admin/communication/extranets/posts/categories/show.html.erb +++ b/app/views/admin/communication/extranets/posts/categories/show.html.erb @@ -1,8 +1,10 @@ <% content_for :title, @category %> <%= render 'admin/communication/extranets/sidebar' do %> - <%= render 'admin/communication/extranets/posts/list', posts: @posts %> - <%= paginate @posts, theme: 'bootstrap-5' %> + <%= osuny_panel Communication::Extranet::Post.model_name.human(count: 2) do %> + <%= render 'admin/communication/extranets/posts/list', posts: @posts %> + <%= paginate @posts, theme: 'bootstrap-5' %> + <% end %> <% end %> <% content_for :action_bar_left do %> diff --git a/app/views/admin/communication/extranets/posts/index.html.erb b/app/views/admin/communication/extranets/posts/index.html.erb index cbf3d5fdf58b1c078afbc51d21172c1a77405044..9b081ed3b7d6be7dba00de95acef7694cf1d7b0b 100644 --- a/app/views/admin/communication/extranets/posts/index.html.erb +++ b/app/views/admin/communication/extranets/posts/index.html.erb @@ -1,14 +1,14 @@ <% content_for :title, Communication::Extranet.human_attribute_name(:feature_posts) %> <%= render 'admin/communication/extranets/sidebar' do %> - <section class="mb-5"> + <% action = create_link Communication::Extranet::Post %> + <%= osuny_panel Communication::Extranet::Post.model_name.human(count: 2), action: action do %> <%= render 'admin/communication/extranets/posts/list', posts: @posts %> <%= paginate @posts, theme: 'bootstrap-5' %> - </section> + <% end %> <% action = link_to t('create'), new_admin_communication_extranet_post_category_path, class: button_classes %> - <%# action = create_link Communication::Website::Category %> - <%= osuny_panel Communication::Website::Category.model_name.human(count: 2), action: action do %> + <%= osuny_panel Communication::Extranet::Post::Category.model_name.human(count: 2), action: action do %> <%= render 'admin/communication/extranets/posts/categories/list', categories: @categories %> <% end %> <% end %> diff --git a/app/views/extranet/home/index.html.erb b/app/views/extranet/home/index.html.erb index dcfaf67ad3356a166c43626f0fa8ce1d732f9060..37429bc56962d7d6915fdca1fe4e7f1bfcdb9305 100644 --- a/app/views/extranet/home/index.html.erb +++ b/app/views/extranet/home/index.html.erb @@ -9,6 +9,6 @@ </div> <% end %> +<%= render 'extranet/home/features/contacts' if current_extranet.feature_contacts %> <%= render 'extranet/home/features/posts' if current_extranet.feature_posts %> <%= render 'extranet/home/features/alumni' if current_extranet.feature_alumni %> -<%= render 'extranet/home/features/contacts' if current_extranet.feature_contacts %> diff --git a/app/views/extranet/library/documents/index.html.erb b/app/views/extranet/library/documents/index.html.erb index c21d83314f85098eb1bf9c256d7961bec5b6637c..c832f8bb7a0892837925097515bc778910551870 100644 --- a/app/views/extranet/library/documents/index.html.erb +++ b/app/views/extranet/library/documents/index.html.erb @@ -1,23 +1,36 @@ <% content_for :title, Communication::Extranet::Document.model_name.human(count: 2) %> -<div class="row mt-n5 documents-list"> - <% @documents.each do |document| %> - <div class="col-sm-6 col-md-4 col-xxl-3"> - <article class="position-relative mt-5"> - <div> - <i class="bi bi-file-earmark-text display-1"></i> - <span>PDF - 120ko</span> +<div class="row"> + <div class="col-lg-3"> + <%= render 'faceted_search/facets', facets: @facets, reset: t('extranet.library.reset') %> + </div> + <div class="col-lg-9"> + <div class="row mt-n5 documents-list"> + <% @documents.each do |document| %> + <div class="col-sm-6 col-xxl-4"> + <article class="position-relative mt-5"> + <div> + <i class="bi bi-file-earmark-text display-1"></i> + <% if document.file.attached? %> + <% file = document.file %> + <span> + <%= file.filename.extension.upcase %> + - <%= number_to_human_size file.byte_size %> + </span> + <% end %> + </div> + <p class="mb-3"> + <b><%= document %></b><br> + <span class="text-muted"><%= l document.published_at.to_date %><span> + </p> + <%= link_to t('extranet.library.download'), + document.file.url, + class: 'btn btn-primary stretched-link', + target: :_blank if document.file.attached? %> + </article> </div> - <p> - <b><%= document %></b><br> - <span class="text-muted"><%= l document.published_at.to_date %><span> - </p> - <%= link_to t('extranet.library.download'), - document.file.url, - class: 'btn btn-primary stretched-link', - target: :_blank if document.file.attached? %> - </article> + <% end %> </div> - <% end %> -</div> -<%= paginate @documents, theme: 'bootstrap-5' %> \ No newline at end of file + <%= paginate @documents, theme: 'bootstrap-5' %> + </div> +</div> \ No newline at end of file diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 66cb912bd3ecb57c4db5b03fd4a6882e6852d0f0..a30f9cc6530a7b98cf326b13ce61532888c6f700 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -15,6 +15,12 @@ en: communication/extranet/document: one: Document other: Documents + communication/extranet/document/category: + one: Category + other: Categories + communication/extranet/document/kind: + one: Kind + other: Kinds communication/extranet/post: one: Post other: Posts @@ -88,6 +94,14 @@ en: name: Name published: Published? published_at: Publication date + category: Category + kind: Type + communication/extranet/document/category: + name: Name + quantity: Quantity of documents + communication/extranet/document/kind: + name: Name + quantity: Quantity of documents communication/extranet/post: author: Author category: Category @@ -100,6 +114,7 @@ en: title: Title communication/extranet/post/category: name: Name + quantity: Quantity of posts communication/website: about: About about_: Independent website diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index d5129e4f8932bd7902f731506cea13d9effd5ba1..03479f4a8788d7e0df289e035561c722200470bb 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -15,6 +15,12 @@ fr: communication/extranet/document: one: Document other: Documents + communication/extranet/document/category: + one: Catégorie + other: Catégories + communication/extranet/document/kind: + one: Type + other: Types communication/extranet/post: one: Actualité other: Actualités @@ -88,6 +94,14 @@ fr: name: Nom published: Publié ? published_at: Date de publication + category: Catégorie + kind: Type + communication/extranet/document/category: + name: Nom + quantity: Quantité de documents + communication/extranet/document/kind: + name: Nom + quantity: Quantité de documents communication/extranet/post: author: Auteur·rice category: Catégorie @@ -100,6 +114,7 @@ fr: title: Titre communication/extranet/post/category: name: Nom + quantity: Quantité d'actualités communication/website: about: Sujet du site about_: Site indépendant diff --git a/config/locales/extranet/en.yml b/config/locales/extranet/en.yml index 8e470e5b45f7803d2055e53a1b3df5825cea472a..4b039bc413104602babc3c99f6458aed09f3f0f4 100644 --- a/config/locales/extranet/en.yml +++ b/config/locales/extranet/en.yml @@ -33,6 +33,7 @@ en: welcome: Welcome! library: download: Download + reset: Reset menu: Menu organization: experiences: Alumni in this organization (%{count}) diff --git a/config/locales/extranet/fr.yml b/config/locales/extranet/fr.yml index 1c80d42bc669ca36ad67f6cf15572ea5842efe8e..2ec73a62c078e5af88960546811a860385465f35 100644 --- a/config/locales/extranet/fr.yml +++ b/config/locales/extranet/fr.yml @@ -33,6 +33,7 @@ fr: welcome: Bienvenue ! library: download: Télécharger + reset: Réinitialiser menu: Menu organization: experiences: Alumni dans cette organisation (%{count}) diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index 5db6d8e7f5f1afcaa5be3d48e3afd530010e5dee..1be8ac580fcc562aaac80aa273418d850349f356 100644 --- a/config/routes/admin/communication.rb +++ b/config/routes/admin/communication.rb @@ -73,8 +73,6 @@ namespace :communication do post :disconnect end end - namespace :posts do - end resources :posts, controller: 'extranets/posts' do collection do resources :categories, controller: 'extranets/posts/categories', as: 'post_categories' @@ -85,7 +83,12 @@ namespace :communication do end # Automatic routes based on feature names get 'library' => 'extranets/documents#index', as: :library - resources :documents, controller: 'extranets/documents' + resources :documents, controller: 'extranets/documents' do + collection do + resources :categories, controller: 'extranets/documents/categories', as: 'document_categories' + resources :kinds, controller: 'extranets/documents/kinds', as: 'document_kinds' + end + end resources :jobs, controller: 'extranets/jobs' end resources :alumni do diff --git a/db/migrate/20230310081519_create_communication_extranet_document_kinds.rb b/db/migrate/20230310081519_create_communication_extranet_document_kinds.rb new file mode 100644 index 0000000000000000000000000000000000000000..2471fc11fc72188fc3adf11e476589a8ea838643 --- /dev/null +++ b/db/migrate/20230310081519_create_communication_extranet_document_kinds.rb @@ -0,0 +1,13 @@ +class CreateCommunicationExtranetDocumentKinds < ActiveRecord::Migration[7.0] + def change + create_table :communication_extranet_document_kinds, id: :uuid do |t| + t.references :extranet, null: false, foreign_key: {to_table: :communication_extranets}, type: :uuid + t.references :university, null: false, foreign_key: true, type: :uuid, index: { name: 'extranet_document_kinds_universities' } + t.string :name + + t.timestamps + end + + add_reference :communication_extranet_documents, :kind, foreign_key: {to_table: :communication_extranet_document_kinds}, type: :uuid, index: { name: 'index_extranet_document_kinds' } + end +end diff --git a/db/migrate/20230310081530_create_communication_extranet_document_categories.rb b/db/migrate/20230310081530_create_communication_extranet_document_categories.rb new file mode 100644 index 0000000000000000000000000000000000000000..83446e18c5c6283348d80fd9246f3344fca364db --- /dev/null +++ b/db/migrate/20230310081530_create_communication_extranet_document_categories.rb @@ -0,0 +1,13 @@ +class CreateCommunicationExtranetDocumentCategories < ActiveRecord::Migration[7.0] + def change + create_table :communication_extranet_document_categories, id: :uuid do |t| + t.references :extranet, null: false, foreign_key: {to_table: :communication_extranets}, type: :uuid + t.references :university, null: false, foreign_key: true, type: :uuid, index: { name: 'extranet_document_categories_universities' } + t.string :name + + t.timestamps + end + + add_reference :communication_extranet_documents, :category, foreign_key: {to_table: :communication_extranet_document_categories}, type: :uuid, index: { name: 'extranet_document_categories' } + end +end diff --git a/db/migrate/20230310083029_add_slugs_to_document_categories_and_kinds.rb b/db/migrate/20230310083029_add_slugs_to_document_categories_and_kinds.rb new file mode 100644 index 0000000000000000000000000000000000000000..1e64b54ce376330e0d2f8457a8265bf4f0d51565 --- /dev/null +++ b/db/migrate/20230310083029_add_slugs_to_document_categories_and_kinds.rb @@ -0,0 +1,6 @@ +class AddSlugsToDocumentCategoriesAndKinds < ActiveRecord::Migration[7.0] + def change + add_column :communication_extranet_document_categories, :slug, :string + add_column :communication_extranet_document_kinds, :slug, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 36ef9f0312d8396ce0b564e9e59cc8b9dc1d1d73..a47a0f1993c3aa56fdb9e59385075a70a6f64199 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_03_09_143644) do +ActiveRecord::Schema[7.0].define(version: 2023_03_10_083029) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -105,6 +105,28 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_143644) do t.index ["university_id"], name: "index_communication_extranet_connections_on_university_id" end + create_table "communication_extranet_document_categories", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.uuid "extranet_id", null: false + t.uuid "university_id", null: false + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "slug" + t.index ["extranet_id"], name: "index_communication_extranet_document_categories_on_extranet_id" + t.index ["university_id"], name: "extranet_document_categories_universities" + end + + create_table "communication_extranet_document_kinds", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.uuid "extranet_id", null: false + t.uuid "university_id", null: false + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "slug" + t.index ["extranet_id"], name: "index_communication_extranet_document_kinds_on_extranet_id" + t.index ["university_id"], name: "extranet_document_kinds_universities" + end + create_table "communication_extranet_documents", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "name" t.uuid "university_id", null: false @@ -113,7 +135,11 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_143644) do t.datetime "published_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.uuid "kind_id" + t.uuid "category_id" + t.index ["category_id"], name: "extranet_document_categories" t.index ["extranet_id"], name: "index_communication_extranet_documents_on_extranet_id" + t.index ["kind_id"], name: "index_extranet_document_kinds" t.index ["university_id"], name: "index_communication_extranet_documents_on_university_id" end @@ -176,7 +202,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_143644) do t.text "home_sentence" t.text "sass" t.text "css" - t.boolean "allow_experiences_modification", default: true t.index ["about_type", "about_id"], name: "index_communication_extranets_on_about" t.index ["university_id"], name: "index_communication_extranets_on_university_id" end @@ -403,7 +428,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_143644) do t.index ["university_id"], name: "index_communication_website_pages_on_university_id" end - create_table "communication_website_permalinks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_permalinks", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false t.string "about_type", null: false @@ -1000,6 +1025,12 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_143644) do add_foreign_key "communication_blocks", "universities" add_foreign_key "communication_extranet_connections", "communication_extranets", column: "extranet_id" add_foreign_key "communication_extranet_connections", "universities" + add_foreign_key "communication_extranet_document_categories", "communication_extranets", column: "extranet_id" + add_foreign_key "communication_extranet_document_categories", "universities" + add_foreign_key "communication_extranet_document_kinds", "communication_extranets", column: "extranet_id" + add_foreign_key "communication_extranet_document_kinds", "universities" + add_foreign_key "communication_extranet_documents", "communication_extranet_document_categories", column: "category_id" + add_foreign_key "communication_extranet_documents", "communication_extranet_document_kinds", column: "kind_id" add_foreign_key "communication_extranet_documents", "communication_extranets", column: "extranet_id" add_foreign_key "communication_extranet_documents", "universities" add_foreign_key "communication_extranet_post_categories", "communication_extranets", column: "extranet_id" diff --git a/test/fixtures/communication/extranet/document/categories.yml b/test/fixtures/communication/extranet/document/categories.yml new file mode 100644 index 0000000000000000000000000000000000000000..db2c02aa9d63f0605450cda38919189323f00489 --- /dev/null +++ b/test/fixtures/communication/extranet/document/categories.yml @@ -0,0 +1,32 @@ +# == Schema Information +# +# Table name: communication_extranet_document_categories +# +# id :uuid not null, primary key +# name :string +# slug :string +# created_at :datetime not null +# updated_at :datetime not null +# extranet_id :uuid not null, indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# extranet_document_categories_universities (university_id) +# index_communication_extranet_document_categories_on_extranet_id (extranet_id) +# +# Foreign Keys +# +# fk_rails_6f2232d9f8 (university_id => universities.id) +# fk_rails_76e327b90f (extranet_id => communication_extranets.id) +# + +one: + extranet: one + university: one + name: MyString + +two: + extranet: two + university: two + name: MyString diff --git a/test/fixtures/communication/extranet/document/kinds.yml b/test/fixtures/communication/extranet/document/kinds.yml new file mode 100644 index 0000000000000000000000000000000000000000..480abfc3a3f956f364e177f076727962d5eb094a --- /dev/null +++ b/test/fixtures/communication/extranet/document/kinds.yml @@ -0,0 +1,32 @@ +# == Schema Information +# +# Table name: communication_extranet_document_kinds +# +# id :uuid not null, primary key +# name :string +# slug :string +# created_at :datetime not null +# updated_at :datetime not null +# extranet_id :uuid not null, indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# extranet_document_kinds_universities (university_id) +# index_communication_extranet_document_kinds_on_extranet_id (extranet_id) +# +# Foreign Keys +# +# fk_rails_27a9b91ed8 (extranet_id => communication_extranets.id) +# fk_rails_2a55cf899a (university_id => universities.id) +# + +one: + extranet: one + university: one + name: MyString + +two: + extranet: two + university: two + name: MyString diff --git a/test/fixtures/communication/extranet/documents.yml b/test/fixtures/communication/extranet/documents.yml index be1d0d6ab57326b590356596a4609a335ddd6e69..fb4fa23733ee89bef580ed42a2418d63d9d1b4cd 100644 --- a/test/fixtures/communication/extranet/documents.yml +++ b/test/fixtures/communication/extranet/documents.yml @@ -8,18 +8,24 @@ # published_at :datetime # created_at :datetime not null # updated_at :datetime not null +# category_id :uuid indexed # extranet_id :uuid not null, indexed +# kind_id :uuid indexed # university_id :uuid not null, indexed # # Indexes # +# extranet_document_categories (category_id) # index_communication_extranet_documents_on_extranet_id (extranet_id) # index_communication_extranet_documents_on_university_id (university_id) +# index_extranet_document_kinds (kind_id) # # Foreign Keys # # fk_rails_1272fd263c (extranet_id => communication_extranets.id) +# fk_rails_51f7db2f66 (kind_id => communication_extranet_document_kinds.id) # fk_rails_af877a8c0c (university_id => universities.id) +# fk_rails_eb351dc444 (category_id => communication_extranet_document_categories.id) # one: diff --git a/test/fixtures/communication/extranets.yml b/test/fixtures/communication/extranets.yml index 5b00f559b78ac19b9a3871e2736923e92e325c4b..c4a72564511a4905256b44eff1b90d9ad95d76db 100644 --- a/test/fixtures/communication/extranets.yml +++ b/test/fixtures/communication/extranets.yml @@ -2,35 +2,34 @@ # # Table name: communication_extranets # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# allow_experiences_modification :boolean default(TRUE) -# color :string -# cookies_policy :text -# css :text -# feature_alumni :boolean default(FALSE) -# feature_contacts :boolean default(FALSE) -# feature_jobs :boolean default(FALSE) -# feature_library :boolean default(FALSE) -# feature_posts :boolean default(FALSE) -# has_sso :boolean default(FALSE) -# home_sentence :text -# host :string -# name :string -# privacy_policy :text -# registration_contact :string -# sass :text -# sso_button_label :string -# sso_cert :text -# sso_mapping :jsonb -# sso_name_identifier_format :string -# sso_provider :integer default("saml") -# sso_target_url :string -# terms :text -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# color :string +# cookies_policy :text +# css :text +# feature_alumni :boolean default(FALSE) +# feature_contacts :boolean default(FALSE) +# feature_jobs :boolean default(FALSE) +# feature_library :boolean default(FALSE) +# feature_posts :boolean default(FALSE) +# has_sso :boolean default(FALSE) +# home_sentence :text +# host :string +# name :string +# privacy_policy :text +# registration_contact :string +# sass :text +# sso_button_label :string +# sso_cert :text +# sso_mapping :jsonb +# sso_name_identifier_format :string +# sso_provider :integer default("saml") +# sso_target_url :string +# terms :text +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# university_id :uuid not null, indexed # # Indexes # diff --git a/test/models/communication/extranet/document/category_test.rb b/test/models/communication/extranet/document/category_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..6c922f2461aa953d17d095c6576465dd40bf673a --- /dev/null +++ b/test/models/communication/extranet/document/category_test.rb @@ -0,0 +1,29 @@ +# == Schema Information +# +# Table name: communication_extranet_document_categories +# +# id :uuid not null, primary key +# name :string +# slug :string +# created_at :datetime not null +# updated_at :datetime not null +# extranet_id :uuid not null, indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# extranet_document_categories_universities (university_id) +# index_communication_extranet_document_categories_on_extranet_id (extranet_id) +# +# Foreign Keys +# +# fk_rails_6f2232d9f8 (university_id => universities.id) +# fk_rails_76e327b90f (extranet_id => communication_extranets.id) +# +require "test_helper" + +class Communication::Extranet::Document::CategoryTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/communication/extranet/document/kind_test.rb b/test/models/communication/extranet/document/kind_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..acca11c4caa41646a8789d1eacd0952b3e64a41a --- /dev/null +++ b/test/models/communication/extranet/document/kind_test.rb @@ -0,0 +1,29 @@ +# == Schema Information +# +# Table name: communication_extranet_document_kinds +# +# id :uuid not null, primary key +# name :string +# slug :string +# created_at :datetime not null +# updated_at :datetime not null +# extranet_id :uuid not null, indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# extranet_document_kinds_universities (university_id) +# index_communication_extranet_document_kinds_on_extranet_id (extranet_id) +# +# Foreign Keys +# +# fk_rails_27a9b91ed8 (extranet_id => communication_extranets.id) +# fk_rails_2a55cf899a (university_id => universities.id) +# +require "test_helper" + +class Communication::Extranet::Document::KindTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/communication/extranet_test.rb b/test/models/communication/extranet_test.rb index 0fbfb1c43e253bdc46da936417e5b507126faf56..72be11939515c0927e5c3266698692eae000ee5a 100644 --- a/test/models/communication/extranet_test.rb +++ b/test/models/communication/extranet_test.rb @@ -2,35 +2,34 @@ # # Table name: communication_extranets # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# allow_experiences_modification :boolean default(TRUE) -# color :string -# cookies_policy :text -# css :text -# feature_alumni :boolean default(FALSE) -# feature_contacts :boolean default(FALSE) -# feature_jobs :boolean default(FALSE) -# feature_library :boolean default(FALSE) -# feature_posts :boolean default(FALSE) -# has_sso :boolean default(FALSE) -# home_sentence :text -# host :string -# name :string -# privacy_policy :text -# registration_contact :string -# sass :text -# sso_button_label :string -# sso_cert :text -# sso_mapping :jsonb -# sso_name_identifier_format :string -# sso_provider :integer default("saml") -# sso_target_url :string -# terms :text -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# color :string +# cookies_policy :text +# css :text +# feature_alumni :boolean default(FALSE) +# feature_contacts :boolean default(FALSE) +# feature_jobs :boolean default(FALSE) +# feature_library :boolean default(FALSE) +# feature_posts :boolean default(FALSE) +# has_sso :boolean default(FALSE) +# home_sentence :text +# host :string +# name :string +# privacy_policy :text +# registration_contact :string +# sass :text +# sso_button_label :string +# sso_cert :text +# sso_mapping :jsonb +# sso_name_identifier_format :string +# sso_provider :integer default("saml") +# sso_target_url :string +# terms :text +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# university_id :uuid not null, indexed # # Indexes #