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]
|
params[:semester] = regex[:semester]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@personal_annotation = get_stored_annotation FavoriteCourse, {number: params[:number]}
|
||||||
|
|
||||||
puts params
|
puts params
|
||||||
|
|
||||||
# TissCrawler fetches the course's detail information
|
# TissCrawler fetches the course's detail information
|
||||||
@ -83,6 +85,7 @@ class Crawlers::CoursesCrawlerController < Crawlers::TissCrawlerController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_annotation
|
def add_annotation
|
||||||
|
store_annotation FavoriteCourse, 'Course', {number: params[:id]}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -53,7 +53,7 @@ class Crawlers::PeopleCrawlerController < Crawlers::TissCrawlerController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_annotation
|
def add_annotation
|
||||||
store_annotation FavoritePerson, 'Person', params[:id]
|
store_annotation FavoritePerson, 'Person', {tiss_id: params[:id]}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,6 +21,8 @@ class Crawlers::ProjectsCrawlerController < Crawlers::TissCrawlerController
|
|||||||
|
|
||||||
@id = params[:id]
|
@id = params[:id]
|
||||||
|
|
||||||
|
@personal_annotation = get_stored_annotation FavoriteProject, {id: @id}
|
||||||
|
|
||||||
puts params
|
puts params
|
||||||
# TissCrawler fetches the project's detail information
|
# TissCrawler fetches the project's detail information
|
||||||
@project = TissCrawler.get_project_details(params)
|
@project = TissCrawler.get_project_details(params)
|
||||||
@ -48,5 +50,6 @@ class Crawlers::ProjectsCrawlerController < Crawlers::TissCrawlerController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_annotation
|
def add_annotation
|
||||||
|
store_annotation FavoriteProject, 'Project', {id: params[:id]}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,6 +21,8 @@ class Crawlers::ThesesCrawlerController < Crawlers::TissCrawlerController
|
|||||||
|
|
||||||
@id = params[:id]
|
@id = params[:id]
|
||||||
|
|
||||||
|
@personal_annotation = get_stored_annotation FavoriteThesis, {id: @id}
|
||||||
|
|
||||||
puts params
|
puts params
|
||||||
# TissCrawler fetches the thesis' detail information
|
# TissCrawler fetches the thesis' detail information
|
||||||
@thesis = TissCrawler.get_thesis_details(params)
|
@thesis = TissCrawler.get_thesis_details(params)
|
||||||
@ -48,5 +50,6 @@ class Crawlers::ThesesCrawlerController < Crawlers::TissCrawlerController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_annotation
|
def add_annotation
|
||||||
|
store_annotation FavoriteThesis, 'Thesis', {id: params[:id]}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -40,16 +40,20 @@ class Crawlers::TissCrawlerController < ApplicationController
|
|||||||
|
|
||||||
private
|
private
|
||||||
def get_stored_annotation(object, id_hash)
|
def get_stored_annotation(object, id_hash)
|
||||||
if object.exists?(params[:tiss_id])
|
id_hash['user_id'] = current_user
|
||||||
object.where(id_hash, user_id: current_user.id)[0]['personal_annotation']
|
if object.exists?(id_hash)
|
||||||
|
object.where(id_hash)[0]['personal_annotation']
|
||||||
else
|
else
|
||||||
""
|
""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def store_annotation(object, object_name, id)
|
def store_annotation(object, object_name, id_hash)
|
||||||
if object.exists?(id)
|
id_hash['user_id'] = current_user
|
||||||
object.update(id, :personal_annotation => params[:body])
|
|
||||||
|
# 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!'
|
flash[:alert] = 'Annotation stored!'
|
||||||
else
|
else
|
||||||
flash[:alert] = object_name + ' has to be favorited first!'
|
flash[:alert] = object_name + ' has to be favorited first!'
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
<%= form_tag "add_annotation", :id => "id" do -%>
|
<%= form_tag "add_annotation", :id => "id" do -%>
|
||||||
|
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
|
||||||
<p>
|
<p>
|
||||||
Add an annotation:
|
Add an annotation:
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<% if @course != nil %>
|
<% if @course != nil %>
|
||||||
<%-# TODO parse more fields and style them appropriately -%>
|
<%-# 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>
|
<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'] %>
|
<%= button_to 'Add to favorites', action: :add_to_fav, number: @course['courseNumber'], semester: @course['semesterCode'] %>
|
||||||
<% if @lecturers_names != nil %>
|
<% if @lecturers_names != nil %>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<% if @person != nil %>
|
<% if @person != nil %>
|
||||||
<h2><%= @person['first_name'] %> <%= @person['last_name'] %></h2>
|
<h2>Person: <%= @person['first_name'] %> <%= @person['last_name'] %></h2>
|
||||||
<div class="profile-picture">
|
<div class="profile-picture">
|
||||||
<% if @person['picture_uri'] != nil %>
|
<% if @person['picture_uri'] != nil %>
|
||||||
<%= image_tag @host + @person['picture_uri'] %>
|
<%= image_tag @host + @person['picture_uri'] %>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<% if @project != nil %>
|
<% if @project != nil %>
|
||||||
<h2><%= @project['titleDe'] %></h2>
|
<h2>Project: <%= @project['titleDe'] %></h2>
|
||||||
<h5><%= @project['contractBegin'] %> - <%= @project['contractEnd'] %></h5>
|
<h5><%= @project['contractBegin'] %> - <%= @project['contractEnd'] %></h5>
|
||||||
<%= button_to 'Add to favorites', action: :add_to_fav, id: @id, title: @project['titleDe'] %>
|
<%= button_to 'Add to favorites', action: :add_to_fav, id: @id, title: @project['titleDe'] %>
|
||||||
<% if @project['abstractDe'] != nil %>
|
<% if @project['abstractDe'] != nil %>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<% if @thesis != nil %>
|
<% if @thesis != nil %>
|
||||||
<h2><%= @thesis['title']['de'] %></h2>
|
<h2>Thesis: <%= @thesis['title']['de'] %></h2>
|
||||||
<h5><%= @thesis['thesisType'] %>, <%= @thesis['instituteCode'] %> <%= @thesis['instituteName']['de'] %></h5>
|
<h5><%= @thesis['thesisType'] %>, <%= @thesis['instituteCode'] %> <%= @thesis['instituteName']['de'] %></h5>
|
||||||
<%= button_to 'Add to favorites', action: :add_to_fav, id: @id, title: @thesis['title']['de'] %>
|
<%= button_to 'Add to favorites', action: :add_to_fav, id: @id, title: @thesis['title']['de'] %>
|
||||||
<% if @thesis['advisor'] != nil %>
|
<% if @thesis['advisor'] != nil %>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user