Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • JSTUREK8/unl-resource-scheduler
  • erasmussen2/unl-resource-scheduler
  • dxg/unl-resource-scheduler
3 results
Show changes
Commits on Source (140)
Showing
with 857 additions and 119 deletions
......@@ -8,7 +8,7 @@
/test/tmp/
/test/version_tmp/
/tmp/
/public/wdn/
/public/wdn
/db/scripts/private/
## Documentation cache and generated files:
......
source "https://rubygems.org"
ruby '2.2.3'
#ruby '2.6.5'
gem 'sinatra'
gem 'sinatra-contrib'
gem 'activerecord', :require => 'active_record'
gem 'mysql'
gem 'mysql2'
gem 'bcrypt'
gem 'unicorn'
gem 'pony'
gem 'rest-client'
gem 'rack', '2.2.3'
gem 'rack-cas'
gem 'icalendar'
gem 'json'
gem 'bigdecimal'
group :development do
gem 'shotgun'
......
GEM
remote: https://rubygems.org/
specs:
activemodel (4.2.6)
activesupport (= 4.2.6)
builder (~> 3.1)
activerecord (4.2.6)
activemodel (= 4.2.6)
activesupport (= 4.2.6)
arel (~> 6.0)
activesupport (4.2.6)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.4.0)
arel (6.0.3)
backports (3.6.8)
bcrypt (3.1.11)
builder (3.2.2)
coderay (1.1.1)
activemodel (7.0.3)
activesupport (= 7.0.3)
activerecord (7.0.3)
activemodel (= 7.0.3)
activesupport (= 7.0.3)
activesupport (7.0.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
bcrypt (3.1.18)
bigdecimal (3.1.2)
coderay (1.1.3)
commonjs (0.2.7)
daemons (1.2.3)
domain_name (0.5.20160310)
concurrent-ruby (1.1.10)
daemons (1.4.1)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
eventmachine (1.2.0.1)
ffi (1.9.10)
formatador (0.2.5)
guard (2.14.0)
eventmachine (1.2.7)
ffi (1.15.5)
formatador (1.1.0)
guard (2.18.0)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (~> 1.0)
lumberjack (>= 1.0.12, < 2.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
pry (>= 0.13.0)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
......@@ -41,105 +38,113 @@ GEM
guard (~> 2.0)
guard-compat (~> 1.2)
less (~> 2.3)
http-cookie (1.0.2)
http-accept (1.7.0)
http-cookie (1.0.5)
domain_name (~> 0.5)
i18n (0.7.0)
json (1.8.3)
kgio (2.10.0)
i18n (1.10.0)
concurrent-ruby (~> 1.0)
icalendar (2.7.1)
ice_cube (~> 0.16)
ice_cube (0.16.4)
json (2.6.2)
kgio (2.11.4)
less (2.6.0)
commonjs (~> 0.2.7)
libv8 (3.16.14.15)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
lumberjack (1.0.10)
mail (2.6.4)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (2.99.2)
mini_portile2 (2.1.0)
minitest (5.9.0)
multi_json (1.12.1)
mysql (2.9.1)
libv8 (3.16.14.19-x86_64-linux)
listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
lumberjack (1.2.8)
mail (2.7.1)
mini_mime (>= 0.1.1)
method_source (1.0.0)
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2022.0105)
mini_mime (1.1.2)
minitest (5.15.0)
multi_json (1.15.0)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
mysql2 (0.5.4)
nenv (0.3.0)
netrc (0.11.0)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
notiffany (0.1.0)
nokogiri (1.13.6-x86_64-linux)
racc (~> 1.4)
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
pkg-config (1.1.7)
pony (1.11)
pony (1.13.1)
mail (>= 2.0)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.6.4)
rack-cas (0.13.0)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (4.0.7)
racc (1.6.0)
rack (2.2.3)
rack-cas (0.16.1)
addressable (~> 2.3)
nokogiri (~> 1.5)
rack (~> 1.3)
rack-protection (1.5.3)
rack (>= 1.3)
rack-protection (2.2.0)
rack
rack-test (0.6.3)
rack (>= 1.0)
raindrops (0.16.0)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
raindrops (0.20.0)
rb-fsevent (0.11.1)
rb-inotify (0.10.1)
ffi (~> 1.0)
ref (2.0.0)
rest-client (1.8.0)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
ruby_dep (1.3.1)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
ruby2_keywords (0.0.5)
shellany (0.0.1)
shotgun (0.9.1)
shotgun (0.9.2)
rack (>= 1.0)
sinatra (1.4.7)
rack (~> 1.5)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
sinatra-contrib (1.4.7)
backports (>= 2.0)
sinatra (2.2.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.2.0)
tilt (~> 2.0)
sinatra-contrib (2.2.0)
multi_json
rack-protection
rack-test
sinatra (~> 1.4.0)
tilt (>= 1.3, < 3)
slop (3.6.0)
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
mustermann (~> 1.0)
rack-protection (= 2.2.0)
sinatra (= 2.2.0)
tilt (~> 2.0)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thin (1.7.0)
thin (1.8.1)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
thor (1.2.1)
tilt (2.0.10)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.2)
unicorn (5.1.0)
unf_ext (0.0.8.1)
unicorn (6.1.0)
kgio (~> 2.6)
raindrops (~> 0.7)
PLATFORMS
ruby
x86_64-linux
DEPENDENCIES
activerecord
bcrypt
bigdecimal
guard
guard-less
mysql
icalendar
json
mysql2
pony
rack (= 2.2.3)
rack-cas
rest-client
shotgun
......@@ -150,4 +155,4 @@ DEPENDENCIES
unicorn
BUNDLED WITH
1.10.6
2.2.24
GEM
remote: https://rubygems.org/
specs:
activemodel (6.0.2.1)
activesupport (= 6.0.2.1)
activerecord (6.0.2.1)
activemodel (= 6.0.2.1)
activesupport (= 6.0.2.1)
activesupport (6.0.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
backports (3.15.0)
bcrypt (3.1.13)
coderay (1.1.2)
commonjs (0.2.7)
concurrent-ruby (1.1.5)
daemons (1.3.1)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
eventmachine (1.2.7)
ffi (1.11.3)
formatador (0.2.5)
guard (2.16.1)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (>= 1.0.12, < 2.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-less (2.0.0)
guard (~> 2.0)
guard-compat (~> 1.2)
less (~> 2.3)
http-accept (1.7.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
icalendar (2.6.1)
ice_cube (~> 0.16)
ice_cube (0.16.3)
kgio (2.11.3)
less (2.6.0)
commonjs (~> 0.2.7)
libv8 (3.16.14.19)
listen (3.2.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
lumberjack (1.1.1)
mail (2.7.1)
mini_mime (>= 0.1.1)
method_source (0.9.2)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.0)
multi_json (1.14.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
mysql2 (0.5.3)
nenv (0.3.0)
netrc (0.11.0)
nokogiri (1.10.7)
mini_portile2 (~> 2.4.0)
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
pony (1.13.1)
mail (>= 2.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (4.0.3)
rack (2.2.3)
rack-cas (0.16.1)
addressable (~> 2.3)
nokogiri (~> 1.5)
rack (>= 1.3)
rack-protection (2.0.8.1)
rack
raindrops (0.19.1)
rb-fsevent (0.10.3)
rb-inotify (0.10.1)
ffi (~> 1.0)
ref (2.0.0)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
ruby2_keywords (0.0.2)
shellany (0.0.1)
shotgun (0.9.2)
rack (>= 1.0)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.8.1)
tilt (~> 2.0)
sinatra-contrib (2.0.8.1)
backports (>= 2.8.2)
multi_json
mustermann (~> 1.0)
rack-protection (= 2.0.8.1)
sinatra (= 2.0.8.1)
tilt (~> 2.0)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thin (1.7.2)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.10)
tzinfo (1.2.6)
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.6)
unicorn (5.5.2)
kgio (~> 2.6)
raindrops (~> 0.7)
zeitwerk (2.2.2)
PLATFORMS
ruby
DEPENDENCIES
activerecord
bcrypt
guard
guard-less
icalendar
mysql2
pony
rack (= 2.2.3)
rack-cas
rest-client
shotgun
sinatra
sinatra-contrib
therubyracer
thin
unicorn
RUBY VERSION
ruby 2.6.5p114
BUNDLED WITH
1.17.3
GEM
remote: https://rubygems.org/
specs:
activemodel (6.0.2.1)
activesupport (= 6.0.2.1)
activerecord (6.0.2.1)
activemodel (= 6.0.2.1)
activesupport (= 6.0.2.1)
activesupport (6.0.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
backports (3.15.0)
bcrypt (3.1.13)
coderay (1.1.2)
commonjs (0.2.7)
concurrent-ruby (1.1.5)
daemons (1.3.1)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
eventmachine (1.2.7)
ffi (1.11.3)
formatador (0.2.5)
guard (2.16.1)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (>= 1.0.12, < 2.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-less (2.0.0)
guard (~> 2.0)
guard-compat (~> 1.2)
less (~> 2.3)
http-accept (1.7.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (1.8.1)
concurrent-ruby (~> 1.0)
icalendar (2.6.1)
ice_cube (~> 0.16)
ice_cube (0.16.3)
kgio (2.11.3)
less (2.6.0)
commonjs (~> 0.2.7)
libv8 (3.16.14.19)
listen (3.2.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
lumberjack (1.1.1)
mail (2.7.1)
mini_mime (>= 0.1.1)
method_source (0.9.2)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.13.0)
multi_json (1.14.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
mysql2 (0.5.3)
nenv (0.3.0)
netrc (0.11.0)
nokogiri (1.10.7)
mini_portile2 (~> 2.4.0)
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
pony (1.13.1)
mail (>= 2.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (4.0.3)
rack (2.1.0)
rack-cas (0.16.1)
addressable (~> 2.3)
nokogiri (~> 1.5)
rack (>= 1.3)
rack-protection (2.0.8.1)
rack
raindrops (0.19.1)
rb-fsevent (0.10.3)
rb-inotify (0.10.1)
ffi (~> 1.0)
ref (2.0.0)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
ruby2_keywords (0.0.2)
shellany (0.0.1)
shotgun (0.9.2)
rack (>= 1.0)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.8.1)
tilt (~> 2.0)
sinatra-contrib (2.0.8.1)
backports (>= 2.8.2)
multi_json
mustermann (~> 1.0)
rack-protection (= 2.0.8.1)
sinatra (= 2.0.8.1)
tilt (~> 2.0)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thin (1.7.2)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.10)
tzinfo (1.2.6)
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.6)
unicorn (5.5.2)
kgio (~> 2.6)
raindrops (~> 0.7)
zeitwerk (2.2.2)
PLATFORMS
ruby
DEPENDENCIES
activerecord
bcrypt
guard
guard-less
icalendar
mysql2
pony
rack-cas
rest-client
shotgun
sinatra
sinatra-contrib
therubyracer
thin
unicorn
RUBY VERSION
ruby 2.6.5p114
BUNDLED WITH
1.17.3
UNL Resource Scheduler
======================
UNL Resource Scheduler is a web app developed around managing timed reservations for various campus resources. This app was initially created for the Nebraska Innovation Studio, and then expanded and generalized to be able to be used by all departments at UNL. New features are in development and feature and bugfix requests will usually be attended to quickly.
Patch
============
Supporting UNL's October 2018 move to shib.unl.edu/idp/profile/cas requires CAS tickets longer than 256 chars. Manually patch the rack-cas library to support tickets up to 1024.
- https://github.com/biola/rack-cas/blob/master/lib/rack-cas/cas_request.rb#L35
- vendor/bundle/ruby/3.0.0/gems/rack-cas-0.16.1/lib/rack-cas/cas_request.rb
This has been fixed as of https://github.com/biola/rack-cas/commit/b6787f521e645ebd703d2749c629e84e419c2777 in 2020 but as of May 2022 there is not a newer release than 0.16.1 that includes the update.
Installation
============
Using local resources
---------------------
0. Run `xcode-select --install`. Congratulations, you have saved yourself 5000 insanity points.
1. Get the right ruby on your machine. UNL Resource Scheduler currently runs on Ruby 2.6.5. Get RVM on your machine with `\curl -sSL https://get.rvm.io | bash`.
2. Now using RVM, install the ruby with `rvm install 2.6.5`.
3. You probably do not have the `bundler` gem. Check with `bundle`. If not, install it with `gem install bundler`.
4. In the project root, install the gems using `bundle install`.
5. Create a mysql database you'd like to use, you can typically use one on your computer. `brew install mysql` if necessary.
6. `config/config.json` is a committed file, and a template for the configuration. Create a copy in the same directoy named `server.json` and edit it to match your database.
7. Your database is currently blank. Run the migrations from the root of the project using `rake migrate` to bring in all the tables and columns.
8. Install the WDN Framework into the `public/wdn` directory...see [WDN Documentation](http://wdn.unl.edu/documentation).
9. Start the server by going to the root directory and doing `bundle exec shotgun -o 0.0.0.0 -p 9292`. This launches the server on localhost port 9292, listening everywhere (you can use your iimlemburg.unl.edu or whichever), and the server will automatically update to new code. If you add gems to the bundle, you will need to re-execute this command.
10. Navigate to `localhost:9292/` or similar and begin!
11. In another terminal, type `bundle exec guard` in the project root to execute LESS compilation.
Quick Tutorial
==============
1. Service spaces refer to different silos of the University that will utilize resources. E.g. the math department, the Honors program, or University Communication.
2. Super Admins of a space can do anything, including giving others access and privileges to the space.
3. Resources are created, and then may be reserved by anyone who has the User Access privilege in the space.
4. Events *may* include a resource reservation but do not have to.
5. Admins with the right privilege can set the *hours* of the space, which indicate when reservations can be made.
6. The agenda is a quick overview of the day for Admins to look at.
Deploying Updates on Production
===============================
```
$ sudo -u ucommscheduler -s -H
$ systemctl --user restart unicorn
```
......@@ -4,9 +4,13 @@ require 'rack/session/abstract/id'
require 'rack/cas'
require 'rack-cas'
require 'rack-cas/session_store/active_record'
require 'models/session'
require 'models/user'
require 'models/resource'
require 'models/service_space'
include ERB::Util
module Rack
module Session
class RackCASActiveRecordStore < Rack::Session::Abstract::ID
......@@ -16,12 +20,18 @@ module Rack
end
use Rack::Session::RackCASActiveRecordStore
use Rack::CAS, server_url: 'https://login.unl.edu/cas',
use Rack::CAS, server_url: 'https://shib.unl.edu/idp/profile/cas',
session_store: RackCAS::ActiveRecordStore
Time.zone = "America/Chicago"
DIRECTORY_URL = 'http://directory.unl.edu/'
DIRECTORY_URL = 'https://directory.unl.edu/'
NIS_SS_ID = ServiceSpace.where(:name => 'Innovation Studio').first.id
NIS_TOOL_RESOURCE_CLASS_ID = 1
HALF_HOUR_HEIGHT = 28 # pixel height of half-hour sections in calendar. DO NOT CHANGE RESPONSIVELY
SIX_AM_MINUTES = 360 # start time of calendar
EIGHT_PM_MINUTES = 1200 # end time of calendar
# this gives the user messages
def flash(type, header, message)
......@@ -34,15 +44,15 @@ def flash(type, header, message)
end
before do
require_login
session['init'] = true
# site defaults
@inline_body_script_content = ''
@title = 'UNL Resource Scheduler'
@breadcrumbs = [
{
:href => 'http://www.unl.edu/',
:text => 'UNL',
:title => 'University of Nebraska&ndash;Lincoln'
:href => 'https://www.unl.edu/',
:text => 'Nebraska',
},
{
:href => '/',
......@@ -51,6 +61,14 @@ before do
]
end
def append_script_tag(src)
@inline_body_script_content << "<script type=\"text/javascript\" src=\"#{src}\"></script>\n"
end
def append_script_declaration(content)
@inline_body_script_content << "<script>#{content}</script>\n"
end
def calculate_time(date_string, hour, minute, am_pm)
hour ||= 0
minute ||= 0
......@@ -66,13 +84,13 @@ def calculate_time(date_string, hour, minute, am_pm)
end
helpers do
def load_service_space
def load_service_space(authorize_user = true)
url_name = params[:service_space_url_name]
space = ServiceSpace.find_by(:url_name => url_name)
raise Sinatra::NotFound if space.nil?
@space = space
if !@user.in_space?(@space)
if authorize_user && @user && !@user.in_space?(@space)
flash :error, 'Unauthorized', 'Sorry, you don\'t have access to this service space.'
redirect '/'
end
......@@ -80,6 +98,14 @@ helpers do
@breadcrumbs << {:text => @space.name, :href => @space.href}
end
def check_login
if !session['cas'].nil? && !session['cas']['user'].nil?
@user = User.find_by(:username => session['cas']['user'], :creation_method => 'CAS')
else
@user = nil
end
end
def require_login
if session['cas'].nil? || session['cas']['user'].nil?
halt 401
......@@ -95,9 +121,9 @@ helpers do
# create this user
@user = User.create(
username: session['cas']['user'],
email: info['mail'][0],
first_name: info['givenName'][0],
last_name: info['sn'][0],
email: (info['mail'][0] rescue nil),
first_name: (info['givenName'][0] rescue nil),
last_name: (info['sn'][0] rescue nil),
date_created: Time.now,
creation_method: 'CAS',
is_admin: false
......@@ -124,21 +150,45 @@ error do
end
get '/' do
check_login
@breadcrumbs << {:text => 'Home'}
# get the service spaces that this user has access to
spaces = @user.service_spaces
spaces = @user ? @user.service_spaces : []
app_wide_resources = Resource.where(:available_app_wide => true).all
page = params[:page]
page = page.to_i >= 1 ? page.to_i : 1
reservations = []
total_pages = 1
if @user
reservations = Reservation.joins(:resource).includes(:event).
where(:resources => {:available_app_wide => true}).
where(:user_id => @user.id).
where('end_time >= ?', Time.now.midnight).
order(:start_time).limit(5).offset((page-1)*5)
total_pages = (Reservation.joins(:resource).includes(:event).
where(:resources => {:available_app_wide => true}).
where(:user_id => @user.id).
where('end_time >= ?', Time.now.midnight).count + 4) / 5
end
erb :home, :layout => :fixed, :locals => {
spaces: spaces
spaces: spaces,
resources: app_wide_resources,
reservations: reservations,
total_pages: total_pages,
page: page
}
end
get '/images/:event_id/?' do
event = Event.find_by(:id => params[:event_id])
if event.nil? || event.imagedata.nil?
raise Sinatra::NotFound
end
return event.imagedata
get '/kiosk-logout/' do
session.clear
erb :kiosk_logout, :layout => :fixed, :locals => {
url_redirect: params[:url_redirect],
kiosk_mode: 'true'
}
end
Dir.glob("#{ROOT}/routes/*.rb") { |file| require file }
\ No newline at end of file
Dir.glob("#{ROOT}/routes/*.rb") { |file| require file }
{
"database" : {
"adapter" : "mysql",
"adapter" : "mysql2",
"host" : "localhost",
"username" : "root",
"password" : "",
......
require 'active_record'
class CreateDatabase < ActiveRecord::Migration
def change
create_table :resources do |t|
t.string :name
t.string :resource_type
t.string :model
t.text :description
t.integer :service_space_id
t.integer :minutes_per_reservation
t.boolean :needs_authorization
t.boolean :needs_approval
end
create_table :users do |t|
t.string :username
t.string :password_hash
t.string :email
t.string :first_name
t.string :last_name
t.string :university_status
t.datetime :date_created
t.integer :created_by_user_id
end
create_table :events do |t|
t.string :title
t.text :description
t.datetime :start_time
t.datetime :end_time
t.integer :service_space_id
end
create_table :reservations do |t|
t.integer :resource_id
t.integer :event_id
t.integer :user_id
t.datetime :start_time
t.datetime :end_time
t.boolean :is_training
end
create_table :resource_authorizations do |t|
t.integer :resource_id
t.integer :user_id
end
create_table :resource_approvers do |t|
t.integer :resource_id
t.integer :user_id
end
create_table :service_spaces do |t|
t.string :name
end
create_table :event_signups do |t|
t.integer :event_id
t.integer :user_id
t.string :name
end
end
end
\ No newline at end of file
require 'active_record'
class AddAdmin < ActiveRecord::Migration
def up
add_column :users, :is_admin, :boolean, :default => false
end
def down
remove_column :users, :is_admin
end
end
\ No newline at end of file
require 'active_record'
class AddEventTypes < ActiveRecord::Migration
def change
add_column :events, :event_type_id, :integer
create_table :event_types do |t|
t.string :description
t.integer :service_space_id
end
end
end
\ No newline at end of file
require 'active_record'
require 'models/service_space'
require 'models/event_type'
class InnovationStudioSs < ActiveRecord::Migration
def up
ss = ServiceSpace.create(
:name => 'Innovation Studio'
)
EventType.create(
:description => 'New Member Orientation',
:service_space_id => ss.id
)
EventType.create(
:description => 'Machine Training',
:service_space_id => ss.id
)
EventType.create(
:description => 'Advanced Skill-Based Workshop',
:service_space_id => ss.id
)
EventType.create(
:description => 'Creation Workshop',
:service_space_id => ss.id
)
EventType.create(
:description => 'General Workshop',
:service_space_id => ss.id
)
end
def down
ss = ServiceSpace.where(:name => 'Innovation Studio').first
EventType.where(:service_space_id => ss.id).delete_all
ss.delete
end
end
\ No newline at end of file
require 'active_record'
require 'models/location'
require 'models/service_space'
class AddLocations < ActiveRecord::Migration
def up
create_table :locations do |t|
t.string :name
t.string :streetaddress
t.string :streetaddress2
t.string :city
t.string :state
t.string :zip
t.string :additionalinfo
t.integer :service_space_id
end
Location.reset_column_information
ss = ServiceSpace.where(:name => "Innovation Studio").first
Location.create(
:name => 'Nebraska Innovation Studio',
:streetaddress => "2021 Transformation Drive",
:streetaddress2 => 'Suite 1500',
:city => 'Lincoln',
:state => 'NE',
:zip => '68508',
:additionalinfo => nil,
:service_space_id => ss.id
)
add_column :events, :location_id, :integer
end
def down
remove_column :events, :location_id
drop_table :locations
end
end
\ No newline at end of file
require 'active_record'
require 'models/service_space'
require 'models/resource'
class AddToolsFromDocument < ActiveRecord::Migration
def up
ss = ServiceSpace.where(:name => "Innovation Studio").first
[
['Oscilloscope', 'Rigo DS1054'],
['DC Power Supply', 'Gwinstek GPD-3303S'],
['Soldering Iron', 'Hakko FX-88D'],
['SMD Rework Station', 'Spark Fun 303D'],
['Vacuum Pen', 'Virtual Industries Inc. SMD-VAC HP'],
['Lead Free Solder Pot', 'SMT max ML-52T5'],
['Function/Arbitrary Waveform Generator', 'Rigol DG1022'],
['96" x 48" CNC Router', 'ShopBot PRSalpha'],
['Drill Press', 'Clausing 20'],
['Sliding Compound Miter Saw', 'Festrool Kapex KS 120 EB'],
['Table Saw', 'Saw Stop 10" Industrial Grade Cabinet Saw'],
['Laser Cutter', 'Epilog Fusion 32'],
['Large Format Printer', 'Epson Style Pro 4900'],
['3D Filament Desktop Printer', 'Ultimaker 2'],
['6" Industrial Belt Sander', 'Jet Stock # 414600'],
['12" Industrial Disc Sander', 'Jet Stock # 414602'],
['18" Variable Speed Scroll Saw', 'Delta'],
['18" Wood Band Saw', 'Laguna'],
['Panel Saw', 'Safety Speed'],
['3D Filament Desktop Printer', 'Stratasys Mojo'],
['Air Assist Pump (laser cutter)', 'GAST'],
['Desktop 3D Scanner', 'Next Engine'],
['Vinyl Cutter', 'Graphtec Cutting Plotter CE6000-60'],
['Industrial Sewing Machine', 'JUKI # 2DODE00141'],
['Standard Sewing Machine', 'Bernina 830'],
['Standard Sewing Machine', 'Bernina 803'],
['Ironing Station', '']
].each do |arr|
Resource.create(
:name => arr[0],
:resource_type => arr[0],
:model => arr[1],
:service_space_id => ss.id,
:needs_authorization => true,
:needs_approval => false
)
end
end
def down
ss = ServiceSpace.where(:name => "Innovation Studio").first
Resource.where(:service_space_id => ss.id).delete_all
end
end
\ No newline at end of file
require 'active_record'
class AddEmailEventSignup < ActiveRecord::Migration
def change
add_column :event_signups, :email, :string
end
end
\ No newline at end of file
require 'active_record'
class AddHours < ActiveRecord::Migration
def change
create_table :space_hours do |t|
t.integer :service_space_id
t.integer :day_of_week # 0 = Sunday, 6 = Saturday
t.datetime :effective_date # date to begin using these hours
t.boolean :one_off # is this all of this day moving forward or a special day
t.string :hours # encoded string describing the hours
end
end
end
\ No newline at end of file
require 'active_record'
require 'models/resource'
class ToolProperties < ActiveRecord::Migration
def up
add_column :resources, :is_reservable, :boolean
add_column :resources, :max_reservations_per_slot, :integer
Resource.reset_column_information
Resource.all.each do |resource|
resource.minutes_per_reservation = 60
resource.max_reservations_per_slot = 5
if resource.name == '96" x 48" CNC Router'
resource.minutes_per_reservation = 120
resource.max_reservations_per_slot = 3
end
resource.is_reservable = true
if resource.name == '3D Filament Desktop Printer'
resource.is_reservable = false
end
resource.save
end
end
def down
drop_column :resources, :is_reservable
drop_column :resources, :max_reservations_per_slot
end
end
\ No newline at end of file
require 'active_record'
require 'models/service_space'
require 'models/event_type'
class AddMoreEventTypes < ActiveRecord::Migration
def up
ss = ServiceSpace.find_by(
:name => 'Innovation Studio'
)
EventType.create(
:description => 'Free Event',
:service_space_id => ss.id
)
EventType.create(
:description => 'RSVP Only Event',
:service_space_id => ss.id
)
end
def down
ss = ServiceSpace.find_by(
:name => 'Innovation Studio'
)
EventType.where(:service_space_id => ss.id, :description => 'Free Event').delete
EventType.where(:service_space_id => ss.id, :description => 'RSVP Only Event').delete
end
end
\ No newline at end of file
require 'active_record'
class MaxSignups < ActiveRecord::Migration
def change
add_column :events, :max_signups, :integer
end
end
\ No newline at end of file