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

working

parent b7c9e7b0
No related branches found
No related tags found
No related merge requests found
Showing
with 115 additions and 34 deletions
app/assets/images/extranet/avatar.png

13 KiB

...@@ -9,3 +9,14 @@ footer ...@@ -9,3 +9,14 @@ footer
padding: .95rem padding: .95rem
&-danger &-danger
color: #82322F color: #82322F
h1
border-bottom: 1px solid
border-top: 1px solid
height: 100%
min-height: 160px
padding-top: 50px
.breadcrumb
font-size: 14px
padding-bottom: 50px
...@@ -2,6 +2,7 @@ class ApplicationController < ActionController::Base ...@@ -2,6 +2,7 @@ class ApplicationController < ActionController::Base
include WithErrors include WithErrors
include WithLocale include WithLocale
include WithDomain include WithDomain
before_action :authenticate_user! before_action :authenticate_user!
def breadcrumb def breadcrumb
......
class Extranet::AcademicYearsController < ApplicationController class Extranet::AcademicYearsController < Extranet::ApplicationController
load_and_authorize_resource class: Education::AcademicYear, load_and_authorize_resource class: Education::AcademicYear,
through: :current_university, through: :current_university,
through_association: :academic_years through_association: :academic_years
def index def index
@academic_years = @academic_years.ordered.page(params[:page]) @academic_years = @academic_years.ordered.page(params[:page])
breadcrumb
end end
def show def show
breadcrumb
end
protected
def breadcrumb
super
add_breadcrumb Education::AcademicYear.model_name.human(count: 2), education_academic_years_path
add_breadcrumb @academic_year if @academic_year
end end
end end
class Extranet::ApplicationController < ApplicationController
def breadcrumb
add_breadcrumb t('home'), root_path
end
end
class Extranet::CohortsController < ApplicationController class Extranet::CohortsController < Extranet::ApplicationController
load_and_authorize_resource class: Education::Cohort, load_and_authorize_resource class: Education::Cohort,
through: :current_university, through: :current_university,
through_association: :education_cohorts through_association: :education_cohorts
def index def index
@cohorts = @cohorts.ordered.page(params[:page]) @cohorts = @cohorts.ordered.page(params[:page])
breadcrumb
end end
def show def show
breadcrumb
end
protected
def breadcrumb
super
add_breadcrumb Education::Cohort.model_name.human(count: 2), education_cohorts_path
add_breadcrumb @cohort if @cohort
end end
end end
class Extranet::OrganizationsController < ApplicationController class Extranet::OrganizationsController < Extranet::ApplicationController
load_and_authorize_resource class: University::Organization, load_and_authorize_resource class: University::Organization,
through: :current_university, through: :current_university,
through_association: :organizations through_association: :organizations
def index def index
@organizations = @organizations.ordered.page(params[:page]) @organizations = @organizations.ordered.page(params[:page])
breadcrumb
end end
def show def show
breadcrumb
end
protected
def breadcrumb
super
add_breadcrumb University::Organization.model_name.human(count: 2), university_organizations_path
add_breadcrumb @organization if @organization
end end
end end
class Extranet::PersonsController < ApplicationController class Extranet::PersonsController < Extranet::ApplicationController
load_and_authorize_resource class: University::Person::Alumnus, load_and_authorize_resource class: University::Person::Alumnus,
through: :current_university, through: :current_university,
through_association: :people through_association: :people
def index def index
breadcrumb
end end
def show def show
breadcrumb
end
protected
def breadcrumb
super
add_breadcrumb University::Person::Alumnus.model_name.human(count: 2), university_persons_path
add_breadcrumb @person if @person
end end
end end
...@@ -101,10 +101,10 @@ class University::Person < ApplicationRecord ...@@ -101,10 +101,10 @@ class University::Person < ApplicationRecord
before_validation :sanitize_email before_validation :sanitize_email
scope :ordered, -> { order(:last_name, :first_name) } scope :ordered, -> { order(:last_name, :first_name) }
scope :administration, -> { where(is_administration: true) } scope :administration, -> { where(is_administration: true) }
scope :teachers, -> { where(is_teacher: true) } scope :teachers, -> { where(is_teacher: true) }
scope :researchers, -> { where(is_researcher: true) } scope :researchers, -> { where(is_researcher: true) }
scope :alumni, -> { where(is_alumnus: true) } scope :alumni, -> { where(is_alumnus: true) }
def to_s def to_s
"#{first_name} #{last_name}" "#{first_name} #{last_name}"
......
...@@ -49,7 +49,7 @@ class University::Person::Alumnus::Import < ApplicationRecord ...@@ -49,7 +49,7 @@ class University::Person::Alumnus::Import < ApplicationRecord
# status # status
# socialtwitter # socialtwitter
# sociallinkedin # sociallinkedin
row['program'] = '23279cab-8bc1-4c75-bcd8-1fccaa03ad55' #TMP local fix # row['program'] = '23279cab-8bc1-4c75-bcd8-1fccaa03ad55' #TMP local fix
program = university.education_programs program = university.education_programs
.find_by(id: row['program']) .find_by(id: row['program'])
next if program.nil? next if program.nil?
...@@ -79,9 +79,20 @@ class University::Person::Alumnus::Import < ApplicationRecord ...@@ -79,9 +79,20 @@ class University::Person::Alumnus::Import < ApplicationRecord
person.is_alumnus = true person.is_alumnus = true
person.url = url person.url = url
person.slug = person.to_s.parameterize.dasherize person.slug = person.to_s.parameterize.dasherize
person.twitter = row['socialtwitter']
person.linkedin = row['sociallinkedin']
byebug unless person.valid? byebug unless person.valid?
person.save person.save
cohort.people << person unless person.in?(cohort.people) cohort.people << person unless person.in?(cohort.people)
photo = row['photo'].to_s
if photo.end_with?('.jpg') || photo.end_with?('.png')
filename = File.basename photo
begin
file = URI.open photo
person.picture.attach(io: file, filename: 'some-image.jpg')
rescue
end
end
end end
end end
......
<% content_for :title, Education::AcademicYear.model_name.human(count: 2) %> <% content_for :title, Education::AcademicYear.model_name.human(count: 2) %>
<h1><%= Education::AcademicYear.model_name.human(count: 2) %></h1>
<table class="<%= table_classes %>"> <table class="<%= table_classes %>">
<thead> <thead>
<tr> <tr>
......
<% content_for :title, @academic_year %> <% content_for :title, @academic_year %>
<h1><%= @academic_year %></h1>
<% @academic_year.cohorts.each do |cohort| %> <% @academic_year.cohorts.each do |cohort| %>
<%= link_to cohort, cohort %> <%= link_to cohort, cohort %>
<% end %> <% end %>
......
<% content_for :title, Education::Cohort.model_name.human(count: 2) %> <% content_for :title, Education::Cohort.model_name.human(count: 2) %>
<h1><%= Education::Cohort.model_name.human(count: 2) %></h1>
<table class="<%= table_classes %>"> <table class="<%= table_classes %>">
<thead> <thead>
<tr> <tr>
...@@ -12,7 +14,7 @@ ...@@ -12,7 +14,7 @@
<% @cohorts.each do |cohort| %> <% @cohorts.each do |cohort| %>
<tr> <tr>
<td><%= link_to cohort, cohort %></td> <td><%= link_to cohort, cohort %></td>
<td></td> <td><%= cohort.people.count %></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>
......
<% content_for :title, @cohort %> <% content_for :title, @cohort %>
<h1><%= @cohort %></h1>
<%= render 'extranet/persons/list', people: @cohort.people %> <%= render 'extranet/persons/list', people: @cohort.people %>
<% content_for :title, University::Organization.model_name.human(count: 2) %> <% content_for :title, University::Organization.model_name.human(count: 2) %>
<h1><%= University::Organization.model_name.human(count: 2) %></h1>
<table class="<%= table_classes %>"> <table class="<%= table_classes %>">
<thead> <thead>
<tr> <tr>
......
<% content_for :title, @organization %> <% content_for :title, @organization %>
<h1><%= @organization %></h1>
...@@ -6,34 +6,20 @@ people_paged = people.ordered.page(params[:page]).per(60) ...@@ -6,34 +6,20 @@ people_paged = people.ordered.page(params[:page]).per(60)
<div class="row"> <div class="row">
<% people_paged.each do |person| %> <% people_paged.each do |person| %>
<div class="col-xxl-2 col-md-3"> <div class="col-xxl-2 col-md-3">
<article class="card mb-4"> <article class="mb-4 position-relative">
<div class="card-body"> <% if person.picture.attached? %>
<%= link_to person, class: 'stretched-link' do %> <%= kamifusen_tag person.picture, width: 400, class: 'img-fluid' %>
<span class="small"><%= person.first_name %></span><br> <% else %>
<%= image_tag 'extranet/avatar.png', width: 400, class: 'img-fluid' %>
<% end %>
<%= link_to person, class: 'stretched-link' do %>
<%= person.first_name %>
<b>
<%= person.last_name %> <%= person.last_name %>
<% end %> </b>
</div> <% end %>
</article> </article>
</div> </div>
<% end %> <% end %>
</div> </div>
<table class="<%= table_classes %>">
<thead>
<tr>
<th>Name</th>
<th></th>
</tr>
</thead>
<tbody>
<% people_paged.each do |person| %>
<tr>
<td><%= link_to person, person %></td>
<td></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate people_paged, theme: 'bootstrap-5' %> <%= paginate people_paged, theme: 'bootstrap-5' %>
<% content_for :title, University::Person::Alumnus.model_name.human(count: 2) %> <% content_for :title, University::Person::Alumnus.model_name.human(count: 2) %>
<h1><%= University::Person::Alumnus.model_name.human(count: 2) %></h1>
<%= render 'extranet/persons/list', people: @people %> <%= render 'extranet/persons/list', people: @people %>
<% content_for :title, @person %> <% content_for :title, @person %>
<div class="row">
<div class="col-md-9">
<h1><%= @person %></h1>
</div>
<div class="col-md-3">
<% if @person.picture.attached? %>
<%= kamifusen_tag @person.picture, width: 400, class: 'img-fluid' %>
<% else %>
<%= image_tag 'extranet/avatar.png', width: 400, class: 'img-fluid' %>
<% end %>
</div>
</div>
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
<body class="<%= body_classes %>"> <body class="<%= body_classes %>">
<%= render 'nav' %> <%= render 'nav' %>
<main class="container"> <main class="container">
<h1><%= yield :title %></h1>
<%= render_breadcrumbs builder: Appstack::BreadcrumbsOnRailsBuilder %> <%= render_breadcrumbs builder: Appstack::BreadcrumbsOnRailsBuilder %>
<%= yield %> <%= yield %>
</main> </main>
......
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