-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
includes: - institute model - world universitites json (public json file) - select2 (v4)
- Loading branch information
Showing
20 changed files
with
116,172 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,6 @@ | |
|
||
#= require cocoon | ||
|
||
#= require select2.min | ||
|
||
#= require_tree . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
class PagesController < ApplicationController | ||
|
||
def world_universities | ||
# JSON file downloaded from: | ||
# https://github.com/Hipo/university-domains-list | ||
# Opting with this approach as issues with CORS on ajax request | ||
# For updated university list, this file would need to be re-downloaded. | ||
# FYI: last updated datestamp included in the filename | ||
file = File.read("#{Rails.root}/public/assets/25012018_world_universities.json") | ||
unis = JSON.parse(file).each_with_index.map do |uni, i| | ||
uni["id"] = i + 1 # view logic: required for select purposes | ||
uni | ||
end | ||
if name_q = params[:name] | ||
unis = unis.select { |u| u["name"].downcase.include?(name_q) } | ||
end | ||
render json: unis | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Institute < ApplicationRecord | ||
|
||
def to_s | ||
"#{name}, #{country}" | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
class Scholar < ApplicationRecord | ||
|
||
belongs_to :discipline | ||
belongs_to :institute, optional: true | ||
has_many :web_urls, as: :linkable | ||
|
||
accepts_nested_attributes_for :web_urls, reject_if: :all_blank, allow_destroy: true | ||
|
||
validates :first_name, :last_name, :discipline, presence: true | ||
|
||
attr_reader :institute_token | ||
|
||
def name | ||
[first_name, middle_name, last_name].compact.join(" ") | ||
end | ||
|
||
def institute_token=(token) | ||
val = token.split(",") | ||
return if val.blank? | ||
self.institute = Institute.find_or_create_by name: val[0], country: val[1] | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div class="card flex-md-row mb-4 box-shadow h-md-250"> | ||
<div class="card-body d-flex flex-column align-items-start"> | ||
<strong class="d-inline-block mb-2 <%= scholar.discipline.root.code %>"><%= scholar.discipline.root %></strong> | ||
<h5 class="mb-0"> | ||
<%= scholar.name %> | ||
</h5> | ||
<div class="mb-1 text-muted small"><%= scholar.discipline %></div> | ||
<div class="mb-1 text-muted small"><%= scholar.institute %></div> | ||
<p class="card-text mb-auto"><%= scholar.description %></p> | ||
<div class="small"> | ||
<% scholar.web_urls.each do |web_url| %> | ||
<%= link_to web_url.title, web_url.url, target: "_blank" %> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateInstitutes < ActiveRecord::Migration[5.1] | ||
def change | ||
create_table :institutes do |t| | ||
t.string :name, null: false | ||
t.string :country, null: false | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddInstituteIdToScholar < ActiveRecord::Migration[5.1] | ||
def change | ||
add_reference :scholars, :institute, foreign_key: {references: :institutes} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.