personal annotations for all classes implemented
This commit is contained in:
@@ -26,6 +26,8 @@ class Crawlers::CoursesCrawlerController < Crawlers::TissCrawlerController
|
||||
params[:semester] = regex[:semester]
|
||||
end
|
||||
|
||||
@personal_annotation = get_stored_annotation FavoriteCourse, {number: params[:number]}
|
||||
|
||||
puts params
|
||||
|
||||
# TissCrawler fetches the course's detail information
|
||||
@@ -83,6 +85,7 @@ class Crawlers::CoursesCrawlerController < Crawlers::TissCrawlerController
|
||||
end
|
||||
|
||||
def add_annotation
|
||||
store_annotation FavoriteCourse, 'Course', {number: params[:id]}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -53,7 +53,7 @@ class Crawlers::PeopleCrawlerController < Crawlers::TissCrawlerController
|
||||
end
|
||||
|
||||
def add_annotation
|
||||
store_annotation FavoritePerson, 'Person', params[:id]
|
||||
store_annotation FavoritePerson, 'Person', {tiss_id: params[:id]}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -21,6 +21,8 @@ class Crawlers::ProjectsCrawlerController < Crawlers::TissCrawlerController
|
||||
|
||||
@id = params[:id]
|
||||
|
||||
@personal_annotation = get_stored_annotation FavoriteProject, {id: @id}
|
||||
|
||||
puts params
|
||||
# TissCrawler fetches the project's detail information
|
||||
@project = TissCrawler.get_project_details(params)
|
||||
@@ -48,5 +50,6 @@ class Crawlers::ProjectsCrawlerController < Crawlers::TissCrawlerController
|
||||
end
|
||||
|
||||
def add_annotation
|
||||
store_annotation FavoriteProject, 'Project', {id: params[:id]}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,6 +21,8 @@ class Crawlers::ThesesCrawlerController < Crawlers::TissCrawlerController
|
||||
|
||||
@id = params[:id]
|
||||
|
||||
@personal_annotation = get_stored_annotation FavoriteThesis, {id: @id}
|
||||
|
||||
puts params
|
||||
# TissCrawler fetches the thesis' detail information
|
||||
@thesis = TissCrawler.get_thesis_details(params)
|
||||
@@ -48,5 +50,6 @@ class Crawlers::ThesesCrawlerController < Crawlers::TissCrawlerController
|
||||
end
|
||||
|
||||
def add_annotation
|
||||
store_annotation FavoriteThesis, 'Thesis', {id: params[:id]}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -40,16 +40,20 @@ class Crawlers::TissCrawlerController < ApplicationController
|
||||
|
||||
private
|
||||
def get_stored_annotation(object, id_hash)
|
||||
if object.exists?(params[:tiss_id])
|
||||
object.where(id_hash, user_id: current_user.id)[0]['personal_annotation']
|
||||
id_hash['user_id'] = current_user
|
||||
if object.exists?(id_hash)
|
||||
object.where(id_hash)[0]['personal_annotation']
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
def store_annotation(object, object_name, id)
|
||||
if object.exists?(id)
|
||||
object.update(id, :personal_annotation => params[:body])
|
||||
def store_annotation(object, object_name, id_hash)
|
||||
id_hash['user_id'] = current_user
|
||||
|
||||
# Allow storing empty strings as a way of "clearing" the stored val
|
||||
if object.exists?(id_hash)
|
||||
object.where(id_hash)[0].update(:personal_annotation => params[:body])
|
||||
flash[:alert] = 'Annotation stored!'
|
||||
else
|
||||
flash[:alert] = object_name + ' has to be favorited first!'
|
||||
|
||||
Reference in New Issue
Block a user