From bfcb576d7f0a06460391758b9a140e5e1950c247 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Tue, 12 Apr 2022 08:18:49 +0200
Subject: [PATCH] import

---
 app/models/university/person/alumnus/import.rb      | 13 ++++++-------
 .../admin/university/person/alumni/index.html.erb   |  2 +-
 .../university/person/alumnus/imports/new.html.erb  | 10 +++++-----
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/app/models/university/person/alumnus/import.rb b/app/models/university/person/alumnus/import.rb
index c35dcadee..7bfc413b4 100644
--- a/app/models/university/person/alumnus/import.rb
+++ b/app/models/university/person/alumnus/import.rb
@@ -30,7 +30,7 @@ class University::Person::Alumnus::Import < ApplicationRecord
 
   def parse
     csv.each do |row|
-      row['program'] = '23279cab-8bc1-4c75-bcd8-1fccaa03ad55' #TMP local fix
+      # row['program'] = '23279cab-8bc1-4c75-bcd8-1fccaa03ad55' #TMP local fix
       program = university.education_programs
                           .find_by(id: row['program'])
       next if program.nil?
@@ -59,19 +59,18 @@ class University::Person::Alumnus::Import < ApplicationRecord
       # TODO all fields
       # gender
       # birth
-      # phonepro
-      # phoneperso
+      # phone_professional
+      # phone_personal
       # address
       # zipcode
       # city
       # country
-      # status
       person.is_alumnus = true
       person.url = url
       person.slug = person.to_s.parameterize.dasherize
-      person.twitter ||= row['socialtwitter']
-      person.linkedin ||= row['sociallinkedin']
-      person.biography ||= row['status']
+      person.twitter ||= row['social_twitter']
+      person.linkedin ||= row['social_linkedin']
+      person.biography ||= row['biography']
       person.phone ||= row['mobile']
       byebug unless person.valid?
       person.save
diff --git a/app/views/admin/university/person/alumni/index.html.erb b/app/views/admin/university/person/alumni/index.html.erb
index 00d3f1961..81016b583 100644
--- a/app/views/admin/university/person/alumni/index.html.erb
+++ b/app/views/admin/university/person/alumni/index.html.erb
@@ -6,7 +6,7 @@
 
 <% content_for :action_bar_left do %>
   <%= link_to t('import'),
-              admin_university_person_alumnus_imports_path,
+              new_admin_university_person_alumnus_import_path,
               class: button_classes if can? :manage, University::Person::Alumnus::Import %>
 <% end %>
 
diff --git a/app/views/admin/university/person/alumnus/imports/new.html.erb b/app/views/admin/university/person/alumnus/imports/new.html.erb
index e63db9d06..054e17203 100644
--- a/app/views/admin/university/person/alumnus/imports/new.html.erb
+++ b/app/views/admin/university/person/alumnus/imports/new.html.erb
@@ -58,11 +58,11 @@
           <td>https://www.stephanedupond.fr</td>
         </tr>
         <tr>
-          <th>phonepro</th>
+          <th>phone_professional</th>
           <td>+33 1 01 01 01 01</td>
         </tr>
         <tr>
-          <th>phoneperso</th>
+          <th>phone_personal</th>
           <td>+33 1 01 01 01 01</td>
         </tr>
         <tr>
@@ -86,15 +86,15 @@
           <td>FR</td>
         </tr>
         <tr>
-          <th>status</th>
+          <th>biography</th>
           <td>Product Designer</td>
         </tr>
         <tr>
-          <th>socialtwitter</th>
+          <th>social_twitter</th>
           <td>stephanedupond</td>
         </tr>
         <tr>
-          <th>sociallinkedin</th>
+          <th>social_linkedin</th>
           <td>https://www.linkedin.com/in/stephanedupond</td>
         </tr>
       </tbody>
-- 
GitLab