diff --git a/.gitignore b/.gitignore index 705de5c..a550897 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ # Ignore the default SQLite database. /db/*.sqlite3 +/db/*.sqlite3.* # Ignore all logfiles and tempfiles. /log/*.log @@ -17,5 +18,7 @@ # Ignore compiled assets /public/assets -# Ignore config file +# Ignore config and database files (passwords) /config/config.yml +/config/database.yml +/config/initializers/secret_token.rb diff --git a/Gemfile b/Gemfile index ca2b42f..e065e8b 100644 --- a/Gemfile +++ b/Gemfile @@ -8,6 +8,8 @@ gem 'rails', '3.2.3' # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3' +gem 'pg' +gem 'taps' gem 'json' diff --git a/Gemfile.lock b/Gemfile.lock index 0f56725..a338e91 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,6 +68,7 @@ GEM daemon_controller (>= 1.1.0) rack rake (>= 0.8.1) + pg (0.17.0) polyglot (0.3.3) rack (1.4.1) rack-cache (1.2) @@ -94,16 +95,26 @@ GEM rake (0.9.2.2) rdoc (3.12) json (~> 1.4) + rest-client (1.6.7) + mime-types (>= 1.16) sass (3.2.1) sass-rails (3.2.5) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) + sequel (3.20.0) + sinatra (1.0) + rack (>= 1.0) sprockets (2.1.3) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) sqlite3 (1.3.6) + taps (0.3.24) + rack (>= 1.0.1) + rest-client (>= 1.4.0, < 1.7.0) + sequel (~> 3.20.0) + sinatra (~> 1.0.0) therubyracer (0.10.1) libv8 (~> 3.3.10) thor (0.14.6) @@ -130,8 +141,10 @@ DEPENDENCIES jquery-rails json passenger + pg rails (= 3.2.3) sass-rails (~> 3.2.3) sqlite3 + taps therubyracer uglifier (>= 1.0.3) diff --git a/README.rdoc b/README.rdoc index 387e615..dbc77ce 100644 --- a/README.rdoc +++ b/README.rdoc @@ -10,6 +10,8 @@ Distributed under a Creative Commons Attribution 3.0 license http://creativecomm To use: * Load into a Rails 3 environment -* Rename config/config.yml.example to config/config.yml and edit appropriately +* Copy config/config.yml.example to config/config.yml and edit appropriately +* Copy config/database.yml.example to config/database.yml and edit appropriately +* Copy config/initializers/secret_token.rb.example to config/config/initializers/secret_token.rb and edit appropriately * Use the Rails console to create a new User and set user.admin = true * Run bundle install, rake db:migrate, etc. diff --git a/app/controllers/cards_controller.rb b/app/controllers/cards_controller.rb index fa00f01..60c42cb 100644 --- a/app/controllers/cards_controller.rb +++ b/app/controllers/cards_controller.rb @@ -16,7 +16,7 @@ class CardsController < ApplicationController @cards.each do |card| card_num_R = card.card_number.to_i(16)%32767 Rails.logger.info card_num_R - card[:accesses_this_week] = DoorLog.where('key = "G" AND data =? AND created_at > ?', card_num_R, DateTime.now - 7.days).order("created_at DESC").count + card[:accesses_this_week] = DoorLog.where("key = ? AND data = ? AND created_at > ?", 'G', card_num_R, DateTime.now - 7.days).order("created_at DESC").count Rails.logger.info card[:accesses_this_week] if(card[:accesses_this_week] > most_active_count) then Rails.logger.info "ACTIVE" @@ -37,7 +37,7 @@ class CardsController < ApplicationController def show if can? :read, DoorLog then card_num_R = @card.card_number.to_i(16)%32767 - @door_logs = DoorLog.where('key = "R" AND data =?', card_num_R).order("created_at DESC") + @door_logs = DoorLog.where('key = ? AND data = ?', "R", card_num_R).order("created_at DESC") end respond_to do |format| format.html # show.html.erb diff --git a/config/database.yml b/config/database.yml deleted file mode 100644 index 6c8cb16..0000000 --- a/config/database.yml +++ /dev/null @@ -1,31 +0,0 @@ -# SQLite version 3.x -# gem install sqlite3 -# -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem 'sqlite3' -development: - adapter: sqlite3 - database: db/development.sqlite3 - pool: 5 - timeout: 5000 - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - adapter: sqlite3 - database: db/test.sqlite3 - pool: 5 - timeout: 5000 - -production: - adapter: sqlite3 - database: db/production.sqlite3 - pool: 5 - timeout: 5000 -# adapter: postgresql -# encoding: unicode -# database: members -# pool: 5 -# username: postgres -# password: diff --git a/config/database.yml.example b/config/database.yml.example new file mode 100644 index 0000000..6769cb8 --- /dev/null +++ b/config/database.yml.example @@ -0,0 +1,54 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' + +# development: +# adapter: sqlite3 +# database: db/development.sqlite3 +# pool: 5 +# timeout: 5000 + +development: + adapter: postgresql + encoding: unicode + database: YOUR_DATABASE_development + host: localhost + pool: 5 + username: YOUR_USERNAME_HERE + password: YOUR_PASSWORD_HERE + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. + +# test: +# adapter: sqlite3 +# database: db/test.sqlite3 +# pool: 5 +# timeout: 5000 + +test: + adapter: postgresql + encoding: unicode + database: YOUR_DATABASE_test + host: localhost + pool: 5 + username: YOUR_USERNAME_HERE + password: YOUR_PASSWORD_HERE + +# production: +# adapter: sqlite3 +# database: db/production.sqlite3 +# pool: 5 +# timeout: 5000 + +production: + adapter: postgresql + encoding: unicode + database: YOUR_DATABASE_production + host: localhost + pool: 5 + username: YOUR_USERNAME_HERE + password: YOUR_PASSWORD_HERE \ No newline at end of file diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb.example similarity index 64% rename from config/initializers/secret_token.rb rename to config/initializers/secret_token.rb.example index a73d68b..eae3f95 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb.example @@ -4,4 +4,4 @@ # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -Dooraccess::Application.config.secret_token = 'd258ec483070c67d9e7ba7bb8b6b506a30fb38d0d95ac561ef603785f4639a688747a4adf872f627acae9b57f44f822a0c4dc2f2fd3d8e6135ad0b491f72751f' +Dooraccess::Application.config.secret_token = YOUR_RANDOM_STRING_HERE diff --git a/db/migrate/20130922060217_change_surveys_to_text.rb b/db/migrate/20130922060217_change_surveys_to_text.rb new file mode 100644 index 0000000..00670b5 --- /dev/null +++ b/db/migrate/20130922060217_change_surveys_to_text.rb @@ -0,0 +1,13 @@ +class ChangeSurveysToText < ActiveRecord::Migration + def up + change_column :users, :current_skills, :text, :limit => nil + change_column :users, :desired_skills, :text, :limit => nil + change_column :users, :marketing_source, :text, :limit => nil + end + + def down + change_column :users, :current_skills, :string + change_column :users, :desired_skills, :string + change_column :users, :marketing_source, :string + end +end diff --git a/db/migrate/20130922064241_change_member_level_to_integer.rb b/db/migrate/20130922064241_change_member_level_to_integer.rb new file mode 100644 index 0000000..3e61e12 --- /dev/null +++ b/db/migrate/20130922064241_change_member_level_to_integer.rb @@ -0,0 +1,9 @@ +class ChangeMemberLevelToInteger < ActiveRecord::Migration + def up + change_column :users, :member_level, :integer + end + + def down + change_column :users, :member_level, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 21e3651..6b07ea3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130829074549) do +ActiveRecord::Schema.define(:version => 20130922064241) do create_table "cards", :force => true do |t| t.string "card_number" @@ -146,14 +146,14 @@ ActiveRecord::Schema.define(:version => 20130829074549) do t.string "emergency_name" t.string "emergency_phone" t.string "emergency_email" - t.string "member_level" + t.integer "member_level", :limit => 255 t.string "payment_method" t.string "phone" - t.string "current_skills" - t.string "desired_skills" + t.text "current_skills" + t.text "desired_skills" t.boolean "instructor" t.boolean "hidden" - t.string "marketing_source" + t.text "marketing_source" t.string "payee" t.boolean "accountant" t.string "exit_reason"