Skip to content
Snippets Groups Projects
Commit 0ad6e52e authored by Arnaud Levy's avatar Arnaud Levy
Browse files

alumni

parent c8c4709a
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......@@ -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
......
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
......@@ -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'
......
......@@ -8,12 +8,5 @@
<p><small><%= link_to organization.url, organization.url %></small></p>
<% end %>
</div>
<% if organization.logo.attached? %>
<div>
<%= link_to organization do %>
<%= kamifusen_tag organization.logo, height: 80, class: 'img-fluid' %>
<% end %>
</div>
<% end %>
</div>
<% end %>
......@@ -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">
<%= render "extranet/organizations/list" %>
......
<% 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,12 @@
<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(" - ") %>
<% if experience.description.present? %>
<%= experience.description %><br>
<% end %>
<%= experience.from_year %>
<%= experience.to_year || 'Aujourd\'hui' %>
</p>
</div>
</li>
......@@ -70,4 +71,4 @@
<% end %>
</dl>
</div>
</div>
\ No newline at end of file
</div>
......@@ -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>
......@@ -94,4 +94,3 @@
</dl>
</div>
</div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment