Implement search, show_basic, show_detail and add_to_fav for theses
This commit is contained in:
@@ -1,13 +1,42 @@
|
||||
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 courses
|
||||
@theses = TissCrawler.search(params)
|
||||
end
|
||||
|
||||
def show_detail
|
||||
params[:api] = '/api/thesis/'
|
||||
|
||||
@id = params[:id]
|
||||
|
||||
puts params
|
||||
# TissCrawler fetches the person's 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
|
||||
|
||||
Reference in New Issue
Block a user