Skip to content
This repository has been archived by the owner on Aug 20, 2019. It is now read-only.

Commit

Permalink
modified: app/models/audio_event.rb
Browse files Browse the repository at this point in the history
modified:   app/models/audio_event_tag.rb
modified:   app/models/audio_recording.rb
modified:   app/models/project.rb
modified:   app/models/site.rb
modified:   app/models/tag.rb
	-- added proper foregin key notation for creator_id fields (from userstamp)

modified:   config/routes.rb
new file:   app/assets/javascripts/bookmarks.js.coffee
new file:   app/assets/javascripts/progresses.js.coffee
new file:   app/assets/javascripts/saved_searches.js.coffee
new file:   app/assets/stylesheets/bookmarks.css.scss
new file:   app/assets/stylesheets/progresses.css.scss
new file:   app/assets/stylesheets/saved_searches.css.scss
new file:   app/controllers/bookmarks_controller.rb
new file:   app/controllers/progresses_controller.rb
new file:   app/controllers/saved_searches_controller.rb
new file:   app/helpers/bookmarks_helper.rb
new file:   app/helpers/progresses_helper.rb
new file:   app/helpers/saved_searches_helper.rb
new file:   app/views/bookmarks/_form.html.erb
new file:   app/views/bookmarks/edit.html.erb
new file:   app/views/bookmarks/index.html.erb
new file:   app/views/bookmarks/new.html.erb
new file:   app/views/bookmarks/show.html.erb
new file:   app/views/progresses/_form.html.erb
new file:   app/views/progresses/edit.html.erb
new file:   app/views/progresses/index.html.erb
new file:   app/views/progresses/new.html.erb
new file:   app/views/progresses/show.html.erb
new file:   app/views/saved_searches/_form.html.erb
new file:   app/views/saved_searches/edit.html.erb
new file:   app/views/saved_searches/index.html.erb
new file:   app/views/saved_searches/new.html.erb
new file:   app/views/saved_searches/show.html.erb
new file:   test/fixtures/bookmarks.yml
new file:   test/fixtures/progresses.yml
new file:   test/fixtures/saved_searches.yml
new file:   test/functional/bookmarks_controller_test.rb
new file:   test/functional/progresses_controller_test.rb
new file:   test/functional/saved_searches_controller_test.rb
new file:   test/unit/bookmark_test.rb
new file:   test/unit/helpers/bookmarks_helper_test.rb
new file:   test/unit/helpers/progresses_helper_test.rb
new file:   test/unit/helpers/saved_searches_helper_test.rb
new file:   test/unit/progress_test.rb
new file:   test/unit/saved_search_test.rb
new file:   app/models/saved_search.rb
new file:   db/migrate/20121119025736_create_saved_searches.rb
new file:   db/migrate/20121119032032_create_progresses.rb
new file:   db/migrate/20121119063100_create_bookmarks.rb
new file:   app/models/bookmark.rb
new file:   app/models/progress.rb
	-- rails scaffold bookmarks, progress, and saved searches. also added validation. did not make tests.
  • Loading branch information
atruskie committed Nov 19, 2012
1 parent b129c1a commit 0e7531c
Show file tree
Hide file tree
Showing 53 changed files with 957 additions and 7 deletions.
3 changes: 3 additions & 0 deletions app/assets/javascripts/bookmarks.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/javascripts/progresses.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/javascripts/saved_searches.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/bookmarks.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Bookmarks controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/progresses.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Progresses controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/saved_searches.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the SavedSearches controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
83 changes: 83 additions & 0 deletions app/controllers/bookmarks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
class BookmarksController < ApplicationController
# GET /bookmarks
# GET /bookmarks.json
def index
@bookmarks = Bookmark.all

respond_to do |format|
format.html # index.html.erb
format.json { render json: @bookmarks }
end
end

# GET /bookmarks/1
# GET /bookmarks/1.json
def show
@bookmark = Bookmark.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.json { render json: @bookmark }
end
end

# GET /bookmarks/new
# GET /bookmarks/new.json
def new
@bookmark = Bookmark.new

respond_to do |format|
format.html # new.html.erb
format.json { render json: @bookmark }
end
end

# GET /bookmarks/1/edit
def edit
@bookmark = Bookmark.find(params[:id])
end

# POST /bookmarks
# POST /bookmarks.json
def create
@bookmark = Bookmark.new(params[:bookmark])

respond_to do |format|
if @bookmark.save
format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }
format.json { render json: @bookmark, status: :created, location: @bookmark }
else
format.html { render action: "new" }
format.json { render json: @bookmark.errors, status: :unprocessable_entity }
end
end
end

# PUT /bookmarks/1
# PUT /bookmarks/1.json
def update
@bookmark = Bookmark.find(params[:id])

respond_to do |format|
if @bookmark.update_attributes(params[:bookmark])
format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @bookmark.errors, status: :unprocessable_entity }
end
end
end

# DELETE /bookmarks/1
# DELETE /bookmarks/1.json
def destroy
@bookmark = Bookmark.find(params[:id])
@bookmark.destroy

respond_to do |format|
format.html { redirect_to bookmarks_url }
format.json { head :no_content }
end
end
end
83 changes: 83 additions & 0 deletions app/controllers/progresses_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
class ProgressesController < ApplicationController
# GET /progresses
# GET /progresses.json
def index
@progresses = Progress.all

respond_to do |format|
format.html # index.html.erb
format.json { render json: @progresses }
end
end

# GET /progresses/1
# GET /progresses/1.json
def show
@progress = Progress.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.json { render json: @progress }
end
end

# GET /progresses/new
# GET /progresses/new.json
def new
@progress = Progress.new

respond_to do |format|
format.html # new.html.erb
format.json { render json: @progress }
end
end

# GET /progresses/1/edit
def edit
@progress = Progress.find(params[:id])
end

# POST /progresses
# POST /progresses.json
def create
@progress = Progress.new(params[:progress])

respond_to do |format|
if @progress.save
format.html { redirect_to @progress, notice: 'Progress was successfully created.' }
format.json { render json: @progress, status: :created, location: @progress }
else
format.html { render action: "new" }
format.json { render json: @progress.errors, status: :unprocessable_entity }
end
end
end

# PUT /progresses/1
# PUT /progresses/1.json
def update
@progress = Progress.find(params[:id])

respond_to do |format|
if @progress.update_attributes(params[:progress])
format.html { redirect_to @progress, notice: 'Progress was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @progress.errors, status: :unprocessable_entity }
end
end
end

# DELETE /progresses/1
# DELETE /progresses/1.json
def destroy
@progress = Progress.find(params[:id])
@progress.destroy

respond_to do |format|
format.html { redirect_to progresses_url }
format.json { head :no_content }
end
end
end
83 changes: 83 additions & 0 deletions app/controllers/saved_searches_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
class SavedSearchesController < ApplicationController
# GET /saved_searches
# GET /saved_searches.json
def index
@saved_searches = SavedSearch.all

respond_to do |format|
format.html # index.html.erb
format.json { render json: @saved_searches }
end
end

# GET /saved_searches/1
# GET /saved_searches/1.json
def show
@saved_search = SavedSearch.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.json { render json: @saved_search }
end
end

# GET /saved_searches/new
# GET /saved_searches/new.json
def new
@saved_search = SavedSearch.new

respond_to do |format|
format.html # new.html.erb
format.json { render json: @saved_search }
end
end

# GET /saved_searches/1/edit
def edit
@saved_search = SavedSearch.find(params[:id])
end

# POST /saved_searches
# POST /saved_searches.json
def create
@saved_search = SavedSearch.new(params[:saved_search])

respond_to do |format|
if @saved_search.save
format.html { redirect_to @saved_search, notice: 'Saved search was successfully created.' }
format.json { render json: @saved_search, status: :created, location: @saved_search }
else
format.html { render action: "new" }
format.json { render json: @saved_search.errors, status: :unprocessable_entity }
end
end
end

# PUT /saved_searches/1
# PUT /saved_searches/1.json
def update
@saved_search = SavedSearch.find(params[:id])

respond_to do |format|
if @saved_search.update_attributes(params[:saved_search])
format.html { redirect_to @saved_search, notice: 'Saved search was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @saved_search.errors, status: :unprocessable_entity }
end
end
end

# DELETE /saved_searches/1
# DELETE /saved_searches/1.json
def destroy
@saved_search = SavedSearch.find(params[:id])
@saved_search.destroy

respond_to do |format|
format.html { redirect_to saved_searches_url }
format.json { head :no_content }
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/bookmarks_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module BookmarksHelper
end
2 changes: 2 additions & 0 deletions app/helpers/progresses_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ProgressesHelper
end
2 changes: 2 additions & 0 deletions app/helpers/saved_searches_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module SavedSearchesHelper
end
2 changes: 1 addition & 1 deletion app/models/audio_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AudioEvent < ActiveRecord::Base

# userstamp
stampable
belongs_to :user
belongs_to :user, :class_name => 'User', :foreign_key => :creator_id
acts_as_paranoid
validates_as_paranoid

Expand Down
8 changes: 7 additions & 1 deletion app/models/audio_event_tag.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
class AudioEventTag < ActiveRecord::Base

# relations
belongs_to :audio_event
belongs_to :tag

# userstamp
stampable
belongs_to :user
bbelongs_to :user, :class_name => 'User', :foreign_key => :creator_id

# validations
validates :audio_event_id, :presence => true
validates :tag_id, :presence => true

end
2 changes: 1 addition & 1 deletion app/models/audio_recording.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AudioRecording < ActiveRecord::Base

# userstamp
stampable
belongs_to :user
belongs_to :user, :class_name => 'User', :foreign_key => :creator_id
acts_as_paranoid
validates_as_paranoid

Expand Down
21 changes: 21 additions & 0 deletions app/models/bookmark.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Bookmark < ActiveRecord::Base
# flex store
store :notes

# relations
belongs_to :audio_recording

# attr
attr_accessible :name, :notes, :offset

# userstamp
stampable
belongs_to :user, :class_name => 'User', :foreign_key => :creator_id

# validation
validates :offset, :presence => true, :numericality => { :greater_than_or_equal_to => 0 }
validates :audio_recording_id, :presence => true



end
41 changes: 41 additions & 0 deletions app/models/progress.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class Progress < ActiveRecord::Base
# this model is a 6-way composite key with a value between these fields:
# user, activity, saved search, audio recording, start offset, and end offset

# relations
belongs_to :saved_search
belongs_to :audio_recording

# attr
attr_accessible :offset_list, # <- this is the actual data packet
# ↓ these are just keys ↓
:activity, :saved_search_id, :audio_recording_id,
:start_offset_seconds, :end_offset_seconds


# userstamp
stampable
belongs_to :user, :class_name => 'User', :foreign_key => :creator_id

# validation
validates_uniqueness_of :activity,
:scope => [:saved_search_id, :audio_recording_id,
:start_offset_seconds, :end_offset_seconds, :creator_id ]

validates_presence_of :activity, :saved_search_id, :audio_recording_id,
:start_offset_seconds, :end_offset_seconds, :creator_id

validates :start_offset_seconds, :presence => true, :numericality => { :greater_than_or_equal_to => 0 }
validates :end_offset_seconds, :presence => true, :numericality => { :greater_than_or_equal_to => 0 }
validate :start_time_must_be_lte_end_time

# custom validation methods
def start_time_must_be_lte_end_time

if start_offset_seconds > end_offset_seconds then
errors.add(:start_time_seconds, " start offset must be lower than end offset")
end
end


end
2 changes: 1 addition & 1 deletion app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Project < ActiveRecord::Base

# userstamp
stampable
belongs_to :user
belongs_to :user, :class_name => 'User', :foreign_key => :creator_id
acts_as_paranoid
validates_as_paranoid

Expand Down
Loading

0 comments on commit 0e7531c

Please sign in to comment.