initial checkin of full application

This commit is contained in:
ioBridge
2011-03-27 16:56:15 -04:00
parent a36868bc86
commit 740a1b338c
127 changed files with 13777 additions and 0 deletions

24
app/models/api_key.rb Normal file
View File

@ -0,0 +1,24 @@
class ApiKey < ActiveRecord::Base
belongs_to :channel
validates_uniqueness_of :api_key
end
# == Schema Information
#
# Table name: api_keys
#
# id :integer(4) not null, primary key
# api_key :string(16)
# channel_id :integer(4)
# user_id :integer(4)
# write_flag :boolean(1) default(FALSE)
# created_at :datetime
# updated_at :datetime
# note :string(255)
#

44
app/models/channel.rb Normal file
View File

@ -0,0 +1,44 @@
class Channel < ActiveRecord::Base
belongs_to :user
has_many :feeds
has_many :api_keys
end
# == Schema Information
#
# Table name: channels
#
# id :integer(4) not null, primary key
# user_id :integer(4)
# name :string(255)
# description :string(255)
# latitude :decimal(15, 10)
# longitude :decimal(15, 10)
# field1 :text
# field2 :text
# field3 :text
# field4 :text
# field5 :text
# field6 :text
# field7 :text
# field8 :text
# scale1 :integer(4)
# scale2 :integer(4)
# scale3 :integer(4)
# scale4 :integer(4)
# scale5 :integer(4)
# scale6 :integer(4)
# scale7 :integer(4)
# scale8 :integer(4)
# created_at :datetime
# updated_at :datetime
# elevation :string(255)
# last_entry_id :integer(4)
# public_flag :boolean(1) default(FALSE)
#

30
app/models/feed.rb Normal file
View File

@ -0,0 +1,30 @@
class Feed < ActiveRecord::Base
belongs_to :channel
self.include_root_in_json = false
end
# == Schema Information
#
# Table name: feeds
#
# id :integer(4) not null, primary key
# channel_id :integer(4)
# raw_data :text
# field1 :text
# field2 :text
# field3 :text
# field4 :text
# field5 :text
# field6 :text
# field7 :text
# field8 :text
# created_at :datetime
# updated_at :datetime
# entry_id :integer(4)
#

11
app/models/mailer.rb Normal file
View File

@ -0,0 +1,11 @@
class Mailer < ActionMailer::Base
#default :from => 'support@thingspeak.com'
def password_reset(user, webpage)
@user = user
@webpage = webpage
mail(:to => @user.email,
:subject => t(:password_reset_subject))
end
end

31
app/models/user.rb Normal file
View File

@ -0,0 +1,31 @@
class User < ActiveRecord::Base
has_many :channels
acts_as_authentic
def self.find_by_login_or_email(login)
User.find_by_login(login) || User.find_by_email(login)
end
end
# == Schema Information
#
# Table name: users
#
# id :integer(4) not null, primary key
# login :string(255) not null
# email :string(255) not null
# crypted_password :string(255) not null
# password_salt :string(255) not null
# persistence_token :string(255) not null
# perishable_token :string(255) not null
# current_login_at :datetime
# last_login_at :datetime
# current_login_ip :string(255)
# last_login_ip :string(255)
# created_at :datetime
# updated_at :datetime
# time_zone :string(255)
#

View File

@ -0,0 +1,7 @@
class UserSession < Authlogic::Session::Base
find_by_login_method :find_by_login_or_email
def to_key
new_record? ? nil : [ self.send(self.class.primary_key) ]
end
end