-
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.
deleted: .idea/.generators deleted: .idea/.name deleted: .idea/codeStyleSettings.xml deleted: .idea/dictionaries/n6330274.xml deleted: .idea/encodings.xml deleted: .idea/misc.xml deleted: .idea/modules.xml deleted: .idea/scopes/scope_settings.xml deleted: .idea/vcs.xml -- removed .idea folder from git - it should not be hosted publically anyway new file: app/assets/javascripts/tags.js.coffee new file: app/assets/stylesheets/tags.css.scss new file: app/controllers/tags_controller.rb new file: app/helpers/tags_helper.rb new file: app/models/tag.rb new file: app/views/tags/_form.html.erb new file: app/views/tags/edit.html.erb new file: app/views/tags/index.html.erb new file: app/views/tags/new.html.erb new file: app/views/tags/show.html.erb modified: config/routes.rb new file: db/migrate/20121031055154_create_tags.rb new file: test/fixtures/tags.yml new file: test/functional/tags_controller_test.rb new file: test/unit/helpers/tags_helper_test.rb new file: test/unit/tag_test.rb -- scaffolding for tags modified: test/test_helper.rb -- seeds.rb will be now be executed when running tests! modified: app/models/audio_event.rb new file: app/models/audio_event_tag.rb modified: app/models/audio_recording.rb modified: app/models/permission.rb modified: app/models/photo.rb modified: app/models/project.rb modified: app/models/site.rb modified: app/models/user.rb modified: db/migrate/20121030060408_create_audio_events.rb modified: db/migrate/20121031023244_create_permissions.rb new file: db/migrate/20121031060534_add_many_to_many_for_events_and_tags.rb -- added all the validation and relationships for all model elements and cleaned up files modified: db/schema.rb -- autogened by migration runner
- Loading branch information
Showing
28 changed files
with
351 additions
and
151 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 Tags 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,83 @@ | ||
class TagsController < ApplicationController | ||
# GET /tags | ||
# GET /tags.json | ||
def index | ||
@tags = Tag.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @tags } | ||
end | ||
end | ||
|
||
# GET /tags/1 | ||
# GET /tags/1.json | ||
def show | ||
@tag = Tag.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @tag } | ||
end | ||
end | ||
|
||
# GET /tags/new | ||
# GET /tags/new.json | ||
def new | ||
@tag = Tag.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @tag } | ||
end | ||
end | ||
|
||
# GET /tags/1/edit | ||
def edit | ||
@tag = Tag.find(params[:id]) | ||
end | ||
|
||
# POST /tags | ||
# POST /tags.json | ||
def create | ||
@tag = Tag.new(params[:tag]) | ||
|
||
respond_to do |format| | ||
if @tag.save | ||
format.html { redirect_to @tag, notice: 'Tag was successfully created.' } | ||
format.json { render json: @tag, status: :created, location: @tag } | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @tag.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /tags/1 | ||
# PUT /tags/1.json | ||
def update | ||
@tag = Tag.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @tag.update_attributes(params[:tag]) | ||
format.html { redirect_to @tag, notice: 'Tag was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @tag.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /tags/1 | ||
# DELETE /tags/1.json | ||
def destroy | ||
@tag = Tag.find(params[:id]) | ||
@tag.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to tags_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 TagsHelper | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class AudioEventTag < ActiveRecord::Base | ||
belongs_to :audio_event | ||
belongs_to :tag | ||
|
||
# userstamp | ||
stampable | ||
belongs_to :user | ||
|
||
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 |
---|---|---|
@@ -1,38 +1,51 @@ | ||
require 'timeliness' | ||
|
||
class AudioRecording < ActiveRecord::Base | ||
# flex store | ||
store :notes | ||
belongs_to :user | ||
|
||
# relations | ||
belongs_to :site | ||
has_many :audio_events | ||
|
||
# attr | ||
attr_accessible :bit_rate_bps, :channels, :data_length_bytes, | ||
:duration_seconds, :hash, :media_type, :notes, | ||
:recorded_date, :sample_rate_hertz, :status | ||
|
||
# userstamp | ||
stampable | ||
belongs_to :user | ||
acts_as_paranoid | ||
validates_as_paranoid | ||
|
||
# validation | ||
validates :uuid, :presence => true, :length => {:is => 36} | ||
validates :uuid, :presence => true, :length => {:is => 36}, :uniqueness => { :case_sensitive => false } | ||
validates :user, :presence => true | ||
|
||
validates :recorded_date, :presence => true, :on_or_before => :now | ||
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 :sample_rate_hertz, :numericality => { :only_integer => true, :greater_than_or_equal_to => 0 } | ||
|
||
# the channels field encodes our special version of a bit flag. 0 (no bits flipped) represents | ||
# a mix down option - we don't store mix downs (if we did they would be stored as single channel / mono (value = 1)) | ||
validates :channels, :presence => true, :numericality => { :only_integer => true, :greater_than => 0 } | ||
validates :bit_rate_bps, :numericality => { :only_integer => true, :greater_than => 0 } | ||
validates :bit_rate_bps, :numericality => { :only_integer => true, :greater_than_or_equal_to => 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 | ||
|
||
private | ||
|
||
# default values | ||
def default_values | ||
# empty | ||
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 |
---|---|---|
@@ -1,4 +1,37 @@ | ||
class Permission < ActiveRecord::Base | ||
extend Enumerize | ||
|
||
# relations | ||
belongs_to :user | ||
attr_accessible :level | ||
belongs_to :permissionable, :polymorphic => true | ||
|
||
# attr | ||
attr_accessible :level, :permissionable_type, :permissionable_id | ||
|
||
# userstamp | ||
stampable | ||
# belongs_to :user | ||
|
||
# enumerations | ||
enumerize :level, :in => [:owner, :write, :read, :none], :default => :none, predicates: true | ||
|
||
# validation | ||
validates :level, :presence => true | ||
validate :anonymous_permission_can_only_be_read_or_none | ||
|
||
|
||
# custom validation methods | ||
def anonymous_permission_can_only_be_read_or_none | ||
return unless self.user_id.nil? | ||
|
||
return if self.read? || self.none? | ||
|
||
errors.add(:level, "The permission level can only be 'read' or 'none' for anonymous permissions") | ||
end | ||
|
||
# methods | ||
def anonymous? | ||
self.user.nil? | ||
end | ||
|
||
end |
Oops, something went wrong.