diff --git a/app/assets/stylesheets/extranet/_default/abstracts/_variables.sass b/app/assets/stylesheets/extranet/_default/abstracts/_variables.sass index 467091aefe50a0d086432b35dcfc85d63204f4b6..f096b4a16e7f4c62706fbed39f30f36465234060 100644 --- a/app/assets/stylesheets/extranet/_default/abstracts/_variables.sass +++ b/app/assets/stylesheets/extranet/_default/abstracts/_variables.sass @@ -36,7 +36,7 @@ $breadcrumb-divider-color: black $breadcrumb-margin-bottom: 45px // List -$list-border-color: rgba(0, 0, 0, 0.3) +$list-border-color: rgba(0, 0, 0, 0.15) // Pagination $pagination-border-width: 0 @@ -45,4 +45,4 @@ $pagination-font-size: $small-font-size $navbar-link-active-color: $primary // Border -$light-border-color: rgba($primary, 0.3) \ No newline at end of file +$light-border-color: rgba($primary, 0.3) diff --git a/app/controllers/extranet/organizations_controller.rb b/app/controllers/extranet/organizations_controller.rb index 1fd325c4a67c4d6d12118a0e6668d6cf48c36a3c..1f8e867b1cda98c5fbc04ed8fa091f10f7da284c 100644 --- a/app/controllers/extranet/organizations_controller.rb +++ b/app/controllers/extranet/organizations_controller.rb @@ -4,8 +4,14 @@ class Extranet::OrganizationsController < Extranet::ApplicationController through_association: :organizations def index - @organizations = about&.alumni_organizations - @organizations = @organizations.ordered.page(params[:page]) + @facets = University::Organization::Facets.new params[:facets], { + model: about&.alumni_organizations, + about: about + } + @organizations = @facets.results + .ordered + .page(params[:page]) + .per(60) @count = @organizations.total_count breadcrumb end diff --git a/app/models/ability.rb b/app/models/ability.rb index 643651eb8a158dceea2e76a56f473c5fa8444739..687a45581f0ebf746e3bc5f740a90c2384c18d08 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -97,6 +97,8 @@ class Ability can :manage, Communication::Website::Imported::Website, university_id: @user.university_id can :manage, Communication::Website::Imported::Page, university_id: @user.university_id can :manage, Communication::Website::Imported::Post, university_id: @user.university_id + can :manage, Education::AcademicYear, university_id: @user.university_id + can :manage, Education::Cohort, university_id: @user.university_id can :manage, Education::School, university_id: @user.university_id can :manage, Education::Program, university_id: @user.university_id can :manage, :all_programs # needed to prevent program_manager to access specific global screens diff --git a/app/models/university/organization/facets.rb b/app/models/university/organization/facets.rb new file mode 100644 index 0000000000000000000000000000000000000000..6ecc8f5114e0b7f3427f5b3d43532ffc4940c59d --- /dev/null +++ b/app/models/university/organization/facets.rb @@ -0,0 +1,13 @@ +class University::Organization::Facets < FacetedSearch::Facets + def initialize(params, options) + super params + + @model = options[:model] + @about = options[:about] + + filter_with_text :name, { + title: University::Organization.human_attribute_name('name') + } + + end +end diff --git a/app/models/university/person/alumnus/import.rb b/app/models/university/person/alumnus/import.rb index 54d973d228117a591047d8b12038ca669e17e261..d20bb55ea706dbba6ecad79822f23ac4bf44c31c 100644 --- a/app/models/university/person/alumnus/import.rb +++ b/app/models/university/person/alumnus/import.rb @@ -30,106 +30,103 @@ class University::Person::Alumnus::Import < ApplicationRecord def parse csv.each do |row| - program_id = row['program'] - if Rails.env.development? - # substitute local data for testing - substitutes = { - # 'c6b78fac-0a5f-4c44-ad22-4ee68ed382bb' => '23279cab-8bc1-4c75-bcd8-1fccaa03ad55', # DUT MMI - # 'ae3e067a-63b4-4c3f-ba9c-468ade0e4182' => '863b8c9c-1ed1-4af7-b92c-7264dfb6b4da', # MASTER IJBA - # 'f4d4a92f-8b8f-4778-a127-9293684666be' => '8dfaee2a-c876-4b1c-8e4e-8380d720c71f', # DU_BILINGUE - # '6df53074-195c-4299-8b49-bbc9d7cad41a' => 'be3cb0b2-7f66-4c5f-b8d7-6a39a0480c46', # DU_JRI - # '0d81d3a2-a12c-4326-a395-fd0df4a3ea4f' => '56a50383-3ef7-43f6-8e98-daf279e86802' # DUT_JOURNALISME - - 'c6b78fac-0a5f-4c44-ad22-4ee68ed382bb' => '02e6f703-d15b-4841-ac95-3c47d88e21b5', # DUT MMI - 'ae3e067a-63b4-4c3f-ba9c-468ade0e4182' => '8fdfafb7-11fd-456c-9f47-7fd76dddb373', # MASTER IJBA - 'f4d4a92f-8b8f-4778-a127-9293684666be' => 'fab9b86c-8872-4df5-9a97-0e30b104a837', # DU_BILINGUE - '6df53074-195c-4299-8b49-bbc9d7cad41a' => 'cb1a26b9-fe5c-4ad1-9715-71cec4642910', # DU_JRI - '0d81d3a2-a12c-4326-a395-fd0df4a3ea4f' => '91c44fd2-f0a4-4189-a3f5-311322b7b472' # DUT_JOURNALISME - } - program_id = substitutes[program_id] if substitutes.has_key? program_id - end - program = university.education_programs - .find_by(id: program_id) - next if program.nil? - academic_year = university.academic_years - .where(year: row['year']) - .first_or_create + person = import_person row + next unless person + import_cohort row, person + organization = import_organization row + next unless organization + import_experience row, person, organization + end + end - cohort = university.education_cohorts - .where(program: program, academic_year: academic_year) + def import_person(row) + first_name = clean_encoding row['first_name'] + last_name = clean_encoding row['last_name'] + email = clean_encoding(row['mail']).to_s.downcase + return if first_name.blank? && last_name.blank? && email.blank? + url = clean_encoding row['url'] + if email.present? + person = university.people + .where(email: email) .first_or_create - first_name = clean_encoding row['first_name'] - last_name = clean_encoding row['last_name'] - email = clean_encoding(row['mail']).to_s.downcase - next if first_name.blank? && last_name.blank? && email.blank? - url = clean_encoding row['url'] - if email.present? - person = university.people - .where(email: email) - .first_or_create - person.first_name = first_name - person.last_name = last_name - elsif first_name.present? && last_name.present? - person = university.people - .where(first_name: first_name, last_name: last_name) - .first_or_create - end - next unless person - # TODO all fields - # gender - # birth - # address - # zipcode - # city - # country - person.is_alumnus = true - person.url = url - person.slug = person.to_s.parameterize.dasherize - person.twitter ||= row['social_twitter'] - person.linkedin ||= row['social_linkedin'] - person.biography ||= clean_encoding row['biography'] - person.phone ||= row['mobile'] - person.phone ||= row['phone_personal'] - person.phone ||= row['phone_professional'] - byebug unless person.valid? - person.save - person.add_to_cohort cohort - add_picture person, row['photo'] + person.first_name = first_name + person.last_name = last_name + elsif first_name.present? && last_name.present? + person = university.people + .where(first_name: first_name, last_name: last_name) + .first_or_create + end + return if person.nil? + # TODO all fields + # gender + # birth + # address + # zipcode + # city + # country + person.is_alumnus = true + person.url = url + person.slug = person.to_s.parameterize.dasherize + person.twitter ||= row['social_twitter'] + person.linkedin ||= row['social_linkedin'] + person.biography ||= clean_encoding row['biography'] + person.phone ||= row['mobile'] + person.phone ||= row['phone_personal'] + person.phone ||= row['phone_professional'] + byebug unless person.valid? + person.save + add_picture person, row['photo'] + person + end - company_name = clean_encoding row['company_name'] - company_siren = clean_encoding row['company_siren'] - company_nic = clean_encoding row['company_nic'] - if company_name.present? - if !row['company_siren'].blank? && !row['company_nic'].blank? - organization = university.organizations - .find_by siren: company_siren, - nic: company_nic - elsif !row['company_siren'].blank? - organization ||= university.organizations - .find_by siren: company_siren - end - if !company_name.blank? - organization ||= university.organizations - .find_by name: company_name - end - organization ||= university.organizations - .where( name: company_name, - siren: company_siren, - nic: company_nic) - .first_or_create - experience_job = row['experience_job'] - experience_from = row['experience_from'] - experience_to = row['experience_to'] - experience = person.experiences - .where(university: university, - organization: organization, - description: experience_job) - .first_or_create - experience.from_year = experience_from - experience.to_year = experience_to - experience.save - end + def import_cohort(row, person) + program = program_with_id row['program'] + return if program.nil? + academic_year = university.academic_years + .where(year: row['year']) + .first_or_create + cohort = university.education_cohorts + .where(program: program, academic_year: academic_year) + .first_or_create + person.add_to_cohort cohort + end + + def import_organization(row) + name = clean_encoding row['company_name'] + siren = clean_encoding row['company_siren'] + nic = clean_encoding row['company_nic'] + return if name.blank? + if !siren.blank? && !nic.blank? + organization = university.organizations + .find_by siren: siren, + nic: nic + elsif !siren.blank? + organization ||= university.organizations + .find_by siren: siren end + organization ||= university.organizations + .find_by name: name + organization ||= university.organizations + .where( name: name, + siren: siren, + nic: nic) + .first_or_create + organization + end + + def import_experience(row, person, organization) + job = row['experience_job'] + from = row['experience_from'] + to = row['experience_to'] + experience = person.experiences + .where(university: university, + organization: organization, + from_year: from) + .first_or_create + experience.description = job + experience.to_year = to + experience.save + experience end def add_picture(person, photo) @@ -144,6 +141,28 @@ class University::Person::Alumnus::Import < ApplicationRecord end end + def program_with_id(id) + if Rails.env.development? + # substitute local data for testing + substitutes = { + # Arnaud + 'c6b78fac-0a5f-4c44-ad22-4ee68ed382bb' => '23279cab-8bc1-4c75-bcd8-1fccaa03ad55', # DUT MMI + 'ae3e067a-63b4-4c3f-ba9c-468ade0e4182' => '863b8c9c-1ed1-4af7-b92c-7264dfb6b4da', # MASTER IJBA + 'f4d4a92f-8b8f-4778-a127-9293684666be' => '8dfaee2a-c876-4b1c-8e4e-8380d720c71f', # DU_BILINGUE + '6df53074-195c-4299-8b49-bbc9d7cad41a' => 'be3cb0b2-7f66-4c5f-b8d7-6a39a0480c46', # DU_JRI + '0d81d3a2-a12c-4326-a395-fd0df4a3ea4f' => '56a50383-3ef7-43f6-8e98-daf279e86802' # DUT_JOURNALISME + # Alex + # 'c6b78fac-0a5f-4c44-ad22-4ee68ed382bb' => '02e6f703-d15b-4841-ac95-3c47d88e21b5', # DUT MMI + # 'ae3e067a-63b4-4c3f-ba9c-468ade0e4182' => '8fdfafb7-11fd-456c-9f47-7fd76dddb373', # MASTER IJBA + # 'f4d4a92f-8b8f-4778-a127-9293684666be' => 'fab9b86c-8872-4df5-9a97-0e30b104a837', # DU_BILINGUE + # '6df53074-195c-4299-8b49-bbc9d7cad41a' => 'cb1a26b9-fe5c-4ad1-9715-71cec4642910', # DU_JRI + # '0d81d3a2-a12c-4326-a395-fd0df4a3ea4f' => '91c44fd2-f0a4-4189-a3f5-311322b7b472' # DUT_JOURNALISME + } + id = substitutes[id] if substitutes.has_key? id + end + university.education_programs.find_by(id: id) + end + def clean_encoding(value) return if value.nil? if value.encoding != 'UTF-8' diff --git a/app/views/extranet/home/index.html.erb b/app/views/extranet/home/index.html.erb index cfd1242c07c3ebb1fabd51966a28ef9e741606a8..d52d0fe629874f9a8ecc21990e7a37f89a5cf9d7 100644 --- a/app/views/extranet/home/index.html.erb +++ b/app/views/extranet/home/index.html.erb @@ -22,11 +22,13 @@ <div> <div> <p class="mb-md-0"> - <%= experience.person.first_name %> <b><%= experience.person.last_name %></b> + <%= experience.person.first_name %> <%= experience.person.last_name %> <br> - <%= experience.description %> — <%= experience.organization %> + <%= experience.description %> + <%= '—' if experience.description.present? && experience.organization.present? %> + <%= experience.organization %> </p> - <small><%= experience.created_at %></small> + <small><%= l experience.created_at.to_date, format: :long %></small> </div> <% if experience.organization.present? %> <% if experience.organization.logo.attached? %> @@ -54,4 +56,4 @@ <% end %> </ul> </div> -</div> \ No newline at end of file +</div> diff --git a/app/views/extranet/organizations/_list.erb b/app/views/extranet/organizations/_list.erb index cc98bdbc81f9ae7120ee913f62a291842ab34ffc..5977b368badd10f35ee4b680bdff70082b34a529 100644 --- a/app/views/extranet/organizations/_list.erb +++ b/app/views/extranet/organizations/_list.erb @@ -6,12 +6,5 @@ <div> <p><small><%= link_to organization.url, organization.url if organization.url %></small></p> </div> - <% if organization.logo.attached? %> - <div> - <%= link_to organization do %> - <%= kamifusen_tag organization.logo, height: 80, class: 'img-fluid' %> - <% end %> - </div> - <% end %> </div> <% end %> diff --git a/app/views/extranet/organizations/index.html.erb b/app/views/extranet/organizations/index.html.erb index 9711628d7e25ab1856d4e0d5c0ca50aa59951761..3ebd842b40b192cc05a9b7d7e1231ceebdf86edd 100644 --- a/app/views/extranet/organizations/index.html.erb +++ b/app/views/extranet/organizations/index.html.erb @@ -11,7 +11,7 @@ <div class="row"> <div class="col-md-3"> - <%#= render 'faceted_search/facets', facets: @facets %> + <%= render 'faceted_search/facets', facets: @facets %> </div> <div class="offset-lg-1 col-lg-8"> <div class="organizations"> diff --git a/app/views/extranet/organizations/show.html.erb b/app/views/extranet/organizations/show.html.erb index 184e335b820ccc4a88d400a97c8ed3a3af6e1200..bc668bb2d82bd0b0622e6292954e54b8b300f798 100644 --- a/app/views/extranet/organizations/show.html.erb +++ b/app/views/extranet/organizations/show.html.erb @@ -1,6 +1,6 @@ <% content_for :title, @organization %> <div class="row mb-5 top"> - <div class="col-md-9"> + <div class="<%= 'col-md-9' if @organization.logo.attached? %>"> <header> <h1><%= @organization %></h1> <% if @organization.url %> @@ -8,13 +8,11 @@ <% end %> </header> </div> - <div class="col-md-3"> - <% if @organization.logo.attached? %> + <% if @organization.logo.attached? %> + <div class="col-md-3"> <%= kamifusen_tag @organization.logo, width: 400, class: 'img-fluid' %> - <% else %> - <%= image_tag 'extranet/avatar.png', width: 400, class: 'img-fluid' %> - <% end %> - </div> + </div> + <% end %> </div> @@ -40,9 +38,9 @@ <div> <p><b><%= experience.person.name %></b></p> <p> - <%= experience.description %><br> - <%# // TODO : pretty way to avoid empty dash " - " %> - <%= [experience.from_year, experience.to_year].join(" - ") %> + <%= "#{experience.description}<br>" if experience.description.present? %> + <%= "#{experience.from_year} —" if experience.from_year %> + <%= experience.to_year || University::Person::Experience.human_attribute_name(:today) %> </p> </div> </li> @@ -70,4 +68,4 @@ <% end %> </dl> </div> -</div> \ No newline at end of file +</div> diff --git a/app/views/extranet/persons/show.html.erb b/app/views/extranet/persons/show.html.erb index d459c90517113fc74ab9349abc7ad96017974d0a..d40ac0236c9b3f98038febdd721815879bc79e18 100644 --- a/app/views/extranet/persons/show.html.erb +++ b/app/views/extranet/persons/show.html.erb @@ -20,7 +20,7 @@ <div class="biography"> <p><%= @person.biography %></p> </div> - <% if @person.experiences %> + <% if @person.experiences.any? %> <div class="experiences"> <p class="mb-4">Parcours professionel</p> <ul> @@ -28,7 +28,10 @@ <li> <div> <p><b><%= experience.description %></b></p> - <p class="mb-0"><%= experience.from_year %> - <%= experience.to_year %></p> + <p class="mb-0"> + <%= "#{experience.from_year} —" if experience.from_year %> + <%= experience.to_year || University::Person::Experience.human_attribute_name(:today) %> + </p> </div> <div> <% if experience.organization.present? %> @@ -61,11 +64,19 @@ <% end %> <% if @person.phone.present? %> <dt><%= University::Person.human_attribute_name(:phone) %></dt> - <dd><a href="tel:<%= @person.phone %>" target="_blank" rel="noreferrer"><%= @person.phone %></a></dd> + <dd> + <a href="tel:<%= @person.phone %>" target="_blank" rel="noreferrer"> + <%= @person.phone %> + </a> + </dd> <% end %> <% if @person.email.present? %> <dt><%= University::Person.human_attribute_name(:email) %></dt> - <dd><a href="mailto:<%= @person.email %>" target="_blank" rel="noreferrer"><%= @person.email %></a></dd> + <dd> + <a href="mailto:<%= @person.email %>" target="_blank" rel="noreferrer"> + <%= @person.email %> + </a> + </dd> <% end %> <% if @person.url.present? %> <dt><%= University::Person.human_attribute_name(:url) %></dt> @@ -94,4 +105,3 @@ </dl> </div> </div> - diff --git a/config/application.rb b/config/application.rb index 42ca666b01aa256c57a18f21684d2147d5fb0743..959a1b37c9dd48f10200d5d67e983c9b720b337b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -67,7 +67,7 @@ module Osuny "sgid", "content-type", "url", "filename", "filesize", "previewable" ] - config.allowed_special_chars = '#?!,@$%^&*+:;£µ-' + config.allowed_special_chars = '#?!,_@$%^&*+:;£µ-' config.generators do |g| g.orm :active_record, primary_key_type: :uuid diff --git a/config/locales/university/en.yml b/config/locales/university/en.yml index 8b3633d360145d4a543319a7e49e7a7415508b2a..2e9ea4d69c0ae389d611c9f297dfe4f64dfc5fcd 100644 --- a/config/locales/university/en.yml +++ b/config/locales/university/en.yml @@ -54,6 +54,8 @@ en: twitter: Twitter username url: Website user: User + university/person/experience: + today: Today university/person/involvement: description: Mission (in this context) person: Person @@ -92,6 +94,9 @@ en: university/person/alumnus: one: Alumnus other: Alumni + university/person/Experience: + one: Experience + other: Experiences university/organization: one: Organization other: Organizations diff --git a/config/locales/university/fr.yml b/config/locales/university/fr.yml index 049859fb4d3a08af294c74cf74428c0d05e2e548..bd2215aba23d0f3d6f36c0be7c102f408c688426 100644 --- a/config/locales/university/fr.yml +++ b/config/locales/university/fr.yml @@ -54,6 +54,8 @@ fr: twitter: Twitter (nom d'utilisateur) url: Site web user: Utilisateur + university/person/experience: + today: Aujourd'hui university/person/involvement: description: Mission (dans ce contexte) person: Personne @@ -92,6 +94,9 @@ fr: university/person/alumnus: one: Alumnus other: Alumni + university/person/Experience: + one: Expérience + other: Expériences university/organization: one: Organisation other: Organisations