Implement show_basic, show_detail and add_to_fav methods
This commit is contained in:
parent
61933c23d4
commit
bba13f249c
@ -1,13 +1,42 @@
|
||||
class Crawlers::ProjectsCrawlerController < Crawlers::TissCrawlerController
|
||||
def show_basic
|
||||
params[:api] = '/api/search/projectFullSearch/v1.0/projects'
|
||||
params[:search_parameter] = 'searchterm'
|
||||
puts params[:search_context]
|
||||
@host = TissCrawler.get_host
|
||||
|
||||
# TissCrawler performs general search over the available projects
|
||||
@projects = TissCrawler.search(params)
|
||||
end
|
||||
|
||||
def show_detail
|
||||
params[:api] = '/api/pdb/rest/project/v2/'
|
||||
|
||||
@id = params[:id]
|
||||
|
||||
puts params
|
||||
# TissCrawler fetches the project's detail information
|
||||
@project = TissCrawler.get_project_details(params)
|
||||
# Host is needed for image rendering
|
||||
@host = TissCrawler.get_host
|
||||
end
|
||||
|
||||
def add_to_fav
|
||||
params[:api] = '/api/pdb/rest/project/v2/'
|
||||
puts params[:id]
|
||||
@project = TissCrawler.get_project_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: @project['titleDe']}
|
||||
if FavoriteProject.create(favorite_hash).valid?
|
||||
FavoriteProject.create(favorite_hash)
|
||||
flash[:alert] = 'Project added to your favorites!'
|
||||
else
|
||||
flash[:alert] = 'Project is already favorited!'
|
||||
end
|
||||
redirect_back(fallback_location: search)
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user