Merge branch 'master' of https://gitlab.com/kranklyboy/tiss2go
This commit is contained in:
commit
b47a37daea
@ -23,3 +23,24 @@
|
||||
background-color: #009688;
|
||||
}
|
||||
}
|
||||
|
||||
.thumb {
|
||||
width: 3em;
|
||||
}
|
||||
|
||||
.table_wrapper {
|
||||
overflow-x: auto;
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
th, td {
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,3 +1,49 @@
|
||||
// Place all the styles related to the ThesesCrawler controller here.
|
||||
// Place all the styles related to the thesesCrawler controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: https://sass-lang.com/
|
||||
|
||||
.theses-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.thesis {
|
||||
line-height: 72px;
|
||||
width: 100%;
|
||||
padding: 8px 0 8px 0;
|
||||
|
||||
.list-link {
|
||||
float: left;
|
||||
width: 89%;
|
||||
height: 72px;
|
||||
}
|
||||
|
||||
.thesis-title {
|
||||
width: 100%;
|
||||
display: inline-block;
|
||||
text-align: left;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.add-to-fav {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
float: right;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
|
||||
svg {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
class Crawlers::CoursesCrawlerController < TissCrawlerController
|
||||
class Crawlers::CoursesCrawlerController < Crawlers::TissCrawlerController
|
||||
|
||||
def show_basic
|
||||
params[:api] = '/api/search/course/v1.0/quickSearch'
|
||||
@ -12,10 +12,12 @@ class Crawlers::CoursesCrawlerController < TissCrawlerController
|
||||
|
||||
def show_detail
|
||||
params[:api] = '/api/course/'
|
||||
regex = params[:detail_url].match(/courseNr=(?<number>\S{6})/)
|
||||
params[:number] = regex[:number]
|
||||
regex = params[:detail_url].match(/semester=(?<semester>\d{4}[SW])/)
|
||||
params[:semester] = regex[:semester]
|
||||
if (params[:number] || params[:semester]) == nil
|
||||
regex = params[:detail_url].match(/courseNr=(?<number>\S{6})/)
|
||||
params[:number] = regex[:number]
|
||||
regex = params[:detail_url].match(/semester=(?<semester>\d{4}[SW])/)
|
||||
params[:semester] = regex[:semester]
|
||||
end
|
||||
|
||||
puts params
|
||||
|
||||
@ -27,11 +29,19 @@ class Crawlers::CoursesCrawlerController < TissCrawlerController
|
||||
@lecturers_oid = @course['lecturers']['oid']
|
||||
@lecturers_names = []
|
||||
|
||||
puts @lecturers_oid
|
||||
|
||||
if @lecturers_oid != nil
|
||||
@lecturers_oid.each do |item|
|
||||
# For each org id get the associated name
|
||||
puts TissCrawler.get_oid_name(item)
|
||||
@lecturers_names << (TissCrawler.get_oid_name(item))
|
||||
if @lecturers_oid.is_a?(Array)
|
||||
# In case @lecturers_oid contains multiple items
|
||||
@lecturers_oid.each do |item|
|
||||
# For each org id get the associated name
|
||||
puts TissCrawler.get_oid_name(item)
|
||||
@lecturers_names << (TissCrawler.get_oid_name(item))
|
||||
end
|
||||
else
|
||||
# In case @lecturers_oid only contains one item
|
||||
@lecturers_names << (TissCrawler.get_oid_name(@lecturers_oid))
|
||||
end
|
||||
end
|
||||
|
||||
@ -40,6 +50,29 @@ class Crawlers::CoursesCrawlerController < TissCrawlerController
|
||||
end
|
||||
|
||||
def add_to_fav
|
||||
params[:api] = '/api/course/'
|
||||
if (params[:number] || params[:semester]) == nil
|
||||
regex = params[:detail_url].match(/courseNr=(?<number>\S{6})/)
|
||||
params[:number] = regex[:number]
|
||||
regex = params[:detail_url].match(/semester=(?<semester>\d{4}[SW])/)
|
||||
params[:semester] = regex[:semester]
|
||||
end
|
||||
|
||||
@course = TissCrawler.get_course_details(params)
|
||||
|
||||
# create stores the object to the db after creation
|
||||
favorite_hash = {number: @course['courseNumber'],
|
||||
semester: @course['semesterCode'],
|
||||
title: @course['title']['de'],
|
||||
# the user who is currently active
|
||||
user_id: current_user.id}
|
||||
if FavoriteCourse.create(favorite_hash).valid?
|
||||
FavoriteCourse.create(favorite_hash)
|
||||
flash[:alert] = 'Course added to your favorites!'
|
||||
else
|
||||
flash[:alert] = 'Course is already favorited!'
|
||||
end
|
||||
redirect_back(fallback_location: search)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
class Crawlers::PeopleCrawlerController < TissCrawlerController
|
||||
class Crawlers::PeopleCrawlerController < Crawlers::TissCrawlerController
|
||||
|
||||
def show_basic
|
||||
params[:api] = '/api/person/v22/psuche'
|
||||
@ -27,14 +27,19 @@ class Crawlers::PeopleCrawlerController < TissCrawlerController
|
||||
@person = TissCrawler.get_details(params)
|
||||
|
||||
# create stores the object to the db after creation
|
||||
if FavoritePerson.create(tiss_id: @person['tiss_id'], first_name: @person['first_name'], last_name: @person['last_name'], picture_uri: @person['picture_uri']).valid?
|
||||
FavoritePerson.create(tiss_id: @person['tiss_id'], first_name: @person['first_name'], last_name: @person['last_name'], picture_uri: @person['picture_uri'])
|
||||
flash[:alert] = "Person added to your favorites!"
|
||||
redirect_back(fallback_location: search)
|
||||
favorite_hash = { tiss_id: @person['tiss_id'],
|
||||
# the user who is currently active
|
||||
user_id: current_user.id,
|
||||
first_name: @person['first_name'],
|
||||
last_name: @person['last_name'],
|
||||
picture_uri: @person['picture_uri'] }
|
||||
if FavoritePerson.create(favorite_hash).valid?
|
||||
FavoritePerson.create(favorite_hash)
|
||||
flash[:alert] = 'Person added to your favorites!'
|
||||
else
|
||||
flash[:alert] = "Person is already favorited!"
|
||||
redirect_back(fallback_location: search)
|
||||
flash[:alert] = 'Person is already favorited!'
|
||||
end
|
||||
redirect_back(fallback_location: search)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
class Crawlers::ProjectsCrawlerController < TissCrawlerController
|
||||
class Crawlers::ProjectsCrawlerController < Crawlers::TissCrawlerController
|
||||
def show_basic
|
||||
|
||||
end
|
||||
|
||||
@ -1,13 +1,42 @@
|
||||
class Crawlers::ThesesCrawlerController < TissCrawlerController
|
||||
class Crawlers::ThesesCrawlerController < Crawlers::TissCrawlerController
|
||||
def show_basic
|
||||
params[:api] = '/api/search/thesis/v1.0/quickSearch'
|
||||
params[:search_parameter] = 'searchterm'
|
||||
puts params[:search_context]
|
||||
@host = TissCrawler.get_host
|
||||
|
||||
# TissCrawler performs general search over the available theses
|
||||
@theses = TissCrawler.search(params)
|
||||
end
|
||||
|
||||
def show_detail
|
||||
params[:api] = '/api/thesis/'
|
||||
|
||||
@id = params[:id]
|
||||
|
||||
puts params
|
||||
# TissCrawler fetches the thesis' detail information
|
||||
@thesis = TissCrawler.get_thesis_details(params)
|
||||
# Host is needed for image rendering
|
||||
@host = TissCrawler.get_host
|
||||
end
|
||||
|
||||
def add_to_fav
|
||||
params[:api] = '/api/thesis/'
|
||||
puts params[:id]
|
||||
@thesis = TissCrawler.get_thesis_details(params)
|
||||
|
||||
# create stores the object to the db after creation
|
||||
favorite_hash = {id: params[:id],
|
||||
# the user who is currently active
|
||||
user_id: current_user.id,
|
||||
title: @thesis['title']['de']}
|
||||
if FavoriteThesis.create(favorite_hash).valid?
|
||||
FavoriteThesis.create(favorite_hash)
|
||||
flash[:alert] = 'Thesis added to your favorites!'
|
||||
else
|
||||
flash[:alert] = 'Thesis is already favorited!'
|
||||
end
|
||||
redirect_back(fallback_location: search)
|
||||
end
|
||||
end
|
||||
|
||||
@ -16,8 +16,10 @@ class Crawlers::TissCrawlerController < ApplicationController
|
||||
# redirect to courses_show_basic, propagate the search_term
|
||||
redirect_to :controller => 'crawlers/courses_crawler', :action => :show_basic, :search_term => params[:search_term]
|
||||
when 'Theses'
|
||||
# redirect to thesis_show_basic, propagate the search_term
|
||||
redirect_to :controller => 'crawlers/theses_crawler', :action => :show_basic, :search_term => params[:search_term]
|
||||
when 'Projects'
|
||||
else
|
||||
else
|
||||
puts 'Undefined search context'
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,19 +1,50 @@
|
||||
class FavoritesController < ApplicationController
|
||||
helper_method :sort_column, :sort_direction
|
||||
|
||||
def people
|
||||
@favoritePeople = FavoritePerson.all
|
||||
@favorite_people = FavoritePerson.where('user_id': current_user.id)
|
||||
.order(sort_column + " " + sort_direction)
|
||||
@host = 'https://tiss.tuwien.ac.at'
|
||||
end
|
||||
|
||||
def courses
|
||||
def delete_person
|
||||
FavoritePerson.find_by_tiss_id(params[:tiss_id]).destroy
|
||||
redirect_back(fallback_location: people)
|
||||
end
|
||||
|
||||
def courses
|
||||
@favorite_courses = FavoriteCourse.where('user_id': current_user.id)
|
||||
.order(sort_column + " " + sort_direction)
|
||||
@host = 'https://tiss.tuwien.ac.at'
|
||||
end
|
||||
|
||||
def delete_course
|
||||
FavoriteCourse.find_by(number: params[:number], semester: params[:semester]).destroy
|
||||
redirect_back(fallback_location: courses)
|
||||
end
|
||||
|
||||
def theses
|
||||
@favorite_theses = FavoriteThesis.where('user_id': current_user.id)
|
||||
.order(sort_column + " " + sort_direction)
|
||||
@host = 'https://tiss.tuwien.ac.at'
|
||||
end
|
||||
|
||||
def delete_thesis
|
||||
FavoriteThesis.find_by(id: params[:id]).destroy
|
||||
redirect_back(fallback_location: theses)
|
||||
end
|
||||
|
||||
def projects
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sort_column
|
||||
params[:sort] || ''
|
||||
end
|
||||
|
||||
def sort_direction
|
||||
params[:direction] || ''
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
module CoursesCrawlerHelper
|
||||
end
|
||||
2
app/helpers/crawlers/courses_crawler_helper.rb
Normal file
2
app/helpers/crawlers/courses_crawler_helper.rb
Normal file
@ -0,0 +1,2 @@
|
||||
module Crawlers::CoursesCrawlerHelper
|
||||
end
|
||||
2
app/helpers/crawlers/people_crawler_helper.rb
Normal file
2
app/helpers/crawlers/people_crawler_helper.rb
Normal file
@ -0,0 +1,2 @@
|
||||
module Crawlers::PeopleCrawlerHelper
|
||||
end
|
||||
2
app/helpers/crawlers/projects_crawler_helper.rb
Normal file
2
app/helpers/crawlers/projects_crawler_helper.rb
Normal file
@ -0,0 +1,2 @@
|
||||
module Crawlers::ProjectsCrawlerHelper
|
||||
end
|
||||
2
app/helpers/crawlers/theses_crawler_helper.rb
Normal file
2
app/helpers/crawlers/theses_crawler_helper.rb
Normal file
@ -0,0 +1,2 @@
|
||||
module Crawlers::ThesesCrawlerHelper
|
||||
end
|
||||
2
app/helpers/crawlers/tiss_crawler_helper.rb
Normal file
2
app/helpers/crawlers/tiss_crawler_helper.rb
Normal file
@ -0,0 +1,2 @@
|
||||
module Crawlers::TissCrawlerHelper
|
||||
end
|
||||
@ -1,2 +1,6 @@
|
||||
module FavoritesHelper
|
||||
def sortable(title, column)
|
||||
direction = column == sort_column && sort_direction == 'asc' ? 'desc' : 'asc'
|
||||
link_to title, :sort => column, :direction => direction
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
module PeopleCrawlerHelper
|
||||
end
|
||||
@ -1,2 +0,0 @@
|
||||
module ProjectsCrawlerHelper
|
||||
end
|
||||
@ -1,2 +0,0 @@
|
||||
module ThesesCrawlerHelper
|
||||
end
|
||||
@ -1,2 +0,0 @@
|
||||
module TissCrawlerHelper
|
||||
end
|
||||
4
app/models/favorite_course.rb
Normal file
4
app/models/favorite_course.rb
Normal file
@ -0,0 +1,4 @@
|
||||
class FavoriteCourse < ApplicationRecord
|
||||
validates :title, :semester, :number, presence: true
|
||||
validates :semester, :number, uniqueness: {scope: [:semester, :number]}
|
||||
end
|
||||
5
app/models/favorite_thesis.rb
Normal file
5
app/models/favorite_thesis.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class FavoriteThesis < ApplicationRecord
|
||||
self.primary_key = 'id'
|
||||
|
||||
validates :id, uniqueness: true
|
||||
end
|
||||
20
app/views/crawlers/theses_crawler/show_basic.html.erb
Normal file
20
app/views/crawlers/theses_crawler/show_basic.html.erb
Normal file
@ -0,0 +1,20 @@
|
||||
<h1>Results for "<%= params[:search_term] %>"</h1>
|
||||
|
||||
<ul class="theses-list">
|
||||
<% @theses.each_with_index do |thesis| %>
|
||||
<li class="thesis">
|
||||
<%= link_to crawlers_theses_crawler_show_detail_url(:id => thesis['id'], :title => thesis['title']) do %>
|
||||
<span class="list-link">
|
||||
<span class="thesis-title">
|
||||
<%= thesis['title'] %>
|
||||
</span>
|
||||
</span>
|
||||
<% end %>
|
||||
<span class="add-to-fav">
|
||||
<%= link_to crawlers_theses_crawler_add_to_fav_url(:id => thesis['id'], :title => thesis['title']) do %>
|
||||
<%= show_svg('favorite-24px.svg') %>
|
||||
<% end %>
|
||||
</span>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
13
app/views/crawlers/theses_crawler/show_detail.html.erb
Normal file
13
app/views/crawlers/theses_crawler/show_detail.html.erb
Normal file
@ -0,0 +1,13 @@
|
||||
<% if @thesis != nil %>
|
||||
<h2><%= @thesis['title']['de'] %></h2>
|
||||
<h5><%= @thesis['thesisType'] %>, <%= @thesis['instituteCode'] %> <%= @thesis['instituteName']['de'] %></h5>
|
||||
<%= button_to 'Add to favorites', action: :add_to_fav, id: @id, title: @thesis['title']['de'] %>
|
||||
<% if @thesis['advisor'] != nil %>
|
||||
<h4>Advisor</h4>
|
||||
<p><%= @thesis['advisor']['familyName'] %> <%= @thesis['advisor']['givenName'] %></p>
|
||||
<% end %>
|
||||
<% if @thesis['assistant'] != nil %>
|
||||
<h4>Assistant</h4>
|
||||
<p><%= @thesis['assistant']['familyName'] %> <%= @thesis['assistant']['givenName'] %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@ -1,3 +1,34 @@
|
||||
<%= render(:partial => "nav")%>
|
||||
<%= render(:partial => "nav") %>
|
||||
|
||||
<p>Fav Courses</p>
|
||||
<h1>Favorite Courses</h1>
|
||||
|
||||
<% if !@favorite_courses[0].blank? %>
|
||||
<div class="table_wrapper">
|
||||
<table>
|
||||
<tr>
|
||||
<th><%= sortable "Title", "title" %></th>
|
||||
<th><%= sortable "Registration Date", "created_at" %></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<% for course in @favorite_courses %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= course['title'] %>
|
||||
</td>
|
||||
<td>
|
||||
<%= course['created_at'] %>
|
||||
</td>
|
||||
<td>
|
||||
<%= button_to 'Details', crawlers_courses_crawler_show_detail_url(:number => course['number'], :semester => course['semester']) %>
|
||||
</td>
|
||||
<td>
|
||||
<%= button_to 'Delete', {:action => "delete_course", :number => course['number'], :semester => course['semester']}, :method => 'delete' %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
||||
<% else %>
|
||||
No favorite courses added yet!
|
||||
<% end %>
|
||||
|
||||
@ -1,25 +1,72 @@
|
||||
<%= render(:partial => "nav")%>
|
||||
<%= render(:partial => "nav") %>
|
||||
|
||||
<h1>Favorite People</h1>
|
||||
|
||||
<ul class="people-list">
|
||||
<% @favoritePeople.each do |person| %>
|
||||
<li class="person">
|
||||
<%= link_to crawlers_people_crawler_show_detail_url(:tiss_id => person['tiss_id']) do %>
|
||||
<span class="list-link">
|
||||
<span class="person-icon">
|
||||
<% if person['picture_uri'] != nil %>
|
||||
<%= image_tag @host + person['picture_uri'] %>
|
||||
<% else %>
|
||||
<%= show_svg('account_circle-black-48dp.svg') %>
|
||||
<% end %>
|
||||
</span>
|
||||
<span class="person-name">
|
||||
<%= person['first_name'] %>
|
||||
<!--<ul class="people-list">-->
|
||||
<%# @favorite_people.each do |person| %>
|
||||
<!-- <li class="person">-->
|
||||
<%#= link_to crawlers_people_crawler_show_detail_url(:tiss_id => person['tiss_id']) do %>
|
||||
<!-- <span class="list-link">-->
|
||||
<!-- <span class="person-icon">-->
|
||||
<%# if person['picture_uri'] != nil %>
|
||||
<%#= image_tag @host + person['picture_uri'] %>
|
||||
<%# else %>
|
||||
<%#= show_svg('account_circle-black-48dp.svg') %>
|
||||
<%# end %>
|
||||
<!-- </span>-->
|
||||
<!-- <span class="person-name">-->
|
||||
<%#= person['first_name'] %>
|
||||
<%#= person['last_name'] %>
|
||||
<!-- </span>-->
|
||||
<!-- </span>-->
|
||||
<%# end %>
|
||||
<!-- </li>-->
|
||||
<%# end %>
|
||||
<!--</ul>-->
|
||||
|
||||
<% if !@favorite_people[0].blank? %>
|
||||
<div class="table_wrapper">
|
||||
<table>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><%= sortable "First Name", "first_name" %></th>
|
||||
<th><%= sortable "Last Name", "last_name" %></th>
|
||||
<th><%= sortable "Registration Date", "created_at" %></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<% for person in @favorite_people %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= link_to crawlers_people_crawler_show_detail_url(:tiss_id => person['tiss_id']) do %>
|
||||
<span>
|
||||
<% if person['picture_uri'] != nil %>
|
||||
<%= image_tag @host + person['picture_uri'], class: 'thumb'%>
|
||||
<% else %>
|
||||
<%= show_svg('account_circle-black-48dp.svg')%>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<%= person['first_name'] %>
|
||||
</td>
|
||||
<td>
|
||||
<%= person['last_name'] %>
|
||||
</span>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<%= person['created_at'] %>
|
||||
</td>
|
||||
<td>
|
||||
<%= button_to 'Details', crawlers_people_crawler_show_detail_url(:tiss_id => person['tiss_id']) %>
|
||||
</td>
|
||||
<td>
|
||||
<%= button_to "Delete", {:action => "delete_person", :tiss_id => person['tiss_id']}, :method => 'delete' %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</table>
|
||||
</div>
|
||||
<% else %>
|
||||
No favorite people added yet!
|
||||
<% end %>
|
||||
@ -1,3 +1,34 @@
|
||||
<%= render(:partial => "nav")%>
|
||||
<%= render(:partial => "nav") %>
|
||||
|
||||
<p>Fav Theses</p>
|
||||
<h1>Favorite Theses</h1>
|
||||
|
||||
<% if !@favorite_theses[0].blank? %>
|
||||
<div class="table_wrapper">
|
||||
<table>
|
||||
<tr>
|
||||
<th><%= sortable "Title", "title" %></th>
|
||||
<th><%= sortable "Registration Date", "created_at" %></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<% for thesis in @favorite_theses %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= thesis['title'] %>
|
||||
</td>
|
||||
<td>
|
||||
<%= thesis['created_at'] %>
|
||||
</td>
|
||||
<td>
|
||||
<%= button_to 'Details', crawlers_theses_crawler_show_detail_url(:id => thesis['id']) %>
|
||||
</td>
|
||||
<td>
|
||||
<%= button_to 'Delete', {:action => "delete_thesis", :id => thesis['id']}, :method => 'delete' %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
||||
<% else %>
|
||||
No favorite theses added yet!
|
||||
<% end %>
|
||||
|
||||
@ -22,12 +22,23 @@ Rails.application.routes.draw do
|
||||
get 'add_to_fav'
|
||||
post 'add_to_fav'
|
||||
end
|
||||
|
||||
namespace :theses_crawler do
|
||||
get 'show_basic'
|
||||
get 'show_detail'
|
||||
post 'show_detail'
|
||||
get 'add_to_fav'
|
||||
post 'add_to_fav'
|
||||
end
|
||||
end
|
||||
|
||||
namespace :favorites do
|
||||
get 'people'
|
||||
delete 'delete_person'
|
||||
get 'courses'
|
||||
delete 'delete_course'
|
||||
get 'theses'
|
||||
delete 'delete_thesis'
|
||||
get 'projects'
|
||||
end
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
class CreateFavoritePeople < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :favorite_people, id: false do |t|
|
||||
t.string :tiss_id, null: false
|
||||
t.integer :tiss_id, null: false
|
||||
t.integer :user_id, null: false
|
||||
t.string :first_name
|
||||
t.string :last_name
|
||||
|
||||
t.string :picture_uri
|
||||
|
||||
t.timestamps
|
||||
|
||||
13
db/migrate/20200521091231_create_favorite_courses.rb
Normal file
13
db/migrate/20200521091231_create_favorite_courses.rb
Normal file
@ -0,0 +1,13 @@
|
||||
class CreateFavoriteCourses < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :favorite_courses do |t|
|
||||
t.string :number, null: false
|
||||
t.string :semester, null: false
|
||||
t.string :title, null: false
|
||||
t.integer :user_id, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :favorite_courses, [:number, :semester], unique: true
|
||||
end
|
||||
end
|
||||
12
db/migrate/20200525132942_create_favorite_theses.rb
Normal file
12
db/migrate/20200525132942_create_favorite_theses.rb
Normal file
@ -0,0 +1,12 @@
|
||||
class CreateFavoriteTheses < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :favorite_theses, id: false do |t|
|
||||
t.integer :id, null: false
|
||||
t.integer :user_id, null: false
|
||||
t.string :title
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :favorite_theses, :id, unique: true
|
||||
end
|
||||
end
|
||||
24
db/schema.rb
24
db/schema.rb
@ -10,10 +10,21 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2020_04_21_152314) do
|
||||
ActiveRecord::Schema.define(version: 2020_05_25_132942) do
|
||||
|
||||
create_table "favorite_courses", force: :cascade do |t|
|
||||
t.string "number", null: false
|
||||
t.string "semester", null: false
|
||||
t.string "title", null: false
|
||||
t.integer "user_id", null: false
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.index ["number", "semester"], name: "index_favorite_courses_on_number_and_semester", unique: true
|
||||
end
|
||||
|
||||
create_table "favorite_people", id: false, force: :cascade do |t|
|
||||
t.string "tiss_id", null: false
|
||||
t.integer "tiss_id", null: false
|
||||
t.integer "user_id", null: false
|
||||
t.string "first_name"
|
||||
t.string "last_name"
|
||||
t.string "picture_uri"
|
||||
@ -22,6 +33,15 @@ ActiveRecord::Schema.define(version: 2020_04_21_152314) do
|
||||
t.index ["tiss_id"], name: "index_favorite_people_on_tiss_id", unique: true
|
||||
end
|
||||
|
||||
create_table "favorite_theses", id: false, force: :cascade do |t|
|
||||
t.integer "id", null: false
|
||||
t.integer "user_id", null: false
|
||||
t.string "title"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.index ["id"], name: "index_favorite_theses_on_id", unique: true
|
||||
end
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "email", default: "", null: false
|
||||
t.string "encrypted_password", default: "", null: false
|
||||
|
||||
@ -36,6 +36,16 @@ class TissCrawler
|
||||
response.parsed_response['tuvienna']['course']
|
||||
end
|
||||
|
||||
def self.get_thesis_details(params)
|
||||
api = params[:api]
|
||||
id = params[:id]
|
||||
url = $host + api + id
|
||||
puts(url)
|
||||
|
||||
response = HTTParty.get(url)
|
||||
response.parsed_response['tuvienna']['thesis']
|
||||
end
|
||||
|
||||
def self.get_host
|
||||
$host
|
||||
end
|
||||
|
||||
11
test/fixtures/favorite_courses.yml
vendored
Normal file
11
test/fixtures/favorite_courses.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
11
test/fixtures/favorite_theses.yml
vendored
Normal file
11
test/fixtures/favorite_theses.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
7
test/models/favorite_course_test.rb
Normal file
7
test/models/favorite_course_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class FavoriteCourseTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
7
test/models/favorite_thesis_test.rb
Normal file
7
test/models/favorite_thesis_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class FavoriteThesisTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user