Compare commits
57 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 75851ed88d | |||
| a022b72eb9 | |||
| 37106f65e0 | |||
| 1865123201 | |||
| 8ab6fa10ea | |||
| e9c648d36e | |||
| 7193ec832c | |||
| c547af5391 | |||
| 3d00bbed03 | |||
| 2327340b71 | |||
| 0b6975a655 | |||
| 95374a8c1f | |||
| 6d0a7b165a | |||
| bb7b2aeca5 | |||
| 7cadcabdce | |||
| 63b1b05010 | |||
| 653fcc3112 | |||
| 6e77b2bf68 | |||
| 43d949dc1d | |||
| fe283b051f | |||
| d44ae6a69f | |||
| cc3857604b | |||
| 4fc18013d9 | |||
| 31f220e121 | |||
| 257c1e5a8b | |||
|
|
0b5978d4ef | ||
| 1a9c77fbce | |||
|
|
4ad622e906 | ||
| d1ef1e7db9 | |||
| 0254f9aa2c | |||
| ccd432a67d | |||
| dc0586045f | |||
| 152d6e4e03 | |||
| 5174b4c50c | |||
| cd4f689400 | |||
| daa202131c | |||
| d73ea31625 | |||
| f3443a3a82 | |||
| ed8d284619 | |||
| 1f74d13ba7 | |||
| 921ba21a40 | |||
| 93e77b692f | |||
| 0bc5858101 | |||
| d3b8ad7222 | |||
| 03d99741e5 | |||
| 1e4dcfd9f3 | |||
| 33a9363b0d | |||
| f3a05d64c1 | |||
| c80c3bbe5c | |||
| 8c36b67cfb | |||
| 99f24fe144 | |||
| 72f5a1202a | |||
| 62fb513491 | |||
| 6df97cc3a7 | |||
| 7f623cf2ec | |||
| 8b775d9172 | |||
| b28efe046c |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -13,3 +13,9 @@
|
||||
# Ignore all logfiles and tempfiles.
|
||||
/log/*.log
|
||||
/tmp
|
||||
|
||||
# Ignore compiled assets
|
||||
/public/assets
|
||||
|
||||
# Ignore config file
|
||||
/config/config.yml
|
||||
|
||||
9
Gemfile
9
Gemfile
@@ -23,8 +23,12 @@ end
|
||||
|
||||
gem 'jquery-rails'
|
||||
|
||||
gem 'devise'
|
||||
|
||||
gem "cancan"
|
||||
|
||||
# To use ActiveModel has_secure_password
|
||||
# gem 'bcrypt-ruby', '~> 3.0.0'
|
||||
gem 'bcrypt-ruby', '~> 3.0.0'
|
||||
|
||||
# To use Jbuilder templates for JSON
|
||||
# gem 'jbuilder'
|
||||
@@ -37,3 +41,6 @@ gem 'jquery-rails'
|
||||
|
||||
# To use debugger
|
||||
# gem 'ruby-debug'
|
||||
|
||||
#gem "paperclip", "~> 3.0"
|
||||
gem 'gravtastic'
|
||||
|
||||
15
Gemfile.lock
15
Gemfile.lock
@@ -29,7 +29,9 @@ GEM
|
||||
i18n (~> 0.6)
|
||||
multi_json (~> 1.0)
|
||||
arel (3.0.2)
|
||||
bcrypt-ruby (3.0.1)
|
||||
builder (3.0.0)
|
||||
cancan (1.6.8)
|
||||
coffee-rails (3.2.2)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (~> 3.2.0)
|
||||
@@ -37,9 +39,15 @@ GEM
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.3.3)
|
||||
devise (2.1.1)
|
||||
bcrypt-ruby (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (~> 3.1)
|
||||
warden (~> 1.2.1)
|
||||
erubis (2.7.0)
|
||||
execjs (1.4.0)
|
||||
multi_json (~> 1.0)
|
||||
gravtastic (3.2.6)
|
||||
hike (1.2.1)
|
||||
i18n (0.6.0)
|
||||
journey (1.0.4)
|
||||
@@ -54,6 +62,7 @@ GEM
|
||||
treetop (~> 1.4.8)
|
||||
mime-types (1.19)
|
||||
multi_json (1.3.6)
|
||||
orm_adapter (0.1.0)
|
||||
polyglot (0.3.3)
|
||||
rack (1.4.1)
|
||||
rack-cache (1.2)
|
||||
@@ -101,12 +110,18 @@ GEM
|
||||
uglifier (1.2.7)
|
||||
execjs (>= 0.3.0)
|
||||
multi_json (~> 1.3)
|
||||
warden (1.2.1)
|
||||
rack (>= 1.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
bcrypt-ruby (~> 3.0.0)
|
||||
cancan
|
||||
coffee-rails (~> 3.2.1)
|
||||
devise
|
||||
gravtastic
|
||||
jquery-rails
|
||||
json
|
||||
rails (= 3.2.3)
|
||||
|
||||
270
README.rdoc
270
README.rdoc
@@ -1,261 +1,15 @@
|
||||
== Welcome to Rails
|
||||
== Open Access Control Web Interface
|
||||
Web software for managing a database of members in a collaborative grassroots workshop,
|
||||
and also controlling Arclight of 23b Hackerspace's Arduino access control system
|
||||
via Ethernet ( see: https://github.com/zyphlar/Open_Access_Control_Ethernet )
|
||||
|
||||
Rails is a web-application framework that includes everything needed to create
|
||||
database-backed web applications according to the Model-View-Control pattern.
|
||||
https://github.com/zyphlar/Open-Source-Access-Control-Web-Interface
|
||||
|
||||
This pattern splits the view (also called the presentation) into "dumb"
|
||||
templates that are primarily responsible for inserting pre-built data in between
|
||||
HTML tags. The model contains the "smart" domain objects (such as Account,
|
||||
Product, Person, Post) that holds all the business logic and knows how to
|
||||
persist themselves to a database. The controller handles the incoming requests
|
||||
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
||||
and directing data to the view.
|
||||
Copyright Will Bradley, 2012-2013
|
||||
Distributed under a Creative Commons Attribution 3.0 license http://creativecommons.org/licenses/by/3.0/
|
||||
|
||||
In Rails, the model is handled by what's called an object-relational mapping
|
||||
layer entitled Active Record. This layer allows you to present the data from
|
||||
database rows as objects and embellish these data objects with business logic
|
||||
methods. You can read more about Active Record in
|
||||
link:files/vendor/rails/activerecord/README.html.
|
||||
|
||||
The controller and view are handled by the Action Pack, which handles both
|
||||
layers by its two parts: Action View and Action Controller. These two layers
|
||||
are bundled in a single package due to their heavy interdependence. This is
|
||||
unlike the relationship between the Active Record and Action Pack that is much
|
||||
more separate. Each of these packages can be used independently outside of
|
||||
Rails. You can read more about Action Pack in
|
||||
link:files/vendor/rails/actionpack/README.html.
|
||||
|
||||
|
||||
== Getting Started
|
||||
|
||||
1. At the command prompt, create a new Rails application:
|
||||
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
|
||||
|
||||
2. Change directory to <tt>myapp</tt> and start the web server:
|
||||
<tt>cd myapp; rails server</tt> (run with --help for options)
|
||||
|
||||
3. Go to http://localhost:3000/ and you'll see:
|
||||
"Welcome aboard: You're riding Ruby on Rails!"
|
||||
|
||||
4. Follow the guidelines to start developing your application. You can find
|
||||
the following resources handy:
|
||||
|
||||
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
|
||||
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
|
||||
|
||||
|
||||
== Debugging Rails
|
||||
|
||||
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
||||
will help you debug it and get it back on the rails.
|
||||
|
||||
First area to check is the application log files. Have "tail -f" commands
|
||||
running on the server.log and development.log. Rails will automatically display
|
||||
debugging and runtime information to these files. Debugging info will also be
|
||||
shown in the browser on requests from 127.0.0.1.
|
||||
|
||||
You can also log your own messages directly into the log file from your code
|
||||
using the Ruby logger class from inside your controllers. Example:
|
||||
|
||||
class WeblogController < ActionController::Base
|
||||
def destroy
|
||||
@weblog = Weblog.find(params[:id])
|
||||
@weblog.destroy
|
||||
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
|
||||
end
|
||||
end
|
||||
|
||||
The result will be a message in your log file along the lines of:
|
||||
|
||||
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
||||
|
||||
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
||||
|
||||
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
||||
several books available online as well:
|
||||
|
||||
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
||||
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
||||
|
||||
These two books will bring you up to speed on the Ruby language and also on
|
||||
programming in general.
|
||||
|
||||
|
||||
== Debugger
|
||||
|
||||
Debugger support is available through the debugger command when you start your
|
||||
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
||||
execution at any point in the code, investigate and change the model, and then,
|
||||
resume execution! You need to install ruby-debug to run the server in debugging
|
||||
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
||||
|
||||
class WeblogController < ActionController::Base
|
||||
def index
|
||||
@posts = Post.all
|
||||
debugger
|
||||
end
|
||||
end
|
||||
|
||||
So the controller will accept the action, run the first line, then present you
|
||||
with a IRB prompt in the server window. Here you can do things like:
|
||||
|
||||
>> @posts.inspect
|
||||
=> "[#<Post:0x14a6be8
|
||||
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
||||
#<Post:0x14a6620
|
||||
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
||||
>> @posts.first.title = "hello from a debugger"
|
||||
=> "hello from a debugger"
|
||||
|
||||
...and even better, you can examine how your runtime objects actually work:
|
||||
|
||||
>> f = @posts.first
|
||||
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
||||
>> f.
|
||||
Display all 152 possibilities? (y or n)
|
||||
|
||||
Finally, when you're ready to resume execution, you can enter "cont".
|
||||
|
||||
|
||||
== Console
|
||||
|
||||
The console is a Ruby shell, which allows you to interact with your
|
||||
application's domain model. Here you'll have all parts of the application
|
||||
configured, just like it is when the application is running. You can inspect
|
||||
domain models, change values, and save to the database. Starting the script
|
||||
without arguments will launch it in the development environment.
|
||||
|
||||
To start the console, run <tt>rails console</tt> from the application
|
||||
directory.
|
||||
|
||||
Options:
|
||||
|
||||
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
||||
made to the database.
|
||||
* Passing an environment name as an argument will load the corresponding
|
||||
environment. Example: <tt>rails console production</tt>.
|
||||
|
||||
To reload your controllers and models after launching the console run
|
||||
<tt>reload!</tt>
|
||||
|
||||
More information about irb can be found at:
|
||||
link:http://www.rubycentral.org/pickaxe/irb.html
|
||||
|
||||
|
||||
== dbconsole
|
||||
|
||||
You can go to the command line of your database directly through <tt>rails
|
||||
dbconsole</tt>. You would be connected to the database with the credentials
|
||||
defined in database.yml. Starting the script without arguments will connect you
|
||||
to the development database. Passing an argument will connect you to a different
|
||||
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
||||
PostgreSQL and SQLite 3.
|
||||
|
||||
== Description of Contents
|
||||
|
||||
The default directory structure of a generated Ruby on Rails application:
|
||||
|
||||
|-- app
|
||||
| |-- assets
|
||||
| |-- images
|
||||
| |-- javascripts
|
||||
| `-- stylesheets
|
||||
| |-- controllers
|
||||
| |-- helpers
|
||||
| |-- mailers
|
||||
| |-- models
|
||||
| `-- views
|
||||
| `-- layouts
|
||||
|-- config
|
||||
| |-- environments
|
||||
| |-- initializers
|
||||
| `-- locales
|
||||
|-- db
|
||||
|-- doc
|
||||
|-- lib
|
||||
| `-- tasks
|
||||
|-- log
|
||||
|-- public
|
||||
|-- script
|
||||
|-- test
|
||||
| |-- fixtures
|
||||
| |-- functional
|
||||
| |-- integration
|
||||
| |-- performance
|
||||
| `-- unit
|
||||
|-- tmp
|
||||
| |-- cache
|
||||
| |-- pids
|
||||
| |-- sessions
|
||||
| `-- sockets
|
||||
`-- vendor
|
||||
|-- assets
|
||||
`-- stylesheets
|
||||
`-- plugins
|
||||
|
||||
app
|
||||
Holds all the code that's specific to this particular application.
|
||||
|
||||
app/assets
|
||||
Contains subdirectories for images, stylesheets, and JavaScript files.
|
||||
|
||||
app/controllers
|
||||
Holds controllers that should be named like weblogs_controller.rb for
|
||||
automated URL mapping. All controllers should descend from
|
||||
ApplicationController which itself descends from ActionController::Base.
|
||||
|
||||
app/models
|
||||
Holds models that should be named like post.rb. Models descend from
|
||||
ActiveRecord::Base by default.
|
||||
|
||||
app/views
|
||||
Holds the template files for the view that should be named like
|
||||
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
||||
eRuby syntax by default.
|
||||
|
||||
app/views/layouts
|
||||
Holds the template files for layouts to be used with views. This models the
|
||||
common header/footer method of wrapping views. In your views, define a layout
|
||||
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
||||
Inside default.html.erb, call <% yield %> to render the view using this
|
||||
layout.
|
||||
|
||||
app/helpers
|
||||
Holds view helpers that should be named like weblogs_helper.rb. These are
|
||||
generated for you automatically when using generators for controllers.
|
||||
Helpers can be used to wrap functionality for your views into methods.
|
||||
|
||||
config
|
||||
Configuration files for the Rails environment, the routing map, the database,
|
||||
and other dependencies.
|
||||
|
||||
db
|
||||
Contains the database schema in schema.rb. db/migrate contains all the
|
||||
sequence of Migrations for your schema.
|
||||
|
||||
doc
|
||||
This directory is where your application documentation will be stored when
|
||||
generated using <tt>rake doc:app</tt>
|
||||
|
||||
lib
|
||||
Application specific libraries. Basically, any kind of custom code that
|
||||
doesn't belong under controllers, models, or helpers. This directory is in
|
||||
the load path.
|
||||
|
||||
public
|
||||
The directory available for the web server. Also contains the dispatchers and the
|
||||
default HTML files. This should be set as the DOCUMENT_ROOT of your web
|
||||
server.
|
||||
|
||||
script
|
||||
Helper scripts for automation and generation.
|
||||
|
||||
test
|
||||
Unit and functional tests along with fixtures. When using the rails generate
|
||||
command, template test files will be generated for you and placed in this
|
||||
directory.
|
||||
|
||||
vendor
|
||||
External libraries that the application depends on. Also includes the plugins
|
||||
subdirectory. If the app has frozen rails, those gems also go here, under
|
||||
vendor/rails/. This directory is in the load path.
|
||||
To use:
|
||||
* Load into a Rails 3 environment
|
||||
* Rename config/config.yml.example to config/config.yml and edit appropriately
|
||||
* Use the Rails console to create a new User and set user.admin = true
|
||||
* Run bundle install, rake db:migrate, etc.
|
||||
|
||||
BIN
app/assets/images/logo.png
Normal file
BIN
app/assets/images/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
app/assets/images/nil.png
Normal file
BIN
app/assets/images/nil.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 95 B |
Binary file not shown.
|
Before Width: | Height: | Size: 6.5 KiB |
3
app/assets/javascripts/certifications.js.coffee
Normal file
3
app/assets/javascripts/certifications.js.coffee
Normal file
@@ -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
app/assets/javascripts/home.js.coffee
Normal file
3
app/assets/javascripts/home.js.coffee
Normal file
@@ -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
app/assets/javascripts/user_certifications.js.coffee
Normal file
3
app/assets/javascripts/user_certifications.js.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
jQuery ->
|
||||
$('.collapsible dt').click ->
|
||||
$(this).parent().toggleClass('expanded')
|
||||
@@ -1,3 +1,7 @@
|
||||
# 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/
|
||||
jQuery ->
|
||||
$('#user_payment_method').change ->
|
||||
$('.payment_instructions').hide()
|
||||
$('#pmt_'+$(this).val()).show()
|
||||
|
||||
3
app/assets/stylesheets/certifications.css.scss
Normal file
3
app/assets/stylesheets/certifications.css.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the Certifications controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
3
app/assets/stylesheets/home.css.scss
Normal file
3
app/assets/stylesheets/home.css.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the home controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
@@ -4,6 +4,7 @@ body {
|
||||
font-family: verdana, arial, helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
p, ol, ul, td {
|
||||
@@ -35,10 +36,28 @@ div {
|
||||
}
|
||||
}
|
||||
|
||||
#header {
|
||||
background-color: #eee; border: 1px solid #ddd;
|
||||
border-bottom-left-radius: 1em;
|
||||
border-bottom-right-radius: 1em;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
#header a {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
#logo {
|
||||
height: 2.0em;
|
||||
width: 2.0em;
|
||||
}
|
||||
|
||||
#notice {
|
||||
color: green;
|
||||
}
|
||||
|
||||
#content { margin: 1em; }
|
||||
|
||||
.field_with_errors {
|
||||
padding: 2px;
|
||||
background-color: red;
|
||||
@@ -67,3 +86,13 @@ div {
|
||||
list-style: square;
|
||||
}
|
||||
}
|
||||
|
||||
table { border-spacing: 0; }
|
||||
td, th { padding: 0.5em; }
|
||||
.col_highlight { background-color: #ccc; }
|
||||
dt { font-weight: bold; }
|
||||
.notice { color: green; }
|
||||
.alert { color: red; }
|
||||
.hidden, .hidden a { color: #ccc; }
|
||||
|
||||
.payment_instructions { display: none }
|
||||
|
||||
10
app/assets/stylesheets/user_certifications.css.scss
Normal file
10
app/assets/stylesheets/user_certifications.css.scss
Normal file
@@ -0,0 +1,10 @@
|
||||
// Place all the styles related to the UserCertifications controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
|
||||
.collapsible dt { cursor: pointer; }
|
||||
.collapsible dt:before { content: '\229e'; }
|
||||
.collapsible dd { display: none; }
|
||||
|
||||
.expanded dt:before { content: '\229f'; }
|
||||
.expanded dd { display: block; }
|
||||
@@ -1,3 +1,13 @@
|
||||
// Place all the styles related to the users controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
|
||||
.iconinfo, .hoverinfo { font-size: 1.5em; }
|
||||
.hoverinfo { cursor: progress; }
|
||||
|
||||
.payment_links { background-color: #ddd; padding: 1em; border-radius: 1em;
|
||||
display: inline-block; float: right; }
|
||||
|
||||
.avatar { height: 2em; width: 2em; }
|
||||
|
||||
textarea { height: 10em; }
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
if !current_user.nil? && current_user.orientation.blank? then
|
||||
flash[:alert] = "Sorry, you probably need to complete New Member Orientation before having access to this page. <br/>Please check your email and schedule a New Member Orientation with a volunteer."
|
||||
else
|
||||
flash[:alert] = "Nothing to see here!"
|
||||
end
|
||||
redirect_to root_url
|
||||
end
|
||||
|
||||
@payment_methods = [[nil],["PayPal"],["Dwolla"],["Bill Pay"],["Check"],["Cash"],["Other"]]
|
||||
@payment_instructions = {nil => nil, :paypal => "Set up a monthly recurring payment to hslfinances@gmail.com", :dwolla => "Set up a monthly recurring payment to hslfinances@gmail.com", :billpay => "Have your bank send a monthly check to HeatSync Labs Treasurer, 140 W Main St, Mesa AZ 85201", :check => "Mail to HeatSync Labs Treasurer, 140 W Main St, Mesa AZ 85201 OR put in the drop safe at the Lab with a deposit slip firmly attached each month.", :cash => "Put in the drop safe at the Lab with a deposit slip firmly attached each month.", :other => "Hmm... talk to a Treasurer!"}
|
||||
end
|
||||
|
||||
109
app/controllers/cards_controller.rb
Normal file
109
app/controllers/cards_controller.rb
Normal file
@@ -0,0 +1,109 @@
|
||||
class CardsController < ApplicationController
|
||||
load_and_authorize_resource
|
||||
before_filter :authenticate_user!
|
||||
|
||||
# GET /cards
|
||||
# GET /cards.json
|
||||
def index
|
||||
#@cards = Card.all
|
||||
#authorize! :read, @cards
|
||||
@cards = @cards.sort_by{|e| e[:id]}
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render :json => @cards }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /cards/1
|
||||
# GET /cards/1.json
|
||||
def show
|
||||
#@card = Card.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render :json => @card }
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /cards/1/upload
|
||||
def upload
|
||||
#@card = Card.find(params[:id])
|
||||
@upload_result = @card.upload_to_door
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render :json => @upload_result }
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /cards/upload_all
|
||||
def upload_all
|
||||
@upload_result = Card.upload_all_to_door
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render :json => @upload_result }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /cards/new
|
||||
# GET /cards/new.json
|
||||
def new
|
||||
#@card = Card.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render :json => @card }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /cards/1/edit
|
||||
def edit
|
||||
#@card = Card.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /cards
|
||||
# POST /cards.json
|
||||
def create
|
||||
#@card = Card.new(params[:card])
|
||||
|
||||
respond_to do |format|
|
||||
if @card.save
|
||||
format.html { redirect_to cards_url, :notice => 'Card was successfully created.' }
|
||||
format.json { render :json => @card, :status => :created, :location => @card }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.json { render :json => @card.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /cards/1
|
||||
# PUT /cards/1.json
|
||||
def update
|
||||
#@card = Card.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @card.update_attributes(params[:card])
|
||||
format.html { redirect_to cards_url, :notice => 'Card was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.json { render :json => @card.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /cards/1
|
||||
# DELETE /cards/1.json
|
||||
def destroy
|
||||
#@card = Card.find(params[:id])
|
||||
@card.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to cards_url, :notice => 'Card successfully deleted.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
end
|
||||
84
app/controllers/certifications_controller.rb
Normal file
84
app/controllers/certifications_controller.rb
Normal file
@@ -0,0 +1,84 @@
|
||||
class CertificationsController < ApplicationController
|
||||
load_and_authorize_resource :certification
|
||||
load_and_authorize_resource :user, :through => :certification
|
||||
before_filter :authenticate_user!
|
||||
|
||||
# GET /certifications
|
||||
# GET /certifications.json
|
||||
def index
|
||||
@certifications = @certifications.sort_by(&:name)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render :json => @certifications }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /certifications/1
|
||||
# GET /certifications/1.json
|
||||
def show
|
||||
@certification_users = []
|
||||
|
||||
#TODO: make a better SQL query for this
|
||||
@certification.users.sort_by(&:name).each do |user|
|
||||
@certification_users.push user if can? :read, user
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render :json => @certification }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /certifications/new
|
||||
# GET /certifications/new.json
|
||||
def new
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render :json => @certification }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /certifications/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /certifications
|
||||
# POST /certifications.json
|
||||
def create
|
||||
respond_to do |format|
|
||||
if @certification.save
|
||||
format.html { redirect_to Certification, :notice => 'Certification was successfully created.' }
|
||||
format.json { render :json => @certification, :status => :created, :location => @certification }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.json { render :json => @certification.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /certifications/1
|
||||
# PUT /certifications/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @certification.update_attributes(params[:certification])
|
||||
format.html { redirect_to Certification, :notice => 'Certification was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.json { render :json => @certification.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /certifications/1
|
||||
# DELETE /certifications/1.json
|
||||
def destroy
|
||||
@certification.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to certifications_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,8 +1,11 @@
|
||||
class DoorLogsController < ApplicationController
|
||||
authorize_resource :except => :auto_download
|
||||
before_filter :authenticate_user!, :except => :auto_download
|
||||
|
||||
# GET /door_logs
|
||||
# GET /door_logs.json
|
||||
def index
|
||||
@door_logs = DoorLog.all
|
||||
@door_logs = DoorLog.find(:all, :order => "created_at DESC", :limit => 500)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
@@ -10,19 +13,7 @@ class DoorLogsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
# GET /door_logs/1
|
||||
# GET /door_logs/1.json
|
||||
# def show
|
||||
# @door_log = DoorLog.find(params[:id])
|
||||
#
|
||||
# respond_to do |format|
|
||||
# format.html # show.html.erb
|
||||
# format.json { render :json => @door_log }
|
||||
# end
|
||||
# end
|
||||
|
||||
# GET /door_logs/1
|
||||
# GET /door_logs/1.json
|
||||
# GET /door_logs/download
|
||||
def download
|
||||
@results = DoorLog.download_from_door
|
||||
|
||||
@@ -32,63 +23,15 @@ class DoorLogsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
# # GET /door_logs/new
|
||||
# # GET /door_logs/new.json
|
||||
# def new
|
||||
# @door_log = DoorLog.new
|
||||
#
|
||||
# respond_to do |format|
|
||||
# format.html # new.html.erb
|
||||
# format.json { render :json => @door_log }
|
||||
# end
|
||||
# end
|
||||
# GET /door_logs/auto_download
|
||||
def auto_download
|
||||
@results = DoorLog.download_from_door
|
||||
|
||||
# GET /door_logs/1/edit
|
||||
# def edit
|
||||
# @door_log = DoorLog.find(params[:id])
|
||||
# end
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render :json => @results }
|
||||
end
|
||||
end
|
||||
|
||||
# POST /door_logs
|
||||
# POST /door_logs.json
|
||||
# def create
|
||||
# @door_log = DoorLog.new(params[:door_log])
|
||||
#
|
||||
# respond_to do |format|
|
||||
# if @door_log.save
|
||||
# format.html { redirect_to @door_log, :notice => 'Door log was successfully created.' }
|
||||
# format.json { render :json => @door_log, :status => :created, :location => @door_log }
|
||||
# else
|
||||
# format.html { render :action => "new" }
|
||||
# format.json { render :json => @door_log.errors, :status => :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# PUT /door_logs/1
|
||||
# PUT /door_logs/1.json
|
||||
# def update
|
||||
# @door_log = DoorLog.find(params[:id])
|
||||
#
|
||||
# respond_to do |format|
|
||||
# if @door_log.update_attributes(params[:door_log])
|
||||
# format.html { redirect_to @door_log, :notice => 'Door log was successfully updated.' }
|
||||
# format.json { head :no_content }
|
||||
# else
|
||||
# format.html { render :action => "edit" }
|
||||
# format.json { render :json => @door_log.errors, :status => :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# DELETE /door_logs/1
|
||||
# DELETE /door_logs/1.json
|
||||
# def destroy
|
||||
# @door_log = DoorLog.find(params[:id])
|
||||
# @door_log.destroy
|
||||
#
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to door_logs_url }
|
||||
# format.json { head :no_content }
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
18
app/controllers/home_controller.rb
Normal file
18
app/controllers/home_controller.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class HomeController < ApplicationController
|
||||
|
||||
def index
|
||||
@num_certs = UserCertification.count
|
||||
@recent_certs = UserCertification.where("created_at > ?", DateTime.now - 7.days).count
|
||||
@num_users = User.count
|
||||
@recent_users = User.where("created_at > ?", DateTime.now - 7.days).count
|
||||
@num_door_opens = DoorLog.where("key = 'G'").count
|
||||
@recent_door_opens = DoorLog.where("key = 'G' AND created_at > ?", DateTime.now - 7.days).count
|
||||
@num_door_denieds = DoorLog.where("key = 'D'").count
|
||||
@recent_door_denieds = DoorLog.where("key = 'D' AND created_at > ?", DateTime.now - 7.days).count
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
14
app/controllers/registrations_controller.rb
Normal file
14
app/controllers/registrations_controller.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class RegistrationsController < Devise::RegistrationsController
|
||||
protected
|
||||
|
||||
# After signup
|
||||
def after_sign_up_path_for(resource)
|
||||
'/users/edit/?flash=welcome_msg'
|
||||
end
|
||||
|
||||
# After edit
|
||||
def after_update_path_for(resource)
|
||||
'/users/edit'
|
||||
end
|
||||
|
||||
end
|
||||
94
app/controllers/user_certifications_controller.rb
Normal file
94
app/controllers/user_certifications_controller.rb
Normal file
@@ -0,0 +1,94 @@
|
||||
class UserCertificationsController < ApplicationController
|
||||
load_and_authorize_resource :user_certification
|
||||
load_and_authorize_resource :user, :through => :user_certification
|
||||
load_and_authorize_resource :certification, :through => :user_certification
|
||||
before_filter :authenticate_user!
|
||||
|
||||
# Load users and certs based on current ability
|
||||
before_filter :only => [:new, :edit, :create, :update] do
|
||||
@users = User.accessible_by(current_ability).sort_by(&:name)
|
||||
@certifications = Certification.accessible_by(current_ability).sort_by(&:name)
|
||||
end
|
||||
|
||||
# GET /user_certifications
|
||||
# GET /user_certifications.json
|
||||
def index
|
||||
@grouped_user_certs = @user_certifications.group_by { |uc| uc.certification }
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render :json => @user_certifications }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /user_certifications/1
|
||||
# GET /user_certifications/1.json
|
||||
def show
|
||||
@created_by = User.find(@user_certification.created_by) unless @user_certification.created_by.blank?
|
||||
@updated_by = User.find(@user_certification.updated_by) unless @user_certification.updated_by.blank?
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render :json => @user_certification }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /user_certifications/new
|
||||
# GET /user_certifications/new.json
|
||||
def new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render :json => @user_certification }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /user_certifications/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /user_certifications
|
||||
# POST /user_certifications.json
|
||||
def create
|
||||
#Log who created this
|
||||
@user_certification.created_by = current_user.id
|
||||
|
||||
respond_to do |format|
|
||||
if @user_certification.save
|
||||
format.html { redirect_to UserCertification, :notice => 'User certification was successfully created.' }
|
||||
format.json { render :json => @user_certification, :status => :created, :location => @user_certification }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.json { render :json => @user_certification.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /user_certifications/1
|
||||
# PUT /user_certifications/1.json
|
||||
def update
|
||||
#Log who updated this
|
||||
@user_certification.updated_by = current_user.id
|
||||
|
||||
respond_to do |format|
|
||||
if @user_certification.update_attributes(params[:user_certification])
|
||||
format.html { redirect_to UserCertification, :notice => 'User certification was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.json { render :json => @user_certification.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /user_certifications/1
|
||||
# DELETE /user_certifications/1.json
|
||||
def destroy
|
||||
@user_certification.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to user_certifications_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,8 +1,31 @@
|
||||
class UsersController < ApplicationController
|
||||
load_and_authorize_resource
|
||||
before_filter :authenticate_user!
|
||||
|
||||
# GET /users
|
||||
# GET /users.json
|
||||
def index
|
||||
@users = User.all
|
||||
case params[:sort]
|
||||
when "name"
|
||||
@users = @users.sort_by(&:name)
|
||||
when "certifications"
|
||||
@users = @users.sort_by{ |u| [-u.certifications.count,u.name] }
|
||||
when "orientation"
|
||||
@users = @users.sort_by{ |u| [-u.orientation.to_i,u.name] }
|
||||
when "waiver"
|
||||
@users = @users.sort_by{ |u| [-u.waiver.to_i,u.name] }
|
||||
when "member"
|
||||
@users = @users.sort_by{ |u| [-u.member.to_i,-u.member_level.to_i,u.name] }
|
||||
when "card"
|
||||
@users = @users.sort_by{ |u| [-u.cards.count,u.name] }
|
||||
when "instructor"
|
||||
@users = @users.sort{ |a,b| [b.instructor.to_s,a.name] <=> [a.instructor.to_s,b.name] }
|
||||
when "admin"
|
||||
@users = @users.sort{ |a,b| [b.admin.to_s,a.name] <=> [a.admin.to_s,b.name] }
|
||||
else
|
||||
@users = @users.sort_by(&:name)
|
||||
end
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
@@ -13,40 +36,15 @@ class UsersController < ApplicationController
|
||||
# GET /users/1
|
||||
# GET /users/1.json
|
||||
def show
|
||||
@user = User.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render :json => @user }
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /users/1/upload
|
||||
def upload
|
||||
@user = User.find(params[:id])
|
||||
@upload_result = @user.upload_to_door
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render :json => @upload_result }
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /users/upload_all
|
||||
def upload_all
|
||||
@upload_result = User.upload_all_to_door
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render :json => @upload_result }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /users/new
|
||||
# GET /users/new.json
|
||||
def new
|
||||
@user = User.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render :json => @user }
|
||||
@@ -55,17 +53,14 @@ class UsersController < ApplicationController
|
||||
|
||||
# GET /users/1/edit
|
||||
def edit
|
||||
@user = User.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /users
|
||||
# POST /users.json
|
||||
def create
|
||||
@user = User.new(params[:user])
|
||||
|
||||
respond_to do |format|
|
||||
if @user.save
|
||||
format.html { redirect_to @user, :notice => 'User was successfully created.' }
|
||||
format.html { redirect_to users_url, :notice => 'User was successfully created.' }
|
||||
format.json { render :json => @user, :status => :created, :location => @user }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
@@ -77,11 +72,9 @@ class UsersController < ApplicationController
|
||||
# PUT /users/1
|
||||
# PUT /users/1.json
|
||||
def update
|
||||
@user = User.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @user.update_attributes(params[:user])
|
||||
format.html { redirect_to @user, :notice => 'User was successfully updated.' }
|
||||
format.html { redirect_to users_url, :notice => 'User was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
@@ -93,11 +86,10 @@ class UsersController < ApplicationController
|
||||
# DELETE /users/1
|
||||
# DELETE /users/1.json
|
||||
def destroy
|
||||
@user = User.find(params[:id])
|
||||
@user.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to users_url }
|
||||
format.html { redirect_to users_url, :notice => 'User successfully deleted.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
module ApplicationHelper
|
||||
@payment_methods = [[nil],["PayPal"],["Dwolla"],["Bill Pay"],["Check"],["Cash"],["Other"]]
|
||||
@payment_instructions = {nil => nil, :paypal => "Set up a monthly recurring payment to hslfinances@gmail.com", :dwolla => "Set up a monthly recurring payment to hslfinances@gmail.com", :billpay => "Have your bank send a monthly check to HeatSync Labs Treasurer, 140 W Main St, Mesa AZ 85201", :check => "Mail to HeatSync Labs Treasurer, 140 W Main St, Mesa AZ 85201 OR put in the drop safe at the Lab with a deposit slip firmly attached each month.", :cash => "Put in the drop safe at the Lab with a deposit slip firmly attached each month.", :other => "Hmm... talk to a Treasurer!"}
|
||||
end
|
||||
|
||||
2
app/helpers/certifications_helper.rb
Normal file
2
app/helpers/certifications_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module CertificationsHelper
|
||||
end
|
||||
2
app/helpers/home_helper.rb
Normal file
2
app/helpers/home_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module HomeHelper
|
||||
end
|
||||
2
app/helpers/user_certifications_helper.rb
Normal file
2
app/helpers/user_certifications_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module UserCertificationsHelper
|
||||
end
|
||||
59
app/models/ability.rb
Normal file
59
app/models/ability.rb
Normal file
@@ -0,0 +1,59 @@
|
||||
class Ability
|
||||
include CanCan::Ability
|
||||
|
||||
def initialize(user)
|
||||
if !user.nil?
|
||||
|
||||
# By default, users can only see their own stuff
|
||||
can :read, Card, :user_id => user.id
|
||||
can :read, Certification
|
||||
can :read, User, :id => user.id #TODO: why can users update themselves?
|
||||
can :read, UserCertification, :user_id => user.id
|
||||
|
||||
# Admins can manage all
|
||||
if user.admin?
|
||||
can :manage, :all
|
||||
end
|
||||
# Instructors can manage certs and see users
|
||||
if user.instructor?
|
||||
can :manage, Certification
|
||||
can [:create,:read], User, :hidden => [nil,false]
|
||||
can :manage, UserCertification
|
||||
end
|
||||
# Users can see others' stuff if they've been oriented
|
||||
unless user.orientation.blank?
|
||||
can :read, User, :hidden => [nil,false]
|
||||
can :read, UserCertification
|
||||
end
|
||||
|
||||
# Prevent all destruction for now
|
||||
cannot :destroy, User
|
||||
cannot :destroy, Card
|
||||
cannot :destroy, Certification
|
||||
cannot :destroy, UserCertification
|
||||
cannot :destroy, DoorLog
|
||||
end
|
||||
# Define abilities for the passed in user here. For example:
|
||||
#
|
||||
# user ||= User.new # guest user (not logged in)
|
||||
# if user.admin?
|
||||
# can :manage, :all
|
||||
# else
|
||||
# can :read, :all
|
||||
# end
|
||||
#
|
||||
# The first argument to `can` is the action you are giving the user permission to do.
|
||||
# If you pass :manage it will apply to every action. Other common actions here are
|
||||
# :read, :create, :update and :destroy.
|
||||
#
|
||||
# The second argument is the resource the user can perform the action on. If you pass
|
||||
# :all it will apply to every resource. Otherwise pass a Ruby class of the resource.
|
||||
#
|
||||
# The third argument is an optional hash of conditions to further filter the objects.
|
||||
# For example, here the user can only update published articles.
|
||||
#
|
||||
# can :update, Article, :published => true
|
||||
#
|
||||
# See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
|
||||
end
|
||||
end
|
||||
77
app/models/card.rb
Normal file
77
app/models/card.rb
Normal file
@@ -0,0 +1,77 @@
|
||||
class Card < ActiveRecord::Base
|
||||
require 'open-uri'
|
||||
|
||||
attr_accessible :id, :user_id, :name, :card_number, :card_permissions
|
||||
validates_uniqueness_of :id,:card_number
|
||||
belongs_to :user
|
||||
|
||||
def upload_to_door
|
||||
# load config values
|
||||
door_access_url = APP_CONFIG['door_access_url']
|
||||
door_access_password = APP_CONFIG['door_access_password']
|
||||
|
||||
# connect to door access system
|
||||
source = open("#{door_access_url}?e=#{door_access_password}").read
|
||||
results = source.scan(/authok/)
|
||||
if(results.size > 0) then
|
||||
#only continue if we've got an OK login
|
||||
cardid = self.id.to_s.rjust(3, '0') #TODO: provide ability for
|
||||
cardperm = self.card_permissions.to_s.rjust(3, '0')
|
||||
cardnum = self.card_number.rjust(8, '0')
|
||||
|
||||
source = open("#{door_access_url}?m#{cardid}&p#{cardperm}&t#{cardnum}").read
|
||||
results = source.scan(/cur/)
|
||||
|
||||
#logout
|
||||
open("#{door_access_url}?e=0000")
|
||||
|
||||
if(results.size > 0) then
|
||||
#only return true if we got some kind of decent response
|
||||
return true
|
||||
else
|
||||
# We didn't get a decent response.
|
||||
return false
|
||||
end
|
||||
else
|
||||
# We didn't get an OK login.
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def self.upload_all_to_door
|
||||
@cards = Card.all
|
||||
@end_results = Array.new
|
||||
|
||||
# load config values
|
||||
door_access_url = APP_CONFIG['door_access_url']
|
||||
door_access_password = APP_CONFIG['door_access_password']
|
||||
|
||||
source = open("#{door_access_url}?e=#{door_access_password}").read
|
||||
results = source.scan(/authok/)
|
||||
if(results.size > 0) then
|
||||
@cards.each do |u|
|
||||
#only continue if we've got an OK login
|
||||
cardid = u.id.to_s.rjust(3, '0')
|
||||
cardperm = u.card_permissions.to_s.rjust(3, '0')
|
||||
cardnum = u.card_number.rjust(8, '0')
|
||||
|
||||
source = open("#{door_access_url}?m#{cardid}&p#{cardperm}&t#{cardnum}").read
|
||||
results = source.scan(/cur/)
|
||||
|
||||
if(results.size > 0) then
|
||||
#only return true if we got some kind of decent response
|
||||
@end_results.push([cardid,"OK"])
|
||||
else
|
||||
@end_results.push([cardid,"FAIL"])
|
||||
end
|
||||
end
|
||||
|
||||
#logout
|
||||
open("#{door_access_url}?e=0000")
|
||||
else
|
||||
@end_results.push([cardid,"FAIL"])
|
||||
end
|
||||
|
||||
return @end_results
|
||||
end
|
||||
end
|
||||
5
app/models/certification.rb
Normal file
5
app/models/certification.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class Certification < ActiveRecord::Base
|
||||
attr_accessible :description, :name
|
||||
has_many :user_certifications
|
||||
has_many :users, :through => :user_certifications
|
||||
end
|
||||
@@ -3,14 +3,18 @@ class DoorLog < ActiveRecord::Base
|
||||
require 'open-uri'
|
||||
|
||||
def self.download_from_door
|
||||
# do shit here
|
||||
source = open("http://192.168.1.177?e=1234").read
|
||||
# load config values
|
||||
door_access_url = APP_CONFIG['door_access_url']
|
||||
door_access_password = APP_CONFIG['door_access_password']
|
||||
|
||||
# connect to door access system
|
||||
source = open("#{door_access_url}?e=#{door_access_password}").read
|
||||
results = source.scan(/authok/)
|
||||
if(results.size > 0) then
|
||||
@end_results = Array.new
|
||||
|
||||
#only continue if we've got an OK login
|
||||
source = open("http://192.168.1.177?z").read
|
||||
source = open("#{door_access_url}?z").read
|
||||
results = source.scan(/(.*): (.*)\r\n/)
|
||||
|
||||
results.each do |r|
|
||||
@@ -20,9 +24,9 @@ class DoorLog < ActiveRecord::Base
|
||||
end
|
||||
|
||||
#clear log
|
||||
open("http://192.168.1.177?y")
|
||||
open("#{door_access_url}?y")
|
||||
#logout
|
||||
open("http://192.168.1.177?e=0000")
|
||||
open("#{door_access_url}?e=0000")
|
||||
|
||||
if(results.size > 0) then
|
||||
#only return true if we got some kind of decent response
|
||||
|
||||
@@ -1,68 +1,48 @@
|
||||
class User < ActiveRecord::Base
|
||||
require 'open-uri'
|
||||
include Gravtastic
|
||||
gravtastic :size => 120, :default => ""
|
||||
|
||||
attr_accessible :card_id, :card_number, :card_permissions, :name
|
||||
validates_uniqueness_of :card_id, :card_number
|
||||
# Include default devise modules. Others available are:
|
||||
# :token_authenticatable, :confirmable,
|
||||
# :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
def upload_to_door
|
||||
# do shit here
|
||||
source = open("http://192.168.1.177?e=1234").read
|
||||
results = source.scan(/authok/)
|
||||
if(results.size > 0) then
|
||||
#only continue if we've got an OK login
|
||||
usernum = self.card_id.to_s.rjust(3, '0')
|
||||
userperm = self.card_permissions.to_s.rjust(3, '0')
|
||||
cardnum = self.card_number.rjust(8, '0')
|
||||
# Setup accessible (or protected) attributes for your model
|
||||
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :admin, :instructor, :member, :emergency_name, :emergency_phone, :current_skills, :desired_skills, :waiver, :emergency_email, :phone, :payment_method, :orientation, :member_level, :certifications, :hidden #TODO: make admin/instructor/member/etc not accessible
|
||||
|
||||
source = open("http://192.168.1.177?m#{usernum}&p#{userperm}&t#{cardnum}").read
|
||||
results = source.scan(/cur/)
|
||||
has_many :cards
|
||||
has_many :user_certifications
|
||||
has_many :certifications, :through => :user_certifications
|
||||
|
||||
#logout
|
||||
open("http://192.168.1.177?e=0000")
|
||||
def member_status
|
||||
output = ""
|
||||
|
||||
if(results.size > 0) then
|
||||
#only return true if we got some kind of decent response
|
||||
return true
|
||||
else
|
||||
# We didn't get a decent response.
|
||||
return false
|
||||
if self.member_level.to_i >= 1 then
|
||||
output = "<span class='hoverinfo' title='Inactive'>◌</span>"
|
||||
end
|
||||
else
|
||||
# We didn't get an OK login.
|
||||
return false
|
||||
|
||||
unless self.member.nil? then
|
||||
# 1 = inactive, show an X
|
||||
if self.member >= 10 then
|
||||
output = "<span class='hoverinfo' title='Volunteer'>◔</span>"
|
||||
# 25 or higher is paying, show a check
|
||||
end
|
||||
if self.member >= 25 then
|
||||
output = "<span class='hoverinfo' title='25'>◑</span>"
|
||||
end
|
||||
if self.member >= 50 then
|
||||
output = "<span class='hoverinfo' title='50'>◕</span>"
|
||||
end
|
||||
if self.member >= 100 then
|
||||
output = "<span class='hoverinfo' title='100'>●</span>"
|
||||
end
|
||||
|
||||
if self.member < self.member_level.to_i then
|
||||
output = "<span class='hoverinfo' title='Lapsed'>✗</span>"
|
||||
end
|
||||
end
|
||||
|
||||
def self.upload_all_to_door
|
||||
@users = User.all
|
||||
@end_results = Array.new
|
||||
|
||||
source = open("http://192.168.1.177?e=1234").read
|
||||
results = source.scan(/authok/)
|
||||
if(results.size > 0) then
|
||||
@users.each do |u|
|
||||
#only continue if we've got an OK login
|
||||
usernum = u.card_id.to_s.rjust(3, '0')
|
||||
userperm = u.card_permissions.to_s.rjust(3, '0')
|
||||
cardnum = u.card_number.rjust(8, '0')
|
||||
|
||||
source = open("http://192.168.1.177?m#{usernum}&p#{userperm}&t#{cardnum}").read
|
||||
results = source.scan(/cur/)
|
||||
|
||||
if(results.size > 0) then
|
||||
#only return true if we got some kind of decent response
|
||||
@end_results.push([usernum,"OK"])
|
||||
else
|
||||
@end_results.push([usernum,"FAIL"])
|
||||
end
|
||||
end
|
||||
|
||||
#logout
|
||||
open("http://192.168.1.177?e=0000")
|
||||
else
|
||||
@end_results.push([usernum,"FAIL"])
|
||||
end
|
||||
|
||||
return @end_results
|
||||
return output
|
||||
end
|
||||
end
|
||||
|
||||
8
app/models/user_certification.rb
Normal file
8
app/models/user_certification.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class UserCertification < ActiveRecord::Base
|
||||
attr_accessible :certification_id, :user_id
|
||||
|
||||
validates_uniqueness_of :certification_id, :scope => :user_id, :message => 'already exists for this user.' # Makes sure users don't get certified twice
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :certification
|
||||
end
|
||||
37
app/views/cards/_form.html.erb
Normal file
37
app/views/cards/_form.html.erb
Normal file
@@ -0,0 +1,37 @@
|
||||
<%= form_for(@card) do |f| %>
|
||||
<% if @card.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@card.errors.count, "error") %> prohibited this card from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @card.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :user %><br />
|
||||
<%= collection_select(:card, :user_id, User.all.sort_by(&:name), :id, :name) %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :name, "Card Note" %><br />
|
||||
<%= f.text_field :name %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :id, "Card DB ID" %><br />
|
||||
<%= f.number_field :id, :in => 10...201 %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :card_number, "Card Number" %><br />
|
||||
<%= f.text_field :card_number %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :card_permissions %><br />
|
||||
<%= f.select :card_permissions, [["Enabled",1],["Disabled",255]] %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
6
app/views/cards/edit.html.erb
Normal file
6
app/views/cards/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing card</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @card %> |
|
||||
<%= link_to 'Back', cards_path %>
|
||||
39
app/views/cards/index.html.erb
Normal file
39
app/views/cards/index.html.erb
Normal file
@@ -0,0 +1,39 @@
|
||||
<h1>Access Cards</h1>
|
||||
|
||||
<%= link_to 'New Card', new_card_path if can? :create, Card %>
|
||||
<%= link_to 'Upload all cards', upload_all_path if can? :upload_all, Card %>
|
||||
<table>
|
||||
<col />
|
||||
<col />
|
||||
<col class="col_highlight" />
|
||||
<col />
|
||||
<col class="col_highlight" />
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>Note</th>
|
||||
<th>DB ID</th>
|
||||
<th>Card #</th>
|
||||
<th>Access?</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% if !@cards.blank? %>
|
||||
<% @cards.each do |card| %>
|
||||
<tr>
|
||||
<td><%= card.user.name %></td>
|
||||
<td><%= card.name %></td>
|
||||
<td><%= card.id %></td>
|
||||
<td><%= card.card_number %></td>
|
||||
<td><%= if card.card_permissions == 1 then "Access" end %></td>
|
||||
<td><%= link_to 'Upload', upload_path(card) if can? :upload, card %></td>
|
||||
<td><%= link_to 'Edit', edit_card_path(card) if can? :update, card %></td>
|
||||
<td><%= link_to 'Destroy', card, :confirm => 'Are you sure? WARNING: THIS DOES NOT REMOVE THE CARD FROM THE DOOR SYSTEM! DISABLE AND UPLOAD IT FIRST.', :method => :delete if can? :destroy, card %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
5
app/views/cards/new.html.erb
Normal file
5
app/views/cards/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New card</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', cards_path %>
|
||||
28
app/views/cards/show.html.erb
Normal file
28
app/views/cards/show.html.erb
Normal file
@@ -0,0 +1,28 @@
|
||||
<p>
|
||||
<b>User:</b>
|
||||
<%= @card.user.name unless @card.user.blank? %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Card Note:</b>
|
||||
<%= @card.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Card DB ID:</b>
|
||||
<%= @card.id %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Card Number:</b>
|
||||
<%= @card.card_number %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Card Permissions:</b>
|
||||
<%= @card.card_permissions %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Upload to Door', upload_path(@card) if can? :upload, @card %>
|
||||
<% if can? :update, @card then %><%= link_to 'Edit', edit_card_path(@card) %> |<% end %>
|
||||
<%= link_to 'Back', cards_path %>
|
||||
14
app/views/cards/upload.html.erb
Normal file
14
app/views/cards/upload.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
<% if @upload_result %>
|
||||
<p>
|
||||
<b>Upload result:</b>
|
||||
<%= @card.card_number %> uploaded successfully.
|
||||
</p>
|
||||
<% else %>
|
||||
<p>
|
||||
<b>Upload result:</b>
|
||||
Error uploading <%= @card.card_number %>.
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= link_to 'Back', cards_path %>
|
||||
@@ -1,4 +1,3 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<b>Upload results:</b>
|
||||
@@ -10,4 +9,4 @@
|
||||
</p>
|
||||
|
||||
|
||||
<%= link_to 'Back', users_path %>
|
||||
<%= link_to 'Back', cards_path %>
|
||||
25
app/views/certifications/_form.html.erb
Normal file
25
app/views/certifications/_form.html.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
<%= form_for(@certification) do |f| %>
|
||||
<% if @certification.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@certification.errors.count, "error") %> prohibited this certification from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @certification.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :name %><br />
|
||||
<%= f.text_field :name %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :description %><br />
|
||||
<%= f.text_area :description %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
6
app/views/certifications/edit.html.erb
Normal file
6
app/views/certifications/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing certification</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @certification %> |
|
||||
<%= link_to 'Back', certifications_path %>
|
||||
15
app/views/certifications/index.html.erb
Normal file
15
app/views/certifications/index.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<h1>Certification Classes</h1>
|
||||
|
||||
<%= link_to 'Create Certification', new_certification_path if can? :create, Certification %>
|
||||
|
||||
<ul>
|
||||
<% @certifications.each do |certification| %>
|
||||
<li><%= link_to certification.name, certification %>
|
||||
<% if can? :update, certification %> | <%= link_to 'Edit', edit_certification_path(certification) %><% end %>
|
||||
<% if can? :destroy, certification %> | <%= link_to 'Destroy', certification, :confirm => 'Are you sure?', :method => :delete %><% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<br />
|
||||
|
||||
5
app/views/certifications/new.html.erb
Normal file
5
app/views/certifications/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New certification</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', certifications_path %>
|
||||
20
app/views/certifications/show.html.erb
Normal file
20
app/views/certifications/show.html.erb
Normal file
@@ -0,0 +1,20 @@
|
||||
<p>
|
||||
<b>Name:</b>
|
||||
<%= @certification.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Description:</b>
|
||||
<%= simple_format @certification.description %>
|
||||
</p>
|
||||
|
||||
<b>Certified Users:</b>
|
||||
<ul>
|
||||
<% @certification_users.each do |user| %>
|
||||
<li><%= link_to user.name, user %></li>
|
||||
<% end %>
|
||||
<% if @certification_users.blank? then %><li>n/a</li><% end %>
|
||||
</ul>
|
||||
|
||||
<% if can? :update, @certification %><%= link_to 'Edit', edit_certification_path(@certification) %> |<% end %>
|
||||
<%= link_to 'Back', certifications_path %>
|
||||
12
app/views/devise/confirmations/new.html.erb
Normal file
12
app/views/devise/confirmations/new.html.erb
Normal file
@@ -0,0 +1,12 @@
|
||||
<h2>Resend confirmation instructions</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></div>
|
||||
|
||||
<div><%= f.submit "Resend confirmation instructions" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "devise/shared/links" %>
|
||||
@@ -0,0 +1,5 @@
|
||||
<p>Welcome <%= @resource.email %>!</p>
|
||||
|
||||
<p>You can confirm your account email through the link below:</p>
|
||||
|
||||
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
|
||||
@@ -0,0 +1,8 @@
|
||||
<p>Hello <%= @resource.email %>!</p>
|
||||
|
||||
<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
|
||||
|
||||
<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
|
||||
|
||||
<p>If you didn't request this, please ignore this email.</p>
|
||||
<p>Your password won't change until you access the link above and create a new one.</p>
|
||||
7
app/views/devise/mailer/unlock_instructions.html.erb
Normal file
7
app/views/devise/mailer/unlock_instructions.html.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<p>Hello <%= @resource.email %>!</p>
|
||||
|
||||
<p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
|
||||
|
||||
<p>Click the link below to unlock your account:</p>
|
||||
|
||||
<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
|
||||
16
app/views/devise/passwords/edit.html.erb
Normal file
16
app/views/devise/passwords/edit.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
<h2>Change your password</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= f.hidden_field :reset_password_token %>
|
||||
|
||||
<div><%= f.label :password, "New password" %><br />
|
||||
<%= f.password_field :password %></div>
|
||||
|
||||
<div><%= f.label :password_confirmation, "Confirm new password" %><br />
|
||||
<%= f.password_field :password_confirmation %></div>
|
||||
|
||||
<div><%= f.submit "Change my password" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "devise/shared/links" %>
|
||||
12
app/views/devise/passwords/new.html.erb
Normal file
12
app/views/devise/passwords/new.html.erb
Normal file
@@ -0,0 +1,12 @@
|
||||
<h2>Forgot your password?</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></div>
|
||||
|
||||
<div><%= f.submit "Send me reset password instructions" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "devise/shared/links" %>
|
||||
65
app/views/devise/registrations/_user.html.erb
Normal file
65
app/views/devise/registrations/_user.html.erb
Normal file
@@ -0,0 +1,65 @@
|
||||
<% if params[:flash] == "welcome_msg" then %>
|
||||
<p class="notice"><strong>Thank for you choosing to become a HeatSync Labs member!</strong> As we foster this community of learning, science, and the arts every member is important. <br/><br/>
|
||||
You can get your payments started by following the instructions on this page. <strong>Please note electronic recurring payments are -highly- encouraged</strong>-- we do not have staff. If you must pay via cash/check, please consider prepaying for 3, 6 or 12 months up front.<br/>
|
||||
<strong>To claim member benefits</strong> such as storage, grab a volunteer during your next stop into HeatSync or schedule a time to meet up in advance. Someone should also be contacting you shortly via the email address you provided.<br/>
|
||||
Please also note that certain privileges like 24/7 card access require community approval.<br/>
|
||||
Thanks again, and happy hacking!</p>
|
||||
<% end %>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => html) do |f| %>
|
||||
<div class="field">
|
||||
<%= f.label :name %><br />
|
||||
<%= f.text_field :name %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :phone %><br />
|
||||
<%= f.text_field :phone %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :emergency_name, "Emergency contact" %><br />
|
||||
<%= f.text_field :emergency_name %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :emergency_phone %><br />
|
||||
<%= f.text_field :emergency_phone %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :emergency_email %><br />
|
||||
<%= f.text_field :emergency_email %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :member_level, "Membership Level" %><br />
|
||||
<%= f.select :member_level, [[nil],["None",0],["Unable",1],["Volunteer",10],["Associate ($25)",25],["Basic ($50)",50],["Plus ($100)",100]] %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= render :partial => "/users/payment_methods", :locals => { :g => f } %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :current_skills %><br />
|
||||
<%= f.text_area :current_skills %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :desired_skills %><br />
|
||||
<%= f.text_area :desired_skills %>
|
||||
</div>
|
||||
|
||||
<div><%= f.label :password %><br />
|
||||
<%= f.password_field :password %></div>
|
||||
|
||||
<div><%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation %></div>
|
||||
|
||||
<% if params[:action]!='new' %>
|
||||
<div><%= f.label :current_password %><br />
|
||||
<%= f.password_field :current_password %></div>
|
||||
<% end %>
|
||||
|
||||
<div><%= f.submit button_label %></div>
|
||||
|
||||
<% end %>
|
||||
71
app/views/devise/registrations/edit.html.erb
Normal file
71
app/views/devise/registrations/edit.html.erb
Normal file
@@ -0,0 +1,71 @@
|
||||
<h2>Edit Your Profile</h2>
|
||||
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<div class="payment_links">
|
||||
<% if resource.payment_method == "Dwolla" %>
|
||||
<h3>Dwolla Payment Link</h3>
|
||||
<% if resource.member_level == "25" %>
|
||||
<strong>Associate Membership ($25/mo):</strong>
|
||||
<a href="http://members.heatsynclabs.org/users/edit" class="dwolla_button" data-name="Associate Membership" data-desc="$25/month membership" data-amount="25" data-shipping="0" data-tax="0" data-key="8nMi2WmI7F8uXVlSNNDmX2o2Cgh9Af8dfJGIrd7ZrgyjNfLIxj">Subscribe</a>
|
||||
<% elsif resource.member_level == "50" %>
|
||||
<strong>Basic Membership ($50/mo):</strong>
|
||||
<a href="http://members.heatsynclabs.org/users/edit" class="dwolla_button" data-name="Basic Membership" data-desc="$50/month membership" data-amount="50" data-shipping="0" data-tax="0" data-key="8nMi2WmI7F8uXVlSNNDmX2o2Cgh9Af8dfJGIrd7ZrgyjNfLIxj">Subscribe</a>
|
||||
<% elsif resource.member_level == "100" %>
|
||||
<strong>Plus Membership ($100/mo):</strong>
|
||||
<a href="http://members.heatsynclabs.org/users/edit" class="dwolla_button" data-name="Plus Membership" data-desc="$100/month membership" data-amount="100" data-shipping="0" data-tax="0" data-key="8nMi2WmI7F8uXVlSNNDmX2o2Cgh9Af8dfJGIrd7ZrgyjNfLIxj">Subscribe</a>
|
||||
<% else %>
|
||||
Hmm, your membership level doesn't appear to be at $25/50/100...
|
||||
<% end %>
|
||||
<script type="text/javascript" src="https://www.dwolla.com/scripts/button.min.js"> </script>
|
||||
<% elsif resource.payment_method == "PayPal" %>
|
||||
<h3>PayPal Payment Link</h3>
|
||||
<% if resource.member_level == "25" %>
|
||||
<strong>Associate Membership ($25/mo):</strong>
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
||||
<input type="hidden" name="cmd" value="_s-xclick">
|
||||
<input type="hidden" name="hosted_button_id" value="SZWVLPAG79XCN">
|
||||
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
||||
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
||||
</form>
|
||||
<% elsif resource.member_level == "50" %>
|
||||
<strong>Basic Membership ($50/mo):</strong>
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
||||
<input type="hidden" name="cmd" value="_s-xclick">
|
||||
<input type="hidden" name="hosted_button_id" value="GEAMCMZZKC4AW">
|
||||
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
||||
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
||||
</form>
|
||||
<% elsif resource.member_level == "100" %>
|
||||
<strong>Plus Membership ($100/mo):</strong>
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
||||
<input type="hidden" name="cmd" value="_s-xclick">
|
||||
<input type="hidden" name="hosted_button_id" value="L7XVC2GUJJR5A">
|
||||
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
||||
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
||||
</form>
|
||||
<% else %>
|
||||
Hmm, your membership level doesn't appear to be at $25/50/100...
|
||||
<% end %>
|
||||
<% elsif resource.payment_method == "BillPay" %>
|
||||
<h3>Bill Pay Info</h3>
|
||||
<p>Have your bank send a monthly check to HeatSync Labs Treasurer, 140 W Main St, Mesa AZ 85201 <strong>Electronic or advance payments are appreciated!</strong></p>
|
||||
<% elsif resource.payment_method == "Check" %>
|
||||
<h3>Check Payment Info</h3>
|
||||
<p>Mail to HeatSync Labs Treasurer, 140 W Main St, Mesa AZ 85201 OR put in the drop safe at the Lab with a deposit slip firmly attached each month. <strong>Electronic or advance payments are appreciated!</strong></p>
|
||||
<% elsif resource.payment_method == "Cash" %>
|
||||
<p>Put in the drop safe at the Lab with a deposit slip firmly attached each month. <strong>Electronic or advance payments are appreciated!</strong></p>
|
||||
<% else %>
|
||||
<h3>Payment Links</h3>
|
||||
<p>Normally you'd see payment buttons here, but you don't seem to have an electronic payment option selected...</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= link_to image_tag(resource.gravatar_url), "https://www.gravatar.com", :title => "Adjust your photo at Gravatar.com" %>
|
||||
|
||||
<%= render :partial => "user", :locals => { :resource => resource, :html => { :method => :put }, :button_label => "Update Profile" } %>
|
||||
|
||||
<%= render "devise/shared/links" %>
|
||||
|
||||
|
||||
<%= link_to "Back", :back %>
|
||||
7
app/views/devise/registrations/new.html.erb
Normal file
7
app/views/devise/registrations/new.html.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<h2>Sign up</h2>
|
||||
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<%= render :partial => "user", :locals => { :resource => resource, :button_label => "Sign Up", :html => nil } %>
|
||||
|
||||
<%= render "devise/shared/links" %>
|
||||
17
app/views/devise/sessions/new.html.erb
Normal file
17
app/views/devise/sessions/new.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<h2>Sign in</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></div>
|
||||
|
||||
<div><%= f.label :password %><br />
|
||||
<%= f.password_field :password %></div>
|
||||
|
||||
<% if devise_mapping.rememberable? -%>
|
||||
<div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
|
||||
<% end -%>
|
||||
|
||||
<div><%= f.submit "Sign in" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "devise/shared/links" %>
|
||||
25
app/views/devise/shared/_links.erb
Normal file
25
app/views/devise/shared/_links.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
<%- if controller_name != 'sessions' %>
|
||||
<%= link_to "Sign in", new_session_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
||||
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
|
||||
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
||||
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
||||
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.omniauthable? %>
|
||||
<%- resource_class.omniauth_providers.each do |provider| %>
|
||||
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
12
app/views/devise/unlocks/new.html.erb
Normal file
12
app/views/devise/unlocks/new.html.erb
Normal file
@@ -0,0 +1,12 @@
|
||||
<h2>Resend unlock instructions</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></div>
|
||||
|
||||
<div><%= f.submit "Resend unlock instructions" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "devise/shared/links" %>
|
||||
6
app/views/door_logs/auto_download.html.erb
Normal file
6
app/views/door_logs/auto_download.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
<p>
|
||||
<b>Download results:</b>
|
||||
<%= !@results.nil? %>
|
||||
</p>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<b>Download results:</b>
|
||||
|
||||
@@ -1,8 +1,49 @@
|
||||
<h1>Listing door_logs</h1>
|
||||
<h1>Door Logs</h1>
|
||||
|
||||
<%= link_to 'Download Door Logs', download_path %>
|
||||
<a href="#" onclick="$('#log-guide').toggle();">Show Log Guide</a>
|
||||
<div id="log-guide" style="display: none;">
|
||||
<pre>
|
||||
Guide to Card Number storage:
|
||||
cardnum = (R+(r*32767)), convert to hex
|
||||
|
||||
Guide to log keys and data:
|
||||
* A=alarm armed (# level)
|
||||
* a=added user (# usernum)
|
||||
* C=keypad command (# command)
|
||||
* c=second half
|
||||
* c=checked user (0=failed, #=found usernum)
|
||||
* D=denied access (# card num)
|
||||
* d=second half
|
||||
* d=deleted user (# usernum)
|
||||
* E=second (#=second)
|
||||
* F=priv fail (0=wrong pw, 1=too many attempts, 2=not logged in)
|
||||
* f=second half
|
||||
* f=card fail (#=usermask)
|
||||
* G=granted access (# card num)
|
||||
* g=second half of card
|
||||
* H=hour (#=hour)
|
||||
* i=attempt to write to invalid eeprom address (# usernum)
|
||||
* I=attempt to delete from invalid eeprom address (# usernum)
|
||||
* L=locked (1=door1, 2=door2, 3=bedtime)
|
||||
* M=minute (#=minute)
|
||||
* m=alarm state (# level)
|
||||
* R=read tag (# card num)
|
||||
* r=second half of tag
|
||||
* Q=superuser authed (#=superuser)
|
||||
* S=auth (0=privileged mode enabled)
|
||||
* s=alarm sensor (# zone)
|
||||
* t=alarm trained (#=sensor value)
|
||||
* T=alarm triggered (0)
|
||||
* U=unlocked door (1=door1, 2=door2, # card num)
|
||||
* u=second half of card
|
||||
* Z=user db cleared (0)
|
||||
* z=log cleared (0)
|
||||
</pre>
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Key</th>
|
||||
<th>Data</th>
|
||||
<th></th>
|
||||
@@ -10,10 +51,33 @@
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @divided_tmp = nil %>
|
||||
<% @door_logs.each do |door_log| %>
|
||||
<tr>
|
||||
<td><%= door_log.created_at %></td>
|
||||
<td><%= door_log.key %></td>
|
||||
<td><%= door_log.data %></td>
|
||||
<%
|
||||
if door_log.key == 'r' || door_log.key == 'd' ||door_log.key == 'g'
|
||||
@divided_tmp = door_log.data.to_i
|
||||
elsif (door_log.key == 'R' || door_log.key == 'D' || door_log.key == 'G') && !@divided_tmp.nil? %>
|
||||
<td>
|
||||
<%= case door_log.key
|
||||
when 'R'
|
||||
"Read"
|
||||
when 'D'
|
||||
"Denied"
|
||||
when 'G'
|
||||
"Granted"
|
||||
end %>
|
||||
<% @cardnum = (door_log.data.to_i+(@divided_tmp*32767)).to_s(16) %>
|
||||
<%= "Card: "+@cardnum %>
|
||||
<% @card = Card.find(:first,:conditions=>['card_number LIKE ?', @cardnum]) %>
|
||||
<%= "("+@card.user.name+")" unless @card.nil? %>
|
||||
</td>
|
||||
<% else
|
||||
@divided_tmp = nil
|
||||
end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<b>Key:</b>
|
||||
|
||||
22
app/views/home/index.html.erb
Normal file
22
app/views/home/index.html.erb
Normal file
@@ -0,0 +1,22 @@
|
||||
<h1>Welcome to the HeatSync Labs Members App.</h1>
|
||||
|
||||
<% if !user_signed_in? then %>
|
||||
<p>You can sign up to become a member here!</p>
|
||||
<% end %>
|
||||
|
||||
<% if user_signed_in? && current_user.member.to_i < current_user.member_level.to_i then %>
|
||||
<p class="alert">Looks like we haven't acknowledged a recent payment for you yet. This could be because we're slow, or this app just got started, but if in doubt please see your profile for payment instructions, or consider updating your membership level to something accurate.<br/>Thanks for supporting HeatSync!</p>
|
||||
<% end %>
|
||||
<h2>Cool Stats:</h2>
|
||||
<dl>
|
||||
<dt># of People in this DB:</dt>
|
||||
<dd><%= @num_users %> (<%= @recent_users %> in the last 7 days)</dd>
|
||||
<dt># of People Certified:</dt>
|
||||
<dd><%= @num_certs %> (<%= @recent_certs %> in the last 7 days)</dd>
|
||||
<dt># of Accesses Granted:</dt>
|
||||
<dd><%= @num_door_opens %> (<%= @recent_door_opens %> in the last 7 days)</dd>
|
||||
<dt># of Accesses Denied:</dt>
|
||||
<dd><%= @num_door_denieds %> (<%= @recent_door_denieds %> in the last 7 days)</dd>
|
||||
<dt># of Accesses Denied:</dt>
|
||||
<dd><%= @num_door_denieds %> (<%= @recent_door_denieds %> in the last 7 days)</dd>
|
||||
</dl>
|
||||
@@ -1,17 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Dooraccess</title>
|
||||
<title>hsl_members(<%= controller.controller_name %>.<%= controller.action_name %><%= "["+params[:id]+"]" unless params[:id].blank? %>)</title>
|
||||
<%= stylesheet_link_tag "application", :media => "all" %>
|
||||
<%= javascript_include_tag "application" %>
|
||||
<%= csrf_meta_tags %>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<a href="/users">Users</a>
|
||||
<a href="/door_logs">Logs</a>
|
||||
<a href="/" title="Home"><img src="/assets/logo.png" id="logo" /></a>
|
||||
<%= link_to 'People', users_path if can? :read, User %>
|
||||
<%= link_to 'Access Cards', cards_path if can? :manage, Card %>
|
||||
<% if can? :manage, UserCertification %>
|
||||
<%= link_to 'Cert Classes', certifications_path if can? :read, Certification %>
|
||||
<%= link_to 'User Certs', user_certifications_path if can? :create, UserCertification %>
|
||||
<% else %>
|
||||
<%= link_to 'Certifications', certifications_path if can? :read, Certification %>
|
||||
<% end %>
|
||||
<%= link_to 'Door Logs', door_logs_path if can? :read, DoorLog %>
|
||||
<% if user_signed_in? then %><%= link_to 'Profile', edit_user_registration_path %><% end %>
|
||||
<%= link_to 'Logout', destroy_user_session_path, :method => :delete if user_signed_in? %>
|
||||
<%= link_to 'Login', new_user_session_path unless user_signed_in? %>
|
||||
<%= link_to 'Become a Member', new_user_registration_path unless user_signed_in? %>
|
||||
</div>
|
||||
<div id="content">
|
||||
<p class="notice"><%= raw(notice) %></p>
|
||||
<p class="alert"><%= raw(alert) %></p>
|
||||
<%= yield %>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
25
app/views/user_certifications/_form.html.erb
Normal file
25
app/views/user_certifications/_form.html.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
<%= form_for(@user_certification) do |f| %>
|
||||
<% if @user_certification.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@user_certification.errors.count, "error") %> prohibited this User Certification from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @user_certification.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :user_id, "User" %><br />
|
||||
<%= collection_select(:user_certification, :user_id, @users, :id, :name) %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :certification_id, "Certification" %><br />
|
||||
<%= collection_select(:user_certification, :certification_id, @certifications, :id, :name) %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
6
app/views/user_certifications/edit.html.erb
Normal file
6
app/views/user_certifications/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing User Certification</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @user_certification %> |
|
||||
<%= link_to 'Back', user_certifications_path %>
|
||||
15
app/views/user_certifications/index.html.erb
Normal file
15
app/views/user_certifications/index.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<h1>User Certifications</h1>
|
||||
|
||||
<%= link_to 'New User Certification', new_user_certification_path %>
|
||||
|
||||
<% @grouped_user_certs.sort.each do |cert, user_certifications| %>
|
||||
<dl class="collapsible">
|
||||
<dt><%= cert.name %></dt>
|
||||
<% user_certifications.sort{|a,b| a.user.name <=> b.user.name}.each do |user_certification| %>
|
||||
<dd>
|
||||
<%= link_to user_certification.user.name, user_certification %>
|
||||
</dd>
|
||||
<% end %>
|
||||
</dl>
|
||||
<% end %>
|
||||
|
||||
5
app/views/user_certifications/new.html.erb
Normal file
5
app/views/user_certifications/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New User Certification</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', user_certifications_path %>
|
||||
25
app/views/user_certifications/show.html.erb
Normal file
25
app/views/user_certifications/show.html.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
<p>
|
||||
<b>User:</b>
|
||||
<%= @user_certification.user.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Certification:</b>
|
||||
<%= @user_certification.certification.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Created:</b> by <%= link_to @created_by.name, @created_by unless @created_by.blank? %>
|
||||
at <%= @user_certification.created_at %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Updated:</b> by <%= link_to @updated_by.name, @updated_by unless @updated_by.blank? %>
|
||||
at <%= @user_certification.updated_at %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', edit_user_certification_path(@user_certification) %> |
|
||||
<%= link_to 'Back', user_certifications_path %>
|
||||
<p>
|
||||
<%= link_to 'Destroy', @user_certification, :confirm => "Are you sure you want to destroy this user's certification?", :method => :delete if can? :destroy, @user_certification %>
|
||||
</p>
|
||||
@@ -1,4 +1,9 @@
|
||||
<%= form_for(@user) do |f| %>
|
||||
<% if @user.id.blank? then
|
||||
this_url = users_create_path
|
||||
else
|
||||
this_url = user_path(@user)
|
||||
end %>
|
||||
<%= form_for @user, :url => this_url do |f| %>
|
||||
<% if @user.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
|
||||
@@ -16,16 +21,85 @@
|
||||
<%= f.text_field :name %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :card_id, "Card DB ID" %><br />
|
||||
<%= f.number_field :card_id, :in => 10...201 %>
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email %>
|
||||
</div>
|
||||
<% if @user.id.blank? || !params[:password].nil? %>
|
||||
<div class="field">
|
||||
<%= f.label :password %><br />
|
||||
<%= f.password_field :password, :autocomplete => "off" %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :card_number, "Card Number" %><br />
|
||||
<%= f.text_field :card_number %>
|
||||
<%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="field">
|
||||
<a href="?password=edit">Change Password</a>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="field">
|
||||
<%= f.label :waiver %><br />
|
||||
<%= f.date_select :waiver, :include_blank => 'true', :default => 'nil' %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :card_permissions %><br />
|
||||
<%= f.select :card_permissions, [["Enabled",1],["Disabled",255]] %>
|
||||
<%= f.label :orientation %><br />
|
||||
<%= f.date_select :orientation, :include_blank => 'true', :default => 'nil' %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :emergency_name %><br />
|
||||
<%= f.text_field :emergency_name %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :emergency_phone %><br />
|
||||
<%= f.text_field :emergency_phone %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :emergency_email %><br />
|
||||
<%= f.text_field :emergency_email %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :member_level, "Desired Member Level" %><br />
|
||||
<%= f.select :member_level, [[nil],["None",0],["Unable",1],["Volunteer",10],["Associate",25],["Basic",50],["Plus",100]] %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= render :partial => "/users/payment_methods", :locals => { :g => f } %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :phone %><br />
|
||||
<%= f.text_field :phone %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :current_skills %><br />
|
||||
<%= f.text_area :current_skills %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :desired_skills %><br />
|
||||
<%= f.text_area :desired_skills %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :member, "Member?" %><br />
|
||||
<%= f.select :member, [[nil],["No",0],["Inactive",1],["Volunteer",10],["Associate",25],["Basic",50],["Plus",100]] %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :instructor, "Instructor?" %><br />
|
||||
<%= f.check_box :instructor %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :admin, "Admin?" %><br />
|
||||
<%= f.check_box :admin %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :hidden, "Hidden?" %><br />
|
||||
<%= f.check_box :hidden %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<h3>Cards</h3>
|
||||
<ul>
|
||||
<% @user.cards.each do |c| %>
|
||||
<li><%= link_to "#{c.card_number} #{c.name}", card_url(c) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
|
||||
15
app/views/users/_payment_methods.html.erb
Normal file
15
app/views/users/_payment_methods.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<% @payment_methods = [[nil],["PayPal"],["Dwolla"],["Bill Pay","BillPay"],["Check"],["Cash"],["Other"]]
|
||||
@payment_instructions = {nil => nil,
|
||||
:PayPal => "Set up a monthly recurring payment to hslfinances@gmail.com",
|
||||
:Dwolla => "Set up a monthly recurring payment to hslfinances@gmail.com",
|
||||
:BillPay => "Have your bank send a monthly check to HeatSync Labs Treasurer, 140 W Main St, Mesa AZ 85201",
|
||||
:Check => "Mail to HeatSync Labs Treasurer, 140 W Main St, Mesa AZ 85201 OR put in the drop safe at the Lab with a deposit slip firmly attached each month.",
|
||||
:Cash => "Put in the drop safe at the Lab with a deposit slip firmly attached each month.",
|
||||
:Other => "Hmm... talk to a Treasurer!"} %>
|
||||
|
||||
<%= g.label :payment_method %> <i>(after changing this, please make sure you update your payment service, it's not automatic.)</i><br />
|
||||
<%= g.select :payment_method, @payment_methods %>
|
||||
<% @payment_instructions.each_pair do |key, value| %>
|
||||
<span class="payment_instructions" id="pmt_<%= key %>"><%= value %></span>
|
||||
<% end %>
|
||||
|
||||
@@ -1,30 +1,62 @@
|
||||
<h1>Listing users</h1>
|
||||
<h1>HeatSync People</h1>
|
||||
|
||||
<%= link_to 'New User', new_user_path %>
|
||||
<%= link_to 'Upload all users', upload_all_path %>
|
||||
<% if can? :create, User %>
|
||||
<%= link_to 'New User', new_user_path %>
|
||||
<% end %>
|
||||
<table>
|
||||
<col />
|
||||
<col />
|
||||
<% if current_user.admin? then %><col /><% end %>
|
||||
<col />
|
||||
<% if current_user.admin? %><col /><% end %>
|
||||
<col class="col_highlight" />
|
||||
<col />
|
||||
<col class="col_highlight" />
|
||||
<col />
|
||||
<col class="col_highlight" />
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Card DB ID</th>
|
||||
<th>Card Number</th>
|
||||
<th>Permissions</th>
|
||||
<th></th>
|
||||
<th><a href="?sort=name">Name</a></th>
|
||||
<% if current_user.admin? then %><th><a href="?sort=email">Email</a></th><% end %>
|
||||
<th><a href="?sort=certifications">Certifications</a></th>
|
||||
<% if current_user.admin? then %>
|
||||
<th><a href="?sort=orientation">Orientation?</a></th>
|
||||
<% end %>
|
||||
<th><a href="?sort=waiver">Waiver?</a></th>
|
||||
<th><a href="?sort=member">Member?</a></th>
|
||||
<th><a href="?sort=card">Card?</a></th>
|
||||
<th><a href="?sort=instructor">Instructor?</a></th>
|
||||
<th><a href="?sort=admin">Admin?</a></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @users.each do |user| %>
|
||||
<tr>
|
||||
<td><%= user.name %></td>
|
||||
<td><%= user.card_id %></td>
|
||||
<td><%= user.card_number %></td>
|
||||
<td><%= user.card_permissions %></td>
|
||||
<td><%= link_to 'Upload', upload_path(user) %></td>
|
||||
<td><%= link_to 'Edit', edit_user_path(user) %></td>
|
||||
<td><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %></td>
|
||||
<% if !@users.blank? %>
|
||||
<% @users.each do |user| %>
|
||||
<tr<%= " class='hidden'" if user.hidden? %>>
|
||||
<td><%= image_tag user.gravatar_url(:default => "http://members.heatsynclabs.org/assets/nil.png"), :class => :avatar %></td>
|
||||
<td><%= link_to user.name, user %></td>
|
||||
<% if current_user.admin? then %><td><%= user.email %></td><% end %>
|
||||
<td><% user.certifications.each do |c| %>
|
||||
<%= link_to c.name, c %><%= "," unless c.id == user.certifications.last.id %>
|
||||
<% end %></td>
|
||||
<% if current_user.admin? then %><td>
|
||||
<%= unless user.orientation.blank? then raw("<span class='hoverinfo' title='"+user.orientation.strftime("%B %d %Y")+"'>✓</span>") end %>
|
||||
</td><% end %>
|
||||
<td><%= unless user.waiver.blank? then raw("<span class='hoverinfo' title='"+user.waiver.strftime("%B %d %Y")+"'>✓</span>") end %></td>
|
||||
<td><%= raw(user.member_status) %></td>
|
||||
<td><%= unless user.cards.blank? then raw("<span class='iconinfo'>✓</span>") end %></td>
|
||||
<td><%= if user.instructor? then raw("<span class='iconinfo'>✓</a>") end %></td>
|
||||
<td><%= if user.admin? then raw("<span class='iconinfo'>✓</a>") end %></td>
|
||||
<td><%= link_to 'Edit', edit_user_path(user) if can? :update, user %></td>
|
||||
<td><%= link_to 'Destroy', user, :confirm => 'Are you sure? WARNING: THIS DOES NOT REMOVE THE USER FROM THE DOOR SYSTEM! DISABLE THEM FIRST.', :method => :delete if can? :destroy, user %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
<% if current_user.orientation.blank? then %>
|
||||
<p class="alert">There's a lot more to see here, but our records show you haven't completed the new member orientation yet. If that's incorrect, please contact a volunteer.</p>
|
||||
<% end %>
|
||||
|
||||
<br />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
<%= image_tag @user.gravatar_url(:default => "http://members.heatsynclabs.org/assets/nil.png") %>
|
||||
|
||||
<p>
|
||||
<b>Name:</b>
|
||||
@@ -6,20 +6,87 @@
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Card DB ID:</b>
|
||||
<%= @user.card_id %>
|
||||
<b>Waiver?</b>
|
||||
<%= @user.waiver.strftime("%B %d %Y") unless @user.waiver.blank? %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Card Number:</b>
|
||||
<%= @user.card_number %>
|
||||
<b>Current Member?</b>
|
||||
<%= raw(@user.member_status) %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Card Permissions:</b>
|
||||
<%= @user.card_permissions %>
|
||||
<b>Instructor?</b>
|
||||
<%= @user.instructor? %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Upload to Door', upload_path(user) %>
|
||||
<%= link_to 'Edit', edit_user_path(@user) %> |
|
||||
<p>
|
||||
<b>Admin?</b>
|
||||
<%= @user.admin? %>
|
||||
</p>
|
||||
|
||||
|
||||
<% if current_user.admin? then %>
|
||||
<p>
|
||||
<b>Email:</b>
|
||||
<%= @user.email %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Orientation?</b>
|
||||
<%= @user.orientation.strftime("%B %d %Y") unless @user.orientation.blank? %>
|
||||
</p>
|
||||
<p>
|
||||
<b>Emergency Name:</b>
|
||||
<%= @user.emergency_name %>
|
||||
</p>
|
||||
<p>
|
||||
<b>Emergency Phone:</b>
|
||||
<%= @user.emergency_phone %>
|
||||
</p>
|
||||
<p>
|
||||
<b>Emergency Email:</b>
|
||||
<%= @user.emergency_email %>
|
||||
</p>
|
||||
<p>
|
||||
<b>Desired Member Level:</b>
|
||||
<%= @user.member_level %>
|
||||
</p>
|
||||
<p>
|
||||
<b>Payment Method:</b>
|
||||
<%= @user.payment_method %>
|
||||
</p>
|
||||
<p>
|
||||
<b>Phone:</b>
|
||||
<%= @user.phone %>
|
||||
</p>
|
||||
<% end %>
|
||||
<p>
|
||||
<b>Current Skills:</b>
|
||||
<%= simple_format @user.current_skills %>
|
||||
</p>
|
||||
<p>
|
||||
<b>Desired Skills:</b>
|
||||
<%= simple_format @user.desired_skills %>
|
||||
</p>
|
||||
<p>
|
||||
<b>Card:</b>
|
||||
<% if current_user.admin? then %>
|
||||
<% @user.cards.each do |c| %>
|
||||
<%= link_to c.card_number, c %><%= "," unless c == @user.cards.last %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= unless @user.cards.blank? then raw("✓") end %>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
<b>Certifications:</b>
|
||||
<ul>
|
||||
<% @user.certifications.each do |certification| %>
|
||||
<li><%= link_to certification.name, certification %></li>
|
||||
<% end %>
|
||||
<% if @user.certifications.blank? %><li>n/a</li><% end %>
|
||||
</ul>
|
||||
|
||||
<% if can? :update, @user then %><%= link_to 'Edit', edit_user_path(@user) %> |<% end %>
|
||||
<%= link_to 'Back', users_path %>
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<% if @upload_result %>
|
||||
<p>
|
||||
<b>Upload result:</b>
|
||||
<%= @user.name %> uploaded successfully.
|
||||
</p>
|
||||
<% else %>
|
||||
<p>
|
||||
<b>Upload result:</b>
|
||||
Error uploading <%= @user.name %>.
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= link_to 'Back', users_path %>
|
||||
@@ -4,9 +4,9 @@ require 'rails/all'
|
||||
|
||||
if defined?(Bundler)
|
||||
# If you precompile assets before deploying to production, use this line
|
||||
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
||||
#Bundler.require(*Rails.groups(:assets => %w(development test)))
|
||||
# If you want your assets lazily compiled in production, use this line
|
||||
# Bundler.require(:default, :assets, Rails.env)
|
||||
Bundler.require(:default, :assets, Rails.env)
|
||||
end
|
||||
|
||||
module Dooraccess
|
||||
@@ -27,7 +27,7 @@ module Dooraccess
|
||||
|
||||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
||||
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
||||
# config.time_zone = 'Central Time (US & Canada)'
|
||||
config.time_zone = 'America/Phoenix'
|
||||
|
||||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
||||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
||||
@@ -54,6 +54,6 @@ module Dooraccess
|
||||
config.assets.enabled = true
|
||||
|
||||
# Version of your assets, change this if you want to expire all your assets
|
||||
config.assets.version = '1.0'
|
||||
config.assets.version = '1.1'
|
||||
end
|
||||
end
|
||||
|
||||
32
config/config.yml.example
Normal file
32
config/config.yml.example
Normal file
@@ -0,0 +1,32 @@
|
||||
development:
|
||||
door_access_url: "http://192.168.1.177"
|
||||
door_access_password: "1234"
|
||||
smtp_tls: true
|
||||
smtp_address: "smtp.gmail.com"
|
||||
smtp_port: 587
|
||||
smtp_domain: "gmail.com"
|
||||
smtp_authentication: "login"
|
||||
smtp_user: ""
|
||||
smtp_password: ""
|
||||
|
||||
test:
|
||||
door_access_url: "http://192.168.1.177"
|
||||
door_access_password: "1234"
|
||||
smtp_tls: true
|
||||
smtp_address: "smtp.gmail.com"
|
||||
smtp_port: 587
|
||||
smtp_domain: "gmail.com"
|
||||
smtp_authentication: "login"
|
||||
smtp_user: ""
|
||||
smtp_password: ""
|
||||
|
||||
production:
|
||||
door_access_url: "http://192.168.1.177"
|
||||
door_access_password: "1234"
|
||||
smtp_tls: true
|
||||
smtp_address: "smtp.gmail.com"
|
||||
smtp_port: 587
|
||||
smtp_domain: "gmail.com"
|
||||
smtp_authentication: "login"
|
||||
smtp_user: ""
|
||||
smtp_password: ""
|
||||
@@ -34,4 +34,6 @@ Dooraccess::Application.configure do
|
||||
|
||||
# Expands the lines which load the assets
|
||||
config.assets.debug = true
|
||||
|
||||
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ Dooraccess::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb
|
||||
|
||||
# Code is not reloaded between requests
|
||||
config.cache_classes = true
|
||||
config.cache_classes = false
|
||||
|
||||
# Full error reports are disabled and caching is turned on
|
||||
config.consider_all_requests_local = false
|
||||
@@ -14,7 +14,7 @@ Dooraccess::Application.configure do
|
||||
# Compress JavaScripts and CSS
|
||||
config.assets.compress = true
|
||||
|
||||
# Don't fallback to assets pipeline if a precompiled asset is missed
|
||||
# Fallback to assets pipeline if a precompiled asset is missed
|
||||
config.assets.compile = false
|
||||
|
||||
# Generate digests for assets URLs
|
||||
@@ -64,4 +64,6 @@ Dooraccess::Application.configure do
|
||||
# Log the query plan for queries taking more than this (works
|
||||
# with SQLite, MySQL, and PostgreSQL)
|
||||
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
||||
|
||||
config.action_mailer.default_url_options = { :host => 'members.heatsynclabs.org' }
|
||||
end
|
||||
|
||||
232
config/initializers/devise.rb
Normal file
232
config/initializers/devise.rb
Normal file
@@ -0,0 +1,232 @@
|
||||
# Use this hook to configure devise mailer, warden hooks and so forth.
|
||||
# Many of these configuration options can be set straight in your model.
|
||||
Devise.setup do |config|
|
||||
# ==> Mailer Configuration
|
||||
# Configure the e-mail address which will be shown in Devise::Mailer,
|
||||
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
|
||||
config.mailer_sender = "toolshare@heatsynclabs.org"
|
||||
|
||||
# Configure the class responsible to send e-mails.
|
||||
# config.mailer = "Devise::Mailer"
|
||||
|
||||
# ==> ORM configuration
|
||||
# Load and configure the ORM. Supports :active_record (default) and
|
||||
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
||||
# available as additional gems.
|
||||
require 'devise/orm/active_record'
|
||||
|
||||
# ==> Configuration for any authentication mechanism
|
||||
# Configure which keys are used when authenticating a user. The default is
|
||||
# just :email. You can configure it to use [:username, :subdomain], so for
|
||||
# authenticating a user, both parameters are required. Remember that those
|
||||
# parameters are used only when authenticating and not when retrieving from
|
||||
# session. If you need permissions, you should implement that in a before filter.
|
||||
# You can also supply a hash where the value is a boolean determining whether
|
||||
# or not authentication should be aborted when the value is not present.
|
||||
# config.authentication_keys = [ :email ]
|
||||
|
||||
# Configure parameters from the request object used for authentication. Each entry
|
||||
# given should be a request method and it will automatically be passed to the
|
||||
# find_for_authentication method and considered in your model lookup. For instance,
|
||||
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
||||
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
||||
# config.request_keys = []
|
||||
|
||||
# Configure which authentication keys should be case-insensitive.
|
||||
# These keys will be downcased upon creating or modifying a user and when used
|
||||
# to authenticate or find a user. Default is :email.
|
||||
config.case_insensitive_keys = [ :email ]
|
||||
|
||||
# Configure which authentication keys should have whitespace stripped.
|
||||
# These keys will have whitespace before and after removed upon creating or
|
||||
# modifying a user and when used to authenticate or find a user. Default is :email.
|
||||
config.strip_whitespace_keys = [ :email ]
|
||||
|
||||
# Tell if authentication through request.params is enabled. True by default.
|
||||
# It can be set to an array that will enable params authentication only for the
|
||||
# given strategies, for example, `config.params_authenticatable = [:database]` will
|
||||
# enable it only for database (email + password) authentication.
|
||||
# config.params_authenticatable = true
|
||||
|
||||
# Tell if authentication through HTTP Basic Auth is enabled. False by default.
|
||||
# It can be set to an array that will enable http authentication only for the
|
||||
# given strategies, for example, `config.http_authenticatable = [:token]` will
|
||||
# enable it only for token authentication.
|
||||
# config.http_authenticatable = false
|
||||
|
||||
# If http headers should be returned for AJAX requests. True by default.
|
||||
# config.http_authenticatable_on_xhr = true
|
||||
|
||||
# The realm used in Http Basic Authentication. "Application" by default.
|
||||
# config.http_authentication_realm = "Application"
|
||||
|
||||
# It will change confirmation, password recovery and other workflows
|
||||
# to behave the same regardless if the e-mail provided was right or wrong.
|
||||
# Does not affect registerable.
|
||||
# config.paranoid = true
|
||||
|
||||
# By default Devise will store the user in session. You can skip storage for
|
||||
# :http_auth and :token_auth by adding those symbols to the array below.
|
||||
# Notice that if you are skipping storage for all authentication paths, you
|
||||
# may want to disable generating routes to Devise's sessions controller by
|
||||
# passing :skip => :sessions to `devise_for` in your config/routes.rb
|
||||
config.skip_session_storage = [:http_auth]
|
||||
|
||||
# ==> Configuration for :database_authenticatable
|
||||
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
||||
# using other encryptors, it sets how many times you want the password re-encrypted.
|
||||
#
|
||||
# Limiting the stretches to just one in testing will increase the performance of
|
||||
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
||||
# a value less than 10 in other environments.
|
||||
config.stretches = Rails.env.test? ? 1 : 10
|
||||
|
||||
# Setup a pepper to generate the encrypted password.
|
||||
# config.pepper = "a2406b0a0ef9399b1367e2a43c435e4e946b5e1ee75644af793405515ce3361c2fe47bcec51a1095f480cf08ab6d7073b12034c92e6e63779245f968a88888f9"
|
||||
|
||||
# ==> Configuration for :confirmable
|
||||
# A period that the user is allowed to access the website even without
|
||||
# confirming his account. For instance, if set to 2.days, the user will be
|
||||
# able to access the website for two days without confirming his account,
|
||||
# access will be blocked just in the third day. Default is 0.days, meaning
|
||||
# the user cannot access the website without confirming his account.
|
||||
# config.allow_unconfirmed_access_for = 2.days
|
||||
|
||||
# If true, requires any email changes to be confirmed (exactly the same way as
|
||||
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
||||
# db field (see migrations). Until confirmed new email is stored in
|
||||
# unconfirmed email column, and copied to email column on successful confirmation.
|
||||
config.reconfirmable = true
|
||||
|
||||
# Defines which key will be used when confirming an account
|
||||
# config.confirmation_keys = [ :email ]
|
||||
|
||||
# ==> Configuration for :rememberable
|
||||
# The time the user will be remembered without asking for credentials again.
|
||||
# config.remember_for = 2.weeks
|
||||
|
||||
# If true, extends the user's remember period when remembered via cookie.
|
||||
# config.extend_remember_period = false
|
||||
|
||||
# Options to be passed to the created cookie. For instance, you can set
|
||||
# :secure => true in order to force SSL only cookies.
|
||||
# config.rememberable_options = {}
|
||||
|
||||
# ==> Configuration for :validatable
|
||||
# Range for password length. Default is 6..128.
|
||||
# config.password_length = 6..128
|
||||
|
||||
# Email regex used to validate email formats. It simply asserts that
|
||||
# an one (and only one) @ exists in the given string. This is mainly
|
||||
# to give user feedback and not to assert the e-mail validity.
|
||||
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
||||
|
||||
# ==> Configuration for :timeoutable
|
||||
# The time you want to timeout the user session without activity. After this
|
||||
# time the user will be asked for credentials again. Default is 30 minutes.
|
||||
# config.timeout_in = 30.minutes
|
||||
|
||||
# If true, expires auth token on session timeout.
|
||||
# config.expire_auth_token_on_timeout = false
|
||||
|
||||
# ==> Configuration for :lockable
|
||||
# Defines which strategy will be used to lock an account.
|
||||
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
||||
# :none = No lock strategy. You should handle locking by yourself.
|
||||
# config.lock_strategy = :failed_attempts
|
||||
|
||||
# Defines which key will be used when locking and unlocking an account
|
||||
# config.unlock_keys = [ :email ]
|
||||
|
||||
# Defines which strategy will be used to unlock an account.
|
||||
# :email = Sends an unlock link to the user email
|
||||
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
||||
# :both = Enables both strategies
|
||||
# :none = No unlock strategy. You should handle unlocking by yourself.
|
||||
# config.unlock_strategy = :both
|
||||
|
||||
# Number of authentication tries before locking an account if lock_strategy
|
||||
# is failed attempts.
|
||||
# config.maximum_attempts = 20
|
||||
|
||||
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
||||
# config.unlock_in = 1.hour
|
||||
|
||||
# ==> Configuration for :recoverable
|
||||
#
|
||||
# Defines which key will be used when recovering the password for an account
|
||||
# config.reset_password_keys = [ :email ]
|
||||
|
||||
# Time interval you can reset your password with a reset password key.
|
||||
# Don't put a too small interval or your users won't have the time to
|
||||
# change their passwords.
|
||||
config.reset_password_within = 6.hours
|
||||
|
||||
# ==> Configuration for :encryptable
|
||||
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
||||
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
||||
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
||||
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
||||
# REST_AUTH_SITE_KEY to pepper)
|
||||
# config.encryptor = :sha512
|
||||
|
||||
# ==> Configuration for :token_authenticatable
|
||||
# Defines name of the authentication token params key
|
||||
# config.token_authentication_key = :auth_token
|
||||
|
||||
# ==> Scopes configuration
|
||||
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
||||
# "users/sessions/new". It's turned off by default because it's slower if you
|
||||
# are using only default views.
|
||||
# config.scoped_views = false
|
||||
|
||||
# Configure the default scope given to Warden. By default it's the first
|
||||
# devise role declared in your routes (usually :user).
|
||||
# config.default_scope = :user
|
||||
|
||||
# Set this configuration to false if you want /users/sign_out to sign out
|
||||
# only the current scope. By default, Devise signs out all scopes.
|
||||
# config.sign_out_all_scopes = true
|
||||
|
||||
# ==> Navigation configuration
|
||||
# Lists the formats that should be treated as navigational. Formats like
|
||||
# :html, should redirect to the sign in page when the user does not have
|
||||
# access, but formats like :xml or :json, should return 401.
|
||||
#
|
||||
# If you have any extra navigational formats, like :iphone or :mobile, you
|
||||
# should add them to the navigational formats lists.
|
||||
#
|
||||
# The "*/*" below is required to match Internet Explorer requests.
|
||||
# config.navigational_formats = ["*/*", :html]
|
||||
|
||||
# The default HTTP method used to sign out a resource. Default is :delete.
|
||||
config.sign_out_via = :delete
|
||||
|
||||
# ==> OmniAuth
|
||||
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
||||
# up on your models and hooks.
|
||||
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
|
||||
|
||||
# ==> Warden configuration
|
||||
# If you want to use other strategies, that are not supported by Devise, or
|
||||
# change the failure app, you can configure them inside the config.warden block.
|
||||
#
|
||||
# config.warden do |manager|
|
||||
# manager.intercept_401 = false
|
||||
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
||||
# end
|
||||
|
||||
# ==> Mountable engine configurations
|
||||
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
|
||||
# is mountable, there are some extra configurations to be taken into account.
|
||||
# The following options are available, assuming the engine is mounted as:
|
||||
#
|
||||
# mount MyEngine, at: "/my_engine"
|
||||
#
|
||||
# The router that invoked `devise_for`, in the example above, would be:
|
||||
# config.router_name = :my_engine
|
||||
#
|
||||
# When using omniauth, Devise cannot automatically set Omniauth path,
|
||||
# so you need to do it manually. For the users scope, it would be:
|
||||
# config.omniauth_path_prefix = "/my_engine/users/auth"
|
||||
end
|
||||
13
config/initializers/load_config.rb
Normal file
13
config/initializers/load_config.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")[Rails.env]
|
||||
|
||||
ActionMailer::Base.delivery_method = :smtp
|
||||
ActionMailer::Base.smtp_settings = {
|
||||
:tls => APP_CONFIG['smtp_tls'],
|
||||
:address => APP_CONFIG['smtp_address'],
|
||||
:port => APP_CONFIG['smtp_port'],
|
||||
:domain => APP_CONFIG['smtp_domain'],
|
||||
:authentication => APP_CONFIG['smtp_authentication'],
|
||||
:user_name => APP_CONFIG['smtp_user'],
|
||||
:password => APP_CONFIG['smtp_password']
|
||||
}
|
||||
|
||||
58
config/locales/devise.en.yml
Normal file
58
config/locales/devise.en.yml
Normal file
@@ -0,0 +1,58 @@
|
||||
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
|
||||
|
||||
en:
|
||||
errors:
|
||||
messages:
|
||||
expired: "has expired, please request a new one"
|
||||
not_found: "not found"
|
||||
already_confirmed: "was already confirmed, please try signing in"
|
||||
not_locked: "was not locked"
|
||||
not_saved:
|
||||
one: "1 error prohibited this %{resource} from being saved:"
|
||||
other: "%{count} errors prohibited this %{resource} from being saved:"
|
||||
|
||||
devise:
|
||||
failure:
|
||||
already_authenticated: 'You are already signed in.'
|
||||
unauthenticated: 'You need to sign in or sign up before continuing.'
|
||||
unconfirmed: 'You have to confirm your account before continuing.'
|
||||
locked: 'Your account is locked.'
|
||||
invalid: 'Invalid email or password.'
|
||||
invalid_token: 'Invalid authentication token.'
|
||||
timeout: 'Your session expired, please sign in again to continue.'
|
||||
inactive: 'Your account was not activated yet.'
|
||||
sessions:
|
||||
signed_in: 'Signed in successfully.'
|
||||
signed_out: 'Signed out successfully.'
|
||||
passwords:
|
||||
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
|
||||
updated: 'Your password was changed successfully. You are now signed in.'
|
||||
updated_not_active: 'Your password was changed successfully.'
|
||||
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
|
||||
no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
|
||||
confirmations:
|
||||
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
|
||||
send_paranoid_instructions: 'If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
|
||||
confirmed: 'Your account was successfully confirmed. You are now signed in.'
|
||||
registrations:
|
||||
signed_up: 'Welcome! You have signed up successfully.'
|
||||
signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
|
||||
signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
|
||||
signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
|
||||
updated: 'You updated your account successfully.'
|
||||
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
|
||||
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
|
||||
unlocks:
|
||||
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
|
||||
unlocked: 'Your account has been unlocked successfully. Please sign in to continue.'
|
||||
send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
|
||||
omniauth_callbacks:
|
||||
success: 'Successfully authenticated from %{kind} account.'
|
||||
failure: 'Could not authenticate you from %{kind} because "%{reason}".'
|
||||
mailer:
|
||||
confirmation_instructions:
|
||||
subject: 'Confirmation instructions'
|
||||
reset_password_instructions:
|
||||
subject: 'Reset password instructions'
|
||||
unlock_instructions:
|
||||
subject: 'Unlock Instructions'
|
||||
@@ -1,11 +1,33 @@
|
||||
Dooraccess::Application.routes.draw do
|
||||
|
||||
match 'users/upload_all' => 'users#upload_all', :as => :upload_all
|
||||
resources :users
|
||||
match 'users/:id/upload' => 'users#upload', :as => :upload
|
||||
resources :user_certifications
|
||||
|
||||
resources :certifications
|
||||
|
||||
devise_for :users, :skip => :registrations
|
||||
devise_scope :user do
|
||||
resource :registration,
|
||||
:only => [:new, :create, :edit, :update],
|
||||
:path => 'users',
|
||||
:path_names => { :new => 'sign_up' },
|
||||
:controller => 'registrations',
|
||||
:as => :user_registration do
|
||||
get :cancel
|
||||
end
|
||||
end
|
||||
|
||||
resources :users
|
||||
match 'users/create' => 'users#create', :via => :post # Use POST users/create instead of POST users to avoid devise conflict
|
||||
|
||||
match 'cards/upload_all' => 'cards#upload_all', :as => :upload_all
|
||||
resources :cards
|
||||
match 'cards/:id/upload' => 'cards#upload', :as => :upload
|
||||
|
||||
match 'door_logs' => 'door_logs#index', :as => :door_logs
|
||||
match 'door_logs/download' => 'door_logs#download', :as => :download
|
||||
resources :door_logs
|
||||
match 'door_logs/auto_download' => 'door_logs#auto_download', :as => :auto_download
|
||||
|
||||
root :to => "home#index"
|
||||
|
||||
# The priority is based upon order of creation:
|
||||
# first created -> highest priority.
|
||||
|
||||
60
db/migrate/20120902105919_add_devise_to_users.rb
Normal file
60
db/migrate/20120902105919_add_devise_to_users.rb
Normal file
@@ -0,0 +1,60 @@
|
||||
class AddDeviseToUsers < ActiveRecord::Migration
|
||||
def self.up
|
||||
change_table(:users) do |t|
|
||||
## Database authenticatable
|
||||
t.string :email, :null => false, :default => ""
|
||||
t.string :encrypted_password, :null => false, :default => ""
|
||||
|
||||
## Recoverable
|
||||
t.string :reset_password_token
|
||||
t.datetime :reset_password_sent_at
|
||||
|
||||
## Rememberable
|
||||
t.datetime :remember_created_at
|
||||
|
||||
## Trackable
|
||||
t.integer :sign_in_count, :default => 0
|
||||
t.datetime :current_sign_in_at
|
||||
t.datetime :last_sign_in_at
|
||||
t.string :current_sign_in_ip
|
||||
t.string :last_sign_in_ip
|
||||
|
||||
## Confirmable
|
||||
# t.string :confirmation_token
|
||||
# t.datetime :confirmed_at
|
||||
# t.datetime :confirmation_sent_at
|
||||
# t.string :unconfirmed_email # Only if using reconfirmable
|
||||
|
||||
## Lockable
|
||||
# t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
|
||||
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
||||
# t.datetime :locked_at
|
||||
|
||||
## Token authenticatable
|
||||
# t.string :authentication_token
|
||||
|
||||
|
||||
# Uncomment below if timestamps were not included in your original model.
|
||||
# t.timestamps
|
||||
end
|
||||
|
||||
@users = User.all
|
||||
@users.each do |u|
|
||||
u.email = (100000*rand()).to_s+"@example.com"
|
||||
u.save
|
||||
end
|
||||
|
||||
|
||||
add_index :users, :email, :unique => true
|
||||
add_index :users, :reset_password_token, :unique => true
|
||||
# add_index :users, :confirmation_token, :unique => true
|
||||
# add_index :users, :unlock_token, :unique => true
|
||||
# add_index :users, :authentication_token, :unique => true
|
||||
end
|
||||
|
||||
def self.down
|
||||
# By default, we don't want to make any assumption about how to roll back a migration when your
|
||||
# model already existed. Please edit below which fields you would like to remove in this migration.
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
5
db/migrate/20120904024426_add_admin_to_users.rb
Normal file
5
db/migrate/20120904024426_add_admin_to_users.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddAdminToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :admin, :boolean
|
||||
end
|
||||
end
|
||||
10
db/migrate/20121014114058_create_cards.rb
Normal file
10
db/migrate/20121014114058_create_cards.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateCards < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :cards do |t|
|
||||
t.string :card_number
|
||||
t.integer :card_permissions
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
5
db/migrate/20121014114527_add_user_id_to_cards.rb
Normal file
5
db/migrate/20121014114527_add_user_id_to_cards.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddUserIdToCards < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :cards, :user_id, :integer
|
||||
end
|
||||
end
|
||||
5
db/migrate/20121014120140_add_name_to_cards.rb
Normal file
5
db/migrate/20121014120140_add_name_to_cards.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddNameToCards < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :cards, :name, :string
|
||||
end
|
||||
end
|
||||
11
db/migrate/20121014120609_move_card_data_to_cards.rb
Normal file
11
db/migrate/20121014120609_move_card_data_to_cards.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class MoveCardDataToCards < ActiveRecord::Migration
|
||||
def up
|
||||
User.all.each do |u|
|
||||
u.cards.create(:id => u.card_id, :name => u.name, :card_number => u.card_number, :card_permissions => u.card_permissions)
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
13
db/migrate/20121014122548_remove_card_from_users.rb
Normal file
13
db/migrate/20121014122548_remove_card_from_users.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class RemoveCardFromUsers < ActiveRecord::Migration
|
||||
def up
|
||||
remove_column :users, :card_id
|
||||
remove_column :users, :card_number
|
||||
remove_column :users, :card_permissions
|
||||
end
|
||||
|
||||
def down
|
||||
add_column :users, :card_id, :integer
|
||||
add_column :users, :card_number, :string
|
||||
add_column :users, :card_permissions, :integer
|
||||
end
|
||||
end
|
||||
15
db/migrate/20121016211727_add_active_to_users.rb
Normal file
15
db/migrate/20121016211727_add_active_to_users.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class AddActiveToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :active, :boolean
|
||||
add_column :users, :waiver, :datetime
|
||||
add_column :users, :orientation, :datetime
|
||||
add_column :users, :emergency_name, :string
|
||||
add_column :users, :emergency_phone, :string
|
||||
add_column :users, :emergency_email, :string
|
||||
add_column :users, :member_level, :string
|
||||
add_column :users, :payment_method, :string
|
||||
add_column :users, :phone, :string
|
||||
add_column :users, :current_skills, :string
|
||||
add_column :users, :desired_skills, :string
|
||||
end
|
||||
end
|
||||
10
db/migrate/20130125085218_create_certifications.rb
Normal file
10
db/migrate/20130125085218_create_certifications.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateCertifications < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :certifications do |t|
|
||||
t.string :name
|
||||
t.string :description
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
5
db/migrate/20130125101623_add_instructor_to_users.rb
Normal file
5
db/migrate/20130125101623_add_instructor_to_users.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddInstructorToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :instructor, :boolean
|
||||
end
|
||||
end
|
||||
10
db/migrate/20130125102002_create_user_certifications.rb
Normal file
10
db/migrate/20130125102002_create_user_certifications.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateUserCertifications < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :user_certifications do |t|
|
||||
t.integer :user_id
|
||||
t.integer :certification_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class ChangeUsersActiveToMember < ActiveRecord::Migration
|
||||
def change
|
||||
change_column :users, :active, :string
|
||||
rename_column :users, :active, :member
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class ChangeUsersMemberToInteger < ActiveRecord::Migration
|
||||
def change
|
||||
change_column :users, :member, :integer
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddUpdatedByToUserCertifications < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :user_certifications, :updated_by, :integer
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddCreatedByToUserCertifications < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :user_certifications, :created_by, :integer
|
||||
end
|
||||
end
|
||||
5
db/migrate/20130125185724_add_hidden_to_users.rb
Normal file
5
db/migrate/20130125185724_add_hidden_to_users.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddHiddenToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :hidden, :boolean
|
||||
end
|
||||
end
|
||||
61
db/schema.rb
61
db/schema.rb
@@ -10,7 +10,23 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20120825041626) do
|
||||
ActiveRecord::Schema.define(:version => 20130125185724) do
|
||||
|
||||
create_table "cards", :force => true do |t|
|
||||
t.string "card_number"
|
||||
t.integer "card_permissions"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "user_id"
|
||||
t.string "name"
|
||||
end
|
||||
|
||||
create_table "certifications", :force => true do |t|
|
||||
t.string "name"
|
||||
t.string "description"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "door_logs", :force => true do |t|
|
||||
t.string "key"
|
||||
@@ -19,13 +35,46 @@ ActiveRecord::Schema.define(:version => 20120825041626) do
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "users", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "card_id"
|
||||
t.string "card_number"
|
||||
t.integer "card_permissions"
|
||||
create_table "user_certifications", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "certification_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "updated_by"
|
||||
t.integer "created_by"
|
||||
end
|
||||
|
||||
create_table "users", :force => true do |t|
|
||||
t.string "name"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :default => "", :null => false
|
||||
t.string "reset_password_token"
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.datetime "remember_created_at"
|
||||
t.integer "sign_in_count", :default => 0
|
||||
t.datetime "current_sign_in_at"
|
||||
t.datetime "last_sign_in_at"
|
||||
t.string "current_sign_in_ip"
|
||||
t.string "last_sign_in_ip"
|
||||
t.boolean "admin"
|
||||
t.integer "member", :limit => 255
|
||||
t.datetime "waiver"
|
||||
t.datetime "orientation"
|
||||
t.string "emergency_name"
|
||||
t.string "emergency_phone"
|
||||
t.string "emergency_email"
|
||||
t.string "member_level"
|
||||
t.string "payment_method"
|
||||
t.string "phone"
|
||||
t.string "current_skills"
|
||||
t.string "desired_skills"
|
||||
t.boolean "instructor"
|
||||
t.boolean "hidden"
|
||||
end
|
||||
|
||||
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
||||
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
|
||||
|
||||
end
|
||||
|
||||
0
log/.gitkeep
Normal file → Executable file
0
log/.gitkeep
Normal file → Executable file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user