diff --git a/app/controllers/admin/communication/website/home_controller.rb b/app/controllers/admin/communication/website/home_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..59ce01e0ac6e1b8455081adb1d94389cb0b405f7 --- /dev/null +++ b/app/controllers/admin/communication/website/home_controller.rb @@ -0,0 +1,29 @@ +class Admin::Communication::Website::HomeController < Admin::Communication::Website::ApplicationController + before_action :get_home + + def edit + breadcrumb + add_breadcrumb Communication::Website::Home.model_name.human + end + + def update + if @home.update(home_params) + redirect_to admin_communication_website_path(@website), notice: t('admin.successfully_updated_html', model: Communication::Website::Home.model_name.human) + else + breadcrumb + add_breadcrumb Communication::Website::Home.model_name.human + render :edit, status: :unprocessable_entity + end + end + + protected + + def get_home + @home = @website.home + end + + def home_params + params.require(:communication_website_home) + .permit(:text, :featured_image, :featured_image_delete, :featured_image_infos) + end +end diff --git a/app/controllers/admin/education/schools_controller.rb b/app/controllers/admin/education/schools_controller.rb index 821eb116ef1f81cd475fbc4d9486036aeb704754..2fa2f4fa1f3da19b9c6c3122afaac757a89fbd63 100644 --- a/app/controllers/admin/education/schools_controller.rb +++ b/app/controllers/admin/education/schools_controller.rb @@ -54,6 +54,6 @@ class Admin::Education::SchoolsController < Admin::Education::ApplicationControl def school_params params.require(:education_school) - .permit(:university_id, :name, :address, :zipcode, :city, :country, :latitude, :longitude) + .permit(:university_id, :name, :address, :zipcode, :city, :country, :phone) end end diff --git a/app/helpers/admin/application_helper.rb b/app/helpers/admin/application_helper.rb index 461fadf88def1748e7e0006a48151b36b871f089..9a6d98c6d21970fd24408faf582a748b52422ff6 100644 --- a/app/helpers/admin/application_helper.rb +++ b/app/helpers/admin/application_helper.rb @@ -62,9 +62,10 @@ module Admin::ApplicationHelper def prepare_for_github(html, university) text = html.to_s + text = sanitize text, - tags: %w(table a figure img figcaption i em b strong p h2 h3 h4 h5 h6 blockquote br), - attributes: %w(href alt title target rel src srcset width height) + tags: %w(table figure figcaption strong em b i u p code pre tt samp kbd var sub sup dfn cite big small address hr br span h1 h2 h3 h4 h5 h6 ul ol li dl dt dd abbr acronym a img blockquote del ins), + attributes: %w(rel href src srcset width height alt cite datetime title class name xml:lang abbr style target) text.gsub! "\r", '' text.gsub! "\n", ' ' text.gsub! "/rails/active_storage", "#{university.url}/rails/active_storage" diff --git a/app/models/ability.rb b/app/models/ability.rb index a89951285f9a4c09f9ec4b8b35867ffd39aca83b..72e77c19270bb9dd909780c1e72033853d5d34b3 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -16,6 +16,7 @@ class Ability can :read, Communication::Website, university_id: @user.university_id can :read, Communication::Website::Page, university_id: @user.university_id can :read, Communication::Website::Post, university_id: @user.university_id + can :read, Communication::Website::Home, university_id: @user.university_id can :read, Communication::Website::Imported::Website, university_id: @user.university_id can :read, Communication::Website::Imported::Page, university_id: @user.university_id can :read, Communication::Website::Imported::Post, university_id: @user.university_id @@ -35,6 +36,7 @@ class Ability can :manage, Communication::Website::Page, university_id: @user.university_id can :manage, Communication::Website::Post, university_id: @user.university_id can :manage, Communication::Website::Category, university_id: @user.university_id + can :manage, Communication::Website::Home, university_id: @user.university_id can [:read, :update, :reorder], Communication::Website::Menu, university_id: @user.university_id can :manage, Communication::Website::Menu::Item, university_id: @user.university_id can :manage, Communication::Website::Imported::Website, university_id: @user.university_id diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index a727058f2e91bcc9d6e88afd1f5aef088ce94d2c..32f1ca6cefe59f0c8f5e05cc7508c741af6aec49 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -25,6 +25,10 @@ class Communication::Website < ApplicationRecord belongs_to :university belongs_to :about, polymorphic: true, optional: true + has_one :home, + class_name: 'Communication::Website::Home', + foreign_key: :communication_website_id, + dependent: :destroy has_many :pages, foreign_key: :communication_website_id, dependent: :destroy @@ -47,6 +51,8 @@ class Communication::Website < ApplicationRecord class_name: 'Communication::Website::Imported::Website', dependent: :destroy + after_create :create_home + after_save :send_infos_to_github after_save_commit :set_programs_categories!, if: -> (website) { website.about_type == 'Education::School' } def self.about_types @@ -121,6 +127,16 @@ class Communication::Website < ApplicationRecord create_programs_categories_level(programs_root_category, about.programs.root.ordered) end + def send_infos_to_github + if self.about_type == "Education::School" + github = Github.with_site self + return unless github.valid? + github.publish path: "_data/school.yml", + data: about.to_yml, + commit: "[School infos] Save" + end + end + protected def publish_objects(model, objects) @@ -165,4 +181,8 @@ class Communication::Website < ApplicationRecord create_programs_categories_level(program_category, program_children) end end + + def create_home + build_home(university_id: university_id).save + end end diff --git a/app/models/communication/website/home.rb b/app/models/communication/website/home.rb new file mode 100644 index 0000000000000000000000000000000000000000..7ed72d7be7b6c6848b218460e40e6f155b3abb6f --- /dev/null +++ b/app/models/communication/website/home.rb @@ -0,0 +1,48 @@ +# == Schema Information +# +# Table name: communication_website_homes +# +# id :uuid not null, primary key +# github_path :text +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null +# university_id :uuid not null +# +# Indexes +# +# idx_comm_website_homes_on_communication_website_id (communication_website_id) +# index_communication_website_homes_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_... (communication_website_id => communication_websites.id) +# fk_rails_... (university_id => universities.id) +# +class Communication::Website::Home < ApplicationRecord + include WithGithub + + belongs_to :university + belongs_to :website, foreign_key: :communication_website_id + + has_rich_text :text + has_one_attached_deletable :featured_image + + def github_path_generated + '_pages/index.html' + end + + def to_s + '' + end + + def to_jekyll + ApplicationController.render( + template: 'admin/communication/website/home/jekyll', + layout: false, + assigns: { home: self } + ) + end + + +end diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index 9c60d9ceb6d4e08d523f8b083a6ea634690d9ebc..5e7b1f45b56247773cfd420db7338f51bf9a7459 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -63,7 +63,6 @@ class Communication::Website::Page < ApplicationRecord dependent: :nullify validates :title, presence: true - validate :homepage_is_published? before_validation :make_path after_save :update_children_paths if :saved_change_to_path? @@ -91,10 +90,6 @@ class Communication::Website::Page < ApplicationRecord "#{ title }" end - def is_homepage? - path == '/' - end - protected def make_path @@ -105,9 +100,5 @@ class Communication::Website::Page < ApplicationRecord children.each(&:save) end - def homepage_is_published? - if is_homepage? and !published - errors.add(:published, :home_not_published) - end - end + end diff --git a/app/models/concerns/with_slug.rb b/app/models/concerns/with_slug.rb index 81ec3bc25299ccd0f01729c3665ea52eead0fef1..c13d07f016e818ec64cf5be2dfab675273d00ef0 100644 --- a/app/models/concerns/with_slug.rb +++ b/app/models/concerns/with_slug.rb @@ -5,7 +5,6 @@ module WithSlug validates :slug, uniqueness: { scope: :university_id } validates :slug, - format: { with: /\A[a-z0-9\-]+\z/, message: "ne peut contenir que des lettres minuscules, des chiffres et des traits d'union." }, - allow_blank: true + format: { with: /\A[a-z0-9\-]+\z/, message: I18n.t('slug_error') } end end diff --git a/app/models/education/school.rb b/app/models/education/school.rb index bf7dc359882e514f308a7642549abbef0b87c7cc..394b8f47f85ad501e2fd8799abb13b8c45153ded 100644 --- a/app/models/education/school.rb +++ b/app/models/education/school.rb @@ -9,6 +9,7 @@ # latitude :float # longitude :float # name :string +# phone :string # zipcode :string # created_at :datetime not null # updated_at :datetime not null @@ -24,7 +25,7 @@ # class Education::School < ApplicationRecord belongs_to :university - has_one :website, class_name: 'Communication::Website', as: :about + has_many :websites, class_name: 'Communication::Website', as: :about has_and_belongs_to_many :programs, class_name: 'Education::Program', join_table: 'education_programs_schools', @@ -35,7 +36,26 @@ class Education::School < ApplicationRecord scope :ordered, -> { order(:name) } + after_save_commit :publish_to_github + def to_s "#{name}" end + + def to_yml + { + name: name, + address: address, + zipcode: zipcode, + city: city, + country: ISO3166::Country[country].translations[country.downcase], + phone: phone + }.deep_stringify_keys.to_yaml.lines[1..-1].join + end + + private + + def publish_to_github + websites.each(&:send_infos_to_github) + end end diff --git a/app/services/github.rb b/app/services/github.rb index e47b9b4ec0403cd6bff32d4daff5d766070e95cf..c9729ee039e8fa1962f7766b8c08c1ea2d88ef27 100644 --- a/app/services/github.rb +++ b/app/services/github.rb @@ -31,7 +31,7 @@ class Github file: local_path, sha: file_sha(path) true - rescue + rescue => e false end diff --git a/app/views/admin/communication/website/home/edit.html.erb b/app/views/admin/communication/website/home/edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..0ed10d7c326e974165510f78f280b8040b2b1018 --- /dev/null +++ b/app/views/admin/communication/website/home/edit.html.erb @@ -0,0 +1,35 @@ +<% content_for :title, t('activerecord.models.communication/website/home.one') %> + +<%= simple_form_for @home, url: admin_communication_website_home_path(website_id: @website.id) do |f| %> + <div class="row"> + <div class="col-md-8"> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title mb-0"><%= t('content') %></h5> + </div> + <div class="card-body"> + <%= f.input :text, as: :rich_text_area %> + </div> + </div> + </div> + <div class="col-md-4"> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title mb-0"><%= t('activerecord.attributes.communication/website/page.featured_image') %></h5> + </div> + <div class="card-body"> + <%= f.input :featured_image, + as: :single_deletable_file, + direct_upload: true, + label: false, + input_html: { accept: '.jpg,.jpeg,.png' }, + preview: true + %> + </div> + </div> + </div> + </div> + <% content_for :action_bar_right do %> + <%= submit f %> + <% end %> +<% end %> diff --git a/app/views/admin/communication/website/home/jekyll.html.erb b/app/views/admin/communication/website/home/jekyll.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..7dff2486eaee71418043d0a41fa257c2ca24cec2 --- /dev/null +++ b/app/views/admin/communication/website/home/jekyll.html.erb @@ -0,0 +1,10 @@ +--- +layout: home +permalink: "/" +<% if @home.featured_image.attached? %> +image: "<%= @home.featured_image.blob.id %>" +<% end %> +description: > + <%= prepare_for_github @home.text, @home.university %> +--- +<%= @home.github_frontmatter.content.html_safe %> diff --git a/app/views/admin/communication/website/pages/jekyll.html.erb b/app/views/admin/communication/website/pages/jekyll.html.erb index c7f5d008d255bd23ddf78d6187dc1213a91c39b0..c99b7a260ca1a0ea45787634f0e7abe123c76a55 100644 --- a/app/views/admin/communication/website/pages/jekyll.html.erb +++ b/app/views/admin/communication/website/pages/jekyll.html.erb @@ -1,7 +1,4 @@ --- -<% if @page.is_homepage? %> -layout: home -<% end %> title: "<%= @page.title %>" permalink: "<%= @page.path %>" identifier: "<%= @page.id %>" diff --git a/app/views/admin/communication/websites/index.html.erb b/app/views/admin/communication/websites/index.html.erb index bd4d631c621b2b39a55f47b4039ef72b587ed324..5d2e263f62912dd352e9debb7614cca966fc9d85 100644 --- a/app/views/admin/communication/websites/index.html.erb +++ b/app/views/admin/communication/websites/index.html.erb @@ -16,7 +16,7 @@ <td><%= link_to website, [:admin, website] %></td> <td><%= link_to website.domain_url, website.domain_url, target: :_blank %></td> <td><%= I18n.t("activerecord.attributes.communication/website.about_#{website.about_type}") %></td> - <td><%= website.about %></td> + <td><%= link_to website.about, [:admin, website.about] %></td> <td class="text-end"> <div class="btn-group" role="group"> <%= edit_link website %> diff --git a/app/views/admin/communication/websites/show.html.erb b/app/views/admin/communication/websites/show.html.erb index f2c550bc2f249f4bada18a450477e42e9239adb8..ccffbb28a0cafa2fba89e5b6e710cc4a1b53a872 100644 --- a/app/views/admin/communication/websites/show.html.erb +++ b/app/views/admin/communication/websites/show.html.erb @@ -10,6 +10,58 @@ <% end %> <% end %> +<div class="row"> + <div class="col-md-4"> + <div class="card mt-5"> + <div class="card-header"> + <div class="float-end"> + <%= link_to t('edit'), + admin_communication_website_home_path(website_id: @website), + class: button_classes if can?(:update, Communication::Website::Home) %> + </div> + <h2 class="card-title"> + <%= Communication::Website::Home.model_name.human %> + </h2> + </div> + <div class="card-body"> + <div class="row"> + <% unless @website.home.text.blank? %> + <div class="col-md-6"> + <%= @website.home.text %> + </div> + <% end %> + <% if @website.home.featured_image.attached? %> + <div class="col-md-6"> + <%= image_tag @website.home.featured_image.variant(resize: '300x^'), class: 'img-fluid' %> + </div> + <% end %> + </div> + </div> + </div> + </div> + <div class="col-md-4"> + <div class="card mt-5"> + <div class="card-header"> + <div class="float-end"> + <%= link_to t('create'), + new_admin_communication_website_menu_path(website_id: @website), + class: button_classes if can?(:create, Communication::Website::Menu) %> + </div> + <h2 class="card-title"> + <%= link_to admin_communication_website_menus_path(website_id: @website) do %> + <%= Communication::Website::Menu.model_name.human(count: 2) %> + <small> + - + <%= t('communication.website.see_all', number: @website.menus.count) %> + </small> + <% end %> + </h2> + </div> + <%= render 'admin/communication/website/menus/list', menus: @website.menus.ordered %> + </div> + </div> +</div> + <div class="card mt-5"> <div class="card-header"> <div class="float-end"> @@ -72,27 +124,7 @@ <%= render 'admin/communication/website/categories/list', categories: @website.categories.root.ordered %> </div> </div> - <div class="col-md-4"> - <div class="card mt-5"> - <div class="card-header"> - <div class="float-end"> - <%= link_to t('create'), - new_admin_communication_website_menu_path(website_id: @website), - class: button_classes if can?(:create, Communication::Website::Menu) %> - </div> - <h2 class="card-title"> - <%= link_to admin_communication_website_menus_path(website_id: @website) do %> - <%= Communication::Website::Menu.model_name.human(count: 2) %> - <small> - - - <%= t('communication.website.see_all', number: @website.menus.count) %> - </small> - <% end %> - </h2> - </div> - <%= render 'admin/communication/website/menus/list', menus: @website.menus.ordered %> - </div> - </div> + <div class="col-md-4"> <div class="card mt-5"> <div class="card-header"> diff --git a/app/views/admin/education/schools/_form.html.erb b/app/views/admin/education/schools/_form.html.erb index a6859f685187a580f2a959d908626175ddce92ac..9ce2da5d4c68effb2d83ce8ecb340053670de17e 100644 --- a/app/views/admin/education/schools/_form.html.erb +++ b/app/views/admin/education/schools/_form.html.erb @@ -2,6 +2,7 @@ <div class="row"> <div class="col-md-4"> <%= f.input :name %> + <%= f.input :phone %> </div> <div class="col-md-8"> <%= f.input :address %> diff --git a/app/views/admin/education/schools/show.html.erb b/app/views/admin/education/schools/show.html.erb index 2947ba58b407a651e38fbc0e1a673a89f416b974..ce1d4a8b834603564723c3112d9e986940222903 100644 --- a/app/views/admin/education/schools/show.html.erb +++ b/app/views/admin/education/schools/show.html.erb @@ -1,10 +1,12 @@ <% content_for :title, @school %> <% content_for :title_right do %> - <% if @school.website %> + <% if @school.websites.any? %> <%= Communication::Website.model_name.human %> <i class="fas fa-arrow-right small"></i> - <%= link_to @school.website, [:admin, @school.website] %><br> + <% @school.websites.each do |website| %> + <%= link_to website, [:admin, website] %><br> + <% end %> <% end %> <% end %> @@ -12,6 +14,7 @@ <%= @school.address %><br> <%= @school.zipcode %> <%= @school.city %><br> <%= @school.country %> + <%= @school.phone %> </p> <% content_for :action_bar_right do %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 3e9878905476c8f2544e87bc0ca6f2a5038ffe31..cd85630bb7e867c5c545a6be9940a9998d8503a8 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -31,6 +31,8 @@ en: one: Category other: Categories all: All categories + communication/website/home: + one: Homepage communication/website/imported/website: one: Imported website other: Imported websites @@ -51,6 +53,7 @@ en: all: All posts attributes: communication/website: + about: About about_: Independent website (no specific subject) about_Education::School: School website about_Research::Journal: Journal website @@ -70,6 +73,9 @@ en: name: Name parent: Parent category slug: Slug + communication/website/home: + text: Text + featured_image: Featured image communication/website/imported/category: original: Original communication/website/imported/medium: @@ -107,19 +113,9 @@ en: text: Text title: Title website: Website - errors: - models: - communication/website/page: - attributes: - published: - home_not_published: must be checked. Homepage has to be published. enums: communication/website/menu/item: kind: blank: Title page: Page url: URL - simple_form: - hints: - communication_website_page: - slug: Leave empty for home page diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index e65bb10270c0f20f55285cfec50deec75327dcad..7116b0d67847b21049a2170c576be4cff78398be 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -31,6 +31,8 @@ fr: one: Catégorie other: Catégories all: Toutes les catégories + communication/website/home: + one: Homepage communication/website/imported/website: one: Site importé other: Sites importés @@ -51,6 +53,7 @@ fr: all: Toutes les actualités attributes: communication/website: + about: Sujet du site about_: Site indépendant (aucun sujet) about_Education::School: Site d'école about_Research::Journal: Site de revue scientifique @@ -70,6 +73,9 @@ fr: name: Nom parent: Catégorie parente slug: Slug + communication/website/home: + text: Texte + featured_image: Image à la une communication/website/imported/category: original: Original communication/website/imported/medium: @@ -107,19 +113,9 @@ fr: text: Texte title: Titre website: Site Web - errors: - models: - communication/website/page: - attributes: - published: - home_not_published: doit être coché. La page d'accueil doit être publiée. enums: communication/website/menu/item: kind: blank: Titre intermédiaire page: Page url: URL - simple_form: - hints: - communication_website_page: - slug: Laisser vide pour la page d'accueil du site diff --git a/config/locales/education/en.yml b/config/locales/education/en.yml index 43f72170495fb0916f8117eee46ef5bb2089ae72..a21482ee0d958268e440d65f36394ff7695054a7 100644 --- a/config/locales/education/en.yml +++ b/config/locales/education/en.yml @@ -38,6 +38,7 @@ en: city: City country: Country name: Name + phone: Phone zipcode: Zipcode education/teacher: biography: Biography diff --git a/config/locales/education/fr.yml b/config/locales/education/fr.yml index 480298bcebc04998f6d7c590758ac49eedd86d59..14ec7d63a5121ef698fe3335f4be5174fbd866ab 100644 --- a/config/locales/education/fr.yml +++ b/config/locales/education/fr.yml @@ -38,6 +38,7 @@ fr: city: Ville country: Pays name: Nom + phone: Téléphone zipcode: Code postal education/teacher: biography: Biographie diff --git a/config/locales/en.yml b/config/locales/en.yml index 683b157c97705fe0fecddbfab1ccd54fa9623697..5401d17f0a016e447185d6f318ff86b3b7dbea70 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -119,6 +119,7 @@ en: simple_form_password_with_hints: test_chars: "%{min_length} characters min." show: Show + slug_error: can only contain downcase letters, numbers, and dashes. terms_of_service: Terms of service terms_of_service_url: https://osuny.org/conditions-d-utilisation time: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index b36549ec4278ac475139f9c2b9545e437ed55128..9ed3416cabc992ab431373503c5ca8c7b7b32bc1 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -119,6 +119,7 @@ fr: simple_form_password_with_hints: test_chars: "%{min_length} caractères min." show: Voir + slug_error: ne peut contenir que des lettres minuscules, des chiffres et des traits d'union. terms_of_service: Conditions d'utilisation terms_of_service_url: https://osuny.org/conditions-d-utilisation time: diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index 4fe17a2a424bb792753f2ed08086f50231ff483a..d27e977b98bc8e629cb6c6dd4837984747668122 100644 --- a/config/routes/admin/communication.rb +++ b/config/routes/admin/communication.rb @@ -1,5 +1,7 @@ namespace :communication do resources :websites do + get 'home' => 'website/home#edit' + patch 'home' => 'website/home#update' member do get :import post :import diff --git a/db/migrate/20211119104156_add_phone_to_school.rb b/db/migrate/20211119104156_add_phone_to_school.rb new file mode 100644 index 0000000000000000000000000000000000000000..a8f44a6fbe9fe811ba2be797bd74e57ecf5ab11f --- /dev/null +++ b/db/migrate/20211119104156_add_phone_to_school.rb @@ -0,0 +1,5 @@ +class AddPhoneToSchool < ActiveRecord::Migration[6.1] + def change + add_column :education_schools, :phone, :string + end +end diff --git a/db/migrate/20211119111703_create_website_home.rb b/db/migrate/20211119111703_create_website_home.rb new file mode 100644 index 0000000000000000000000000000000000000000..15de3c982e2a1d8878a986025e4ed495c4fe9178 --- /dev/null +++ b/db/migrate/20211119111703_create_website_home.rb @@ -0,0 +1,14 @@ +class CreateWebsiteHome < ActiveRecord::Migration[6.1] + def change + create_table :communication_website_homes, id: :uuid do |t| + t.references :university, null: false, foreign_key: true, type: :uuid + t.references :communication_website, + null: false, + foreign_key: { to_table: :communication_websites }, + type: :uuid, + index: { name: 'idx_comm_website_homes_on_communication_website_id' } + + t.timestamps + end + end +end diff --git a/db/migrate/20211119134711_add_github_path_to_homes.rb b/db/migrate/20211119134711_add_github_path_to_homes.rb new file mode 100644 index 0000000000000000000000000000000000000000..e3247a6e15beb851e5a6e5e2e919cb83f6e12575 --- /dev/null +++ b/db/migrate/20211119134711_add_github_path_to_homes.rb @@ -0,0 +1,5 @@ +class AddGithubPathToHomes < ActiveRecord::Migration[6.1] + def change + add_column :communication_website_homes, :github_path, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 487e6776bc6dc2bad2fb74e1af60b52fd2cb7591..8f174938429fcdd59c0bf40f57259bde45574c68 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.define(version: 2021_11_19_102433) do +ActiveRecord::Schema.define(version: 2021_11_19_134711) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -119,6 +119,16 @@ ActiveRecord::Schema.define(version: 2021_11_19_102433) do t.index ["communication_website_post_id", "communication_website_category_id"], name: "post_category" end + create_table "communication_website_homes", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.uuid "university_id", null: false + t.uuid "communication_website_id", null: false + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.text "github_path" + t.index ["communication_website_id"], name: "idx_comm_website_homes_on_communication_website_id" + t.index ["university_id"], name: "index_communication_website_homes_on_university_id" + end + create_table "communication_website_imported_authors", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false @@ -371,6 +381,7 @@ ActiveRecord::Schema.define(version: 2021_11_19_102433) do t.float "longitude" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.string "phone" t.index ["university_id"], name: "index_education_schools_on_university_id" end @@ -527,6 +538,8 @@ ActiveRecord::Schema.define(version: 2021_11_19_102433) do add_foreign_key "communication_website_categories", "communication_websites" add_foreign_key "communication_website_categories", "education_programs", column: "program_id" add_foreign_key "communication_website_categories", "universities" + add_foreign_key "communication_website_homes", "communication_websites" + add_foreign_key "communication_website_homes", "universities" add_foreign_key "communication_website_imported_authors", "communication_website_authors", column: "author_id" add_foreign_key "communication_website_imported_authors", "communication_website_imported_websites", column: "website_id" add_foreign_key "communication_website_imported_authors", "universities" diff --git a/lib/tasks/app.rake b/lib/tasks/app.rake index 9f9f4a3db842b9c87e8cea4c4231782661087b8a..e00449085d6eee8c24f2ad8f6793753591c7e11d 100644 --- a/lib/tasks/app.rake +++ b/lib/tasks/app.rake @@ -12,6 +12,7 @@ namespace :app do # Communication::Website::Page.find_each { |page| page.update(text: page.old_text) } Research::Researcher.find_each { |researcher| researcher.update(biography: researcher.old_biography) if researcher.biography.blank? } Research::Journal::Article.find_each { |article| article.update(text: article.old_text) if article.text.blank? } + Communication::Website.find_each { |website| website.build_home(university_id: website.university_id).save if website.home.nil? } end namespace :db do