From 962671e99224d4be42135a8e7fff2a6d00bd9167 Mon Sep 17 00:00:00 2001 From: Chase Brownell Date: Mon, 10 Apr 2017 19:53:41 -0700 Subject: [PATCH] Pull Team Code Into master (#243) * updated the gemfile to include single test gem * Changed participant test for a current student in integration, added relationship to document test * Created Units tests for Charge model * Unit tests- shifts, events, documents (#228) * Created intial files for event and event type tests, modified documents relationships test * Document unit tests done, besides one clarification issue with search scope * Event unit tests done, added event and event type in factories.rb * Finished unit tests for FAQ * Fixed last error in document, have shift, shift type, and shift participant test passing * Unit Test - Tools (#229) * Created intial files for event and event type tests, modified documents relationships test * Document unit tests done, besides one clarification issue with search scope * Event unit tests done, added event and event type in factories.rb * Finished unit tests for FAQ * Fixed last error in document, have shift, shift type, and shift participant test passing * Made time to now instad of local in shift formatted_name test, finished toop type unit test and scope for tool test. Need to finish tool methods and tool_waitlist unit tests * FInished all unit test assigned to me besides tool and tool waitlist. Once tool waitlist is done, finish tool waitlist method in the tool unit test * Finished tool_waitlist test and finished the last method test in tool_test (now complete) * Test Cases for several models (#231) * created unit test for organization model. almost done * switching to goat branch to checkout akshay's commit * begining to modify test class for organization_alias_class. trying to merge rumby's modification on factories into my test branch * finished creating test class for organization_alias model. Everything functions properly * updated test for organization_category model. Everything functions properly * created new factory for organization_status_type. created a new test class for orgniazation_status but have been getting error message: factory not registered. Will come back to this later * fixed error! added organization_status to the factory file. test for organization_status now passed! * checking Rumby's PR. commiting before switching to goat * fixed previous file name error. Test for organization_status_type passed * finished up organization_timeline_entry test. removed duplicate schema comment in the status_type * updated organization test to include dependency testing * did some refactoring on organization_alias model and test * created test function for downtime methods * fixed syntax for org_category test. added test case for dependency * fixed minor syntax in test case for org_status and org_status_type * added test case for membership * added test case for judge, judgement, judgement_category * Added authorization checks - Home Controller & fixed Event okay/un-okay button (#234) * Added authorization checks so that anyone who isnt logged in cannot see downtime, charges overview, or hardhats * Changed the okay button to correct type of HTTP request so that the events ok/unokay works * Cleaned code (moved authorization from views to controllers) for charges (now participants can't read charges pages from views) * Commented shift test out, opened it up as a bug though so we know to go back and figure out the CI error on it * Added Dependency Tests for Participant, Coverage for Other Models & Bugfix (#237) * Added tests for charge_type model * Added tests for role model * Added tests for StoreItem model * Added tests for StorePurchase model * Added tests for Checkout model * Fixed charge model coverage * Added tests to charge_type, checkout, and partly participant * Added full test coverage for Task model * Added fixes to participant model tests * Added dependency tests for participant * Fixed duplicate cart items bug * Edited factory file to get rid of merge conflict * Added schema.rb file * Added Placeholder value for receiving participant when updating charges (#239) * created unit test for organization model. almost done * switching to goat branch to checkout akshay's commit * begining to modify test class for organization_alias_class. trying to merge rumby's modification on factories into my test branch * finished creating test class for organization_alias model. Everything functions properly * updated test for organization_category model. Everything functions properly * created new factory for organization_status_type. created a new test class for orgniazation_status but have been getting error message: factory not registered. Will come back to this later * fixed error! added organization_status to the factory file. test for organization_status now passed! * checking Rumby's PR. commiting before switching to goat * fixed previous file name error. Test for organization_status_type passed * finished up organization_timeline_entry test. removed duplicate schema comment in the status_type * updated organization test to include dependency testing * did some refactoring on organization_alias model and test * created test function for downtime methods * fixed syntax for org_category test. added test case for dependency * fixed minor syntax in test case for org_status and org_status_type * added test case for membership * added test case for judge, judgement, judgement_category * somehow event_type_test got updated with a new schema entry. Saving change before checking out akshay's unit tests * updated TravisCI's timezone to US Eastern time, which should match with the built in timezone indicated in application.rb * changed TRAVIS CI Setting to eastern time * trying to see if this fix for time works * travis yml syntax incorrect in the previous commit. just fixed it now. Hopefully this works * travis could not load timezone data. trying a different method * both attempts failed. reverted back to master branch version of travis configuration. Will create an issue * added redirect back to organization as a temporary solution for bug #201 * made modification to the charge param and fixed odd behavior, described in issue #202 * added placeholder value so that the receiving_participant does not seem to disappear * Update .travis.yml * Update event_type_test.rb * Cleaned Code for charge, charge_type, checkouts, and documents (#242) * Cleaned code for charges and charge type * Cleaned code for checkout * Cleaned code for documents besides the new * Cleaned views for events and event types * cleaned code for faqs * Added timezone on CI server config to correct CI server shift error (#245) * Reproducing issue #235 * Changing CI timezone to fix issue #235 * Ak/twilio notifications2 (#253) * added twilio messenger module, also tweaked the application config to autoload the module * Added 2 scenarios for notifications * Fixed organization timeline entry twilio notification * Fixed bugs for watch shift twilio notifications * Added assigned field to events and notifications for assignees when note is assigned to them * Switched notification delays to production times * Bl/waitlist notify (#254) * added twilio messenger module, also tweaked the application config to autoload the module * tried to modified messenger with text processing but failed * added code to send out text alert to the next person on the wait list after a tool is checked back in * added a safeguard for phone number in case someone has not put their phonenumber in the system yet * updated messenger module with try-rescue block * commented out code for reply forwarding. There is an issue for the forwarding and it seems to be security related. Need to discuss it with people more knowledgable before implemeting this feature * removed commented code. Will probably add it to a seperate branch. Just trying to merge this code to goat branch * modified messenger to keep track of error code * New features branch (#252) * Prevent participants from skipping saftey video * Added user certifications * Add certification check to tools checkout * Only show certifications required by tool type if they exist * Added cancan checks around certification creation and deletion * Added wristband field to participant view to help with wristband distribution #220 * Added digital signature to waiver #173 * Cleaned waiver code * Changed store items price datatype to support fractional prices #168 * Added rake db:migrate to travis script so it can build with migrations * Added rake db:migrate to travis script so it can build with migrations * Fixing style on PR #248 * Removing nil check for PR #248 * Changed error message after skipping the saftey video * Using migration technique from http://stackoverflow.com/questions/17150529 * Reverting to previous 9V battery price * Fixing spelling of 'safety' * Define wristband colors as constants * Added load_and_authorize_resource to CertificationsController * Changed building_status to is_building in db seeds file * Fixed waiver playing in bg for admin and allow admin to skip video * Added scissor lift wristband color * Updated safety video * Cleaned up waiver code and let user skip waiver on error from previous error * Fixed ForbiddenAttribute error on certification creation * Fixed messed up sidebar on SCC member new waiver * Removed duplicate gems in Gemfile * Added delayed_job bin to git (https://github.com/platanus/capistrano3-delayed-job/pull/21) * Fixed db migration for is_building field in organization_category * Added requested legal clauses to waiver * Fixed scissor lift wristband color * Bl/waitlist notify (#259) * added twilio messenger module, also tweaked the application config to autoload the module * tried to modified messenger with text processing but failed * added code to send out text alert to the next person on the wait list after a tool is checked back in * added a safeguard for phone number in case someone has not put their phonenumber in the system yet * updated messenger module with try-rescue block * commented out code for reply forwarding. There is an issue for the forwarding and it seems to be security related. Need to discuss it with people more knowledgable before implemeting this feature * removed commented code. Will probably add it to a seperate branch. Just trying to merge this code to goat branch * modified messenger to keep track of error code * made change to charges controller as requested * Ak/twilio notifications2 (#258) * added twilio messenger module, also tweaked the application config to autoload the module * Added 2 scenarios for notifications * Fixed organization timeline entry twilio notification * Fixed bugs for watch shift twilio notifications * Added assigned field to events and notifications for assignees when note is assigned to them * Switched notification delays to production times * Added tweaks stephen requested, including showing preview of the event in text, fixing the scc exec member drop down, and sending a text when everyone is confirmed for a watch shift * Added production times for shift notifications * Added proper messenger code * Fixed up gemfile for merge * Fixed delayed_job mis-spelling * Update participant_test.rb * Updated safety video --- .travis.yml | 4 +- Gemfile | 13 +- Gemfile.lock | 19 ++- Rakefile | 1 + app/controllers/certifications_controller.rb | 44 ++++++ app/controllers/charge_types_controller.rb | 17 +++ app/controllers/charges_controller.rb | 35 ++++- app/controllers/checkouts_controller.rb | 27 +++- app/controllers/documents_controller.rb | 18 +++ app/controllers/event_types_controller.rb | 15 ++- app/controllers/events_controller.rb | 23 +++- app/controllers/faqs_controller.rb | 16 +++ app/controllers/home_controller.rb | 3 + app/controllers/memberships_controller.rb | 25 ++++ .../organization_aliases_controller.rb | 22 +++ .../organization_status_types_controller.rb | 13 ++ .../organization_statuses_controller.rb | 22 +++ ...rganization_timeline_entries_controller.rb | 23 ++++ app/controllers/organizations_controller.rb | 21 +++ app/controllers/participants_controller.rb | 59 ++++++++- .../shift_participants_controller.rb | 23 ++++ app/controllers/shifts_controller.rb | 27 +++- app/controllers/store/purchases_controller.rb | 20 ++- app/controllers/tasks_controller.rb | 18 +++ app/controllers/tool_cart_controller.rb | 12 ++ app/controllers/tool_types_controller.rb | 14 ++ app/controllers/tool_waitlists_controller.rb | 24 ++++ app/controllers/tools_controller.rb | 23 ++++ app/controllers/users_controller.rb | 31 +++++ app/controllers/waivers_controller.rb | 23 +++- app/helpers/charges_helper.rb | 27 ++++ app/helpers/checkouts_helper.rb | 23 ++++ app/helpers/memberships_helper.rb | 25 ++++ app/helpers/organizations_helper.rb | 21 +++ app/helpers/participants_helper.rb | 30 +++++ app/helpers/shift_participants_helper.rb | 23 ++++ app/helpers/shifts_helper.rb | 24 ++++ app/helpers/tasks_helper.rb | 18 +++ app/helpers/tool_types_helper.rb | 14 ++ app/helpers/tool_waitlists_helper.rb | 24 ++++ app/helpers/tools_helper.rb | 23 ++++ app/models/ability.rb | 6 +- app/models/certification.rb | 4 + app/models/certification_type.rb | 3 + app/models/checkout.rb | 22 ++- app/models/event.rb | 41 ++++-- app/models/event_type.rb | 10 +- app/models/membership.rb | 4 +- app/models/organization_alias.rb | 4 +- app/models/organization_category.rb | 13 +- app/models/organization_timeline_entry.rb | 21 ++- app/models/participant.rb | 21 ++- app/models/shift.rb | 53 +++++++- app/models/shift_participant.rb | 2 +- app/models/store_item.rb | 2 +- app/models/store_purchase.rb | 5 +- app/models/tool_type.rb | 2 + app/models/tool_type_certification.rb | 26 ++++ app/views/certifications/_form.html.erb | 18 +++ app/views/certifications/new.html.erb | 6 + app/views/charges/_form.html.erb | 5 +- app/views/charges/edit.html.erb | 14 +- app/views/charges/index.html.erb | 125 +++++++++--------- app/views/charges/new.html.erb | 14 +- app/views/charges/show.html.erb | 95 +++++++------ app/views/checkouts/index.html.erb | 61 ++++----- app/views/documents/edit.html.erb | 14 +- app/views/documents/index.html.erb | 99 +++++++------- app/views/event_types/index.html.erb | 54 ++++---- app/views/event_types/new.html.erb | 8 +- app/views/events/_form.html.erb | 5 +- app/views/events/edit.html.erb | 8 +- app/views/events/index.html.erb | 92 ++++++------- app/views/events/show.html.erb | 6 +- app/views/faqs/edit.html.erb | 15 +-- app/views/faqs/index.html.erb | 80 ++++++----- app/views/participants/show.html.erb | 45 +++++-- app/views/tools/show.html.erb | 10 ++ app/views/waivers/new.html.erb | 121 +++++++++-------- bin/delayed_job | 5 + config/application.rb | 5 + config/routes.rb | 1 + ...5040259_add_waiver_start_to_participant.rb | 5 + ...170321154121_create_certification_types.rb | 9 ++ .../20170321154153_create_certifications.rb | 12 ++ ...2031706_create_tool_type_certifications.rb | 12 ++ ...163001_change_store_item_price_datatype.rb | 6 + .../20170326233627_create_delayed_jobs.rb | 22 +++ ...0402012413_add_participant_id_to_events.rb | 5 + ...dd_is_building_to_organization_category.rb | 5 + db/schema.rb | 116 ++++++++++++---- db/seeds.rb | 27 ++-- db/tool_seed.rb | 9 +- lib/messenger.rb | 31 +++++ public/cheating.html | 34 +++++ public/images/spy.jpg | Bin 0 -> 17388 bytes test/factories.rb | 48 ++++++- test/integration/participant_test.rb | 12 +- test/models/store_item_test.rb | 23 ---- test/test_helper.rb | 2 + test/unit/charge_test.rb | 22 ++- test/unit/charge_type_test.rb | 14 +- test/unit/checkout_test.rb | 21 ++- test/unit/document_test.rb | 25 +++- test/unit/event_test.rb | 40 ++++++ test/unit/event_type_test.rb | 20 +++ test/unit/faq_test.rb | 18 ++- test/{models => unit}/judge_test.rb | 0 .../judgement_category_test.rb | 0 test/{models => unit}/judgement_test.rb | 8 +- test/unit/membership_test.rb | 24 ++-- test/unit/organization_alias_test.rb | 33 ++++- test/unit/organization_category_test.rb | 26 ++-- test/unit/organization_status_test.rb | 70 ++++++++++ test/unit/organization_status_type_test.rb | 58 ++++++++ test/unit/organization_test.rb | 119 ++++++++++++++++- test/unit/organization_timeline_entry_test.rb | 17 ++- test/unit/participant_test.rb | 97 +++++++++++++- test/unit/role_test.rb | 2 + test/unit/shift_participant_test.rb | 15 ++- test/unit/shift_test.rb | 49 ++++++- test/unit/store_item_test.rb | 44 ++++++ test/{models => unit}/store_purchase_test.rb | 30 ++++- test/unit/task_test.rb | 7 + test/unit/tool_test.rb | 76 ++++++++--- test/unit/tool_type_test.rb | 1 + test/unit/tool_waitlist_test.rb | 61 ++++++++- 127 files changed, 2657 insertions(+), 650 deletions(-) create mode 100644 app/controllers/certifications_controller.rb create mode 100644 app/models/certification.rb create mode 100644 app/models/certification_type.rb create mode 100644 app/models/tool_type_certification.rb create mode 100644 app/views/certifications/_form.html.erb create mode 100644 app/views/certifications/new.html.erb create mode 100755 bin/delayed_job create mode 100644 db/migrate/20170305040259_add_waiver_start_to_participant.rb create mode 100644 db/migrate/20170321154121_create_certification_types.rb create mode 100644 db/migrate/20170321154153_create_certifications.rb create mode 100644 db/migrate/20170322031706_create_tool_type_certifications.rb create mode 100644 db/migrate/20170323163001_change_store_item_price_datatype.rb create mode 100644 db/migrate/20170326233627_create_delayed_jobs.rb create mode 100644 db/migrate/20170402012413_add_participant_id_to_events.rb create mode 100644 db/migrate/20170410184313_add_is_building_to_organization_category.rb create mode 100644 lib/messenger.rb create mode 100644 public/cheating.html create mode 100644 public/images/spy.jpg delete mode 100644 test/models/store_item_test.rb create mode 100644 test/unit/event_test.rb create mode 100644 test/unit/event_type_test.rb rename test/{models => unit}/judge_test.rb (100%) rename test/{models => unit}/judgement_category_test.rb (100%) rename test/{models => unit}/judgement_test.rb (91%) create mode 100644 test/unit/organization_status_test.rb create mode 100644 test/unit/organization_status_type_test.rb create mode 100644 test/unit/store_item_test.rb rename test/{models => unit}/store_purchase_test.rb (52%) diff --git a/.travis.yml b/.travis.yml index 5cbcbff5..6b755814 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,6 @@ rvm: bundler_args: --without development staging production sudo: false before_script: - - bundle exec rake db:test:prepare + - bundle exec rake test:prepare + - bundle exec rake db:migrate + - export TZ='America/New_York' diff --git a/Gemfile b/Gemfile index 8250c27e..d5304fce 100644 --- a/Gemfile +++ b/Gemfile @@ -26,6 +26,11 @@ gem 'activeldap', :require => 'active_ldap/railtie' # For Card-lookup requests gem 'savon' +# For delayed jobs +gem 'daemons' +gem 'delayed_job' +gem 'delayed_job_active_record' + # For Capistrano deployment group :development do gem 'capistrano-rbenv', require: false @@ -44,6 +49,7 @@ group :development do # sudo commands in capistrano gem 'sshkit-sudo' + end # Document attachments @@ -65,6 +71,9 @@ gem 'twilio-ruby' # Dossier for reports gem 'dossier' +# Single test gem for unit testing +gem 'single_test' + group :development do # Automatically generate comments in models and such based on schema gem 'annotate' @@ -84,6 +93,7 @@ end group :development, :staging, :production do gem 'newrelic_rpm' gem 'mysql2' + gem 'capistrano3-delayed-job' end group :test do @@ -113,4 +123,5 @@ end group :staging, :production do gem 'passenger' -end + +end \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 2d8549ef..60dacdc3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -78,6 +78,8 @@ GEM capistrano-rbenv (2.0.4) capistrano (~> 3.1) sshkit (~> 1.3) + capistrano3-delayed-job (1.7.2) + capistrano (~> 3.0, >= 3.0.0) carrierwave (0.11.0) activemodel (>= 3.2.0) activesupport (>= 3.2.0) @@ -103,6 +105,11 @@ GEM safe_yaml (~> 1.0.0) daemons (1.2.3) debug_inspector (0.0.2) + delayed_job (4.1.2) + activesupport (>= 3.0, < 5.1) + delayed_job_active_record (4.1.1) + activerecord (>= 3.0, < 5.1) + delayed_job (>= 3.0, < 5) devise (3.5.6) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -269,6 +276,8 @@ GEM json (~> 1.8) simplecov-html (~> 0.10.0) simplecov-html (0.10.0) + single_test (0.6.0) + rake spring (1.6.4) sprockets (3.5.2) concurrent-ruby (~> 1.0) @@ -337,9 +346,13 @@ DEPENDENCIES capistrano-passenger capistrano-rails capistrano-rbenv + capistrano3-delayed-job carrierwave coffee-rails coveralls + daemons + delayed_job + delayed_job_active_record devise dossier factory_girl_rails @@ -366,6 +379,7 @@ DEPENDENCIES shoulda shoulda-matchers simple_form + single_test spring sqlite3 sshkit-sudo @@ -378,5 +392,8 @@ DEPENDENCIES will_paginate will_paginate-bootstrap +RUBY VERSION + ruby 2.3.0p0 + BUNDLED WITH - 1.11.2 + 1.14.5 diff --git a/Rakefile b/Rakefile index b9fcfc93..b457ecd6 100644 --- a/Rakefile +++ b/Rakefile @@ -2,5 +2,6 @@ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) +require 'single_test/tasks' Trailerapp::Application.load_tasks diff --git a/app/controllers/certifications_controller.rb b/app/controllers/certifications_controller.rb new file mode 100644 index 00000000..682aec0c --- /dev/null +++ b/app/controllers/certifications_controller.rb @@ -0,0 +1,44 @@ +class CertificationsController < ApplicationController + load_and_authorize_resource + + before_action :set_participant, only: [:new, :create] + before_action :set_certification, only: [:destroy] + before_action :check_all_certifications, except: [:destroy] + + def new + @certification = Certification.new(:participant => @participant) + respond_with @certification + end + + def create + @certification = Certification.new(certification_params) + @certification.participant = @participant + @certification.save + respond_with @certification, location: -> { @certification.participant } + end + + def destroy + @certification.destroy + respond_with @certification, location: -> { @certification.participant } + end + + private + def set_participant + @participant = Participant.find(params[:participant_id]) + end + + def set_certification + @certification = Certification.find(params[:id]) + end + + def check_all_certifications + if @participant.certifications.size == CertificationType.all.size + redirect_to (participant_path @participant), :flash => { :error => @participant.name + " has already gotten all certifications." } + end + end + + def certification_params + params.require(:certification).permit(:participant_id, :certification_type_id) + end + +end diff --git a/app/controllers/charge_types_controller.rb b/app/controllers/charge_types_controller.rb index 1095c4a9..8b4e81ab 100644 --- a/app/controllers/charge_types_controller.rb +++ b/app/controllers/charge_types_controller.rb @@ -1,3 +1,20 @@ +# ## Schema Information +# +# Table name: `charge_types` +# +# ### Columns +# +# Name | Type | Attributes +# ------------------------------------ | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`default_amount`** | `decimal(8, 2)` | +# **`description`** | `text(65535)` | +# **`id`** | `integer` | `not null, primary key` +# **`name`** | `string(255)` | +# **`requires_booth_chair_approval`** | `boolean` | +# **`updated_at`** | `datetime` | +# + class ChargeTypesController < ApplicationController load_and_authorize_resource diff --git a/app/controllers/charges_controller.rb b/app/controllers/charges_controller.rb index 970688cd..6a499db6 100644 --- a/app/controllers/charges_controller.rb +++ b/app/controllers/charges_controller.rb @@ -1,5 +1,32 @@ +# ## Schema Information +# +# Table name: `charges` +# +# ### Columns +# +# Name | Type | Attributes +# ------------------------------- | ------------------ | --------------------------- +# **`amount`** | `decimal(8, 2)` | +# **`charge_type_id`** | `integer` | +# **`charged_at`** | `datetime` | +# **`created_at`** | `datetime` | +# **`creating_participant_id`** | `integer` | +# **`description`** | `text(65535)` | +# **`id`** | `integer` | `not null, primary key` +# **`is_approved`** | `boolean` | +# **`issuing_participant_id`** | `integer` | +# **`organization_id`** | `integer` | +# **`receiving_participant_id`** | `integer` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_charges_on_organization_id`: +# * **`organization_id`** +# + class ChargesController < ApplicationController - load_and_authorize_resource skip_load_resource only: [:create] + load_and_authorize_resource before_action :set_charge, only: [:show, :edit, :update, :destroy, :approve] # GET /charges @@ -32,6 +59,7 @@ def new # GET /charges/1/edit def edit + @current_receiving_participant = @charge.receiving_participant? ? "" : @charge.receiving_participant.formatted_name end # POST /charges @@ -49,7 +77,7 @@ def create # PUT /charges/1.json def update @charge.is_approved = false - @charge.update(charge_params) + @charge.update_attributes(charge_params) respond_with(@charge) end @@ -69,7 +97,8 @@ def destroy def approve @charge.is_approved = !@charge.is_approved @charge.save - respond_with @charge, location: -> {charges_path} + + respond_with(@charge, location: @charge.organization) end private diff --git a/app/controllers/checkouts_controller.rb b/app/controllers/checkouts_controller.rb index ae7688e5..923fde83 100644 --- a/app/controllers/checkouts_controller.rb +++ b/app/controllers/checkouts_controller.rb @@ -1,3 +1,26 @@ +# ## Schema Information +# +# Table name: `checkouts` +# +# ### Columns +# +# Name | Type | Attributes +# ---------------------- | ------------------ | --------------------------- +# **`checked_in_at`** | `datetime` | +# **`checked_out_at`** | `datetime` | +# **`created_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`organization_id`** | `integer` | +# **`participant_id`** | `integer` | +# **`tool_id`** | `integer` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_checkouts_on_tool_id`: +# * **`tool_id`** +# + class CheckoutsController < ApplicationController # permissions error - when enabled, this tries to find a Checkout with the current related model id on creation # load_and_authorize_resource @@ -7,6 +30,7 @@ class CheckoutsController < ApplicationController def index @tool = Tool.find(params[:tool_id]) @checkouts = @tool.checkouts + authorize! :read, @checkouts respond_to do |format| format.html # index.html.erb @@ -136,8 +160,6 @@ def uncheckin format.html { redirect_to tool_path(checkout.tool), notice: "Error" } end end - - end @@ -181,5 +203,6 @@ def checkin_bak end end end + end diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 8cbd1ba0..4604a452 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -1,3 +1,21 @@ +# ## Schema Information +# +# Table name: `documents` +# +# ### Columns +# +# Name | Type | Attributes +# ---------------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`document_id`** | `integer` | +# **`id`** | `integer` | `not null, primary key` +# **`name`** | `string(255)` | +# **`organization_id`** | `integer` | +# **`public`** | `boolean` | +# **`updated_at`** | `datetime` | +# **`url`** | `string(255)` | +# + class DocumentsController < ApplicationController load_and_authorize_resource skip_load_resource only: [:create] diff --git a/app/controllers/event_types_controller.rb b/app/controllers/event_types_controller.rb index 062aa102..1ec510d2 100644 --- a/app/controllers/event_types_controller.rb +++ b/app/controllers/event_types_controller.rb @@ -1,3 +1,16 @@ +# ## Schema Information +# +# Table name: `event_types` +# +# ### Columns +# +# Name | Type | Attributes +# -------------- | ------------------ | --------------------------- +# **`display`** | `boolean` | +# **`id`** | `integer` | `not null, primary key` +# **`name`** | `string(255)` | +# + class EventTypesController < ApplicationController load_and_authorize_resource before_action :set_event_type, only: [:show, :edit, :update, :destroy] @@ -78,4 +91,4 @@ def set_event_type def event_type_params params.require(:event_type).permit(:display, :name) end -end +end \ No newline at end of file diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 77fdac97..599fcad0 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -1,3 +1,20 @@ +# ## Schema Information +# +# Table name: `events` +# +# ### Columns +# +# Name | Type | Attributes +# --------------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`description`** | `text(65535)` | +# **`event_type_id`** | `integer` | +# **`id`** | `integer` | `not null, primary key` +# **`is_done`** | `boolean` | +# **`participant_id`** | `integer` | +# **`updated_at`** | `datetime` | +# + class EventsController < ApplicationController load_and_authorize_resource before_action :set_event, only: [:show, :edit, :update, :destroy,:approve] @@ -16,6 +33,7 @@ def show # GET /events/new def new @event = Event.new + @scc_members = Participant.all.scc end # PUT @@ -27,6 +45,7 @@ def approve # GET /events/1/edit def edit + @scc_members = Participant.all.scc @event.updated_at = DateTime.now @event.save end @@ -81,6 +100,6 @@ def set_event # Never trust parameters from the scary internet, only allow the white list through. def event_params - params.require(:event).permit(:is_done, :title, :created_at, :description, :updated_at, :display, :event_type_id) + params.require(:event).permit(:is_done, :title, :created_at, :description, :updated_at, :display, :event_type_id, :participant_id) end -end +end \ No newline at end of file diff --git a/app/controllers/faqs_controller.rb b/app/controllers/faqs_controller.rb index 18d1db20..549806e5 100644 --- a/app/controllers/faqs_controller.rb +++ b/app/controllers/faqs_controller.rb @@ -1,3 +1,18 @@ +# ## Schema Information +# +# Table name: `faqs` +# +# ### Columns +# +# Name | Type | Attributes +# ----------------- | ------------------ | --------------------------- +# **`answer`** | `text(65535)` | +# **`created_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`question`** | `text(65535)` | +# **`updated_at`** | `datetime` | +# + class FaqsController < ApplicationController load_and_authorize_resource skip_load_resource only: [:create] before_action :set_faq, only: [:edit, :update, :destroy] @@ -6,6 +21,7 @@ class FaqsController < ApplicationController # GET /faqs.json def index @faqs = Faq.all + authorize! :read, @faqs end # GET /faqs/new diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 5e85a5aa..ad6d3795 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -71,11 +71,13 @@ def dev_login def hardhats @organizations = Organization.joins(:tools).distinct + authorize! :read, @organizations @total = Tool.hardhats.checked_out.count end def charge_overview @organizations = Organization.joins(:charges).distinct.includes(:charges) + authorize! :read, @organizations @charge_types = ChargeType.all.includes(:charges) @approved_total = Charge.approved.sum('amount') @pending_total = Charge.pending.sum('amount') @@ -84,6 +86,7 @@ def charge_overview def downtime @organizations = Organization.only_categories(['Fraternity', 'Sorority', 'Independent', 'Blitz', 'Concessions']) + authorize! :read, @organizations end def hardhat_return diff --git a/app/controllers/memberships_controller.rb b/app/controllers/memberships_controller.rb index c5f5cdc0..c3292b79 100644 --- a/app/controllers/memberships_controller.rb +++ b/app/controllers/memberships_controller.rb @@ -1,3 +1,28 @@ +# ## Schema Information +# +# Table name: `memberships` +# +# ### Columns +# +# Name | Type | Attributes +# ------------------------ | ------------------ | --------------------------- +# **`booth_chair_order`** | `integer` | +# **`created_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`is_booth_chair`** | `boolean` | +# **`organization_id`** | `integer` | +# **`participant_id`** | `integer` | +# **`title`** | `string(255)` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_memberships_on_organization_id`: +# * **`organization_id`** +# * `index_memberships_on_participant_id`: +# * **`participant_id`** +# + class MembershipsController < ApplicationController load_and_authorize_resource skip_load_resource :only => [:create, :update] diff --git a/app/controllers/organization_aliases_controller.rb b/app/controllers/organization_aliases_controller.rb index 9eca4d32..441e9e8e 100644 --- a/app/controllers/organization_aliases_controller.rb +++ b/app/controllers/organization_aliases_controller.rb @@ -1,3 +1,25 @@ +# ## Schema Information +# +# Table name: `organization_aliases` +# +# ### Columns +# +# Name | Type | Attributes +# ---------------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`name`** | `string(255)` | +# **`organization_id`** | `integer` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_organization_aliases_on_name`: +# * **`name`** +# * `index_organization_aliases_on_organization_id`: +# * **`organization_id`** +# + class OrganizationAliasesController < ApplicationController # permissions error - when enabled, this tries to find a OrganizationAlias with the current related model id on creation responders :flash, :http_cache diff --git a/app/controllers/organization_status_types_controller.rb b/app/controllers/organization_status_types_controller.rb index 94dd95ac..f4ca6a34 100644 --- a/app/controllers/organization_status_types_controller.rb +++ b/app/controllers/organization_status_types_controller.rb @@ -1,3 +1,16 @@ +# ## Schema Information +# +# Table name: `organization_status_types` +# +# ### Columns +# +# Name | Type | Attributes +# -------------- | ------------------ | --------------------------- +# **`display`** | `boolean` | +# **`id`** | `integer` | `not null, primary key` +# **`name`** | `string(255)` | +# + class OrganizationStatusTypesController < ApplicationController load_and_authorize_resource diff --git a/app/controllers/organization_statuses_controller.rb b/app/controllers/organization_statuses_controller.rb index 39ea3f21..42d881c8 100644 --- a/app/controllers/organization_statuses_controller.rb +++ b/app/controllers/organization_statuses_controller.rb @@ -1,3 +1,25 @@ +# ## Schema Information +# +# Table name: `organization_statuses` +# +# ### Columns +# +# Name | Type | Attributes +# ---------------------------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`description`** | `string(255)` | +# **`id`** | `integer` | `not null, primary key` +# **`organization_id`** | `integer` | +# **`organization_status_type_id`** | `integer` | +# **`participant_id`** | `integer` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_organization_statuses_on_organization_id`: +# * **`organization_id`** +# + class OrganizationStatusesController < ApplicationController load_and_authorize_resource skip_load_resource only: [:create] before_action :set_organization_status, only: [:show, :edit, :update, :destroy] diff --git a/app/controllers/organization_timeline_entries_controller.rb b/app/controllers/organization_timeline_entries_controller.rb index edaac014..6b28d9e9 100644 --- a/app/controllers/organization_timeline_entries_controller.rb +++ b/app/controllers/organization_timeline_entries_controller.rb @@ -1,3 +1,26 @@ +# ## Schema Information +# +# Table name: `organization_timeline_entries` +# +# ### Columns +# +# Name | Type | Attributes +# ---------------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`description`** | `text(65535)` | +# **`ended_at`** | `datetime` | +# **`entry_type`** | `integer` | +# **`id`** | `integer` | `not null, primary key` +# **`organization_id`** | `integer` | +# **`started_at`** | `datetime` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_organization_timeline_entries_on_organization_id`: +# * **`organization_id`** +# + class OrganizationTimelineEntriesController < ApplicationController authorize_resource before_action :set_organization_timeline_entry, only: [:update, :destroy, :end, :show] diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 6c9db580..f6d0b42e 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -1,3 +1,24 @@ +# ## Schema Information +# +# Table name: `organizations` +# +# ### Columns +# +# Name | Type | Attributes +# ------------------------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`name`** | `string(255)` | +# **`organization_category_id`** | `integer` | +# **`short_name`** | `string(255)` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_organizations_on_organization_category_id`: +# * **`organization_category_id`** +# + class OrganizationsController < ApplicationController load_and_authorize_resource diff --git a/app/controllers/participants_controller.rb b/app/controllers/participants_controller.rb index 6b0e2b2c..679326de 100644 --- a/app/controllers/participants_controller.rb +++ b/app/controllers/participants_controller.rb @@ -1,7 +1,40 @@ +# ## Schema Information +# +# Table name: `participants` +# +# ### Columns +# +# Name | Type | Attributes +# -------------------------------- | ------------------ | --------------------------- +# **`andrewid`** | `string(255)` | +# **`cache_updated`** | `datetime` | +# **`cached_department`** | `string(255)` | +# **`cached_email`** | `string(255)` | +# **`cached_name`** | `string(255)` | +# **`cached_student_class`** | `string(255)` | +# **`cached_surname`** | `string(255)` | +# **`created_at`** | `datetime` | +# **`has_signed_hardhat_waiver`** | `boolean` | +# **`has_signed_waiver`** | `boolean` | +# **`id`** | `integer` | `not null, primary key` +# **`phone_carrier_id`** | `integer` | +# **`phone_number`** | `string(255)` | +# **`updated_at`** | `datetime` | +# **`user_id`** | `integer` | +# **`waiver_start`** | `datetime` | + +# +# ### Indexes +# +# * `index_participants_on_phone_carrier_id`: +# * **`phone_carrier_id`** +# + class ParticipantsController < ApplicationController load_and_authorize_resource skip_load_resource only: [:create] before_action :set_participant, only: [:show, :edit, :update, :destroy] - + before_action :set_wristband_colors + # GET /participants # GET /participants.json def index @@ -34,6 +67,24 @@ def lookup # GET /participants/1.json def show @memberships = @participant.memberships.all + + if @memberships.empty? + @wristband = "None - No organizations" + elsif !@participant.has_signed_waiver + @wristband = "None - No waiver signature" + else + building_statuses = @memberships.map { |m| m.organization.organization_category.is_building } + if building_statuses.include?(true) + @wristband = @wristband_colors[:building] + else + @wristband = @wristband_colors[:nonbuilding] + end + + certs = @participant.certifications.map { |cert| cert.certification_type } + if certs.include?(CertificationType.find_by_name("Scissor Lift")) + @wristband += " and " + @wristband_colors[:scissor_lift] + end + end end # GET /participants/new @@ -80,5 +131,9 @@ def participant_create_params def participant_update_params params.require(:participant).permit(:phone_number, :has_signed_waiver, :has_signed_hardhat_waiver) end -end + def set_wristband_colors + @wristband_colors = { :building => "Red", :nonbuilding => "Blue", :scissor_lift => "Green" } + end + +end diff --git a/app/controllers/shift_participants_controller.rb b/app/controllers/shift_participants_controller.rb index be2977bb..7d0419b3 100644 --- a/app/controllers/shift_participants_controller.rb +++ b/app/controllers/shift_participants_controller.rb @@ -1,3 +1,26 @@ +# ## Schema Information +# +# Table name: `shift_participants` +# +# ### Columns +# +# Name | Type | Attributes +# --------------------- | ------------------ | --------------------------- +# **`clocked_in_at`** | `datetime` | +# **`created_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`participant_id`** | `integer` | +# **`shift_id`** | `integer` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_shift_participants_on_participant_id`: +# * **`participant_id`** +# * `index_shift_participants_on_shift_id`: +# * **`shift_id`** +# + class ShiftParticipantsController < ApplicationController # DELETE /shift_participants/1 # DELETE /shift_participants/1.json diff --git a/app/controllers/shifts_controller.rb b/app/controllers/shifts_controller.rb index 523193af..3fd6377c 100644 --- a/app/controllers/shifts_controller.rb +++ b/app/controllers/shifts_controller.rb @@ -1,3 +1,27 @@ +# ## Schema Information +# +# Table name: `shifts` +# +# ### Columns +# +# Name | Type | Attributes +# -------------------------------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`description`** | `string(255)` | +# **`ends_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`organization_id`** | `integer` | +# **`required_number_of_participants`** | `integer` | +# **`shift_type_id`** | `integer` | +# **`starts_at`** | `datetime` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_shifts_on_organization_id`: +# * **`organization_id`** +# + class ShiftsController < ApplicationController load_and_authorize_resource skip_load_resource only: [:create] before_action :set_shift, only: [:show, :edit, :update, :destroy] @@ -77,4 +101,5 @@ def set_shift def shift_params params.require(:shift).permit(:starts_at, :ends_at, :shift_type_id, :organization_id, :required_number_of_participants, :description) end -end + +end \ No newline at end of file diff --git a/app/controllers/store/purchases_controller.rb b/app/controllers/store/purchases_controller.rb index 021137b0..f82253fb 100644 --- a/app/controllers/store/purchases_controller.rb +++ b/app/controllers/store/purchases_controller.rb @@ -1,13 +1,21 @@ class Store::PurchasesController < ApplicationController def add_to_cart - @store_purchase = StorePurchase.new + all_store_items = StorePurchase.all.map { |s| s.store_item } item = StoreItem.find params[:id] - @store_purchase.quantity_purchased = 1 - @store_purchase.price_at_purchase = item.price - @store_purchase.store_item = item - @store_purchase.save - + if all_store_items.include?(item) + @old_store_purchase = StorePurchase.where("store_item_id= ?", item.id) + @old_store_purchase[0].quantity_purchased += 1 + @old_store_purchase[0].price_at_purchase = item.price + @old_store_purchase[0].store_item = item + @old_store_purchase[0].save + else + @store_purchase = StorePurchase.new + @store_purchase.quantity_purchased = 1 + @store_purchase.price_at_purchase = item.price + @store_purchase.store_item = item + @store_purchase.save + end #respond_with(@store_purchase) redirect_to store_url end diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb index 5cb5f1fe..0bdf93bf 100644 --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -1,3 +1,21 @@ +# ## Schema Information +# +# Table name: `tasks` +# +# ### Columns +# +# Name | Type | Attributes +# ---------------------- | ------------------ | --------------------------- +# **`completed_by_id`** | `integer` | +# **`created_at`** | `datetime` | +# **`description`** | `text(65535)` | +# **`due_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`is_completed`** | `boolean` | +# **`name`** | `string(255)` | +# **`updated_at`** | `datetime` | +# + class TasksController < ApplicationController load_and_authorize_resource diff --git a/app/controllers/tool_cart_controller.rb b/app/controllers/tool_cart_controller.rb index 7edac331..52517d55 100644 --- a/app/controllers/tool_cart_controller.rb +++ b/app/controllers/tool_cart_controller.rb @@ -62,6 +62,18 @@ def checkout locals: {message: "Invalid organization"} end + participant_certs = participant.certifications.map { |cert| cert.certification_type.name } + session[:tool_cart].each do |tool| + tool = Tool.find_by_barcode(tool) + required_certs = tool.tool_type.tool_type_certifications.map { |cert| cert.certification_type.name } + required_certs.each do |required_cert| + if !participant_certs.include?(required_cert) + return render action: 'tool_cart_error', + locals: {message: "#{required_cert} certification required for #{tool.name} tool!"} + end + end + end + # Add membership if params[:add_membership] Membership.create({participant_id: params[:participant_id], organization_id: params[:organization_id]}) diff --git a/app/controllers/tool_types_controller.rb b/app/controllers/tool_types_controller.rb index 3583a12c..0c2b9ded 100644 --- a/app/controllers/tool_types_controller.rb +++ b/app/controllers/tool_types_controller.rb @@ -1,3 +1,17 @@ +# ## Schema Information +# +# Table name: `tool_types` +# +# ### Columns +# +# Name | Type | Attributes +# ----------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`name`** | `string(255)` | +# **`updated_at`** | `datetime` | +# + class ToolTypesController < ApplicationController load_and_authorize_resource diff --git a/app/controllers/tool_waitlists_controller.rb b/app/controllers/tool_waitlists_controller.rb index 9da55dc1..732c5fc7 100644 --- a/app/controllers/tool_waitlists_controller.rb +++ b/app/controllers/tool_waitlists_controller.rb @@ -1,3 +1,27 @@ +# ## Schema Information +# +# Table name: `tool_waitlists` +# +# ### Columns +# +# Name | Type | Attributes +# ---------------------- | ------------------ | --------------------------- +# **`active`** | `boolean` | `default(TRUE)` +# **`created_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`note`** | `string(255)` | +# **`organization_id`** | `integer` | +# **`participant_id`** | `integer` | +# **`tool_type_id`** | `integer` | +# **`updated_at`** | `datetime` | +# **`wait_start_time`** | `datetime` | +# +# ### Indexes +# +# * `index_tool_waitlists_on_tool_type_id`: +# * **`tool_type_id`** +# + class ToolWaitlistsController < ApplicationController # Can't use load_and_authorize_resource until it's fixed in the # checkout controller as well. diff --git a/app/controllers/tools_controller.rb b/app/controllers/tools_controller.rb index d3007786..c5aeebf8 100644 --- a/app/controllers/tools_controller.rb +++ b/app/controllers/tools_controller.rb @@ -1,3 +1,26 @@ +# ## Schema Information +# +# Table name: `tools` +# +# ### Columns +# +# Name | Type | Attributes +# ------------------- | ------------------ | --------------------------- +# **`barcode`** | `integer` | +# **`created_at`** | `datetime` | +# **`description`** | `text(65535)` | +# **`id`** | `integer` | `not null, primary key` +# **`tool_type_id`** | `integer` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_tools_on_barcode`: +# * **`barcode`** +# * `index_tools_on_tool_type_id`: +# * **`tool_type_id`** +# + class ToolsController < ApplicationController load_and_authorize_resource diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 190accfa..608fe721 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,3 +1,34 @@ +# ## Schema Information +# +# Table name: `users` +# +# ### Columns +# +# Name | Type | Attributes +# ----------------------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`current_sign_in_at`** | `datetime` | +# **`current_sign_in_ip`** | `string(255)` | +# **`email`** | `string(255)` | `default(""), not null` +# **`encrypted_password`** | `string(255)` | `default(""), not null` +# **`id`** | `integer` | `not null, primary key` +# **`last_sign_in_at`** | `datetime` | +# **`last_sign_in_ip`** | `string(255)` | +# **`name`** | `string(255)` | +# **`remember_created_at`** | `datetime` | +# **`reset_password_sent_at`** | `datetime` | +# **`reset_password_token`** | `string(255)` | +# **`sign_in_count`** | `integer` | `default(0), not null` +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_users_on_email` (_unique_): +# * **`email`** +# * `index_users_on_reset_password_token` (_unique_): +# * **`reset_password_token`** +# + class UsersController < ApplicationController before_filter :authenticate_user! diff --git a/app/controllers/waivers_controller.rb b/app/controllers/waivers_controller.rb index cc3eff5b..248f4e61 100644 --- a/app/controllers/waivers_controller.rb +++ b/app/controllers/waivers_controller.rb @@ -1,17 +1,21 @@ class WaiversController < ApplicationController before_filter :require_authenticated_user - + def new if params[:participant_id].nil? or !current_user.participant.is_scc? @user = current_user.participant else @user = Participant.find params[:participant_id] end - + if @user.has_signed_waiver flash[:notice] = "You have already agreed to the release." + elsif !flash[:error] + @user.start_waiver_timer end - + + @should_see_video = !flash[:error] && cannot?(:skip_video, WaiversController) + end @@ -21,16 +25,21 @@ def create else @participant = Participant.find params[:participant_id] end - - - if params[:adult].blank? + + if @participant.is_waiver_cheater? && cannot?(:skip_video, WaiversController) + @participant.start_waiver_timer + redirect_to '/cheating.html' + elsif params[:adult].blank? flash[:error] = "You must be 18 or older to sign the electronic waiver. Please contact Andrew Greenwald (asgreen@andrew.cmu.edu)." redirect_to action: :new elsif params[:agree].blank? flash[:error] = "You must agree to the terms of the release." redirect_to action: :new elsif params[:phone_number] == "" - flash[:error] = "You must provide a mobile phone number" + flash[:error] = "You must provide a mobile phone number." + redirect_to action: :new + elsif params[:signature] != @participant.name + flash[:error] = "You must electronically sign the waiver with your full name as it appears on the waiver." redirect_to action: :new else @participant.phone_number = params[:phone_number] diff --git a/app/helpers/charges_helper.rb b/app/helpers/charges_helper.rb index 414ee900..a98835ba 100644 --- a/app/helpers/charges_helper.rb +++ b/app/helpers/charges_helper.rb @@ -1,2 +1,29 @@ +# ## Schema Information +# +# Table name: `charges` +# +# ### Columns +# +# Name | Type | Attributes +# ------------------------------- | ------------------ | --------------------------- +# **`amount`** | `decimal(8, 2)` | +# **`charge_type_id`** | `integer` | +# **`charged_at`** | `datetime` | +# **`created_at`** | `datetime` | +# **`creating_participant_id`** | `integer` | +# **`description`** | `text(65535)` | +# **`id`** | `integer` | `not null, primary key` +# **`is_approved`** | `boolean` | +# **`issuing_participant_id`** | `integer` | +# **`organization_id`** | `integer` | +# **`receiving_participant_id`** | `integer` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_charges_on_organization_id`: +# * **`organization_id`** +# + module ChargesHelper end diff --git a/app/helpers/checkouts_helper.rb b/app/helpers/checkouts_helper.rb index d6ebab7a..b43c9629 100644 --- a/app/helpers/checkouts_helper.rb +++ b/app/helpers/checkouts_helper.rb @@ -1,2 +1,25 @@ +# ## Schema Information +# +# Table name: `checkouts` +# +# ### Columns +# +# Name | Type | Attributes +# ---------------------- | ------------------ | --------------------------- +# **`checked_in_at`** | `datetime` | +# **`checked_out_at`** | `datetime` | +# **`created_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`organization_id`** | `integer` | +# **`participant_id`** | `integer` | +# **`tool_id`** | `integer` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_checkouts_on_tool_id`: +# * **`tool_id`** +# + module CheckoutsHelper end diff --git a/app/helpers/memberships_helper.rb b/app/helpers/memberships_helper.rb index eaf43c73..e0dc0416 100644 --- a/app/helpers/memberships_helper.rb +++ b/app/helpers/memberships_helper.rb @@ -1,2 +1,27 @@ +# ## Schema Information +# +# Table name: `memberships` +# +# ### Columns +# +# Name | Type | Attributes +# ------------------------ | ------------------ | --------------------------- +# **`booth_chair_order`** | `integer` | +# **`created_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`is_booth_chair`** | `boolean` | +# **`organization_id`** | `integer` | +# **`participant_id`** | `integer` | +# **`title`** | `string(255)` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_memberships_on_organization_id`: +# * **`organization_id`** +# * `index_memberships_on_participant_id`: +# * **`participant_id`** +# + module MembershipsHelper end diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 24cc9a80..6a5fbe91 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -1,2 +1,23 @@ +# ## Schema Information +# +# Table name: `organizations` +# +# ### Columns +# +# Name | Type | Attributes +# ------------------------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`name`** | `string(255)` | +# **`organization_category_id`** | `integer` | +# **`short_name`** | `string(255)` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_organizations_on_organization_category_id`: +# * **`organization_category_id`** +# + module OrganizationsHelper end diff --git a/app/helpers/participants_helper.rb b/app/helpers/participants_helper.rb index 7059f831..a42cc682 100644 --- a/app/helpers/participants_helper.rb +++ b/app/helpers/participants_helper.rb @@ -1,2 +1,32 @@ +# ## Schema Information +# +# Table name: `participants` +# +# ### Columns +# +# Name | Type | Attributes +# -------------------------------- | ------------------ | --------------------------- +# **`andrewid`** | `string(255)` | +# **`cache_updated`** | `datetime` | +# **`cached_department`** | `string(255)` | +# **`cached_email`** | `string(255)` | +# **`cached_name`** | `string(255)` | +# **`cached_student_class`** | `string(255)` | +# **`cached_surname`** | `string(255)` | +# **`created_at`** | `datetime` | +# **`has_signed_hardhat_waiver`** | `boolean` | +# **`has_signed_waiver`** | `boolean` | +# **`id`** | `integer` | `not null, primary key` +# **`phone_carrier_id`** | `integer` | +# **`phone_number`** | `string(255)` | +# **`updated_at`** | `datetime` | +# **`user_id`** | `integer` | +# +# ### Indexes +# +# * `index_participants_on_phone_carrier_id`: +# * **`phone_carrier_id`** +# + module ParticipantsHelper end diff --git a/app/helpers/shift_participants_helper.rb b/app/helpers/shift_participants_helper.rb index 7c537d7a..5e1f8581 100644 --- a/app/helpers/shift_participants_helper.rb +++ b/app/helpers/shift_participants_helper.rb @@ -1,2 +1,25 @@ +# ## Schema Information +# +# Table name: `shift_participants` +# +# ### Columns +# +# Name | Type | Attributes +# --------------------- | ------------------ | --------------------------- +# **`clocked_in_at`** | `datetime` | +# **`created_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`participant_id`** | `integer` | +# **`shift_id`** | `integer` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_shift_participants_on_participant_id`: +# * **`participant_id`** +# * `index_shift_participants_on_shift_id`: +# * **`shift_id`** +# + module ShiftParticipantsHelper end diff --git a/app/helpers/shifts_helper.rb b/app/helpers/shifts_helper.rb index 4f9336b6..5a0755e6 100644 --- a/app/helpers/shifts_helper.rb +++ b/app/helpers/shifts_helper.rb @@ -1,2 +1,26 @@ +# ## Schema Information +# +# Table name: `shifts` +# +# ### Columns +# +# Name | Type | Attributes +# -------------------------------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`description`** | `string(255)` | +# **`ends_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`organization_id`** | `integer` | +# **`required_number_of_participants`** | `integer` | +# **`shift_type_id`** | `integer` | +# **`starts_at`** | `datetime` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_shifts_on_organization_id`: +# * **`organization_id`** +# + module ShiftsHelper end diff --git a/app/helpers/tasks_helper.rb b/app/helpers/tasks_helper.rb index ce894d00..3b9a8765 100644 --- a/app/helpers/tasks_helper.rb +++ b/app/helpers/tasks_helper.rb @@ -1,2 +1,20 @@ +# ## Schema Information +# +# Table name: `tasks` +# +# ### Columns +# +# Name | Type | Attributes +# ---------------------- | ------------------ | --------------------------- +# **`completed_by_id`** | `integer` | +# **`created_at`** | `datetime` | +# **`description`** | `text(65535)` | +# **`due_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`is_completed`** | `boolean` | +# **`name`** | `string(255)` | +# **`updated_at`** | `datetime` | +# + module TasksHelper end diff --git a/app/helpers/tool_types_helper.rb b/app/helpers/tool_types_helper.rb index c48d6180..7678d2fd 100644 --- a/app/helpers/tool_types_helper.rb +++ b/app/helpers/tool_types_helper.rb @@ -1,2 +1,16 @@ +# ## Schema Information +# +# Table name: `tool_types` +# +# ### Columns +# +# Name | Type | Attributes +# ----------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`name`** | `string(255)` | +# **`updated_at`** | `datetime` | +# + module ToolTypesHelper end diff --git a/app/helpers/tool_waitlists_helper.rb b/app/helpers/tool_waitlists_helper.rb index 11c36b9b..ac442225 100644 --- a/app/helpers/tool_waitlists_helper.rb +++ b/app/helpers/tool_waitlists_helper.rb @@ -1,2 +1,26 @@ +# ## Schema Information +# +# Table name: `tool_waitlists` +# +# ### Columns +# +# Name | Type | Attributes +# ---------------------- | ------------------ | --------------------------- +# **`active`** | `boolean` | `default(TRUE)` +# **`created_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`note`** | `string(255)` | +# **`organization_id`** | `integer` | +# **`participant_id`** | `integer` | +# **`tool_type_id`** | `integer` | +# **`updated_at`** | `datetime` | +# **`wait_start_time`** | `datetime` | +# +# ### Indexes +# +# * `index_tool_waitlists_on_tool_type_id`: +# * **`tool_type_id`** +# + module ToolWaitlistsHelper end diff --git a/app/helpers/tools_helper.rb b/app/helpers/tools_helper.rb index 6f879599..a7903bbf 100644 --- a/app/helpers/tools_helper.rb +++ b/app/helpers/tools_helper.rb @@ -1,2 +1,25 @@ +# ## Schema Information +# +# Table name: `tools` +# +# ### Columns +# +# Name | Type | Attributes +# ------------------- | ------------------ | --------------------------- +# **`barcode`** | `integer` | +# **`created_at`** | `datetime` | +# **`description`** | `text(65535)` | +# **`id`** | `integer` | `not null, primary key` +# **`tool_type_id`** | `integer` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_tools_on_barcode`: +# * **`barcode`** +# * `index_tools_on_tool_type_id`: +# * **`tool_type_id`** +# + module ToolsHelper end diff --git a/app/models/ability.rb b/app/models/ability.rb index 65e22460..5b3c879a 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -5,12 +5,12 @@ def initialize(user) user ||= User.new # guest user (not logged in) cannot :manage, :all - + if (user.participant.blank?) return end - can :read, [OrganizationAlias, OrganizationCategory, Organization, Participant, + can :read, [OrganizationAlias, OrganizationCategory, Organization, Participant, ShiftType, Tool, ToolWaitlist, Membership] can :search @@ -90,10 +90,12 @@ def initialize(user) can [:create, :update], Tool can [:create, :update], ToolType can [:create, :update , :destroy], ToolWaitlist + can [:create, :destroy], Certification end if user.has_role? :admin can :manage, :all + can :skip_video, WaiversController end end end diff --git a/app/models/certification.rb b/app/models/certification.rb new file mode 100644 index 00000000..442e85de --- /dev/null +++ b/app/models/certification.rb @@ -0,0 +1,4 @@ +class Certification < ActiveRecord::Base + belongs_to :certification_type + belongs_to :participant +end diff --git a/app/models/certification_type.rb b/app/models/certification_type.rb new file mode 100644 index 00000000..d5df13bd --- /dev/null +++ b/app/models/certification_type.rb @@ -0,0 +1,3 @@ +class CertificationType < ActiveRecord::Base + validates :name, :presence => true, :uniqueness => true +end diff --git a/app/models/checkout.rb b/app/models/checkout.rb index d3593823..96c2b6f1 100644 --- a/app/models/checkout.rb +++ b/app/models/checkout.rb @@ -22,6 +22,8 @@ # class Checkout < ActiveRecord::Base + include Messenger + # For lookups def card_number=( card_number ) @card_number = card_number @@ -35,6 +37,7 @@ def card_number validates_associated :tool, :organization, :participant before_save :checked_out_at, :presence => true + after_update :notify belongs_to :participant, :touch => true belongs_to :organization, :touch => true @@ -44,4 +47,21 @@ def card_number scope :old, -> { where('checked_in_at IS NOT NULL') } scope :current, -> { where('checked_in_at IS NULL') } -end + private + + def notify + if (self.checked_in_at != nil) + toolCategory = self.tool.tool_type + waitlist = ToolWaitlist.for_tool_type(toolCategory.id).by_wait_start_time + if (waitlist.count != 0) + nextPerson = waitlist.first.participant + unless (nextPerson.phone_number.blank?) + number = nextPerson.phone_number + content = "#{toolCategory.name} is now available at the trailer. Please come pick it up within 5 minutes!" + send_sms(number, content) + end + end + end + end + +end \ No newline at end of file diff --git a/app/models/event.rb b/app/models/event.rb index efaeabbd..2e59a02f 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -4,17 +4,34 @@ # # ### Columns # -# Name | Type | Attributes -# -------------------- | ------------------ | --------------------------- -# **`created_at`** | `datetime` | -# **`description`** | `text(65535)` | -# **`event_type_id`** | `integer` | -# **`id`** | `integer` | `not null, primary key` -# **`is_done`** | `boolean` | -# **`updated_at`** | `datetime` | +# Name | Type | Attributes +# --------------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`description`** | `text(65535)` | +# **`event_type_id`** | `integer` | +# **`id`** | `integer` | `not null, primary key` +# **`is_done`** | `boolean` | +# **`participant_id`** | `integer` | +# **`updated_at`** | `datetime` | # - +include Messenger class Event < ActiveRecord::Base - belongs_to :event_type - scope :displayable, -> { joins(:event_type).where(is_done:false).where('event_types.display = ?', true) } -end + belongs_to :event_type + belongs_to :participant + + after_create :send_notifications + + scope :displayable, -> { joins(:event_type).where(is_done:false).where('event_types.display = ?', true) } + + #send notification to assignee if their phone is in system + def send_notifications + if self.participant != nil + if self.participant.phone_number.length == 10 + #grab first 95 characters of description to serve as a preview + description_preview = self.description[0...95] + send_sms(self.participant.phone_number, "An event in Binder has been assigned to you: " + description_preview + "...") + end + end + end + +end \ No newline at end of file diff --git a/app/models/event_type.rb b/app/models/event_type.rb index 5eff5f5b..851408e5 100644 --- a/app/models/event_type.rb +++ b/app/models/event_type.rb @@ -4,11 +4,11 @@ # # ### Columns # -# Name | Type | Attributes -# --------------- | ------------------ | --------------------------- -# **`display`** | `boolean` | -# **`id`** | `integer` | `not null, primary key` -# **`name`** | `string(255)` | +# Name | Type | Attributes +# -------------- | ------------------ | --------------------------- +# **`display`** | `boolean` | +# **`id`** | `integer` | `not null, primary key` +# **`name`** | `string(255)` | # class EventType < ActiveRecord::Base diff --git a/app/models/membership.rb b/app/models/membership.rb index 47e43e27..2b6e3973 100644 --- a/app/models/membership.rb +++ b/app/models/membership.rb @@ -40,5 +40,5 @@ def organization_name_formatted organization.name end end -end - + +end \ No newline at end of file diff --git a/app/models/organization_alias.rb b/app/models/organization_alias.rb index 87c878f5..fdafc98d 100644 --- a/app/models/organization_alias.rb +++ b/app/models/organization_alias.rb @@ -25,8 +25,8 @@ class OrganizationAlias < ActiveRecord::Base validates_associated :organization validates :name, :uniqueness => true - belongs_to :organization - + belongs_to :organization + scope :search, lambda { |term| where('lower(name) LIKE lower(?)', "#{term}%") } def formatted_name diff --git a/app/models/organization_category.rb b/app/models/organization_category.rb index ae501a71..d736af2b 100644 --- a/app/models/organization_category.rb +++ b/app/models/organization_category.rb @@ -4,12 +4,13 @@ # # ### Columns # -# Name | Type | Attributes -# ----------------- | ------------------ | --------------------------- -# **`created_at`** | `datetime` | -# **`id`** | `integer` | `not null, primary key` -# **`name`** | `string(255)` | -# **`updated_at`** | `datetime` | +# Name | Type | Attributes +# ------------------ | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`id`** | `integer` | `not null, primary key` +# **`is_building`** | `boolean` | +# **`name`** | `string(255)` | +# **`updated_at`** | `datetime` | # class OrganizationCategory < ActiveRecord::Base diff --git a/app/models/organization_timeline_entry.rb b/app/models/organization_timeline_entry.rb index e3befe74..c7a2f3f7 100644 --- a/app/models/organization_timeline_entry.rb +++ b/app/models/organization_timeline_entry.rb @@ -36,5 +36,24 @@ def duration return ended_at.to_i - started_at.to_i unless ended_at.blank? return DateTime.now.to_i - started_at.to_i end -end + #notifcations + after_create :notifyStart + after_update :notifyEnd + + def notifyStart + for chair in organization.booth_chairs + if chair.phone_number.length == 10 + send_sms(chair.phone_number, "Downtime for your organization, " +organization.name+", has started.") + end + end + end + + def notifyEnd + for chair in organization.booth_chairs + if chair.phone_number.length == 10 + send_sms(chair.phone_number, "Downtime for your organization, " +organization.name+", has ended. You have "+Time.at(organization.remaining_downtime).utc.strftime("%H hours %M minutes")+" left.") + end + end + end +end \ No newline at end of file diff --git a/app/models/participant.rb b/app/models/participant.rb index bdc4d3f5..6e2de06d 100644 --- a/app/models/participant.rb +++ b/app/models/participant.rb @@ -21,6 +21,7 @@ # **`phone_number`** | `string(255)` | # **`updated_at`** | `datetime` | # **`user_id`** | `integer` | +# **`waiver_start`** | `datetime` | # # ### Indexes # @@ -30,24 +31,38 @@ class Participant < ActiveRecord::Base before_save :reformat_phone - + validates :andrewid, :presence => true, :uniqueness => true # validates :has_signed_waiver, :acceptance => {:accept => true} validates_format_of :phone_number, :with => /\A\(?\d{3}\)?[-. ]?\d{3}[-.]?\d{4}\Z/, :message => "should be 10 digits (area code needed) and delimited with dashes only", :allow_blank => true has_many :organizations, :through => :memberships has_many :shifts, :through => :shift_participants + has_many :certs, :through => :certifications, source: :participant has_many :checkouts, dependent: :destroy has_many :tools, :through => :checkouts has_many :memberships, dependent: :destroy has_many :shift_participants, dependent: :destroy + has_many :certifications, dependent: :destroy has_many :organization_statuses, dependent: :destroy + has_many :events belongs_to :phone_carrier belongs_to :user, dependent: :destroy + default_scope { order('andrewid') } scope :search, lambda { |term| where('lower(andrewid) LIKE lower(?) OR lower(cached_name) LIKE lower(?)', "%#{term}%", "%#{term}%") } scope :scc, -> { joins(:organizations).where(organizations: {name: 'Spring Carnival Committee'}) } + scope :exec, -> { joins(:organizations).where(organizations: {name: 'Spring Carnival Committee'}).joins(:memberships).where(memberships: {is_booth_chair: true}) } + + def start_waiver_timer + self.waiver_start = DateTime.now + self.save + end + + def is_waiver_cheater? + (self.waiver_start + 3.minutes + 30.seconds) > DateTime.now + end def is_booth_chair? !memberships.booth_chairs.blank? @@ -197,5 +212,5 @@ def reformat_phone phone_number.gsub!(/[^0-9]/,"") self.phone_number = phone_number end -end - + +end \ No newline at end of file diff --git a/app/models/shift.rb b/app/models/shift.rb index b32b0512..ec7f896c 100644 --- a/app/models/shift.rb +++ b/app/models/shift.rb @@ -21,6 +21,11 @@ # * `index_shifts_on_organization_id`: # * **`organization_id`** # +include Messenger +require 'twilio-ruby' +require 'daemons' +require 'delayed_job' +require 'delayed_job_active_record' class Shift < ActiveRecord::Base validates_presence_of :starts_at, :ends_at, :required_number_of_participants, :shift_type @@ -47,6 +52,12 @@ class Shift < ActiveRecord::Base scope :sec_shifts, -> { where('shift_type_id = ?', 2) } scope :coord_shifts, -> { where('shift_type_id = ?', 3) } + @@notify = 1.hour + @@notify2 = 5.minutes + + after_create :send_notifications + after_create :send_late_notifications + def formatted_name if organization.blank? shift_type.name + " @ " + starts_at.strftime("%b %e at %l:%M %p") @@ -58,5 +69,45 @@ def formatted_name def is_checked_in return participants.size == required_number_of_participants end -end + def when_to_run_normal + self.starts_at - @@notify + end + + def when_to_run_late + self.starts_at + @@notify2 + end + + #send notification to booth chairs of shift's org 1 hour before watch shift starts + def send_notifications + if shift_type.name == "Watch Shift" + for chair in organization.booth_chairs + if chair.phone_number.length == 10 + send_sms(chair.phone_number, "A watch shift for " + organization.name + " starts in 1 hour.") + end + end + end + end + + #send notification to booth chairs of shift's org if required # of people haven't clocked in + def send_late_notifications + if shift_type.name == "Watch Shift" && is_checked_in == false + for chair in organization.booth_chairs + if chair.phone_number.length == 10 + send_sms(chair.phone_number, "Only " + participants.size.to_s + " of " + required_number_of_participants.to_s + " people for your watch shift have checked in. Please send more people as soon as possible.") + end + end + elsif shift_type.name == "Watch Shift" && is_checked_in == true + for chair in organization.booth_chairs + if chair.phone_number.length == 10 + send_sms(chair.phone_number, "The required number of people for your watch shift have checked in. Thank you!") + end + end + end + end + + #delays all jobs using delayed_jobs gem + handle_asynchronously :send_notifications, :run_at => Proc.new { |i| i.when_to_run_normal } + handle_asynchronously :send_late_notifications, :run_at => Proc.new { |i| i.when_to_run_late } + +end \ No newline at end of file diff --git a/app/models/shift_participant.rb b/app/models/shift_participant.rb index 4210cfa2..cb028a3e 100644 --- a/app/models/shift_participant.rb +++ b/app/models/shift_participant.rb @@ -38,5 +38,5 @@ def card_number=( card_number ) def card_number @card_number end -end +end \ No newline at end of file diff --git a/app/models/store_item.rb b/app/models/store_item.rb index 75ea2ec4..df60a6f3 100644 --- a/app/models/store_item.rb +++ b/app/models/store_item.rb @@ -9,7 +9,7 @@ # **`created_at`** | `datetime` | `not null` # **`id`** | `integer` | `not null, primary key` # **`name`** | `string(255)` | -# **`price`** | `decimal(10, )` | +# **`price`** | `decimal(8, 2)` | # **`quantity`** | `integer` | # **`updated_at`** | `datetime` | `not null` # diff --git a/app/models/store_purchase.rb b/app/models/store_purchase.rb index 0b335b76..332ef98b 100644 --- a/app/models/store_purchase.rb +++ b/app/models/store_purchase.rb @@ -9,7 +9,7 @@ # **`charge_id`** | `integer` | # **`created_at`** | `datetime` | `not null` # **`id`** | `integer` | `not null, primary key` -# **`price_at_purchase`** | `decimal(10, )` | +# **`price_at_purchase`** | `decimal(8, 2)` | # **`quantity_purchased`** | `integer` | # **`store_item_id`** | `integer` | # **`updated_at`** | `datetime` | `not null` @@ -23,10 +23,12 @@ # class StorePurchase < ActiveRecord::Base + #relationships belongs_to :charge belongs_to :store_item has_one :organization, through: :charge + #methods def self.items_in_cart self.where(charge: nil) end @@ -34,4 +36,5 @@ def self.items_in_cart def self.items_in_cart? items_in_cart.size > 0 end + end diff --git a/app/models/tool_type.rb b/app/models/tool_type.rb index 3a1167fa..0c8a2181 100644 --- a/app/models/tool_type.rb +++ b/app/models/tool_type.rb @@ -15,6 +15,8 @@ class ToolType < ActiveRecord::Base has_many :tools has_many :tool_waitlists, dependent: :destroy + has_many :certs, :through => :tool_type_certifications, source: :tool_type + has_many :tool_type_certifications, dependent: :destroy validates :name, presence: true, uniqueness: true default_scope {order(:name)} diff --git a/app/models/tool_type_certification.rb b/app/models/tool_type_certification.rb new file mode 100644 index 00000000..7370501c --- /dev/null +++ b/app/models/tool_type_certification.rb @@ -0,0 +1,26 @@ +# ## Schema Information +# +# Table name: `tool_type_certifications` +# +# ### Columns +# +# Name | Type | Attributes +# ---------------------------- | ------------------ | --------------------------- +# **`certification_type_id`** | `integer` | +# **`created_at`** | `datetime` | `not null` +# **`id`** | `integer` | `not null, primary key` +# **`tool_type_id`** | `integer` | +# **`updated_at`** | `datetime` | `not null` +# +# ### Indexes +# +# * `index_tool_type_certifications_on_certification_type_id`: +# * **`certification_type_id`** +# * `index_tool_type_certifications_on_tool_type_id`: +# * **`tool_type_id`** +# + +class ToolTypeCertification < ActiveRecord::Base + belongs_to :tool_type + belongs_to :certification_type +end diff --git a/app/views/certifications/_form.html.erb b/app/views/certifications/_form.html.erb new file mode 100644 index 00000000..4fb9198b --- /dev/null +++ b/app/views/certifications/_form.html.erb @@ -0,0 +1,18 @@ +<% current_certs = @participant.certifications.map { |cert| cert.certification_type.name } %> + +<%= simple_form_for [@participant, @certification], :html => { :class => 'form-horizontal' } do |f| %> +
+
+
+
+
+ <%= f.association :certification_type, collection: CertificationType.all.select { |c| !current_certs.include?(c.name) }, style: "margin-left:80px" %> + <%= f.input :participant_id, :as => :hidden %> +
+ +
+ <%= f.button :submit, :class => 'btn-primary' %> + <%= link_to t('.cancel', :default => t("helpers.links.cancel")), + @participant, :class => 'btn btn-default' %> +
+<% end %> diff --git a/app/views/certifications/new.html.erb b/app/views/certifications/new.html.erb new file mode 100644 index 00000000..41a6ff36 --- /dev/null +++ b/app/views/certifications/new.html.erb @@ -0,0 +1,6 @@ +<%- model_class = Certification -%> + + +<%= render 'form' %> diff --git a/app/views/charges/_form.html.erb b/app/views/charges/_form.html.erb index 374d0e3d..2b7648d1 100644 --- a/app/views/charges/_form.html.erb +++ b/app/views/charges/_form.html.erb @@ -20,11 +20,14 @@ When adding a charge, please ensure that you add a detailed description. This al <%= f.input_field :amount, :as => :string %> <% end %> + <%= f.input :description, :as => :text, textarea: "{ font-size:16px; }" %> + <%= f.association :issuing_participant, :collection => Participant.scc %> + <%= f.input :receiving_participant do %> <%= f.input_field :receiving_participant_id, as: :hidden %> - <%= text_field_tag 'card-number-input', nil, class: 'form-control' %> + <%= text_field_tag 'card-number-input', nil, placeholder: @current_receiving_participant, class: 'form-control'%>
<% end %> diff --git a/app/views/charges/edit.html.erb b/app/views/charges/edit.html.erb index afde73d8..5925b190 100644 --- a/app/views/charges/edit.html.erb +++ b/app/views/charges/edit.html.erb @@ -1,12 +1,8 @@ -<% if can?(:update, @charge) %> - <%- model_class = Charge -%> - +<%- model_class = Charge -%> + - <%= render 'form' %> +<%= render 'form' %> -<% else %> -

Not Authorized!

-<% end %> diff --git a/app/views/charges/index.html.erb b/app/views/charges/index.html.erb index 8622c13e..517e38e8 100644 --- a/app/views/charges/index.html.erb +++ b/app/views/charges/index.html.erb @@ -1,70 +1,65 @@ -<% if can?(:read, Charge) %> - <%- model_class = Charge -%> - +<%- model_class = Charge -%> + - <% if can?(:create, Charge) %> -
- <%= link_to t('.new', :default => t("helpers.links.new_charge")), - new_charge_path, - :class => 'btn btn-primary' %> -
-
- <% end %> +<% if can?(:create, Charge) %> +
+ <%= link_to t('.new', :default => t("helpers.links.new_charge")), + new_charge_path, + :class => 'btn btn-primary' %> +
+
+<% end %> -

- If a row is yellow then the charge is still pending approval by an admin. -

+

+ If a row is yellow then the charge is still pending approval by an admin. +

- - - - - - - - - <% if can?(:approve, Charge) %> - - <% end %> - - - - <% @charges.each do |charge| %> - <% if can?(:read, charge) %> - > - - - - - - <% if can?(:approve, Charge) %> - - <% end %> - - <% end %> +
<%= model_class.human_attribute_name(:charge_type) %><%= model_class.human_attribute_name(:amount) %><%= "Org" unless !@organization.blank? %>
<%= link_to "show", charge, class: 'btn btn-info btn-xs' %><%= charge.charge_type.name %><%= number_to_currency charge.amount %><%= link_to charge.organization.short_name, charge.organization unless !@organization.blank? %>
+ + + + + + + + <% if can?(:approve, Charge) %> + <% end %> - -
<%= model_class.human_attribute_name(:charge_type) %><%= model_class.human_attribute_name(:amount) %><%= "Org" unless !@organization.blank? %>
+ + + + <% @charges.each do |charge| %> + <% if can?(:read, charge) %> + > + <%= link_to "show", charge, class: 'btn btn-info btn-xs' %> + <%= charge.charge_type.name %> + <%= number_to_currency charge.amount %> + <%= link_to charge.organization.short_name, charge.organization unless !@organization.blank? %> + <%= date_and_time(charge.charged_at) %> + <% if can?(:approve, Charge) %> + + <% unless charge.is_approved? %> + <%= form_tag approve_charge_path(charge), method: :put do -%> + <%= hidden_field_tag 'url', request.original_fullpath %> + <%= submit_tag 'Approve', :class => 'btn btn-success btn-xs' %> + <% end -%> + <% else %> + <%= form_tag approve_charge_path(charge), method: :put do -%> + <%= hidden_field_tag 'url', request.original_fullpath %> + <%= submit_tag 'Un-Approve', :class => 'btn btn-danger btn-xs' %> + <% end -%> + <% end %> + + <% end %> + + <% end %> + <% end %> + + - <%= will_paginate @charges, renderer: BootstrapPagination::Rails %> - -<% else %> -

Not Authorized!

-<% end %> \ No newline at end of file +<%= will_paginate @charges, renderer: BootstrapPagination::Rails %> \ No newline at end of file diff --git a/app/views/charges/new.html.erb b/app/views/charges/new.html.erb index f45afaf2..6df1eb54 100644 --- a/app/views/charges/new.html.erb +++ b/app/views/charges/new.html.erb @@ -1,12 +1,8 @@ -<% if can?(:create, @charge) %> - <%- model_class = Charge -%> - +<%- model_class = Charge -%> + - <%= render 'form' %> +<%= render 'form' %> -<% else %> -

Not Authorized!

-<% end %> diff --git a/app/views/charges/show.html.erb b/app/views/charges/show.html.erb index 1a03ee08..9c7f601d 100644 --- a/app/views/charges/show.html.erb +++ b/app/views/charges/show.html.erb @@ -1,58 +1,53 @@ -<% if can?(:read, @charge) %> - <%- model_class = Charge -%> - +<%- model_class = Charge -%> + -
-
<%= model_class.human_attribute_name(:description) %>:
-
<%= @charge.description %>
-
<%= model_class.human_attribute_name(:amount) %>:
-
<%= number_to_currency @charge.amount %>
-
<%= model_class.human_attribute_name(:organization) %>:
-
<%= link_to @charge.organization.name, @charge.organization %>
-
<%= model_class.human_attribute_name(:issuing_participant) %>:
-
<%= link_to @charge.issuing_participant.formatted_name, @charge.issuing_participant %>
-
<%= model_class.human_attribute_name(:receiving_participant) %>:
-
<%= link_to @charge.receiving_participant.formatted_name, @charge.receiving_participant unless @charge.receiving_participant.nil? %>
-
<%= model_class.human_attribute_name(:charged_at) %>:
-
<%= date_and_time @charge.charged_at %>
-
<%= model_class.human_attribute_name(:is_approved) %>
-
<%= format_boolean @charge.is_approved %>
-
+
+
<%= model_class.human_attribute_name(:description) %>:
+
<%= @charge.description %>
+
<%= model_class.human_attribute_name(:amount) %>:
+
<%= number_to_currency @charge.amount %>
+
<%= model_class.human_attribute_name(:organization) %>:
+
<%= link_to @charge.organization.name, @charge.organization %>
+
<%= model_class.human_attribute_name(:issuing_participant) %>:
+
<%= link_to @charge.issuing_participant.formatted_name, @charge.issuing_participant %>
+
<%= model_class.human_attribute_name(:receiving_participant) %>:
+
<%= link_to @charge.receiving_participant.formatted_name, @charge.receiving_participant unless @charge.receiving_participant.nil? %>
+
<%= model_class.human_attribute_name(:charged_at) %>:
+
<%= date_and_time @charge.charged_at %>
+
<%= model_class.human_attribute_name(:is_approved) %>
+
<%= format_boolean @charge.is_approved %>
+
-
+
<%= link_to t('.back', :default => t("helpers.links.back")), charges_path, :class => 'btn btn-default' %> - <% if can?(:approve, Charge) %> - <% unless @charge.is_approved? %> - <%= form_tag approve_charge_path(@charge), method: :put, style: "display: inline;", role: "form" do -%> - <%= hidden_field_tag 'url', request.original_fullpath %> - <%= submit_tag 'Approve', :class => 'btn btn-success', :type => 'submit' %> - <% end -%> - <% else %> - <%= form_tag approve_charge_path(@charge), method: :put, style: "display: inline;", role: "form" do -%> - <%= hidden_field_tag 'url', request.original_fullpath %> - <%= submit_tag 'Un-Approve', :class => 'btn btn-danger', :type => 'submit' %> - <% end -%> - <% end %> + <% if can?(:approve, Charge) %> + <% unless @charge.is_approved? %> + <%= form_tag approve_charge_path(@charge), method: :put, style: "display: inline;", role: "form" do -%> + <%= hidden_field_tag 'url', request.original_fullpath %> + <%= submit_tag 'Approve', :class => 'btn btn-success', :type => 'submit' %> + <% end -%> + <% else %> + <%= form_tag approve_charge_path(@charge), method: :put, style: "display: inline;", role: "form" do -%> + <%= hidden_field_tag 'url', request.original_fullpath %> + <%= submit_tag 'Un-Approve', :class => 'btn btn-danger', :type => 'submit' %> + <% end -%> <% end %> + <% end %> - <% if can?(:update, @charge) %> - <%= link_to t('.edit', :default => t("helpers.links.edit")), - edit_charge_path(@charge), :class => 'btn btn-primary' %> - <% end %> + <% if can?(:update, @charge) %> + <%= link_to t('.edit', :default => t("helpers.links.edit")), + edit_charge_path(@charge), :class => 'btn btn-primary' %> + <% end %> - <% if can?(:destroy, @charge) %> - <%= link_to t('.destroy', :default => t("helpers.links.destroy")), - charge_path(@charge), - :method => 'delete', - :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, - :class => 'btn btn-danger' %> - <% end %> -
- -<% else %> -

Not Authorized!

-<% end %> + <% if can?(:destroy, @charge) %> + <%= link_to t('.destroy', :default => t("helpers.links.destroy")), + charge_path(@charge), + :method => 'delete', + :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, + :class => 'btn btn-danger' %> + <% end %> +
diff --git a/app/views/checkouts/index.html.erb b/app/views/checkouts/index.html.erb index ca70e833..85e77715 100644 --- a/app/views/checkouts/index.html.erb +++ b/app/views/checkouts/index.html.erb @@ -1,35 +1,32 @@ -<% if can?(:read, Checkout) %> - <%- model_class = Checkout -%> - - - - - - - - - - +<%- model_class = Checkout -%> + +
<%= model_class.human_attribute_name(:id) %><%= model_class.human_attribute_name(:tool) %><%= model_class.human_attribute_name(:checked_out_at) %><%= model_class.human_attribute_name(:checked_in_at) %><%= model_class.human_attribute_name(:participant_id) %><%= model_class.human_attribute_name(:organization_id) %>
+ + + + + + + + - - - <% @checkouts.each do |checkout| %> - <% if can?(:read, checkout) %> - - - - - - - - - <% end %> + + + <% @checkouts.each do |checkout| %> + <% if can?(:read, checkout) %> + + + + + + + + <% end %> - -
<%= model_class.human_attribute_name(:id) %><%= model_class.human_attribute_name(:tool) %><%= model_class.human_attribute_name(:checked_out_at) %><%= model_class.human_attribute_name(:checked_in_at) %><%= model_class.human_attribute_name(:participant_id) %><%= model_class.human_attribute_name(:organization_id) %>
<%= checkout.id %><%= checkout.tool.name %><%= date_and_time(checkout.checked_out_at) unless checkout.checked_out_at.nil? %><%= date_and_time(checkout.checked_in_at) unless checkout.checked_in_at.nil? %><%= checkout.participant.andrewid unless checkout.participant.nil? %><%= checkout.organization.name unless checkout.organization.nil?%>
<%= checkout.id %><%= checkout.tool.name %><%= date_and_time(checkout.checked_out_at) unless checkout.checked_out_at.nil? %><%= date_and_time(checkout.checked_in_at) unless checkout.checked_in_at.nil? %><%= checkout.participant.andrewid unless checkout.participant.nil? %><%= checkout.organization.name unless checkout.organization.nil?%>
-<% else %> -

Not Authorized!

-<% end %> + <% end %> + + + diff --git a/app/views/documents/edit.html.erb b/app/views/documents/edit.html.erb index 20fb8781..8e8ef7c8 100644 --- a/app/views/documents/edit.html.erb +++ b/app/views/documents/edit.html.erb @@ -1,11 +1,7 @@ -<% if can?(:update, @document) %> - <%- model_class = Document -%> - +<%- model_class = Document -%> + - <%= render 'form' %> +<%= render 'form' %> -<% else %> -

Not Authorized!

-<% end %> diff --git a/app/views/documents/index.html.erb b/app/views/documents/index.html.erb index f319be1c..fc2a04a6 100644 --- a/app/views/documents/index.html.erb +++ b/app/views/documents/index.html.erb @@ -1,61 +1,58 @@ -<% if can?(:read, Document) %> - <%- model_class = Document -%> - - <% if can?(:create, Document) %> -
- <%= link_to t('.new', :default => t("helpers.links.new_document")), +<% if can?(:create, Document) %> +
+ <%= link_to t('.new', :default => t("helpers.links.new_document")), new_document_path, :class => 'btn btn-primary' %> -
-
- <% end %> +
+
+<% end %> - - - - - - - <% if can?(:update, Document) or can?(:destroy, Document) %> - - <% end %> - - - - <% @documents.each do |document| %> - <% if can?(:read, document) %> - - - - +
<%= model_class.human_attribute_name(:name) %><%= model_class.human_attribute_name(:public) %><%= model_class.human_attribute_name(:organization) %>
<%= link_to(document.name, document.url.to_s) %><%= format_boolean document.public %><%= link_to(document.organization.name, document.organization) unless document.organization.blank? %>
+ + + + + + <% if can?(:update, Document) or can?(:destroy, Document) %> + + <% end %> + + + + <% @documents.each do |document| %> + <% if can?(:read, document) %> + + + + - <% if can?(:update, Document) or can?(:destroy, Document) %> - - <% end %> - - <% end %> + <% end %> + <% if can?(:destroy, document) %> + <%= link_to t('.destroy', :default => t("helpers.links.destroy")), + document_path(document), + :method => :delete, + :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, + :class => 'btn btn-xs btn-danger' %> + <% end %> + + <% end %> + <% end %> - -
<%= model_class.human_attribute_name(:name) %><%= model_class.human_attribute_name(:public) %><%= model_class.human_attribute_name(:organization) %>
<%= link_to(document.name, document.url.to_s) %><%= format_boolean document.public %><%= link_to(document.organization.name, document.organization) unless document.organization.blank? %>
+ <% end %> + + -<% else %> -

Not Authorized!

-<% end %> + diff --git a/app/views/event_types/index.html.erb b/app/views/event_types/index.html.erb index 2e334f62..5f76b807 100644 --- a/app/views/event_types/index.html.erb +++ b/app/views/event_types/index.html.erb @@ -1,32 +1,32 @@ -

Event Types

+

Event Types

- - - - - - - - +
NameDisplay in Sidebar
+ + + + + + + - - <% @event_types.each do |event_type| %> - - - - - <% end %> - <% if can?(:destroy, EventType) %> + + <% @event_types.each do |event_type| %> + + + + + <% end %> + <% if can?(:destroy, EventType) %> <%= link_to 'Destroy', event_type, method: :delete, data: { confirm: 'Are you sure?' },:class => 'btn btn-danger btn-xs' %> - <% end %> - - - <% end %> - -
NameDisplay in Sidebar
<%= event_type.name %><%= event_type.display ? 'Yes':'No' %> - <% if can?(:edit, EventType) %> - <%= link_to 'Edit', edit_event_type_path(event_type),:class => 'btn btn-primary btn-xs' %>
<%= event_type.name %><%= event_type.display ? 'Yes':'No' %> + <% if can?(:edit, EventType) %> + <%= link_to 'Edit', edit_event_type_path(event_type),:class => 'btn btn-primary btn-xs' %>
+ <% end %> + + + <% end %> + + -
+
- <%= link_to 'New Event Type', new_event_type_path,:class => 'btn btn-primary' %> \ No newline at end of file +<%= link_to 'New Event Type', new_event_type_path,:class => 'btn btn-primary' %> \ No newline at end of file diff --git a/app/views/event_types/new.html.erb b/app/views/event_types/new.html.erb index 2b000813..cbcde165 100644 --- a/app/views/event_types/new.html.erb +++ b/app/views/event_types/new.html.erb @@ -1,5 +1,5 @@ - + - <%= render 'form' %> \ No newline at end of file + <%= render 'form' %> \ No newline at end of file diff --git a/app/views/events/_form.html.erb b/app/views/events/_form.html.erb index 3689a1b2..5e86115f 100644 --- a/app/views/events/_form.html.erb +++ b/app/views/events/_form.html.erb @@ -6,6 +6,9 @@
<%= f.association :event_type, :prompt => 'Select an event type', :selected => 1 %>
+
+ <%= f.association :participant, collection: Participant.exec, :prompt => 'Select a member of SCC (optional)' %> +
<% if can?(:create, EventType) %>
<%= link_to "Or create a new event type", new_event_type_path, class: 'btn btn-primary' %> @@ -22,4 +25,4 @@ <%= link_to t('.cancel', :default => t("helpers.links.cancel")), @event, :class => 'btn btn-default' %>
-<% end %> +<% end %> \ No newline at end of file diff --git a/app/views/events/edit.html.erb b/app/views/events/edit.html.erb index bbf88c8c..4c9199c5 100644 --- a/app/views/events/edit.html.erb +++ b/app/views/events/edit.html.erb @@ -1,5 +1,5 @@ - + - <%= render 'form' %> \ No newline at end of file +<%= render 'form' %> \ No newline at end of file diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb index 748f081f..d8047139 100644 --- a/app/views/events/index.html.erb +++ b/app/views/events/index.html.erb @@ -1,50 +1,50 @@ - + - <% if can?(:create, Event) %> -
- <%= link_to 'New Event', new_event_path, :class => 'btn btn-primary' %> -
-
- <% end %> +<% if can?(:create, Event) %> +
+ <%= link_to 'New Event', new_event_path, :class => 'btn btn-primary' %> +
+
+<% end %> - - - - - - - - - - +
Event TypeDescriptionActions
+ + + + + + + + + - - <% @events.each do |event| %> - > - - - - - + <% @events.each do |event| %> + > + + + + + - - <% end %> - -
Event TypeDescriptionActions
<%= link_to 'Show', event, :class => 'btn btn-info btn-xs' %><%= event.event_type.name %><%= event.description %> - <% if can?(:approve, Event) %> - <%= form_tag approve_event_path(event), :style => "display: inline", method: :put do %> - <% if !event.is_done %> - <%= submit_tag 'OK', :class => 'btn btn-success btn-xs' %> - <% else %> - <%= submit_tag 'Un-OK', :class => 'btn btn-warning btn-xs' %> - <% end %> - <% end %> +
<%= link_to 'Show', event, :class => 'btn btn-info btn-xs' %><%= event.event_type.name %><%= event.description %> + <% if can?(:approve, Event) %> + <%= form_tag approve_event_path(event), :style => "display: inline", method: :post do %> + <% if !event.is_done %> + <%= submit_tag 'OK', :class => 'btn btn-success btn-xs' %> + <% else %> + <%= submit_tag 'Un-OK', :class => 'btn btn-warning btn-xs' %> + <% end %> <% end %> - <% if can?(:update, Event) %> - <%= link_to 'Edit', edit_event_path(event),:class => 'btn btn-primary btn-xs' %> - <% end %> - <% if can?(:destroy, Event) %> - <%= link_to 'Destroy', event, method: :delete, data: { confirm: 'Are you sure?' },:class => 'btn btn-danger btn-xs' %> - <% end %> -
+ <% end %> + <% if can?(:update, Event) %> + <%= link_to 'Edit', edit_event_path(event),:class => 'btn btn-primary btn-xs' %> + <% end %> + <% if can?(:destroy, Event) %> + <%= link_to 'Destroy', event, method: :delete, data: { confirm: 'Are you sure?' },:class => 'btn btn-danger btn-xs' %> + <% end %> + + + <% end %> + + diff --git a/app/views/events/show.html.erb b/app/views/events/show.html.erb index 74f105f0..84022f25 100644 --- a/app/views/events/show.html.erb +++ b/app/views/events/show.html.erb @@ -5,8 +5,10 @@
<%= @event.event_type.name %>
Created At:
<%= date_and_time @event.created_at %>
-
Is done:
+
Is Done:
<%= format_boolean @event.is_done %>
+
Assigned To:
+
<%= @event.participant.name if @event.participant != nil %>
Description:
<%= @event.description %>
@@ -25,4 +27,4 @@ :method => 'delete', :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger' %> -<% end %> +<% end %> \ No newline at end of file diff --git a/app/views/faqs/edit.html.erb b/app/views/faqs/edit.html.erb index b9840ad9..470fd340 100644 --- a/app/views/faqs/edit.html.erb +++ b/app/views/faqs/edit.html.erb @@ -1,11 +1,6 @@ -<% if can?(:update, @faq) %> - <%- model_class = Faq -%> - +<%- model_class = Faq -%> + - <%= render :partial => 'form' %> - -<% else %> -

Not Authorized!

-<% end %> +<%= render :partial => 'form' %> diff --git a/app/views/faqs/index.html.erb b/app/views/faqs/index.html.erb index 2b342660..245942f3 100644 --- a/app/views/faqs/index.html.erb +++ b/app/views/faqs/index.html.erb @@ -1,57 +1,53 @@ -<% if can?(:read, Faq) %> - <%- model_class = Faq -%> - +<%- model_class = Faq -%> + - <% if can?(:create, Faq) %> -
- <%= link_to t('.new', :default => t("helpers.links.new_faq")), +<% if can?(:create, Faq) %> +
+ <%= link_to t('.new', :default => t("helpers.links.new_faq")), new_faq_path, :class => 'btn btn-primary' %> -
-
- <% end %> +
+
+<% end %> -
- <% @faqs.each do |faq| %> -
- -
-
- <%= faq.answer %> - <% if can?(:update, faq) or can?(:destroy, faq) %> -
-
- <% if can?(:update, faq) %> - <%= link_to t('.edit', :default => t("helpers.links.edit")), +
+ <% @faqs.each do |faq| %> +
+ +
+
+ <%= faq.answer %> + <% if can?(:update, faq) or can?(:destroy, faq) %> +
+
+ <% if can?(:update, faq) %> + <%= link_to t('.edit', :default => t("helpers.links.edit")), edit_faq_path(faq), :class => "btn btn-xs btn-primary" %> - <% end %> + <% end %> - <% if can?(:destroy, faq) %> - <%= link_to t('.destroy', :default => t("helpers.links.destroy")), + <% if can?(:destroy, faq) %> + <%= link_to t('.destroy', :default => t("helpers.links.destroy")), faq_path(faq), :method => :delete, :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => "btn btn-xs btn-danger" %> - <% end %> -
- <% end %> -
+ <% end %> +
+ <% end %>
- <% end %>
+ <% end %> +
-<% else %> -

Not Authorized!

-<% end %> diff --git a/app/views/participants/show.html.erb b/app/views/participants/show.html.erb index 016bcc17..0965ab09 100644 --- a/app/views/participants/show.html.erb +++ b/app/views/participants/show.html.erb @@ -5,12 +5,14 @@
+
Wristband:
+
<%= @wristband %>
+
<%= model_class.human_attribute_name(:has_signed_waiver) %>:
+
<%= @participant.has_signed_waiver ? "Yes" : "No" %>
<% if can?(:read_phone_number, @participant) %>
<%= model_class.human_attribute_name(:phone_number) %>:
<%= @participant.formatted_phone_number %> - <% end %> -
<%= model_class.human_attribute_name(:has_signed_waiver) %>:
-
<%= @participant.has_signed_waiver ? "yes" : "no" %>
+ <% end %>
<%= model_class.human_attribute_name(:department) %>:
<%= @participant.department %>
<%= model_class.human_attribute_name(:student_class) %>:
@@ -23,12 +25,12 @@
  • <%= link_to membership.organization_name_formatted, membership.organization %> <% if can?(:edit, membership) %> - <%= link_to 'Edit', - edit_participant_membership_path(@participant, membership), + <%= link_to 'Edit', + edit_participant_membership_path(@participant, membership), :class => 'btn btn-primary btn-xs' %> <% end %> <% if can?(:destrory, membership) %> - <%= link_to 'Remove', + <%= link_to 'Remove', participant_membership_path(@participant, membership), :method => :delete, :class => 'btn btn-danger btn-xs' %> @@ -49,7 +51,7 @@ <% end %> <% end %> <% end %> - + <% unless @participant.shifts.blank? %>
    Shifts:
    @@ -60,7 +62,29 @@
    <% end %> - + +
    Certifications:
    +
    +
      + <% @participant.certifications.each do |cert| %> +
    • + <%= cert.certification_type.name %> + <% if can?(:destroy, Certification) %> + <%= link_to "Delete", + participant_certification_path(@participant, cert), + :method => :delete, + :class => 'btn btn-danger btn-xs' %> + <% end %> +
    • + <% end %> + <% if can?(:create, Certification) && @participant.certifications.size < CertificationType.all.size %> +
    • <%= link_to "Add", + new_participant_certification_path(@participant), + :class => 'btn btn-primary btn-xs' %>
    • + <% end %> +
    +
    + <% unless @participant.checkouts.current.blank? %>
    Tools:
    @@ -72,8 +96,8 @@
    <% end %>
  • - - + + <%= link_to t('.back', :default => t("helpers.links.back")), participants_path, :class => 'btn btn-default' %> @@ -101,4 +125,3 @@ <% else %>

    Not Authorized!

    <% end %> - diff --git a/app/views/tools/show.html.erb b/app/views/tools/show.html.erb index e44ebd66..b2218605 100644 --- a/app/views/tools/show.html.erb +++ b/app/views/tools/show.html.erb @@ -14,6 +14,16 @@
    Checked out at:
    <%= date_and_time @tool.checkouts.current.first.checked_out_at %>
    <% end %> + <% if !@tool.tool_type.tool_type_certifications.empty? %> +
    Required Certifications:
    +
    +
      + <% @tool.tool_type.tool_type_certifications.each do |cert| %> +
    • <%= cert.certification_type.name %>
    • + <% end %> +
    +
    + <% end %> <%= link_to t('.back', :default => t("helpers.links.back")), diff --git a/app/views/waivers/new.html.erb b/app/views/waivers/new.html.erb index fb47137a..43aa0d91 100644 --- a/app/views/waivers/new.html.erb +++ b/app/views/waivers/new.html.erb @@ -1,108 +1,105 @@ - - -<% if !current_user.participant.is_scc? or params[:participant_id]== nil %> +

    You must watch the video prior to signing the waiver.

    -<% if !current_user.participant.is_scc? or params[:participant_id]== nil %> -<% end %> diff --git a/bin/delayed_job b/bin/delayed_job new file mode 100755 index 00000000..edf19598 --- /dev/null +++ b/bin/delayed_job @@ -0,0 +1,5 @@ +#!/usr/bin/env ruby + +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment')) +require 'delayed/command' +Delayed::Command.new(ARGV).daemonize diff --git a/config/application.rb b/config/application.rb index 85cabc84..11edc805 100644 --- a/config/application.rb +++ b/config/application.rb @@ -24,6 +24,11 @@ class Application < Rails::Application # Do not swallow errors in after_commit/after_rollback callbacks. config.active_record.raise_in_transactional_callbacks = true + config.autoload_paths += %W(#{config.root}/lib) + + # Enables delay_job gem to queue up tasks + config.active_job.queue_adapter = :delayed_job + WillPaginate::ViewHelpers.pagination_options[:inner_window] = 1 WillPaginate::ViewHelpers.pagination_options[:outer_window] = 0 end diff --git a/config/routes.rb b/config/routes.rb index aff9b4c1..94b7e2e6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,6 +32,7 @@ resources :participants do resources :memberships, :except => [:index, :show] resource :waiver, :except => [:edit, :destroy, :show, :update] + resources :certifications, :only => [:new, :create, :destroy] post 'lookup', on: :collection end diff --git a/db/migrate/20170305040259_add_waiver_start_to_participant.rb b/db/migrate/20170305040259_add_waiver_start_to_participant.rb new file mode 100644 index 00000000..46f785d0 --- /dev/null +++ b/db/migrate/20170305040259_add_waiver_start_to_participant.rb @@ -0,0 +1,5 @@ +class AddWaiverStartToParticipant < ActiveRecord::Migration + def change + add_column :participants, :waiver_start, :datetime + end +end diff --git a/db/migrate/20170321154121_create_certification_types.rb b/db/migrate/20170321154121_create_certification_types.rb new file mode 100644 index 00000000..58a29b36 --- /dev/null +++ b/db/migrate/20170321154121_create_certification_types.rb @@ -0,0 +1,9 @@ +class CreateCertificationTypes < ActiveRecord::Migration + def change + create_table :certification_types do |t| + t.string :name + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20170321154153_create_certifications.rb b/db/migrate/20170321154153_create_certifications.rb new file mode 100644 index 00000000..1db62495 --- /dev/null +++ b/db/migrate/20170321154153_create_certifications.rb @@ -0,0 +1,12 @@ +class CreateCertifications < ActiveRecord::Migration + def change + create_table :certifications do |t| + t.datetime :created_at + t.datetime :updated_at + t.belongs_to :participant, index: true, foreign_key: true + t.belongs_to :certification_type, index: true, foreign_key: true + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20170322031706_create_tool_type_certifications.rb b/db/migrate/20170322031706_create_tool_type_certifications.rb new file mode 100644 index 00000000..ea595dfc --- /dev/null +++ b/db/migrate/20170322031706_create_tool_type_certifications.rb @@ -0,0 +1,12 @@ +class CreateToolTypeCertifications < ActiveRecord::Migration + def change + create_table :tool_type_certifications do |t| + t.datetime :created_at + t.datetime :updated_at + t.belongs_to :tool_type, index: true, foreign_key: true + t.belongs_to :certification_type, index: true, foreign_key: true + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20170323163001_change_store_item_price_datatype.rb b/db/migrate/20170323163001_change_store_item_price_datatype.rb new file mode 100644 index 00000000..9b767922 --- /dev/null +++ b/db/migrate/20170323163001_change_store_item_price_datatype.rb @@ -0,0 +1,6 @@ +class ChangeStoreItemPriceDatatype < ActiveRecord::Migration + def change + change_column :store_items, :price, :decimal, :precision => 8, :scale => 2 + change_column :store_purchases, :price_at_purchase, :decimal, :precision => 8, :scale => 2 + end +end diff --git a/db/migrate/20170326233627_create_delayed_jobs.rb b/db/migrate/20170326233627_create_delayed_jobs.rb new file mode 100644 index 00000000..27fdcf6c --- /dev/null +++ b/db/migrate/20170326233627_create_delayed_jobs.rb @@ -0,0 +1,22 @@ +class CreateDelayedJobs < ActiveRecord::Migration + def self.up + create_table :delayed_jobs, force: true do |table| + table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue + table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually. + table.text :handler, null: false # YAML-encoded string of the object that will do work + table.text :last_error # reason for last failure (See Note below) + table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future. + table.datetime :locked_at # Set when a client is working on this object + table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead) + table.string :locked_by # Who is working on this object (if locked) + table.string :queue # The name of the queue this job is in + table.timestamps null: true + end + + add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority" + end + + def self.down + drop_table :delayed_jobs + end +end diff --git a/db/migrate/20170402012413_add_participant_id_to_events.rb b/db/migrate/20170402012413_add_participant_id_to_events.rb new file mode 100644 index 00000000..26261f14 --- /dev/null +++ b/db/migrate/20170402012413_add_participant_id_to_events.rb @@ -0,0 +1,5 @@ +class AddParticipantIdToEvents < ActiveRecord::Migration + def change + add_column :events, :participant_id, :integer + end +end diff --git a/db/migrate/20170410184313_add_is_building_to_organization_category.rb b/db/migrate/20170410184313_add_is_building_to_organization_category.rb new file mode 100644 index 00000000..4ae80946 --- /dev/null +++ b/db/migrate/20170410184313_add_is_building_to_organization_category.rb @@ -0,0 +1,5 @@ +class AddIsBuildingToOrganizationCategory < ActiveRecord::Migration + def change + add_column :organization_categories, :is_building, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index a1a77c55..2f129a6c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,11 +11,27 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160404161512) do +ActiveRecord::Schema.define(version: 20170410184313) do + + create_table "certification_types", force: :cascade do |t| + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "certifications", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "participant_id", limit: 4 + t.integer "certification_type_id", limit: 4 + end + + add_index "certifications", ["certification_type_id"], name: "index_certifications_on_certification_type_id", using: :btree + add_index "certifications", ["participant_id"], name: "index_certifications_on_participant_id", using: :btree create_table "charge_types", force: :cascade do |t| t.string "name", limit: 255 - t.boolean "requires_booth_chair_approval", limit: 1 + t.boolean "requires_booth_chair_approval" t.decimal "default_amount", precision: 8, scale: 2 t.text "description", limit: 65535 t.datetime "created_at" @@ -32,7 +48,7 @@ t.datetime "created_at" t.datetime "updated_at" t.datetime "charged_at" - t.boolean "is_approved", limit: 1 + t.boolean "is_approved" t.integer "creating_participant_id", limit: 4 end @@ -50,6 +66,38 @@ add_index "checkouts", ["tool_id"], name: "index_checkouts_on_tool_id", using: :btree + create_table "delayed_jobs", force: :cascade do |t| + t.integer "priority", limit: 4, default: 0, null: false + t.integer "attempts", limit: 4, default: 0, null: false + t.text "handler", limit: 65535, null: false + t.text "last_error", limit: 65535 + t.datetime "run_at" + t.datetime "locked_at" + t.datetime "failed_at" + t.string "locked_by", limit: 255 + t.string "queue", limit: 255 + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree + + create_table "delayed_jobs", force: :cascade do |t| + t.integer "priority", limit: 4, default: 0, null: false + t.integer "attempts", limit: 4, default: 0, null: false + t.text "handler", limit: 65535, null: false + t.text "last_error", limit: 65535 + t.datetime "run_at" + t.datetime "locked_at" + t.datetime "failed_at" + t.string "locked_by", limit: 255 + t.string "queue", limit: 255 + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree + create_table "documents", force: :cascade do |t| t.integer "document_id", limit: 4 t.string "name", limit: 255 @@ -57,21 +105,21 @@ t.datetime "created_at" t.datetime "updated_at" t.integer "organization_id", limit: 4 - t.boolean "public", limit: 1 + t.boolean "public" end create_table "event_types", force: :cascade do |t| - t.boolean "display", limit: 1 - t.string "name", limit: 255 - t.integer "priority", limit: 4 + t.boolean "display" + t.string "name", limit: 255 end create_table "events", force: :cascade do |t| - t.boolean "is_done", limit: 1 - t.integer "event_type_id", limit: 4 + t.boolean "is_done" + t.integer "event_type_id", limit: 4 t.datetime "created_at" - t.text "description", limit: 65535 + t.text "description", limit: 65535 t.datetime "updated_at" + t.integer "participant_id", limit: 4 end create_table "faqs", force: :cascade do |t| @@ -115,7 +163,7 @@ t.integer "participant_id", limit: 4 t.datetime "created_at" t.datetime "updated_at" - t.boolean "is_booth_chair", limit: 1 + t.boolean "is_booth_chair" t.string "title", limit: 255 t.integer "booth_chair_order", limit: 4 end @@ -134,14 +182,15 @@ add_index "organization_aliases", ["organization_id"], name: "index_organization_aliases_on_organization_id", using: :btree create_table "organization_categories", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name", limit: 255 t.datetime "created_at" t.datetime "updated_at" + t.boolean "is_building" end create_table "organization_status_types", force: :cascade do |t| t.string "name", limit: 255 - t.boolean "display", limit: 1 + t.boolean "display" end create_table "organization_statuses", force: :cascade do |t| @@ -187,9 +236,9 @@ t.string "andrewid", limit: 255 t.datetime "created_at" t.datetime "updated_at" - t.boolean "has_signed_waiver", limit: 1 + t.boolean "has_signed_waiver" t.string "phone_number", limit: 255 - t.boolean "has_signed_hardhat_waiver", limit: 1 + t.boolean "has_signed_hardhat_waiver" t.integer "user_id", limit: 4 t.string "cached_name", limit: 255 t.string "cached_surname", limit: 255 @@ -197,6 +246,7 @@ t.string "cached_department", limit: 255 t.string "cached_student_class", limit: 255 t.datetime "cache_updated" + t.datetime "waiver_start" t.integer "phone_carrier_id", limit: 4 end @@ -252,19 +302,19 @@ create_table "store_items", force: :cascade do |t| t.string "name", limit: 255 - t.decimal "price", precision: 10 + t.decimal "price", precision: 8, scale: 2 t.integer "quantity", limit: 4 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "store_purchases", force: :cascade do |t| t.integer "charge_id", limit: 4 t.integer "store_item_id", limit: 4 - t.decimal "price_at_purchase", precision: 10 + t.decimal "price_at_purchase", precision: 8, scale: 2 t.integer "quantity_purchased", limit: 4 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "store_purchases", ["charge_id"], name: "index_store_purchases_on_charge_id", using: :btree @@ -277,9 +327,19 @@ t.text "description", limit: 65535 t.datetime "created_at" t.datetime "updated_at" - t.boolean "is_completed", limit: 1 + t.boolean "is_completed" end + create_table "tool_type_certifications", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "tool_type_id", limit: 4 + t.integer "certification_type_id", limit: 4 + end + + add_index "tool_type_certifications", ["certification_type_id"], name: "index_tool_type_certifications_on_certification_type_id", using: :btree + add_index "tool_type_certifications", ["tool_type_id"], name: "index_tool_type_certifications_on_tool_type_id", using: :btree + create_table "tool_types", force: :cascade do |t| t.string "name", limit: 255 t.datetime "created_at" @@ -292,7 +352,7 @@ t.integer "participant_id", limit: 4 t.integer "organization_id", limit: 4 t.string "note", limit: 255 - t.boolean "active", limit: 1, default: true + t.boolean "active", default: true t.datetime "created_at" t.datetime "updated_at" end @@ -336,10 +396,8 @@ add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id", using: :btree - add_foreign_key "judgements", "judgement_categories" - add_foreign_key "judgements", "judges" - add_foreign_key "judgements", "organizations" - add_foreign_key "participants", "phone_carriers" - add_foreign_key "store_purchases", "charges" - add_foreign_key "store_purchases", "store_items" + add_foreign_key "certifications", "certification_types" + add_foreign_key "certifications", "participants" + add_foreign_key "tool_type_certifications", "certification_types" + add_foreign_key "tool_type_certifications", "tool_types" end diff --git a/db/seeds.rb b/db/seeds.rb index f9e6d14b..b0179c41 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -15,14 +15,14 @@ # Organization Categories ----------------------------------------------------- puts 'Organization Categories' -fraternity = OrganizationCategory.create({ name: 'Fraternity'}) -sorority = OrganizationCategory.create({ name: 'Sorority'}) -independent = OrganizationCategory.create({ name: 'Independent'}) -blitz = OrganizationCategory.create({ name: 'Blitz'}) -concessions = OrganizationCategory.create({ name: 'Concessions'}) -non_building = OrganizationCategory.create({ name: 'Non-Building' }) -scc = OrganizationCategory.create({ name: 'SCC'}) -staff = OrganizationCategory.create({ name: 'Staff' }) +fraternity = OrganizationCategory.create({ name: 'Fraternity', is_building: true }) +sorority = OrganizationCategory.create({ name: 'Sorority', is_building: true }) +independent = OrganizationCategory.create({ name: 'Independent', is_building: true}) +blitz = OrganizationCategory.create({ name: 'Blitz', is_building: true }) +concessions = OrganizationCategory.create({ name: 'Concessions', is_building: true }) +non_building = OrganizationCategory.create({ name: 'Non-Building', is_building: false }) +scc = OrganizationCategory.create({ name: 'SCC', is_building: false }) +staff = OrganizationCategory.create({ name: 'Staff', is_building: false }) # Organizations --------------------------------------------------------------- puts 'Organizations' @@ -255,6 +255,14 @@ Membership.create({ organization: tsa_org, participant: Participant.create({ andrewid: 'ppan'}), is_booth_chair: true }) Membership.create({ organization: tsa_org, participant: Participant.create({ andrewid: 'pchao '}), is_booth_chair: true }) +# Certification Types -------------------------------------------------------- +puts 'Certification Types' + +golf_cart_cert = CertificationType.new({ name: 'Golf Cart' }) +scissor_lift_cert = CertificationType.new({ name: 'Scissor Lift' }) +Certification.create({ participant: chair, certification_type: golf_cart_cert }) +Certification.create({ participant: chair, certification_type: scissor_lift_cert }) + # Organization Status Types -------------------------------------------------- puts 'Organization Status Types' @@ -716,6 +724,9 @@ generate_tools +ToolTypeCertification.create({ tool_type: ToolType.find_by_name("Golf Cart"), certification_type: golf_cart_cert }) +ToolTypeCertification.create({ tool_type: ToolType.find_by_name("Scissor Lift"), certification_type: scissor_lift_cert }) + # Store ------------------------------------------------------------------------- puts 'Store' diff --git a/db/tool_seed.rb b/db/tool_seed.rb index b380d908..c713d49d 100644 --- a/db/tool_seed.rb +++ b/db/tool_seed.rb @@ -2636,5 +2636,12 @@ def generate_tools { barcode: 9995, type: 'Socket Wrench Set' }, { barcode: 9996, type: 'Socket Wrench Set' }, { barcode: 9997, type: 'Square', description: '12\'' }, - { barcode: 9998, type: 'Square', description: '12\'' } + { barcode: 9998, type: 'Square', description: '12\'' }, + { barcode: 10001, type: 'Golf Cart', description: 'Four seater' }, + { barcode: 10002, type: 'Golf Cart', description: 'Four seater' }, + { barcode: 10003, type: 'Golf Cart', description: 'Four seater' }, + { barcode: 10004, type: 'Golf Cart', description: 'Two seater with bed' }, + { barcode: 10005, type: 'Golf Cart', description: 'Two seater with bed' }, + { barcode: 10011, type: 'Scissor Lift', description: '12\' scissor lift' }, + { barcode: 10012, type: 'Scissor Lift', description: '12\' scissor lift' } ] diff --git a/lib/messenger.rb b/lib/messenger.rb new file mode 100644 index 00000000..0c293334 --- /dev/null +++ b/lib/messenger.rb @@ -0,0 +1,31 @@ +USER_UNSUBSCRIBED_FROM_TWILIO_ERROR_CODE = 21610 + +module Messenger + + def send_sms(number, content) + sid = ENV["TWILIO_ACCT_SID"] + auth = ENV["TWILIO_AUTH"] + + @client = Twilio::REST::Client.new sid, auth + + from = "+14123854063" + + # The following try-rescue block is needed in case user unsubscribe + # if the user ubsubscribe and we attempt to message them + # the api will report an error + + begin + message = @client.account.messages.create( + :from => from, + :to => '+1'+number, + :body => content + ) + rescue Twilio::REST::RequestError => e + case e.code + when USER_UNSUBSCRIBED_FROM_TWILIO_ERROR_CODE + puts e.message + end + end + end + +end \ No newline at end of file diff --git a/public/cheating.html b/public/cheating.html new file mode 100644 index 00000000..2e2b3294 --- /dev/null +++ b/public/cheating.html @@ -0,0 +1,34 @@ + + + + You tried to do something suspicious + + + + + +
    +

    You tried to skip the safety video

    +

    Please watch the entire safety video before completing the waiver!

    +
    +
    + +
    + + diff --git a/public/images/spy.jpg b/public/images/spy.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ddac8118c95186ef674dc4eb240e60a2f53c7aa4 GIT binary patch literal 17388 zcmb4q1yEeU((V#0L4(^OL4rF3cXwS}0|a+>3l57*U~#v_ZSj!c?(QDkArM~flY005 z|NZ}0Z%);zJ~eZ?r~1t4>HfOsb@6o*@Lpb8P8t9Q2M3V-djVco01^Ns1Vki61SBLx zBxGcywm!NtHtdryE%NJxN-k55cWLrzRW1;odvV4|SNP$jB&fQE*UDaOjBfiRu2o+iMR1>n+?392YzsCEyJf96T1>>kj}a01f~^ z{yW?M+u+{7|D7-L+joDv<=+F~;NjoEBO)Roq97n50{#yFM>p07b|h>uWE?e9XIx5- z;KaA$`E^w4F1=HD_?#M_Lz3#ZE~q66F1gIUCV%IaG{+42ZxA^_`iqzod*^IBKBWNIFuY>YIszf;-=1txcKV9`P3J$%K$X^zx=S^ zu>c}~TX{-~w~;}Vlz_;{H~%%M%p-~=Y!yUVTT!0abmJs_f}GyD1FzN8{d4Sz@v?UO z@E`9+Rs8o%{#gn=HE@i|?hlzwn0~R<$M*{Yg@z>o{vs#E#Z};n_YV!wFess`>|_W( z)*Ku&_3jWg_7RiUM6mS`2D!MfyvOY4hSors0^hQVf#YMCsjqjDxhMWH{cQ?dhm4Fr zm*>c6*@ijp&CPAlD?m&DHS$H~{eWNX$#cT{;Qj#WTtoV!j0qW`pBu?~4a|J-6CkM5 z$(V1A`;~8%yItJ=g*k=HW8Kd$_E#{yPf8!fybk(>-@C&f2DMAs>gpo`g-$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a)!6EOj+;!NDvj6spAk> z_kKz$%j$I#_(VqmCL{u?)g{)NR@sUIyZ~Gv329u>p6?6_{~?9_@0A(fP7NPbVh?(KV<|F^Mq)g-tGvw@yUwXh8SeHs%5S7c ziBfH(<;#0(_{RM~?ZDL?+WoqC^GBMoso=446(jO zllyyDa894o7U-h68Jo9t1sggR(vBm&0{)IgmFQwL?0A~td|>+4do7KmsVTp>?ZoQc zC(4iWt7W^s2_oWFke^gv2?M_!#Q1U9wj{EIG5o}IMqJ;%-KekfCpEWMf28+WfW`a7 z<23NuBYriUZ6ec^HyvwYv>6ItjjLEaikTowjJmw;V0dqIQGT)##sG&|ug)W+(}Vw} zyAA`Rl7)Q+q|Voe;V!uP?REwcttrI|+I+P?eD|Aumo`9@qpn_Cqa*gae$8>s=UM;E z)=!p}D~@r<-;4j&hlMmdF8PLBy{qXae~}D)1)w5mD%;-q>=0M@ES)xTgiAk+MEUx} zTEVUU*;~iNUW0Hj)a3++O2uxSH@pJg>Qs_|$KZ2VBUkUTU!wpB6xRh{L}>U*{rI`T+=?3C~iR> z7Z?uwKpMH{sd95o=C*2|1Xs0Xfg=B7+2?B8ZFB6OAn9EI2uNb^q0pb9|N$PdWdt ze_pg-?3LkGUHgAG{&79hxGBu6oE>p-L&gD)R2^X@rGpBn>yOY6aZnQ!U}f%kvuK8c YqpJZTEgIn0Md&~X [:completed_by, :issuing_participant, :receiving_participant] do andrewid { generate(:random_string) } + waiver_start DateTime.now end # shift @@ -127,6 +151,16 @@ association :tool_type end + # tool waitlist + factory :tool_waitlist do + wait_start_time Time.now + tool_type_id 1 + + association :tool_type + association :organization + association :participant + end + # user factory :user do name "Default Factory User" @@ -135,4 +169,16 @@ association :participant end + #store_purchase + factory :store_purchase do + + association :store_item + end + + #store_item + factory :store_item do + name "Hammer" + + end + end diff --git a/test/integration/participant_test.rb b/test/integration/participant_test.rb index 841bb698..4cab6619 100644 --- a/test/integration/participant_test.rb +++ b/test/integration/participant_test.rb @@ -4,7 +4,7 @@ class ParticipantTest < ActiveSupport::TestCase context "With a refreshed ldap cache, " do setup do - @participant = FactoryGirl.create(:participant, :andrewid => "meribyte") + @participant = FactoryGirl.create(:participant, :andrewid => "erwilson") end teardown do @@ -16,23 +16,23 @@ class ParticipantTest < ActiveSupport::TestCase end should "return name from directory" do - assert_equal "Margaret Richards", @participant.name + assert_equal "Eleanor Wilson", @participant.name end should "return surname from directory" do - assert_equal "Richards", @participant.surname + assert_equal "Wilson", @participant.surname end should "return email from directory" do - assert_equal "mouse@cmu.edu", @participant.email + assert_equal "erwilson@andrew.cmu.edu", @participant.email end should "return department from directory" do - assert_equal "Eberly Center, Teaching Excellence & Educational Innovation", @participant.department + assert_equal "Dietrich College Interdisciplinary", @participant.department end should "return student class from directory" do - assert_equal "Masters", @participant.student_class + assert_equal "Junior", @participant.student_class end end end diff --git a/test/models/store_item_test.rb b/test/models/store_item_test.rb deleted file mode 100644 index dd66a54b..00000000 --- a/test/models/store_item_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -# ## Schema Information -# -# Table name: `store_items` -# -# ### Columns -# -# Name | Type | Attributes -# ----------------- | ------------------ | --------------------------- -# **`created_at`** | `datetime` | `not null` -# **`id`** | `integer` | `not null, primary key` -# **`name`** | `string(255)` | -# **`price`** | `decimal(10, )` | -# **`quantity`** | `integer` | -# **`updated_at`** | `datetime` | `not null` -# - -require 'test_helper' - -class StoreItemTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/test_helper.rb b/test/test_helper.rb index e7d175b3..ba9ed8c3 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -8,6 +8,8 @@ require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' +ActiveRecord::Migration.maintain_test_schema! + class ActiveSupport::TestCase def deny(condition) diff --git a/test/unit/charge_test.rb b/test/unit/charge_test.rb index db76547a..390302fd 100644 --- a/test/unit/charge_test.rb +++ b/test/unit/charge_test.rb @@ -32,23 +32,41 @@ class ChargeTest < ActiveSupport::TestCase should belong_to(:organization) should belong_to(:issuing_participant) should belong_to(:receiving_participant) + should belong_to(:creating_participant) should belong_to(:charge_type) # Validations + should validate_presence_of(:charged_at) + should validate_presence_of(:issuing_participant) + should validate_presence_of(:organization) + should validate_presence_of(:charge_type) + should validate_presence_of(:amount) + + should validate_numericality_of(:amount) # Methods context "With a proper context, " do setup do # Create a charges - @fine = FactoryGirl.create(:charge) + @fine = FactoryGirl.create(:charge, :is_approved => false) + @fine2 = FactoryGirl.create(:charge, :is_approved => false) + @fine3 = FactoryGirl.create(:charge, :is_approved => true) end teardown do end should "show that all factories are properly created" do - assert_equal 1, Charge.all.size + assert_equal 3, Charge.all.size + end + + should "show that pending scope works" do + assert_equal 2, Charge.pending.size + end + + should "show that approved scope works" do + assert_equal 1, Charge.approved.size end context "Testing charges" do diff --git a/test/unit/charge_type_test.rb b/test/unit/charge_type_test.rb index f66e1a12..06329edb 100644 --- a/test/unit/charge_type_test.rb +++ b/test/unit/charge_type_test.rb @@ -23,9 +23,13 @@ class ChargeTypeTest < ActiveSupport::TestCase # Validations + should validate_presence_of(:name) + should validate_uniqueness_of(:name) + context "With a proper context, " do setup do - FactoryGirl.create(:charge_type) + @charge = FactoryGirl.create(:charge_type) + @charge_type = FactoryGirl.create(:charge, :charge_type => @charge) end teardown do @@ -35,8 +39,12 @@ class ChargeTypeTest < ActiveSupport::TestCase assert_equal 1, ChargeType.all.size end - # Scopes + should "show dependency on charge" do + assert_equal 1, Charge.all.size + @charge_type.destroy + assert_equal 0, Charge.all.size + end + - # Methods end end diff --git a/test/unit/checkout_test.rb b/test/unit/checkout_test.rb index 24f97a6c..dec960f3 100644 --- a/test/unit/checkout_test.rb +++ b/test/unit/checkout_test.rb @@ -35,18 +35,33 @@ class CheckoutTest < ActiveSupport::TestCase context "With a proper context, " do setup do - FactoryGirl.create(:checkout) + @org = FactoryGirl.create(:organization, name: "bruce") + @person = FactoryGirl.create(:participant) + @type1 = FactoryGirl.create(:tool_type, name: "hammer") + @type2 = FactoryGirl.create(:tool_type, name: "drill") + @type3 = FactoryGirl.create(:tool_type, name: "lmao") + @t1 = FactoryGirl.create(:tool, barcode: 1111, tool_type: @type1) + @t2 = FactoryGirl.create(:tool, barcode: 2222, tool_type: @type2) + @t3 = FactoryGirl.create(:tool, barcode: 3333, tool_type: @type3) + @checkout1 = FactoryGirl.create(:checkout, :checked_in_at => Time.now, organization: @org, participant: @person, tool: @t1) + @checkout2 = FactoryGirl.create(:checkout, :checked_in_at => Time.now, organization: @org, participant: @person, tool: @t2) + @checkout3 = FactoryGirl.create(:checkout, :checked_in_at => nil, organization: @org, participant: @person, tool: @t3) end teardown do end should "show that all factories are properly created" do - assert_equal 1, Checkout.all.size + assert_equal 3, Checkout.all.size end # Scopes + should "show that current scope works" do + assert_equal 1, Checkout.current.size + end - # Methods + should "show that old scope works" do + assert_equal 2, Checkout.old.size + end end end diff --git a/test/unit/document_test.rb b/test/unit/document_test.rb index 069b43d4..45bec4eb 100644 --- a/test/unit/document_test.rb +++ b/test/unit/document_test.rb @@ -20,11 +20,30 @@ class DocumentTest < ActiveSupport::TestCase # Relationships + should belong_to(:organization) - # Validations + context "With a proper context, " do + setup do + @org = FactoryGirl.create(:organization_alias, :id => 123) + @document = FactoryGirl.create(:document, :organization_id => @org.id, :name => "Booth") + @document2 = FactoryGirl.create(:document, :organization_id => @org.id, :name => "Electric") + end - # Scopes + teardown do + end - # Methods + # Validations- is there a better way to test this? + should "show that a document has an organization assocaited with it" do + assert_equal 123, @document.organization_id + end + + #scopes + should "show that search scope works" do + @doc = Document.search('booth') + assert_equal 'Booth', @doc[0].name + + end + + end end diff --git a/test/unit/event_test.rb b/test/unit/event_test.rb new file mode 100644 index 00000000..efec1250 --- /dev/null +++ b/test/unit/event_test.rb @@ -0,0 +1,40 @@ +# ## Schema Information +# +# Table name: `events` +# +# ### Columns +# +# Name | Type | Attributes +# --------------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`description`** | `text(65535)` | +# **`event_type_id`** | `integer` | +# **`id`** | `integer` | `not null, primary key` +# **`is_done`** | `boolean` | +# **`participant_id`** | `integer` | +# **`updated_at`** | `datetime` | +# + +class EventTest < ActiveSupport::TestCase + # Relationships + should belong_to(:event_type) + + # Scopes + context "With a proper context, " do + setup do + @type1 = FactoryGirl.create(:event_type, :display => false) + @type2 = FactoryGirl.create(:event_type, :display => true) + @event1 = FactoryGirl.create(:event, :is_done => true, :event_type_id => @type1.id) + @event2 = FactoryGirl.create(:event, :is_done => false, :event_type_id => @type2.id) + end + + teardown do + end + + #scopes + should "show that displayable scope works" do + assert_equal 1, Event.displayable.size + end + end + +end diff --git a/test/unit/event_type_test.rb b/test/unit/event_type_test.rb new file mode 100644 index 00000000..2d2877ab --- /dev/null +++ b/test/unit/event_type_test.rb @@ -0,0 +1,20 @@ +# ## Schema Information +# +# Table name: `event_types` +# +# ### Columns +# +# Name | Type | Attributes +# --------------- | ------------------ | --------------------------- +# **`display`** | `boolean` | +# **`id`** | `integer` | `not null, primary key` +# **`name`** | `string(255)` | +# **`priority`** | `integer` | +# + +class EventTypeTest < ActiveSupport::TestCase + # Relationships + should have_many(:events) + + +end diff --git a/test/unit/faq_test.rb b/test/unit/faq_test.rb index 806633fb..5c7e9854 100644 --- a/test/unit/faq_test.rb +++ b/test/unit/faq_test.rb @@ -16,12 +16,22 @@ require 'test_helper' class FaqTest < ActiveSupport::TestCase - # Relationships - # Validations + context "With a proper context, " do + setup do + @faq1 = FactoryGirl.create(:faq, :question => "how to sign a waiver?") + @faq2 = FactoryGirl.create(:faq, :question => "how to build a booth?") + end - # Scopes + teardown do + end - # Methods + # Scope + should "show that a search scope works" do + @ans = Faq.search("sign a waiver?") + assert_equal "how to sign a waiver?", @ans[0].question + end + + end end diff --git a/test/models/judge_test.rb b/test/unit/judge_test.rb similarity index 100% rename from test/models/judge_test.rb rename to test/unit/judge_test.rb diff --git a/test/models/judgement_category_test.rb b/test/unit/judgement_category_test.rb similarity index 100% rename from test/models/judgement_category_test.rb rename to test/unit/judgement_category_test.rb diff --git a/test/models/judgement_test.rb b/test/unit/judgement_test.rb similarity index 91% rename from test/models/judgement_test.rb rename to test/unit/judgement_test.rb index 204c7690..e62ac5d9 100644 --- a/test/models/judgement_test.rb +++ b/test/unit/judgement_test.rb @@ -27,7 +27,7 @@ require 'test_helper' class JudgementTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end + # Relationships + should belong_to(:judgement_category) + should belong_to(:judge) +end \ No newline at end of file diff --git a/test/unit/membership_test.rb b/test/unit/membership_test.rb index 4ab77ae8..dc10977c 100644 --- a/test/unit/membership_test.rb +++ b/test/unit/membership_test.rb @@ -34,28 +34,32 @@ class MembershipTest < ActiveSupport::TestCase should validate_presence_of(:participant) should validate_presence_of(:organization) - context "With a proper context, " do + context 'With a proper context, ' do setup do - FactoryGirl.create(:membership) - @chair = FactoryGirl.create(:membership, :is_booth_chair => true) + @org1 = FactoryGirl.create(:organization) + @org2 = FactoryGirl.create(:organization) + @nonchair = FactoryGirl.create(:membership, organization: @org1) + @chair = FactoryGirl.create(:membership, organization: @org2, :is_booth_chair => true) end teardown do + @nonchair = nil + @chair = nil end - should "show that all factories are properly created" do + should 'show that all factories are properly created' do assert_equal 2, Membership.all.size end # Scopes + should 'booth_chair scope should return all booth chairs' do + assert_equal 1, Membership.booth_chairs.size + end # Methods - context "Testing memberships" do - should "know booth chairs" do - #puts Membership.booth_chairs.map{ |bc| bc.participant.andrewid } - assert_equal 1, Membership.booth_chairs.size - assert_equal @chair, Membership.booth_chairs.first - end + should 'formatted_name should return the organization followed and indication if this member is booth chair' do + assert_equal "#{@org1.name}", @nonchair.organization_name_formatted + assert_equal "#{@org2.name} - Booth Chair", @chair.organization_name_formatted end end end diff --git a/test/unit/organization_alias_test.rb b/test/unit/organization_alias_test.rb index 3448024a..3e5ac9a2 100644 --- a/test/unit/organization_alias_test.rb +++ b/test/unit/organization_alias_test.rb @@ -27,22 +27,47 @@ class OrganizationAliasTest < ActiveSupport::TestCase should belong_to(:organization) # Validations + should validate_presence_of(:name) + should validate_presence_of(:organization) + should validate_uniqueness_of(:name) - context "With a proper context, " do + context 'With a proper context, ' do setup do - FactoryGirl.create(:organization_alias) + @alias1 = FactoryGirl.create(:organization_alias, name: 'winner') + @alias2 = FactoryGirl.create(:organization_alias, name: 'loser') + @org1 = FactoryGirl.create(:organization) + @org2 = FactoryGirl.create(:organization) + @alias1.organization = @org1 + @alias2.organization = @org2 end teardown do + @alias1 = nil + @alias2 = nil + @org1 = nil + @org2 = nil end - should "show that all factories are properly created" do - assert_equal 1, OrganizationAlias.all.size + should 'show that all factories are properly created' do + assert_equal 2, OrganizationAlias.all.size end # Scopes + # Search scope + should 'the search by term function should work correctly' do + assert_equal 1, OrganizationAlias.search("winner").size + assert_equal 1, OrganizationAlias.search("loser").size + assert_equal 0, Organization.search("blah").size + end + # Methods + should 'formatted name should return the organization name followed by the alias in parathesis' do + answer1 = "#{@org1.name} (winner)" + answer2 = "#{@org2.name} (loser)" + assert_equal answer1, @alias1.formatted_name + assert_equal answer2, @alias2.formatted_name + end end end diff --git a/test/unit/organization_category_test.rb b/test/unit/organization_category_test.rb index 9e5fdc1b..55549921 100644 --- a/test/unit/organization_category_test.rb +++ b/test/unit/organization_category_test.rb @@ -19,22 +19,32 @@ class OrganizationCategoryTest < ActiveSupport::TestCase should have_many(:organizations) # Validations + should validate_presence_of(:name) + should validate_uniqueness_of(:name) - context "With a proper context, " do + context 'With a proper context, ' do setup do - FactoryGirl.create(:organization_category) + @cat1 = FactoryGirl.create(:organization_category) + @cat2 = FactoryGirl.create(:organization_category) end teardown do + @cat1 = nil + @cat2 = nil end - should "show that all factories are properly created" do - assert_equal 1, OrganizationCategory.all.size + should 'show that all factories are properly created' do + assert_equal 2, OrganizationCategory.all.size end - # Scopes - - # Methods - + # dependency + should 'remove all associated organizations once this organization category is removed' do + @org1 = FactoryGirl.create(:organization, organization_category: @cat1) + @org2 = FactoryGirl.create(:organization, organization_category: @cat1) + @org3 = FactoryGirl.create(:organization, organization_category: @cat2) + assert_equal 3, Organization.all.size + @cat1.destroy + assert_equal 1, Organization.all.size + end end end diff --git a/test/unit/organization_status_test.rb b/test/unit/organization_status_test.rb new file mode 100644 index 00000000..04ef62b4 --- /dev/null +++ b/test/unit/organization_status_test.rb @@ -0,0 +1,70 @@ +# ## Schema Information +# +# Table name: `organization_statuses` +# +# ### Columns +# +# Name | Type | Attributes +# ---------------------------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | +# **`description`** | `string(255)` | +# **`id`** | `integer` | `not null, primary key` +# **`organization_id`** | `integer` | +# **`organization_status_type_id`** | `integer` | +# **`participant_id`** | `integer` | +# **`updated_at`** | `datetime` | +# +# ### Indexes +# +# * `index_organization_statuses_on_organization_id`: +# * **`organization_id`** +# + +require 'test_helper' + +class OrganizationStatusTest < ActiveSupport::TestCase + + # Relationships + should belong_to(:organization_status_type) + should belong_to(:organization) + should belong_to(:participant) + + # Validations + should validate_presence_of(:organization_status_type) + should validate_presence_of(:organization) + should validate_presence_of(:participant) + + context 'With a proper context,' do + setup do + @status_type1 = FactoryGirl.create(:organization_status_type) + @status_type2 = FactoryGirl.create(:organization_status_type, :display => true) + @org = FactoryGirl.create(:organization) + @p = FactoryGirl.create(:participant) + @status1 = FactoryGirl.create(:organization_status, + :organization_status_type => @status_type1, + :organization => @org, :participant => @p) + @status2 = FactoryGirl.create(:organization_status, + :organization_status_type => @status_type2, + :organization => @org, :participant => @p) + end + + teardown do + @status_type1 = nil + @status_type2 = nil + @org = nil + @p = nil + @status1 = nil + @status2 = nil + end + + should 'show that all factories are properly created' do + assert_equal 2, OrganizationStatus.all.size + end + + # Scope + should 'display statuses that are only displayable' do + assert_equal 1, OrganizationStatus.displayable.size + end + end + +end \ No newline at end of file diff --git a/test/unit/organization_status_type_test.rb b/test/unit/organization_status_type_test.rb new file mode 100644 index 00000000..da8df923 --- /dev/null +++ b/test/unit/organization_status_type_test.rb @@ -0,0 +1,58 @@ +# ## Schema Information +# +# Table name: `organization_status_types` +# +# ### Columns +# +# Name | Type | Attributes +# -------------- | ------------------ | --------------------------- +# **`display`** | `boolean` | +# **`id`** | `integer` | `not null, primary key` +# **`name`** | `string(255)` | +## ## Schema Information +# + + +require 'test_helper' + +class OrganizationStatusTypeTest < ActiveSupport::TestCase + + # Relationships + should have_many(:organization_statuses) + + # Validations + should validate_presence_of(:name) + should validate_uniqueness_of(:name) + + context 'With a proper context, ' do + setup do + @type1 = FactoryGirl.create(:organization_status_type) + @person = FactoryGirl.create(:participant) + @org = FactoryGirl.create(:organization) + @status = FactoryGirl.create(:organization_status, + participant: @person, organization: @org, organization_status_type: @type1) + end + + teardown do + @type1 = nil + @person = nil + @org = nil + @status = nil + end + # + should 'show that all factories are properly created' do + assert_equal 1, OrganizationStatusType.all.size + end + + # Dependency + should 'delete status if status type is destroyed' do + @type1.update_attribute(:display, true) + assert(@status.valid?) + assert_equal 1, OrganizationStatus.all.size + + @type1.destroy + assert_equal 0, OrganizationStatus.all.size + end + end + +end \ No newline at end of file diff --git a/test/unit/organization_test.rb b/test/unit/organization_test.rb index 68f870c9..5969993d 100644 --- a/test/unit/organization_test.rb +++ b/test/unit/organization_test.rb @@ -21,6 +21,7 @@ require 'test_helper' + class OrganizationTest < ActiveSupport::TestCase # Relationships should belong_to(:organization_category) @@ -42,7 +43,7 @@ class OrganizationTest < ActiveSupport::TestCase context "With a proper context, " do setup do - @short_org = FactoryGirl.create(:organization, :name => 'longer name', :short_name => 'name') + @short_org = FactoryGirl.create(:organization, :name => 'short name', :short_name => 'name') @long_org = FactoryGirl.create(:organization, :name => 'long name', :short_name => nil) end @@ -54,11 +55,127 @@ class OrganizationTest < ActiveSupport::TestCase end # Scopes + # only_categories + should "show that the only_categories functions correctly" do + short_org_category = @short_org.organization_category.name + long_org_category = @long_org.organization_category.name + assert_equal ['short name'], Organization.only_categories(short_org_category).map {|org| org.name} + assert_equal ['long name'], Organization.only_categories(long_org_category).map {|org| org.name} + end + + # search + should "show that the search scope functions correcly" do + assert_equal ['long name'], Organization.search('long name').map {|org| org.name } + assert_equal ['long name', 'short name'], Organization.search('name').map {|org| org.name} + end + + # ---------------------------- End of scope testing # Methods should 'have a short_name method' do assert_equal('name', @short_org.short_name) assert_equal('long name', @long_org.short_name) end + + should 'give back the correct booth chair for this organization' do + chair_person = FactoryGirl.create(:participant) + short_chair = FactoryGirl.create(:membership, + is_booth_chair: true, + organization: @short_org, + participant: chair_person) + assert_equal [chair_person.andrewid], @short_org.booth_chairs.map { |bc| bc.andrewid } + assert_equal [], @long_org.booth_chairs + end + + should 'give back the correct hour of current downtime' do + t = Time.now + entry = FactoryGirl.create(:organization_timeline_entry, entry_type: 2, + started_at: t - 2.hours, ended_at: t, organization: @short_org) + + assert_equal 2.hours, @short_org.downtime + end + + should 'give back the correct hour of remaining downtime' do + t = Time.now + entry = FactoryGirl.create(:organization_timeline_entry, entry_type: 2, + started_at: t - 3.hours, ended_at: t, organization: @short_org) + + assert_equal 1.hours, @short_org.remaining_downtime + end + + # --------------------------- End of Methods testing + + # Dependencies + should 'delete all associated organization_aliases once the organization is removed' do + alias1 = FactoryGirl.create(:organization_alias, organization: @short_org) + alias2 = FactoryGirl.create(:organization_alias, organization: @short_org) + alias3 = FactoryGirl.create(:organization_alias, organization: @long_org) + assert_equal 3, OrganizationAlias.all.size + + @short_org.destroy + assert_equal 1, OrganizationAlias.all.size + end + + should 'delete all associated organization_statuses once the organization is removed' do + person1 = FactoryGirl.create(:participant) + person2 = FactoryGirl.create(:participant) + status_type = FactoryGirl.create(:organization_status_type) + status1 = FactoryGirl.create(:organization_status, organization: @short_org, + participant: person1, organization_status_type: status_type) + status2 = FactoryGirl.create(:organization_status, organization: @long_org, + participant: person2, organization_status_type: status_type) + + assert_equal 2, OrganizationStatus.all.size + + @short_org.destroy + assert_equal 1, OrganizationStatus.all.size + end + + should 'delete all associated organization_timeline_entries once the organization is removed' do + entry1 = FactoryGirl.create(:organization_timeline_entry, organization: @short_org) + entry2 = FactoryGirl.create(:organization_timeline_entry, organization: @short_org) + entry3 = FactoryGirl.create(:organization_timeline_entry, organization: @long_org) + + assert_equal 3, OrganizationTimelineEntry.all.size + @short_org.destroy + assert_equal 1, OrganizationTimelineEntry.all.size + end + + should 'delete all associated charges once the organization is removed' do + issuer = FactoryGirl.create(:participant) + type = FactoryGirl.create(:charge_type) + + charge1 = FactoryGirl.create(:charge, + organization: @short_org, issuing_participant: issuer, charge_type: type) + charge2 = FactoryGirl.create(:charge, + organization: @short_org, issuing_participant: issuer, + charge_type: type, is_approved: true) + charge3 = FactoryGirl.create(:charge, + organization: @long_org, issuing_participant: issuer, charge_type: type) + + assert_equal 3, Charge.all.size + + @short_org.destroy + + assert_equal 1, Charge.all.size + end + + should 'delete all associated documents once the organization is removed' do + doc1 = FactoryGirl.create(:document, organization: @short_org) + doc2 = FactoryGirl.create(:document, organization: @short_org) + doc3 = FactoryGirl.create(:document, organization: @long_org) + assert_equal 3, Document.all.size + @short_org.destroy + assert_equal 1, Document.all.size + end + + should 'delete all checkouts once the organization is removed' do + type = FactoryGirl.create(:tool_type) + tool = FactoryGirl.create(:tool, tool_type: type) + checkout = FactoryGirl.create(:checkout, tool: tool, organization: @short_org) + assert_equal 1, Checkout.all.size + @short_org.destroy + assert_equal 0, Checkout.all.size + end end end diff --git a/test/unit/organization_timeline_entry_test.rb b/test/unit/organization_timeline_entry_test.rb index ecf4007b..a9bc0bfa 100644 --- a/test/unit/organization_timeline_entry_test.rb +++ b/test/unit/organization_timeline_entry_test.rb @@ -32,23 +32,28 @@ class OrganizationTimelineEntryTest < ActiveSupport::TestCase should validate_presence_of(:entry_type) should validate_presence_of(:organization) - context "With a proper context, " do + context 'With a proper context, ' do setup do time = Time.now - @finished = FactoryGirl.create(:organization_timeline_entry, :started_at => time - 1.hour, :ended_at => time) - @not_finished = FactoryGirl.create(:organization_timeline_entry, :started_at => DateTime.now - 12.hours, :ended_at => nil) + @finished = FactoryGirl.create(:organization_timeline_entry, + :started_at => time - 1.hour, :ended_at => time) + @not_finished = FactoryGirl.create(:organization_timeline_entry, + :started_at => DateTime.now - 12.hours, :ended_at => nil) end teardown do + @finished = nil + @not_finished = nil end - should "show that all factories are properly created" do + should 'show that all factories are properly created' do assert_equal 2, OrganizationTimelineEntry.all.size end - # Scopes + should 'the current scope should return the ongoing entry' do + assert_equal 1, OrganizationTimelineEntry.current.size + end - # Methods should 'show that the duration method works' do assert_equal 1.hour, @finished.duration assert_equal 12.hour, (@not_finished.duration / 1.hour).round * 1.hour diff --git a/test/unit/participant_test.rb b/test/unit/participant_test.rb index c0c950ca..2fa66161 100644 --- a/test/unit/participant_test.rb +++ b/test/unit/participant_test.rb @@ -21,6 +21,7 @@ # **`phone_number`** | `string(255)` | # **`updated_at`** | `datetime` | # **`user_id`** | `integer` | +# **`waiver_start`** | `datetime` | # # ### Indexes # @@ -45,8 +46,16 @@ class ParticipantTest < ActiveSupport::TestCase context "With a proper context, " do setup do - @participant = FactoryGirl.create(:participant, :phone_number => 1234567890) + @participant = FactoryGirl.create(:participant, :phone_number => 1234567890, :andrewid => "agoradia", :cached_name => "Akshay Goradia", :waiver_start => DateTime.now - 10.minutes) + @organization_category = FactoryGirl.create(:organization_category) + @organization = FactoryGirl.create(:organization, :name => "Spring Carnival Committee", :organization_category => @organization_category) @temp_participant = FactoryGirl.create(:participant) + @membership = FactoryGirl.create(:membership, :is_booth_chair => true, :participant => @participant, :organization => @organization) + @checkout = FactoryGirl.create(:checkout, :participant => @participant) + @shift_participant = FactoryGirl.create(:shift_participant, :participant => @participant) + @organization_status = FactoryGirl.create(:organization_status, :participant => @participant) + @user = FactoryGirl.create(:user, :participant => @participant) + end teardown do @@ -57,12 +66,94 @@ class ParticipantTest < ActiveSupport::TestCase end context "Testing participants" do + + + should "show that dependency on checkout works" do + assert_equal 1, Checkout.all.size + @participant.destroy + assert_equal 0, Checkout.all.size + end + + should "show that dependency on membership works" do + assert_equal 1, Membership.all.size + @participant.destroy + assert_equal 0, Membership.all.size + end + + should "show that dependency on shift_participant works" do + assert_equal 1, ShiftParticipant.all.size + @participant.destroy + assert_equal 0, ShiftParticipant.all.size + end + + should "show that dependency on organization_status works" do + assert_equal 1, OrganizationStatus.all.size + @participant.destroy + assert_equal 0, OrganizationStatus.all.size + end + + should "show that dependency on user works" do + assert_equal 1, User.all.size + @participant.destroy + assert_equal 0, User.all.size + end + + should "show that search scope works properly" do + assert_equal [@participant], Participant.search("agoradia") + assert_equal [], Participant.search("rkelly") + end + + should "show that scc scope works properly" do + assert_equal [@participant], Participant.scc + end + should "correctly format a participant's phone number" do assert_equal "(123) 456-7890", @participant.formatted_phone_number - assert_equal "N/A", @temp_participant.formatted_phone_number end + + should "correctly determine if participant skipped video" do + assert_equal false, @participant.is_waiver_cheater? + + assert_equal true, @temp_participant.is_waiver_cheater? + end + + should "show that is_booth_chair method works correctly" do + assert_equal true, @participant.is_booth_chair? + end + + should "show that is_scc method works correctly" do + assert_equal true, @participant.is_scc? + end + + should "show that name method works correctly" do + assert_equal "Akshay Goradia", @participant.name + end + + should "show that surname method works correctly" do + assert_equal "Goradia", @participant.surname + end + + should "show that email method works correctly" do + assert_equal "agoradia@cmu.edu", @participant.email + end + + should "show that department method works correctly" do + assert_equal "Dietrich College Interdisciplinary, Human-Computer Interaction", @participant.department + end + + should "show that student_class method works correctly" do + assert_equal "Junior", @participant.student_class + end + + should "show that formatted_phone_number method works correctly" do + assert_equal "(123) 456-7890", @participant.formatted_phone_number + end + + should "show that formatted_name method works correctly" do + assert_equal "Akshay Goradia (agoradia)", @participant.formatted_name + end + end - end end diff --git a/test/unit/role_test.rb b/test/unit/role_test.rb index ef52f5bd..dd1b5e6c 100644 --- a/test/unit/role_test.rb +++ b/test/unit/role_test.rb @@ -28,6 +28,8 @@ class RoleTest < ActiveSupport::TestCase # Relationships + should have_and_belong_to_many(:users) + # Validations # Scopes diff --git a/test/unit/shift_participant_test.rb b/test/unit/shift_participant_test.rb index a71c5730..20a9476e 100644 --- a/test/unit/shift_participant_test.rb +++ b/test/unit/shift_participant_test.rb @@ -35,19 +35,30 @@ class ShiftParticipantTest < ActiveSupport::TestCase context "With a proper context, " do setup do - FactoryGirl.create(:shift_participant) + @shift = FactoryGirl.create(:shift, :ends_at => Time.zone.now + 2.hour, :starts_at => Time.zone.now) + @late= FactoryGirl.create(:shift_participant, :shift_id => @shift.id, :clocked_in_at => Time.zone.now + 1.hour) + @not_late= FactoryGirl.create(:shift_participant, :shift_id => @shift.id, :clocked_in_at => Time.zone.now) end teardown do end should "show that all factories are properly created" do - assert_equal 1, ShiftParticipant.all.size + assert_equal 2, ShiftParticipant.all.size end # Scopes + should "show that scope 'checked in late' is working" do + assert_equal @late.id , ShiftParticipant.checked_in_late[0].id + end # Methods end end + + + + + + diff --git a/test/unit/shift_test.rb b/test/unit/shift_test.rb index 3d903a2a..ac2e3803 100644 --- a/test/unit/shift_test.rb +++ b/test/unit/shift_test.rb @@ -35,16 +35,22 @@ class ShiftTest < ActiveSupport::TestCase #does not need to have an organization should validate_presence_of(:starts_at) should validate_presence_of(:ends_at) + should validate_presence_of(:shift_type) should validate_presence_of(:required_number_of_participants) context "With a proper context, " do setup do # Create 3 shifts - @upcomming = FactoryGirl.create(:shift, :ends_at => Time.local(2021,1,1,15,0,0), :starts_at => Time.now + 1.hour) - @current = FactoryGirl.create(:shift, :ends_at => Time.local(2020,1,1,15,0,0), :starts_at => Time.local(2014,1,1,13,4,0)) - @past = FactoryGirl.create(:shift, :ends_at => Time.local(2001,1,1,15,0,0), :starts_at => Time.local(2000,1,1,14,10,0)) - @not_checked_in = FactoryGirl.create(:shift, :required_number_of_participants => 1 ) - @checked_in = FactoryGirl.create(:shift, :required_number_of_participants => 2) + @type1 = FactoryGirl.create(:shift_type, :id => 1) + @type2 = FactoryGirl.create(:shift_type, :id => 2) + @type3 = FactoryGirl.create(:shift_type, :id => 3) + + @upcomming = FactoryGirl.create(:shift, :shift_type_id => @type1.id, :ends_at => Time.local(2021,1,1,16,0,0), :starts_at => Time.zone.now + 1.hour) + @future = FactoryGirl.create(:shift, :shift_type_id => @type2.id, :ends_at => Time.local(2021,1,1,16,0,0), :starts_at => Time.zone.now + 7.hour) + @current = FactoryGirl.create(:shift, :shift_type_id => @type3.id, :ends_at => Time.local(2020,1,1,16,0,0), :starts_at => Time.local(2016,1,1,13,4,0)) + @past = FactoryGirl.create(:shift, :shift_type_id => @type1.id, :ends_at => Time.local(2001,1,1,16,0,0), :starts_at => Time.local(2000,1,1,14,10,0)) + @not_checked_in = FactoryGirl.create(:shift, :shift_type_id => @type2.id, :required_number_of_participants => 1, :ends_at => Time.local(2001,1,1,16,0,0), :starts_at => Time.local(2000,1,1,14,10,0)) + @checked_in = FactoryGirl.create(:shift, :shift_type_id => @type2.id, :required_number_of_participants => 2, :ends_at => Time.local(2001,1,1,16,0,0), :starts_at => Time.local(2000,1,1,14,10,0)) FactoryGirl.create(:shift_participant, :shift => @checked_in) FactoryGirl.create(:shift_participant, :shift => @checked_in) end @@ -53,7 +59,7 @@ class ShiftTest < ActiveSupport::TestCase end should "show that all factories are properly created" do - assert_equal 5, Shift.all.size + assert_equal 6, Shift.all.size end # Scopes @@ -65,11 +71,42 @@ class ShiftTest < ActiveSupport::TestCase assert_equal 1, Shift.upcoming.size end + should "have a scope 'future' that works" do + assert_equal 2, Shift.future.size + end + + should "have a scope 'past' that works" do + assert_equal 3, Shift.past.size + end + + should "have a scope 'missed' that works" do + assert_equal 5, Shift.missed.size + end + + should "have a scope 'watch_shifts' that works" do + assert_equal 2, Shift.watch_shifts.size + end + + should "have a scope 'sec_shifts' that works" do + assert_equal 3, Shift.sec_shifts.size + end + + should "have a scope 'coord_shifts' that works" do + assert_equal 1, Shift.coord_shifts.size + end + # Methods should "have a method 'is_checked_in' that works" do assert_equal true, @checked_in.is_checked_in assert_equal false, @not_checked_in.is_checked_in end + + should "have a method 'formatted_name' that works" do + @type = FactoryGirl.create(:shift_type, :name => "Bob") + @ex = FactoryGirl.create(:shift, :shift_type_id => @type.id, :ends_at => Time.local(2001,1,1,16,0,0), :starts_at => Time.new(2000,1,1)) + assert_equal 'Bob @ Jan 1 at 12:00 AM', @ex.formatted_name + + end end end diff --git a/test/unit/store_item_test.rb b/test/unit/store_item_test.rb new file mode 100644 index 00000000..4de416bd --- /dev/null +++ b/test/unit/store_item_test.rb @@ -0,0 +1,44 @@ +# ## Schema Information +# +# Table name: `store_items` +# +# ### Columns +# +# Name | Type | Attributes +# ----------------- | ------------------ | --------------------------- +# **`created_at`** | `datetime` | `not null` +# **`id`** | `integer` | `not null, primary key` +# **`name`** | `string(255)` | +# **`price`** | `decimal(10, )` | +# **`quantity`** | `integer` | +# **`updated_at`** | `datetime` | `not null` +# + +require 'test_helper' + +class StoreItemTest < ActiveSupport::TestCase + + #relationships + + should have_many(:store_purchases) + + #methods + + context "With a proper context, " do + setup do + # Create store + @store_item = FactoryGirl.create(:store_item, :name => "Hammer", :price => 20, :quantity => 5) + # Create charge + @charge = FactoryGirl.create(:charge, :is_approved => true) + # Create store_purchase + @store_purchase = FactoryGirl.create(:store_purchase, :price_at_purchase => 20, :quantity_purchased => 1, :store_item_id => @store_item.id) + end + + teardown do + end + + should "show that quantity_available method works correctly" do + assert_equal 4, @store_item.quantity_available + end + end +end diff --git a/test/models/store_purchase_test.rb b/test/unit/store_purchase_test.rb similarity index 52% rename from test/models/store_purchase_test.rb rename to test/unit/store_purchase_test.rb index b4141ae9..e994189e 100644 --- a/test/models/store_purchase_test.rb +++ b/test/unit/store_purchase_test.rb @@ -25,7 +25,31 @@ require 'test_helper' class StorePurchaseTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end + + #relationships + should have_one(:organization).through(:charge) + should belong_to(:charge) + should belong_to(:store_item) + + #methods + + context "With a proper context, " do + setup do + # Create store + @store_item = FactoryGirl.create(:store_item, :name => "Hammer", :price => 20, :quantity => 3) + # Create store_purchase + @store_purchase = FactoryGirl.create(:store_purchase, :price_at_purchase => 20, :quantity_purchased => 1, :store_item_id => @store_item.id) + end + + teardown do + end + + should "show that items_in_cart works properly" do + assert_equal [@store_purchase], StorePurchase.items_in_cart + end + + should "show that items_in_cart? works properly" do + assert_equal true, StorePurchase.items_in_cart? + end + end end diff --git a/test/unit/task_test.rb b/test/unit/task_test.rb index 8452c8df..7ea30d68 100644 --- a/test/unit/task_test.rb +++ b/test/unit/task_test.rb @@ -46,6 +46,13 @@ class TaskTest < ActiveSupport::TestCase assert_equal 2, Task.upcoming.size end + should "have a scope 'is_incomplete' that works" do + assert_equal 2, Task.is_incomplete.size + end + + should "have a scope 'is_complete' that works" do + assert_equal 1, Task.is_complete.size + end # Methods should "show that the is_past_due method works" do assert_equal true, @assign_rides.is_past_due diff --git a/test/unit/tool_test.rb b/test/unit/tool_test.rb index 9c0654a8..0d936f65 100644 --- a/test/unit/tool_test.rb +++ b/test/unit/tool_test.rb @@ -31,8 +31,8 @@ class ToolTest < ActiveSupport::TestCase should belong_to(:tool_type) # Validations - # should validate_uniqueness_of(:barcode) - # should validate_uniqueness_of(:name) + should validate_uniqueness_of(:barcode) + should validate_presence_of(:tool_type_id) context "With a proper context, " do setup do @@ -44,7 +44,7 @@ class ToolTest < ActiveSupport::TestCase @shannon_participant = FactoryGirl.create(:participant) # Create 6 tools - @hammer = FactoryGirl.create(:tool) + @hammer = FactoryGirl.create(:tool, :barcode => 12811) @saw_type = FactoryGirl.create(:tool_type, name: 'Saw') @saw = FactoryGirl.create(:tool, :barcode => 12390, :description => "SAW", tool_type: @saw_type) @@ -57,7 +57,7 @@ class ToolTest < ActiveSupport::TestCase @hard_hat_2 = FactoryGirl.create(:tool, :barcode => 12809, :description => "HARD HAT 2", tool_type: @hard_hat_type) @radio_type = FactoryGirl.create(:tool_type, name: 'Radio') - @radio = FactoryGirl.create(:tool, tool_type: @radio_type) + @radio = FactoryGirl.create(:tool, :barcode => 12810, tool_type: @radio_type, :description => "RADIO") # Create 4 checkouts @hammer_checkout1 = FactoryGirl.create(:checkout, :checked_in_at => DateTime.now + 3.days, :tool => @hammer, :organization => @sdc) @@ -68,39 +68,66 @@ class ToolTest < ActiveSupport::TestCase teardown do end + #scopes should "show that all factories are properly created" do assert_equal 6, Tool.all.size end + should "show that the by barcode scope works" do + assert_equal 12012, Tool.by_barcode[0].barcode + assert_equal 12811, Tool.by_barcode[5].barcode + end + + should "show that the by type scope works" do + assert_equal [@hard_hat_1, @hard_hat_2], Tool.by_type(@hard_hat_type) + assert_equal [@radio], Tool.by_type(@radio_type) + assert_equal [@ladder], Tool.by_type(@ladder_type) + end + should "have a scope 'hardhats' that works" do assert_equal 2, Tool.hardhats.size end - should "have a scope 'radios' that works" do assert_equal 1, Tool.radios.size end - should "have a scope 'just_tools' that works" do assert_equal 3, Tool.just_tools.size end - should "show that the 'current_participant' method works" do - assert_equal nil, @hammer.current_participant - assert_equal @shannon_participant, @saw.current_participant - assert_equal nil, @hard_hat_1.current_participant - assert_equal nil, @ladder.current_participant + should "have a scope 'search' that works" do + assert_equal @radio.barcode, Tool.search('radio')[0].barcode + end + + should "have a scope 'checked_in' that works" do + @radio_checkin = FactoryGirl.create(:checkout, :tool => @radio, :checked_out_at => Time.now - 1.hour, :checked_in_at => Time.now + 1.hour) + @ladder_checkin = FactoryGirl.create(:checkout, :tool => @ladder, :checked_out_at => Time.now - 1.hour, :checked_in_at => Time.now + 1.hour) + @hardhat2_checkin = FactoryGirl.create(:checkout, :tool => @hard_hat_2, :checked_out_at => Time.now - 1.hour, :checked_in_at => Time.now + 1.hour) + assert_equal 3, Tool.checked_in.size + end + + should "have a scope 'checked_out' that works" do + assert_equal 3, Tool.checked_out.size end - should "show that the 'current_organization' method works" do + #methods + + should "show that the 'current_organization' method works" do assert_equal @sdc, @hammer.current_organization assert_equal @theta, @saw.current_organization assert_equal @theta, @hard_hat_1.current_organization assert_equal nil, @ladder.current_organization end - + + should "show that the 'current_participant' method works" do + assert_equal nil, @hammer.current_participant + assert_equal @shannon_participant, @saw.current_participant + assert_equal nil, @hard_hat_1.current_participant + assert_equal nil, @ladder.current_participant + end + should "show that the is_checked_out? method works" do assert @hammer.is_checked_out? assert @saw.is_checked_out? @@ -108,14 +135,29 @@ class ToolTest < ActiveSupport::TestCase deny @ladder.is_checked_out? end + should "show that is_waitlist_critical works" do + @wait1 = FactoryGirl.create(:tool_waitlist, :tool_type_id => @saw.id) + @wait2 = FactoryGirl.create(:tool_waitlist, :tool_type_id => @saw.id) + assert_equal true, @saw.is_waitlist_critical? + assert_equal false, @ladder.is_waitlist_critical? + end + + should "show that is_hardhat works" do + assert @hard_hat_1.is_hardhat? + deny @radio.is_hardhat? + end + should "show that the 'self.checked_out_by_organization(organization)' method works" do assert_equal [@saw, @hard_hat_1], Tool.checked_out_by_organization(@theta) end - should "show that the by type scope works" do - assert_equal [@hard_hat_1, @hard_hat_2], Tool.by_type(@hard_hat_type) - assert_equal [@radio], Tool.by_type(@radio_type) - assert_equal [@ladder], Tool.by_type(@ladder_type) + should "show that name works" do + assert_equal 'Radio', @radio.name + end + + should "show that that the method formatted name works" do + assert_equal '12810: Radio - RADIO', @radio.formatted_name + assert_equal '12012: Ladder - LADDER', @ladder.formatted_name end end diff --git a/test/unit/tool_type_test.rb b/test/unit/tool_type_test.rb index c7d7b156..f4762e3c 100644 --- a/test/unit/tool_type_test.rb +++ b/test/unit/tool_type_test.rb @@ -17,6 +17,7 @@ class ToolTypeTest < ActiveSupport::TestCase should have_many(:tools) + should have_many(:tool_waitlists) should validate_presence_of(:name) should validate_uniqueness_of(:name) diff --git a/test/unit/tool_waitlist_test.rb b/test/unit/tool_waitlist_test.rb index 5911841e..e085215e 100644 --- a/test/unit/tool_waitlist_test.rb +++ b/test/unit/tool_waitlist_test.rb @@ -25,7 +25,62 @@ require 'test_helper' class ToolWaitlistTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end +#Relationships + should belong_to(:tool_type) + should belong_to(:organization) + should belong_to(:participant) + + #Validations + should validate_presence_of(:tool_type) + should validate_presence_of(:organization) + should validate_presence_of(:participant) + should validate_presence_of(:wait_start_time) + + context "With a proper context, " do + setup do + # creating people for waitlist + # @person1 = FactoryGirl.create(:participant, :andrewid => 'ersmith') + @person2 = FactoryGirl.create(:participant, :andrewid => 'erbob') + @person3 = FactoryGirl.create(:participant, :andrewid => 'ersam') + + #making tool types + @saw = FactoryGirl.create(:tool_type, name: 'Saw') + @hammer = FactoryGirl.create(:tool_type, name: 'Hammer') + + # making waitlist + @wait1 = FactoryGirl.create(:tool_waitlist, :tool_type_id => @saw.id) + @wait2 = FactoryGirl.create(:tool_waitlist, :tool_type_id => @saw.id, :wait_start_time => (Time.now + 1.hour) ) + @wait3 = FactoryGirl.create(:tool_waitlist, :tool_type_id => @hammer.id, :wait_start_time => (Time.now + 2.hour)) + end + + teardown do + end + + should "show that all factories are properly created" do + assert_equal 3, ToolWaitlist.all.size + end + # Scopes + + should "show that for_tool_type scope works" do + assert_equal 2, ToolWaitlist.for_tool_type(1).size + assert_equal 1, ToolWaitlist.for_tool_type(1)[0].tool_type_id + assert_equal 1, ToolWaitlist.for_tool_type(1)[1].tool_type_id + end + + should "show that by_wait_start_time scope works" do + assert_equal @wait1.id, ToolWaitlist.by_wait_start_time[0].id + assert_equal @wait3.id, ToolWaitlist.by_wait_start_time[2].id + end + + #Methods + should "show that duration method works" do + @wait = FactoryGirl.create(:tool_waitlist, :tool_type_id => @saw.id, :wait_start_time => (Time.now - 1.hour) ) + assert_equal 60, @wait.duration_waiting.round + end + + + + + end + end