-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
580 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the AudioEvents controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the AudioRecordings controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
class AudioEventsController < ApplicationController | ||
# GET /audio_events | ||
# GET /audio_events.json | ||
def index | ||
@audio_events = AudioEvent.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @audio_events } | ||
end | ||
end | ||
|
||
# GET /audio_events/1 | ||
# GET /audio_events/1.json | ||
def show | ||
@audio_event = AudioEvent.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @audio_event } | ||
end | ||
end | ||
|
||
# GET /audio_events/new | ||
# GET /audio_events/new.json | ||
def new | ||
@audio_event = AudioEvent.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @audio_event } | ||
end | ||
end | ||
|
||
# GET /audio_events/1/edit | ||
def edit | ||
@audio_event = AudioEvent.find(params[:id]) | ||
end | ||
|
||
# POST /audio_events | ||
# POST /audio_events.json | ||
def create | ||
@audio_event = AudioEvent.new(params[:audio_event]) | ||
|
||
respond_to do |format| | ||
if @audio_event.save | ||
format.html { redirect_to @audio_event, notice: 'Audio event was successfully created.' } | ||
format.json { render json: @audio_event, status: :created, location: @audio_event } | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @audio_event.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /audio_events/1 | ||
# PUT /audio_events/1.json | ||
def update | ||
@audio_event = AudioEvent.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @audio_event.update_attributes(params[:audio_event]) | ||
format.html { redirect_to @audio_event, notice: 'Audio event was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @audio_event.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /audio_events/1 | ||
# DELETE /audio_events/1.json | ||
def destroy | ||
@audio_event = AudioEvent.find(params[:id]) | ||
@audio_event.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to audio_events_url } | ||
format.json { head :no_content } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
class AudioRecordingsController < ApplicationController | ||
# GET /audio_recordings | ||
# GET /audio_recordings.json | ||
def index | ||
@audio_recordings = AudioRecording.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @audio_recordings } | ||
end | ||
end | ||
|
||
# GET /audio_recordings/1 | ||
# GET /audio_recordings/1.json | ||
def show | ||
@audio_recording = AudioRecording.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @audio_recording } | ||
end | ||
end | ||
|
||
# GET /audio_recordings/new | ||
# GET /audio_recordings/new.json | ||
def new | ||
@audio_recording = AudioRecording.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @audio_recording } | ||
end | ||
end | ||
|
||
# GET /audio_recordings/1/edit | ||
def edit | ||
@audio_recording = AudioRecording.find(params[:id]) | ||
end | ||
|
||
# POST /audio_recordings | ||
# POST /audio_recordings.json | ||
def create | ||
@audio_recording = AudioRecording.new(params[:audio_recording]) | ||
|
||
respond_to do |format| | ||
if @audio_recording.save | ||
format.html { redirect_to @audio_recording, notice: 'Audio recording was successfully created.' } | ||
format.json { render json: @audio_recording, status: :created, location: @audio_recording } | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @audio_recording.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /audio_recordings/1 | ||
# PUT /audio_recordings/1.json | ||
def update | ||
@audio_recording = AudioRecording.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @audio_recording.update_attributes(params[:audio_recording]) | ||
format.html { redirect_to @audio_recording, notice: 'Audio recording was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @audio_recording.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /audio_recordings/1 | ||
# DELETE /audio_recordings/1.json | ||
def destroy | ||
@audio_recording = AudioRecording.find(params[:id]) | ||
@audio_recording.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to audio_recordings_url } | ||
format.json { head :no_content } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module AudioEventsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module AudioRecordingsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class AudioEvent < ActiveRecord::Base | ||
belongs_to :audio_recording | ||
|
||
attr_accessible :end_time_seconds, :high_frequency_hertz, :is_reference, :low_frequency_hertz, :start_time_seconds | ||
|
||
# userstamp | ||
stampable | ||
belongs_to :user | ||
acts_as_paranoid | ||
|
||
# validation | ||
validates :start_time_seconds, :presence => true, :numericality => { :greater_than_or_equal_to => 0 } | ||
validates :end_time_seconds, :presence => true, :numericality => { :greater_than_or_equal_to => 0 } | ||
validates :start_time_must_be_less_than_end_time, :presence => true | ||
|
||
validates :low_frequency_hertz, :presence => true, :numericality => { :greater_than_or_equal_to => 0 } | ||
validates :high_frequency_hertz, :presence => true, :numericality => { :greater_than_or_equal_to => 0 } | ||
validates :low_frequency_must_be_less_than_or_equal_to_high_frequency, :presence => true | ||
|
||
# custom validation methods | ||
def start_time_must_be_less_than_or_equal_to_end_time | ||
if start_time_seconds > end_time_seconds then | ||
errors.add(:start_time_seconds, "must be lower than end time") | ||
end | ||
end | ||
|
||
def low_frequency_must_be_less_than_or_equal_to_high_frequency | ||
if low_frequency_hertz > high_frequency_hertz then | ||
errors.add(:start_time_seconds, "must be lower than high frequency") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class AudioRecording < ActiveRecord::Base | ||
store :notes | ||
belongs_to :user | ||
belongs_to :site | ||
attr_accessible :bit_rate_bps, :channels, :data_length_bytes, | ||
:duration_seconds, :hash, :media_type, :notes, | ||
:recorded_date, :sample_rate_hertz, :status | ||
|
||
stampable | ||
acts_as_paranoid | ||
|
||
# validation | ||
validates :uuid, :presence => true, :length => {:is => 36} | ||
validates :user, :presence => true | ||
|
||
validates :recorded_date, :presence => true, :on_or_before => :today | ||
validates :site, :presence => true | ||
validates :duration_seconds, :presence => true, :numericality => { :greater_than_or_equal_to => 0 } | ||
|
||
validates :sample_rate_hertz, :numericality => { :only_integer => true, :greater_than => 0 } | ||
validates :channels, :presence => true, :numericality => { :only_integer => true, :greater_than => 0 } | ||
validates :bit_rate_bps, :numericality => { :only_integer => true, :greater_than => 0 } | ||
validates :media_type, :presence => true | ||
validates :data_length_bytes, :presence => true, :numericality => { :only_integer => true, :greater_than_or_equal_to => 0 } | ||
|
||
validates :hash, :presence => true | ||
|
||
|
||
# uuid stuff | ||
attr_protected :uuid | ||
validates_presence_of :uuid | ||
validates_uniqueness_of :uuid | ||
|
||
include UUIDHelper | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<%= form_for(@audio_event) do |f| %> | ||
<% if @audio_event.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@audio_event.errors.count, "error") %> prohibited this audio_event from being saved:</h2> | ||
|
||
<ul> | ||
<% @audio_event.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :audio_recording %><br /> | ||
<%= f.text_field :audio_recording %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :start_time_seconds %><br /> | ||
<%= f.text_field :start_time_seconds %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :end_time_seconds %><br /> | ||
<%= f.text_field :end_time_seconds %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :low_frequency_hertz %><br /> | ||
<%= f.text_field :low_frequency_hertz %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :high_frequency %><br /> | ||
<%= f.text_field :high_frequency %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :is_reference %><br /> | ||
<%= f.text_field :is_reference %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing audio_event</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Show', @audio_event %> | | ||
<%= link_to 'Back', audio_events_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<h1>Listing audio_events</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Audio recording</th> | ||
<th>Start time seconds</th> | ||
<th>End time seconds</th> | ||
<th>Low frequency hertz</th> | ||
<th>High frequency</th> | ||
<th>Is reference</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
|
||
<% @audio_events.each do |audio_event| %> | ||
<tr> | ||
<td><%= audio_event.audio_recording %></td> | ||
<td><%= audio_event.start_time_seconds %></td> | ||
<td><%= audio_event.end_time_seconds %></td> | ||
<td><%= audio_event.low_frequency_hertz %></td> | ||
<td><%= audio_event.high_frequency %></td> | ||
<td><%= audio_event.is_reference %></td> | ||
<td><%= link_to 'Show', audio_event %></td> | ||
<td><%= link_to 'Edit', edit_audio_event_path(audio_event) %></td> | ||
<td><%= link_to 'Destroy', audio_event, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New Audio event', new_audio_event_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New audio_event</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Back', audio_events_path %> |
Oops, something went wrong.