tiss2go/app/controllers/people_crawler_controller.rb
Pfingstfrosch 92eff82f1a refactored favorites:
instead of using a fav page for each content, use a general favorites pane where the user can select which favs shall be shown
2020-05-12 19:19:04 +02:00

42 lines
1.4 KiB
Ruby

class PeopleCrawlerController < TissCrawlerController
def show_basic
params[:api] = '/api/person/v22/psuche'
params[:search_parameter] = 'q'
puts params[:search_context]
@host = TissCrawler.get_host
# TissCrawler performs general search over the available people
@people = TissCrawler.search(params)
end
def show_detail
params[:api] = '/api/person/v22/id/'
params[:tiss_id] = params[:tiss_id]
puts params
# TissCrawler fetches the person's detail information
@person = TissCrawler.get_details(params)
# Host is needed for image rendering
@host = TissCrawler.get_host
end
def add_to_fav
params[:api] = '/api/person/v22/id/'
puts params[:tiss_id]
@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'])
respond_to do |format|
format.html { redirect_to favorite_person_index_url, notice: 'Favorite person stored' }
end
else
flash[:alert] = "Person is already favorited!"
redirect_back(fallback_location: search)
end
end
end