personal annotations for all classes implemented
This commit is contained in:
parent
9881e7962d
commit
1e87036094
@ -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!'
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<%= form_tag "add_annotation", :id => "id" do -%>
|
||||
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
|
||||
<p>
|
||||
Add an annotation:
|
||||
</p>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<% if @course != nil %>
|
||||
<%-# TODO parse more fields and style them appropriately -%>
|
||||
<h2><%= @course['title']['de'] %></h2>
|
||||
<h2>Course: <%= @course['title']['de'] %></h2>
|
||||
<h5><%= @course['courseType'] %> <%= @course['semesterCode'] %>, <%= @course['weeklyHours'] %> SWS, <%= @course['instituteCode'] %> <%= @course['instituteName']['de'] %> </h5>
|
||||
<%= button_to 'Add to favorites', action: :add_to_fav, number: @course['courseNumber'], semester: @course['semesterCode'] %>
|
||||
<% if @lecturers_names != nil %>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<% if @person != nil %>
|
||||
<h2><%= @person['first_name'] %> <%= @person['last_name'] %></h2>
|
||||
<h2>Person: <%= @person['first_name'] %> <%= @person['last_name'] %></h2>
|
||||
<div class="profile-picture">
|
||||
<% if @person['picture_uri'] != nil %>
|
||||
<%= image_tag @host + @person['picture_uri'] %>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<% if @project != nil %>
|
||||
<h2><%= @project['titleDe'] %></h2>
|
||||
<h2>Project: <%= @project['titleDe'] %></h2>
|
||||
<h5><%= @project['contractBegin'] %> - <%= @project['contractEnd'] %></h5>
|
||||
<%= button_to 'Add to favorites', action: :add_to_fav, id: @id, title: @project['titleDe'] %>
|
||||
<% if @project['abstractDe'] != nil %>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<% if @thesis != nil %>
|
||||
<h2><%= @thesis['title']['de'] %></h2>
|
||||
<h2>Thesis: <%= @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 %>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user