fe 0.0.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +4 -4
- data/Rakefile +16 -36
- data/app/assets/config/fe/manifest.js +3 -0
- data/app/assets/config/manifest.js +3 -0
- data/app/assets/javascripts/application.js.erb +1 -1
- data/app/assets/javascripts/fe/admin.js +0 -2
- data/app/assets/javascripts/fe/fe.admin.js +40 -20
- data/app/assets/javascripts/fe/fe.common.js.erb +98 -0
- data/app/assets/javascripts/fe/fe.public.js +2 -416
- data/app/assets/javascripts/fe/fe.public.nojquery.js.erb +526 -0
- data/app/assets/javascripts/fe/jquery.html5_upload.js +258 -0
- data/app/assets/javascripts/fe/jquery.validate.pack.js +3 -15
- data/app/assets/stylesheets/fe/fe.screen.css.scss.erb +90 -10
- data/app/assets/stylesheets/fe/validation.css +5 -1
- data/app/controllers/concerns/fe/admin/question_sheets_controller_concern.rb +111 -0
- data/app/controllers/concerns/fe/answer_pages_controller_concern.rb +131 -0
- data/app/controllers/{fe/concerns → concerns/fe}/answer_sheets_controller_concern.rb +15 -7
- data/app/controllers/{fe/concerns → concerns/fe}/application_controller_concern.rb +15 -2
- data/app/controllers/fe/admin/elements_controller.rb +102 -64
- data/app/controllers/fe/admin/email_templates_controller.rb +7 -7
- data/app/controllers/fe/admin/question_pages_controller.rb +9 -9
- data/app/controllers/fe/admin/question_sheets_controller.rb +2 -103
- data/app/controllers/fe/reference_pages_controller.rb +11 -11
- data/app/controllers/fe/reference_sheets_controller.rb +6 -4
- data/app/controllers/fe/references_controller.rb +20 -19
- data/app/controllers/fe/submit_pages_controller.rb +5 -5
- data/app/helpers/fe/answer_pages_helper.rb +1 -1
- data/app/helpers/fe/application_helper.rb +8 -3
- data/app/jobs/fe/update_reference_sheet_visibility_job.rb +11 -0
- data/app/mailers/fe/notifier.rb +12 -5
- data/app/models/answer_sheet.rb +2 -0
- data/app/models/application_record.rb +3 -0
- data/app/models/{fe/concerns → concerns/fe}/answer_concern.rb +2 -2
- data/app/models/{fe/concerns → concerns/fe}/answer_pages_presenter_concern.rb +15 -5
- data/app/models/concerns/fe/answer_sheet_concern.rb +125 -0
- data/app/models/{fe/concerns → concerns/fe}/choice_field_concern.rb +56 -31
- data/app/models/fe/address.rb +2 -2
- data/app/models/fe/answer.rb +1 -1
- data/app/models/fe/answer_sheet.rb +1 -1
- data/app/models/fe/answer_sheet_question_sheet.rb +2 -2
- data/app/models/fe/application.rb +15 -10
- data/app/models/fe/condition.rb +4 -4
- data/app/models/fe/date_field.rb +2 -2
- data/app/models/fe/element.rb +201 -45
- data/app/models/fe/email_address.rb +2 -2
- data/app/models/fe/email_template.rb +1 -1
- data/app/models/fe/page.rb +138 -31
- data/app/models/fe/page_element.rb +8 -3
- data/app/models/fe/page_link.rb +6 -3
- data/app/models/fe/paragraph.rb +1 -1
- data/app/models/fe/person.rb +16 -13
- data/app/models/fe/phone_number.rb +1 -1
- data/app/models/fe/question.rb +64 -44
- data/app/models/fe/question_grid.rb +16 -4
- data/app/models/fe/question_grid_with_total.rb +15 -0
- data/app/models/fe/question_set.rb +54 -14
- data/app/models/fe/question_sheet.rb +54 -19
- data/app/models/fe/reference_question.rb +9 -13
- data/app/models/fe/reference_sheet.rb +113 -54
- data/app/models/fe/state_chooser.rb +2 -2
- data/app/models/fe/text_field.rb +2 -2
- data/app/models/fe/user.rb +1 -1
- data/app/models/staff.rb +8 -6
- data/app/validators/email_validator.rb +11 -0
- data/app/views/fe/admin/elements/create.js.erb +4 -3
- data/app/views/fe/admin/elements/destroy.js.erb +1 -1
- data/app/views/fe/admin/elements/drop.js.erb +2 -1
- data/app/views/fe/admin/elements/duplicate.js.erb +2 -1
- data/app/views/fe/admin/elements/edit.js.erb +1 -1
- data/app/views/fe/admin/elements/error.js.erb +1 -1
- data/app/views/fe/admin/elements/new.js.erb +13 -6
- data/app/views/fe/admin/elements/update.js.erb +1 -1
- data/app/views/fe/admin/email_templates/_form.html.erb +3 -3
- data/app/views/fe/admin/email_templates/edit.html.erb +3 -3
- data/app/views/fe/admin/email_templates/index.html.erb +3 -3
- data/app/views/fe/admin/email_templates/new.html.erb +3 -3
- data/app/views/fe/admin/panels/_advanced_options.html.erb +16 -10
- data/app/views/fe/admin/panels/_common_boolean_fields.html.erb +1 -0
- data/app/views/fe/admin/panels/_common_boolean_fields_default.html.erb +11 -0
- data/app/views/fe/admin/panels/_common_fields.html.erb +18 -19
- data/app/views/fe/admin/panels/_condition.html.erb +1 -1
- data/app/views/fe/admin/panels/_insert.html.erb +25 -25
- data/app/views/fe/admin/panels/_nav_controls.html.erb +4 -4
- data/app/views/fe/admin/panels/_page.html.erb +2 -2
- data/app/views/fe/admin/panels/_pages_list.html.erb +3 -3
- data/app/views/fe/admin/panels/_prop_attachment_field.html.erb +2 -2
- data/app/views/fe/admin/panels/_prop_choice_field.html.erb +52 -24
- data/app/views/fe/admin/panels/_prop_date_field.html.erb +1 -1
- data/app/views/fe/admin/panels/_prop_element.html.erb +7 -14
- data/app/views/fe/admin/panels/_prop_page.html.erb +11 -6
- data/app/views/fe/admin/panels/_prop_paragraph.html.erb +38 -24
- data/app/views/fe/admin/panels/_prop_question_grid.html.erb +7 -2
- data/app/views/fe/admin/panels/_prop_question_grid_with_total.html.erb +2 -2
- data/app/views/fe/admin/panels/_prop_reference_question.html.erb +3 -3
- data/app/views/fe/admin/panels/_prop_section.html.erb +8 -2
- data/app/views/fe/admin/panels/_prop_sheet.html.erb +7 -4
- data/app/views/fe/admin/panels/_prop_text_field.html.erb +12 -12
- data/app/views/fe/admin/question_pages/_element.html.erb +16 -6
- data/app/views/fe/admin/question_pages/_element_show.html.erb +2 -2
- data/app/views/fe/admin/question_pages/_question_page.html.erb +4 -4
- data/app/views/fe/admin/question_pages/create.js.erb +3 -3
- data/app/views/fe/admin/question_pages/destroy.js.erb +3 -3
- data/app/views/fe/admin/question_pages/edit.js.erb +1 -1
- data/app/views/fe/admin/question_pages/error.js.erb +1 -1
- data/app/views/fe/admin/question_pages/show.js.erb +2 -2
- data/app/views/fe/admin/question_pages/show_panel.js.erb +1 -1
- data/app/views/fe/admin/question_pages/update.js.erb +1 -1
- data/app/views/fe/admin/question_sheets/edit.js.erb +1 -1
- data/app/views/fe/admin/question_sheets/error.js.erb +1 -1
- data/app/views/fe/admin/question_sheets/index.html.erb +8 -8
- data/app/views/fe/admin/question_sheets/new.html.erb +3 -3
- data/app/views/fe/admin/question_sheets/show.html.erb +5 -5
- data/app/views/fe/admin/question_sheets/update.js.erb +1 -1
- data/app/views/fe/answer_pages/_answer_page.html.erb +14 -14
- data/app/views/fe/answer_pages/_element.html.erb +25 -6
- data/app/views/fe/answer_pages/_page_name.html.erb +1 -0
- data/app/views/fe/answer_pages/show.html.erb +39 -0
- data/app/views/fe/answer_pages/update.js.erb +11 -3
- data/app/views/fe/answer_sheets/_answer_sheet.html.erb +6 -6
- data/app/views/fe/answer_sheets/_element.html.erb +55 -35
- data/app/views/fe/answer_sheets/_incomplete.html.erb +1 -1
- data/app/views/fe/answer_sheets/_page_link.html.erb +9 -7
- data/app/views/fe/answer_sheets/_pages_list.html.erb +4 -4
- data/app/views/fe/answer_sheets/_submit_to.html.erb +1 -0
- data/app/views/fe/answer_sheets/_title.html.erb +1 -1
- data/app/views/fe/answer_sheets/edit.html.erb +24 -24
- data/app/views/fe/answer_sheets/incomplete.js.erb +9 -3
- data/app/views/fe/answer_sheets/index.html.erb +3 -3
- data/app/views/fe/answer_sheets/show.html.erb +1 -1
- data/app/views/fe/applications/_logout.html.erb +1 -0
- data/app/views/fe/applications/show.html.erb +1 -0
- data/app/views/fe/questions/fe/_acceptance.html.erb +11 -10
- data/app/views/fe/questions/fe/_attachment_field.html.erb +133 -10
- data/app/views/fe/questions/fe/_checkbox_field.html.erb +34 -30
- data/app/views/fe/questions/fe/_country.html.erb +6 -6
- data/app/views/fe/questions/fe/_date_field.html.erb +5 -5
- data/app/views/fe/questions/fe/_date_field_mmyy.html.erb +8 -8
- data/app/views/fe/questions/fe/_drop_down_field.html.erb +7 -6
- data/app/views/fe/questions/fe/_paragraph.html.erb +1 -1
- data/app/views/fe/questions/fe/_question_grid.html.erb +21 -16
- data/app/views/fe/questions/fe/_question_grid_with_total.html.erb +25 -18
- data/app/views/fe/questions/fe/_questions.html.erb +11 -5
- data/app/views/fe/questions/fe/_radio_button_field.html.erb +42 -25
- data/app/views/fe/questions/fe/_rating.html.erb +57 -18
- data/app/views/fe/questions/fe/_reference_discipler.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_friend.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_parent.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_peer.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_question.html.erb +44 -21
- data/app/views/fe/questions/fe/_reference_roommate.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_spiritual.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_staff.html.erb +1 -1
- data/app/views/fe/questions/fe/_section.html.erb +1 -1
- data/app/views/fe/questions/fe/_state_chooser.html.erb +6 -6
- data/app/views/fe/questions/fe/_text_area_field.html.erb +17 -6
- data/app/views/fe/questions/fe/_text_field.html.erb +7 -6
- data/app/views/fe/questions/fe/_yes_no.html.erb +8 -8
- data/app/views/fe/questions/fe/_yes_no_field.erb +12 -9
- data/app/views/fe/reference_pages/_reference.html.erb +15 -15
- data/app/views/fe/reference_pages/edit.html.erb +9 -9
- data/app/views/fe/reference_sheets/done.html.erb +2 -2
- data/app/views/fe/reference_sheets/not_found.html.erb +4 -4
- data/app/views/fe/references/edit.html.erb +6 -6
- data/app/views/fe/references/show.html.erb +8 -8
- data/app/views/fe/references/submit.js.erb +3 -3
- data/app/views/fe/submit_pages/_thankyou.html.erb +1 -1
- data/app/views/fe/submit_pages/edit.html.erb +12 -12
- data/app/views/fe/submit_pages/error.js.erb +1 -1
- data/app/views/fe/submit_pages/submit.js.erb +2 -2
- data/app/views/layouts/fe/_error_messages_for.html.erb +7 -0
- data/app/views/layouts/fe/application.html.erb +4 -5
- data/app/views/layouts/fe/fe_admin.html.erb +30 -0
- data/app/views.current/fe/admin/elements/_errors.html.erb +11 -0
- data/app/views.current/fe/admin/elements/create.js.erb +12 -0
- data/app/views.current/fe/admin/elements/destroy.js.erb +4 -0
- data/app/views.current/fe/admin/elements/drop.js.erb +3 -0
- data/app/views.current/fe/admin/elements/duplicate.js.erb +3 -0
- data/app/views.current/fe/admin/elements/edit.js.erb +4 -0
- data/app/views.current/fe/admin/elements/error.js.erb +4 -0
- data/app/views.current/fe/admin/elements/new.js.erb +17 -0
- data/app/views.current/fe/admin/elements/reorder.js.erb +0 -0
- data/app/views.current/fe/admin/elements/update.js.erb +9 -0
- data/app/views.current/fe/admin/email_templates/_form.html.erb +8 -0
- data/app/views.current/fe/admin/email_templates/edit.html.erb +13 -0
- data/app/views.current/fe/admin/email_templates/index.html.erb +20 -0
- data/app/views.current/fe/admin/email_templates/new.html.erb +11 -0
- data/app/views.current/fe/admin/panels/_advanced_options.html.erb +49 -0
- data/app/views.current/fe/admin/panels/_common_boolean_fields.html.erb +1 -0
- data/app/views.current/fe/admin/panels/_common_boolean_fields_default.html.erb +11 -0
- data/app/views.current/fe/admin/panels/_common_fields.html.erb +23 -0
- data/app/views.current/fe/admin/panels/_condition.html.erb +6 -0
- data/app/views.current/fe/admin/panels/_insert.html.erb +39 -0
- data/app/views.current/fe/admin/panels/_nav_controls.html.erb +6 -0
- data/app/views.current/fe/admin/panels/_page.html.erb +3 -0
- data/app/views.current/fe/admin/panels/_pages_list.html.erb +16 -0
- data/app/views.current/fe/admin/panels/_prop_attachment_field.html.erb +2 -0
- data/app/views.current/fe/admin/panels/_prop_choice_field.html.erb +74 -0
- data/app/views.current/fe/admin/panels/_prop_date_field.html.erb +7 -0
- data/app/views.current/fe/admin/panels/_prop_element.html.erb +23 -0
- data/app/views.current/fe/admin/panels/_prop_page.html.erb +26 -0
- data/app/views.current/fe/admin/panels/_prop_paragraph.html.erb +46 -0
- data/app/views.current/fe/admin/panels/_prop_question_grid.html.erb +28 -0
- data/app/views.current/fe/admin/panels/_prop_question_grid_with_total.html.erb +14 -0
- data/app/views.current/fe/admin/panels/_prop_reference_question.html.erb +12 -0
- data/app/views.current/fe/admin/panels/_prop_section.html.erb +8 -0
- data/app/views.current/fe/admin/panels/_prop_sheet.html.erb +20 -0
- data/app/views.current/fe/admin/panels/_prop_text_field.html.erb +20 -0
- data/app/views.current/fe/admin/question_pages/_element.html.erb +28 -0
- data/app/views.current/fe/admin/question_pages/_element_show.html.erb +10 -0
- data/app/views.current/fe/admin/question_pages/_errors.html.erb +10 -0
- data/app/views.current/fe/admin/question_pages/_question_page.html.erb +13 -0
- data/app/views.current/fe/admin/question_pages/create.js.erb +11 -0
- data/app/views.current/fe/admin/question_pages/destroy.js.erb +5 -0
- data/app/views.current/fe/admin/question_pages/edit.js.erb +3 -0
- data/app/views.current/fe/admin/question_pages/error.js.erb +4 -0
- data/app/views.current/fe/admin/question_pages/show.js.erb +9 -0
- data/app/views.current/fe/admin/question_pages/show_panel.js.erb +3 -0
- data/app/views.current/fe/admin/question_pages/update.js.erb +2 -0
- data/app/views.current/fe/admin/question_sheets/_errors.html.erb +11 -0
- data/app/views.current/fe/admin/question_sheets/edit.js.erb +3 -0
- data/app/views.current/fe/admin/question_sheets/error.js.erb +5 -0
- data/app/views.current/fe/admin/question_sheets/index.html.erb +41 -0
- data/app/views.current/fe/admin/question_sheets/new.html.erb +15 -0
- data/app/views.current/fe/admin/question_sheets/show.html.erb +27 -0
- data/app/views.current/fe/admin/question_sheets/update.js.erb +2 -0
- data/app/views.current/fe/answer_pages/_answer_page.html.erb +53 -0
- data/app/views.current/fe/answer_pages/_element.html.erb +32 -0
- data/app/views.current/fe/answer_pages/_page_name.html.erb +1 -0
- data/app/views.current/fe/answer_pages/show.html.erb +39 -0
- data/app/views.current/fe/answer_pages/update.js.erb +13 -0
- data/app/views.current/fe/answer_sheets/_answer_sheet.html.erb +26 -0
- data/app/views.current/fe/answer_sheets/_element.html.erb +74 -0
- data/app/views.current/fe/answer_sheets/_incomplete.html.erb +10 -0
- data/app/views.current/fe/answer_sheets/_page_link.html.erb +9 -0
- data/app/views.current/fe/answer_sheets/_pages_list.html.erb +11 -0
- data/app/views.current/fe/answer_sheets/_submit_to.html.erb +1 -0
- data/app/views.current/fe/answer_sheets/_title.html.erb +1 -0
- data/app/views.current/fe/answer_sheets/edit.html.erb +66 -0
- data/app/views.current/fe/answer_sheets/incomplete.js.erb +11 -0
- data/app/views.current/fe/answer_sheets/index.html.erb +18 -0
- data/app/views.current/fe/answer_sheets/send_reference_invite.js.erb +8 -0
- data/app/views.current/fe/answer_sheets/show.html.erb +13 -0
- data/app/views.current/fe/applications/_logout.html.erb +1 -0
- data/app/views.current/fe/applications/show.html.erb +1 -0
- data/app/views.current/fe/help/builder.html +33 -0
- data/app/views.current/fe/help/question_grid.html +18 -0
- data/app/views.current/fe/questions/fe/_acceptance.html.erb +14 -0
- data/app/views.current/fe/questions/fe/_attachment_field.html.erb +165 -0
- data/app/views.current/fe/questions/fe/_checkbox_field.html.erb +53 -0
- data/app/views.current/fe/questions/fe/_country.html.erb +7 -0
- data/app/views.current/fe/questions/fe/_date_field.html.erb +7 -0
- data/app/views.current/fe/questions/fe/_date_field_mmyy.html.erb +9 -0
- data/app/views.current/fe/questions/fe/_drop_down_field.html.erb +8 -0
- data/app/views.current/fe/questions/fe/_paragraph.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_question_grid.html.erb +70 -0
- data/app/views.current/fe/questions/fe/_question_grid_with_total.html.erb +64 -0
- data/app/views.current/fe/questions/fe/_questions.html.erb +15 -0
- data/app/views.current/fe/questions/fe/_radio_button_field.html.erb +60 -0
- data/app/views.current/fe/questions/fe/_rating.html.erb +64 -0
- data/app/views.current/fe/questions/fe/_reference_discipler.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_friend.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_parent.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_peer.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_question.html.erb +61 -0
- data/app/views.current/fe/questions/fe/_reference_roommate.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_spiritual.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_staff.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_section.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_state_chooser.html.erb +7 -0
- data/app/views.current/fe/questions/fe/_text_area_field.html.erb +17 -0
- data/app/views.current/fe/questions/fe/_text_field.html.erb +9 -0
- data/app/views.current/fe/questions/fe/_yes_no.html.erb +17 -0
- data/app/views.current/fe/questions/fe/_yes_no_field.erb +20 -0
- data/app/views.current/fe/reference_pages/_reference.html.erb +31 -0
- data/app/views.current/fe/reference_pages/edit.html.erb +24 -0
- data/app/views.current/fe/reference_sheets/done.html.erb +2 -0
- data/app/views.current/fe/reference_sheets/not_found.html.erb +5 -0
- data/app/views.current/fe/reference_sheets/submitted.js.erb +1 -0
- data/app/views.current/fe/references/edit.html.erb +8 -0
- data/app/views.current/fe/references/send_invite.js.erb +7 -0
- data/app/views.current/fe/references/show.html.erb +18 -0
- data/app/views.current/fe/references/submit.js.erb +3 -0
- data/app/views.current/fe/submit_pages/_errors.html.erb +1 -0
- data/app/views.current/fe/submit_pages/_thankyou.html.erb +2 -0
- data/app/views.current/fe/submit_pages/edit.html.erb +36 -0
- data/app/views.current/fe/submit_pages/error.js.erb +1 -0
- data/app/views.current/fe/submit_pages/submit.js.erb +3 -0
- data/app/views.current/layouts/fe/_error_messages_for.html.erb +7 -0
- data/app/views.current/layouts/fe/application.html.erb +47 -0
- data/app/{views/layouts/fe/fe.admin.html.erb → views.current/layouts/fe/fe_admin.html.erb} +4 -4
- data/config/initializers/paper_trail.rb +3 -0
- data/config/routes.rb +3 -37
- data/db/migrate/20131003041856_core.rb +23 -23
- data/db/migrate/20131003044250_create_reference_sheets.rb +2 -1
- data/db/migrate/20131003044436_add_element_and_answer_fields.rb +3 -3
- data/db/migrate/20131003044518_create_email_templates.rb +2 -2
- data/db/migrate/20131003044621_add_max_lengths.rb +1 -1
- data/db/migrate/20131003044714_create_join_table.rb +1 -1
- data/db/migrate/20131016162128_remove_question_id_from_element.rb +1 -1
- data/db/migrate/20140623153424_create_fe_people.rb +2 -2
- data/db/migrate/20140624180246_create_fe_addresses.rb +2 -2
- data/db/migrate/{20140624182216_create_create_fe_phone_numbers.rb → 20140624182216_create_fe_phone_numbers.rb} +2 -2
- data/db/migrate/20140625160545_create_fe_users.rb +2 -2
- data/db/migrate/20140808202507_add_conditional_type_to_elements.rb +1 -1
- data/db/migrate/20140808203609_add_conditional_answer_to_elements.rb +1 -1
- data/db/migrate/20141103204704_remove_short_value_column.rb +1 -1
- data/db/migrate/20141109154522_move_conditional_ids_used_for_choice_field_to_their_own_column.rb +1 -1
- data/db/migrate/20150504221439_add_all_element_ids_to_pages.rb +5 -0
- data/db/migrate/20150713022326_add_locale_columns.rb +9 -0
- data/db/migrate/20150714220730_add_locale_to_answer_sheet.rb +5 -0
- data/db/migrate/20150925181652_add_share_to_elements.rb +5 -0
- data/db/migrate/20150928085325_change_pages_all_element_ids_to_text.rb +5 -0
- data/db/migrate/20150930191538_add_locale_to_reference_sheets.rb +5 -0
- data/db/migrate/20151021181928_switch_conditional_answer_separator_to_semicolon.rb +7 -0
- data/db/migrate/20151021184250_add_question_sheet_id_in_refs.rb +12 -0
- data/db/migrate/20160201185838_add_visible_and_visibility_cache_key_to_reference_sheets.rb +6 -0
- data/db/migrate/20160805221415_add_rating_extra_labels.rb +10 -0
- data/db/migrate/20181108201746_create_versions.rb +80 -0
- data/db/migrate/20181218201130_increase_slug_length.rb +5 -0
- data/lib/access_key_generator.rb +12 -0
- data/lib/distinct_distinct_patch.rb +20 -0
- data/lib/fe/engine.rb +26 -14
- data/lib/fe/version.rb +1 -1
- data/lib/fe.rb +11 -1
- data/spec/controllers/fe/admin/elements_controller_spec.rb +211 -1
- data/spec/controllers/fe/admin/email_templates_controller_spec.rb +26 -1
- data/spec/controllers/fe/admin/question_pages_controller_spec.rb +8 -1
- data/spec/controllers/fe/admin/question_sheets_controller_spec.rb +48 -1
- data/spec/controllers/fe/answer_pages_controller_spec.rb +129 -1
- data/spec/controllers/fe/answer_sheets_controller_spec.rb +136 -1
- data/spec/controllers/fe/reference_pages_controller.rb +4 -0
- data/spec/controllers/fe/references_controller_spec.rb +4 -0
- data/spec/controllers/fe/submit_pages_controller_spec.rb +4 -0
- data/spec/dummy/app/assets/config/manifest.js +0 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +9 -0
- data/spec/dummy/app/models/application.rb +3 -0
- data/spec/dummy/app/models/person.rb +11 -0
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +2 -2
- data/spec/dummy/config/application.rb +3 -1
- data/spec/dummy/config/database.yml +20 -17
- data/spec/dummy/config/environments/production.rb +1 -5
- data/spec/dummy/config/environments/test.rb +4 -2
- data/spec/dummy/config/initializers/assets.rb +5 -2
- data/spec/dummy/config/initializers/fast_gettext.rb +5 -0
- data/spec/dummy/config/initializers/to_unsafe_h.rb +5 -0
- data/spec/dummy/config/initializers/to_unsafe_h.rb.new +5 -0
- data/spec/dummy/config/secrets.yml +2 -2
- data/spec/dummy/db/migrate/20141203214017_core.fe_engine.rb +92 -0
- data/spec/dummy/db/migrate/20141203214018_create_reference_sheets.fe_engine.rb +25 -0
- data/spec/dummy/db/migrate/20141203214019_add_element_and_answer_fields.fe_engine.rb +11 -0
- data/spec/dummy/db/migrate/20141203214020_create_email_templates.fe_engine.rb +18 -0
- data/spec/dummy/db/migrate/20141203214021_add_max_lengths.fe_engine.rb +9 -0
- data/spec/dummy/db/migrate/20141203214022_create_join_table.fe_engine.rb +12 -0
- data/spec/dummy/db/migrate/20141203214023_remove_question_id_from_element.fe_engine.rb +10 -0
- data/spec/dummy/db/migrate/20141203214024_create_fe_people.fe_engine.rb +13 -0
- data/spec/dummy/db/migrate/20141203214025_create_fe_addresses.fe_engine.rb +21 -0
- data/spec/dummy/db/migrate/20141203214027_create_fe_users.fe_engine.rb +13 -0
- data/spec/dummy/db/migrate/20141203214028_add_conditional_type_to_elements.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20141203214029_add_conditional_answer_to_elements.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20141203214030_remove_short_value_column.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20141203214031_move_conditional_ids_used_for_choice_field_to_their_own_column.fe_engine.rb +8 -0
- data/spec/dummy/db/migrate/20150123215803_create_users.rb +9 -0
- data/spec/dummy/db/migrate/20150504222619_add_all_element_ids_to_pages.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20150925192557_add_share_to_elements.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20150930190001_create_fe_phone_numbers.fe_engine.rb +20 -0
- data/spec/dummy/db/migrate/20150930190002_add_locale_columns.fe_engine.rb +10 -0
- data/spec/dummy/db/migrate/20150930190003_add_locale_to_answer_sheet.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20150930190004_change_pages_all_element_ids_to_text.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20150930191756_add_locale_to_reference_sheets.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20151021190027_add_question_sheet_id_in_refs.fe_engine.rb +13 -0
- data/spec/dummy/db/migrate/20160204164612_switch_conditional_answer_separator_to_semicolon.fe_engine.rb +8 -0
- data/spec/dummy/db/migrate/20160204164613_add_visible_and_visibility_cache_key_to_reference_sheets.fe_engine.rb +7 -0
- data/spec/dummy/db/migrate/20181108201746_create_versions.rb +80 -0
- data/spec/dummy/db/schema.rb +91 -69
- data/spec/dummy/log/test.log +101278 -419
- data/spec/factories/answer_sheet_question_sheets.rb +1 -1
- data/spec/factories/answer_sheets.rb +2 -2
- data/spec/factories/answers.rb +1 -1
- data/spec/factories/applications.rb +3 -4
- data/spec/factories/dummy_applications.rb +6 -0
- data/spec/factories/dummy_people.rb +6 -0
- data/spec/factories/dummy_users.rb +6 -0
- data/spec/factories/elements.rb +35 -10
- data/spec/factories/email_templates.rb +5 -0
- data/spec/factories/fe_addresses.rb +10 -10
- data/spec/factories/fe_email_addresses.rb +3 -3
- data/spec/factories/fe_email_templates.rb +9 -0
- data/spec/factories/fe_people.rb +5 -7
- data/spec/factories/fe_phone_numbers.rb +3 -3
- data/spec/factories/fe_user.rb +6 -0
- data/spec/factories/page.rb +1 -1
- data/spec/factories/page_elements.rb +1 -1
- data/spec/factories/paragraphs.rb +1 -1
- data/spec/factories/question_sheet.rb +3 -3
- data/spec/factories/reference_questions.rb +1 -1
- data/spec/factories/reference_sheets.rb +9 -0
- data/spec/jobs/fe/update_reference_sheet_visibility_job_spec.rb +40 -0
- data/spec/mailers/fe/notifier_spec.rb +39 -0
- data/spec/models/fe/answer_sheet_question_sheet_spec.rb +1 -1
- data/spec/models/fe/answer_spec.rb +2 -2
- data/spec/models/fe/application_spec.rb +94 -1
- data/spec/models/fe/choice_field_spec.rb +66 -0
- data/spec/models/fe/condition_spec.rb +2 -2
- data/spec/models/fe/element_spec.rb +414 -37
- data/spec/models/fe/email_template_spec.rb +1 -1
- data/spec/models/fe/page_element_spec.rb +1 -1
- data/spec/models/fe/page_spec.rb +168 -11
- data/spec/models/fe/person_spec.rb +1 -1
- data/spec/models/fe/question_set_spec.rb +91 -0
- data/spec/models/fe/question_sheet_spec.rb +103 -1
- data/spec/models/fe/question_spec.rb +73 -6
- data/spec/models/fe/reference_question_spec.rb +20 -0
- data/spec/models/fe/reference_sheet_spec.rb +305 -2
- data/spec/models/fe/text_field_spec.rb +22 -0
- data/spec/rails_helper.rb +85 -54
- data/spec/support/choices.xml +6 -0
- metadata +310 -84
- data/app/assets/javascripts/fe/fe.common.js +0 -57
- data/app/assets/javascripts/fe/jquery.scrollTo-min.js +0 -7
- data/app/assets/javascripts/fe/rails.extra.js +0 -6
- data/app/controllers/fe/applications_controller.rb +0 -183
- data/app/controllers/fe/concerns/answer_pages_controller_concern.rb +0 -83
- data/app/controllers/fe/payments_controller.rb +0 -184
- data/app/models/fe/concerns/answer_sheet_concern.rb +0 -55
- data/app/models/fe/payment.rb +0 -77
- data/app/models/fe/payment_question.rb +0 -22
- data/app/views/fe/admin/panels/_prop_payment_question.html.erb +0 -1
- data/app/views/fe/application/_logout.html.erb +0 -1
- data/app/views/fe/payment_pages/_credit.html.erb +0 -47
- data/app/views/fe/payment_pages/_mail.html.erb +0 -27
- data/app/views/fe/payment_pages/_payment.html.erb +0 -6
- data/app/views/fe/payment_pages/_staff.html.erb +0 -25
- data/app/views/fe/payment_pages/_staff_results.html.erb +0 -17
- data/app/views/fe/payment_pages/edit.html.erb +0 -75
- data/app/views/fe/payment_pages/staff_search.js.erb +0 -2
- data/app/views/fe/payments/_credit.html.erb +0 -47
- data/app/views/fe/payments/_errors.html.erb +0 -1
- data/app/views/fe/payments/_payment.html.erb +0 -13
- data/app/views/fe/payments/_staff.html.erb +0 -21
- data/app/views/fe/payments/_staff_results.html.erb +0 -18
- data/app/views/fe/payments/approve.js.erb +0 -3
- data/app/views/fe/payments/create.js.erb +0 -19
- data/app/views/fe/payments/destroy.js.erb +0 -7
- data/app/views/fe/payments/edit.html.erb +0 -56
- data/app/views/fe/payments/error.js.erb +0 -3
- data/app/views/fe/payments/no_access.html.erb +0 -7
- data/app/views/fe/payments/staff_search.js.erb +0 -1
- data/app/views/fe/payments/update.html.erb +0 -24
- data/app/views/fe/questions/fe/_payment_question.html.erb +0 -70
- data/db/migrate/20140828045339_create_payments.rb +0 -13
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/factories/payments.rb +0 -7
- data/spec/models/fe/payment_question_spec.rb +0 -65
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
function setUpSortables() {
|
|
2
|
-
$('[data-sortable]').sortable({axis:'y',
|
|
3
|
-
dropOnEmpty:false,
|
|
4
|
-
update: function(event, ui) {
|
|
5
|
-
sortable = this;
|
|
6
|
-
$.ajax({data:$(this).sortable('serialize',{key:sortable.id + '[]'}),
|
|
7
|
-
complete: function(request) {$(sortable).effect('highlight')},
|
|
8
|
-
success:function(request){$('#errors').html(request)},
|
|
9
|
-
type:'POST',
|
|
10
|
-
url: $(sortable).attr('data-sortable-url')
|
|
11
|
-
})
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
$('[data-sortable][data-sortable-handle]').each(function() {
|
|
15
|
-
handle = $(this).attr('data-sortable-handle');
|
|
16
|
-
$(this).sortable("option", "handle", handle);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
$('.droppable').droppable({
|
|
21
|
-
activeClass: 'droppable-active',
|
|
22
|
-
drop: function( event, ui ) {
|
|
23
|
-
$.post($(this).attr('data-url'), {draggable_element: ui.draggable.attr('id')}, function() {}, 'script')
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function setUpCalendars() {
|
|
29
|
-
now = new Date();
|
|
30
|
-
year = now.getFullYear() + 10;
|
|
31
|
-
$('[data-calendar]').datepicker({changeYear:true,
|
|
32
|
-
yearRange: '1950:' + year})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function setUpJsHelpers() {
|
|
36
|
-
// ==================
|
|
37
|
-
// Sortable
|
|
38
|
-
setUpSortables();
|
|
39
|
-
// ==================
|
|
40
|
-
|
|
41
|
-
// ==================
|
|
42
|
-
// Calendar
|
|
43
|
-
setUpCalendars();
|
|
44
|
-
// ==================
|
|
45
|
-
$(".tip[title], a[title]").tooltip()
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function fixGridColumnWidths() {
|
|
49
|
-
$("table.grid").each(function(i, grid) {
|
|
50
|
-
num_columns = $(grid).find("th").length;
|
|
51
|
-
if (num_columns > 0) {
|
|
52
|
-
width = (100 / num_columns) + "%";
|
|
53
|
-
$(grid).find("th").css("width", width);
|
|
54
|
-
$(grid).find("td").css("width", width);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2007-2013 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
|
|
3
|
-
* Dual licensed under MIT and GPL.
|
|
4
|
-
* @author Ariel Flesler
|
|
5
|
-
* @version 1.4.6
|
|
6
|
-
*/
|
|
7
|
-
;(function($){var h=$.scrollTo=function(a,b,c){$(window).scrollTo(a,b,c)};h.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1,limit:true};h.window=function(a){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var a=this,isWin=!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return a;var b=(a.contentWindow||a).document||a.ownerDocument||a;return/webkit/i.test(navigator.userAgent)||b.compatMode=='BackCompat'?b.body:b.documentElement})};$.fn.scrollTo=function(e,f,g){if(typeof f=='object'){g=f;f=0}if(typeof g=='function')g={onAfter:g};if(e=='max')e=9e9;g=$.extend({},h.defaults,g);f=f||g.duration;g.queue=g.queue&&g.axis.length>1;if(g.queue)f/=2;g.offset=both(g.offset);g.over=both(g.over);return this._scrollable().each(function(){if(e==null)return;var d=this,$elem=$(d),targ=e,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=$(targ,this);if(!targ.length)return;case'object':if(targ.is||targ.style)toff=(targ=$(targ)).offset()}$.each(g.axis.split(''),function(i,a){var b=a=='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,old=d[key],max=h.max(d,a);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(g.margin){attr[key]-=parseInt(targ.css('margin'+b))||0;attr[key]-=parseInt(targ.css('border'+b+'Width'))||0}attr[key]+=g.offset[pos]||0;if(g.over[pos])attr[key]+=targ[a=='x'?'width':'height']()*g.over[pos]}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)=='%'?parseFloat(c)/100*max:c}if(g.limit&&/^\d+$/.test(attr[key]))attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&g.queue){if(old!=attr[key])animate(g.onAfterFirst);delete attr[key]}});animate(g.onAfter);function animate(a){$elem.animate(attr,f,g.easing,a&&function(){a.call(this,targ,g)})}}).end()};h.max=function(a,b){var c=b=='x'?'Width':'Height',scroll='scroll'+c;if(!$(a).is('html,body'))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,html=a.ownerDocument.documentElement,body=a.ownerDocument.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
module Fe
|
|
2
|
-
class ApplicationsController < ApplicationController
|
|
3
|
-
append_before_filter :check_valid_user, :only => [:show, :collated_refs, :no_conf, :no_ref]
|
|
4
|
-
append_before_filter :setup
|
|
5
|
-
append_before_filter :set_title
|
|
6
|
-
|
|
7
|
-
layout 'fe/application'
|
|
8
|
-
|
|
9
|
-
# dashboard
|
|
10
|
-
def index
|
|
11
|
-
redirect_to :action => :show_default
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def show_default
|
|
15
|
-
@application = get_application
|
|
16
|
-
setup_view
|
|
17
|
-
|
|
18
|
-
render :template => 'fe/answer_sheets/edit'
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# create app
|
|
22
|
-
def create
|
|
23
|
-
@question_sheet = Fe::QuestionSheet.find(params[:question_sheet_id])
|
|
24
|
-
@application = @person.applications.build
|
|
25
|
-
|
|
26
|
-
@application.save!
|
|
27
|
-
@application.question_sheets << @question_sheet
|
|
28
|
-
redirect_to fe_application_path(@application)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# edit an apply
|
|
32
|
-
def edit
|
|
33
|
-
@application = Application.find(params[:id]) unless @application
|
|
34
|
-
|
|
35
|
-
if @application.applicant == current_user.person
|
|
36
|
-
setup_view
|
|
37
|
-
|
|
38
|
-
render :template => 'fe/answer_sheets/edit'
|
|
39
|
-
else
|
|
40
|
-
no_access
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def show
|
|
46
|
-
@application = Application.find(params[:id]) unless @application
|
|
47
|
-
@answer_sheets = @application.answer_sheets
|
|
48
|
-
@show_conf = true
|
|
49
|
-
@viewing = true
|
|
50
|
-
|
|
51
|
-
if @answer_sheets.empty?
|
|
52
|
-
render :action => :too_old
|
|
53
|
-
#raise "No applicant sheets in sleeve '#{@application.sleeve.title}'."
|
|
54
|
-
return
|
|
55
|
-
end
|
|
56
|
-
#render :layout => 'admin_application'
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def no_ref
|
|
60
|
-
@application = Application.find(params[:id]) unless @application
|
|
61
|
-
@answer_sheets = [@application]
|
|
62
|
-
@show_conf = true
|
|
63
|
-
|
|
64
|
-
if @answer_sheets.empty?
|
|
65
|
-
render :action => :too_old
|
|
66
|
-
#raise "No applicant sheets in sleeve '#{@application.sleeve.title}'."
|
|
67
|
-
return
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
#render :layout => 'admin_application', :template => 'fe/applys/show'
|
|
71
|
-
render :template => 'fe/applys/show'
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def no_conf
|
|
75
|
-
@application = Application.find(params[:id]) unless @application
|
|
76
|
-
@answer_sheets = [@application]
|
|
77
|
-
@show_conf = false
|
|
78
|
-
|
|
79
|
-
if @answer_sheets.empty?
|
|
80
|
-
render :action => :too_old
|
|
81
|
-
#raise "No applicant sheets in sleeve '#{@application.sleeve.title}'."
|
|
82
|
-
return
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
#render :layout => 'admin_application', :template => 'fe/applys/show'
|
|
86
|
-
render :template => 'fe/applys/show'
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def collated_refs
|
|
90
|
-
@application = Application.find(params[:id]) unless @application
|
|
91
|
-
@answer_sheets = @application.references
|
|
92
|
-
|
|
93
|
-
if @answer_sheets.empty?
|
|
94
|
-
render :action => :too_old
|
|
95
|
-
#raise "No applicant sheets in sleeve '#{@application.sleeve.title}'."
|
|
96
|
-
return
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
@reference_question_sheet = Fe::QuestionSheet.find(2) #TODO: constant
|
|
100
|
-
|
|
101
|
-
setup_reference("staff")
|
|
102
|
-
setup_reference("discipler")
|
|
103
|
-
setup_reference("roommate")
|
|
104
|
-
setup_reference("friend")
|
|
105
|
-
|
|
106
|
-
@show_conf = true
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def setup_reference(type)
|
|
110
|
-
ref = nil
|
|
111
|
-
eval("ref = @" + type + "_reference = @application." + type + "_reference")
|
|
112
|
-
raise type unless ref
|
|
113
|
-
answer_sheet = ref
|
|
114
|
-
question_sheet = answer_sheet.question_sheet
|
|
115
|
-
if question_sheet
|
|
116
|
-
elements = []
|
|
117
|
-
question_sheet.pages.order(:number).each do |page|
|
|
118
|
-
elements << page.elements.where("#{Fe::Element.table_name}.kind not in (?)", %w(Fe::Paragraph)).to_a
|
|
119
|
-
end
|
|
120
|
-
elements = elements.flatten
|
|
121
|
-
elements.reject! {|e| e.is_confidential} if @show_conf == false
|
|
122
|
-
eval("@" + type + "_elements = Fe::QuestionSet.new(elements, answer_sheet).elements")
|
|
123
|
-
else
|
|
124
|
-
eval("@" + type + "_elements = []")
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def no_access
|
|
130
|
-
redirect_to '/'
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
protected
|
|
134
|
-
def setup
|
|
135
|
-
@person = get_person # current visitor_id
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
def get_year
|
|
139
|
-
Application::YEAR
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
def get_person
|
|
143
|
-
@person ||= current_person
|
|
144
|
-
return nil unless @person
|
|
145
|
-
@person.current_address = ::Fe::Address.new(:address_type =>'current') unless @person.current_address
|
|
146
|
-
@person.emergency_address1 = ::Fe::Address.new(:address_type =>'emergency1') unless @person.emergency_address1
|
|
147
|
-
@person.permanent_address = ::Fe::Address.new(:address_type =>'permanent') unless @person.permanent_address
|
|
148
|
-
return @person
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
def get_application
|
|
152
|
-
unless @application
|
|
153
|
-
@person ||= get_person
|
|
154
|
-
# if this is the user's first visit, we will need to create an apply
|
|
155
|
-
if @person.application.nil?
|
|
156
|
-
create_application
|
|
157
|
-
@application.save!
|
|
158
|
-
@person.application = @app
|
|
159
|
-
else
|
|
160
|
-
@application ||= @person.application
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
@application
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def create_application
|
|
167
|
-
@application = Fe::Application.create :applicant_id => @person.id
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
def setup_view
|
|
171
|
-
@answer_sheet = @application
|
|
172
|
-
# edit the first page
|
|
173
|
-
@presenter = Fe::AnswerPagesPresenter.new(self, @answer_sheet)
|
|
174
|
-
@elements = @presenter.questions_for_page(:first).elements
|
|
175
|
-
@page = @presenter.pages.first
|
|
176
|
-
@presenter.active_page ||= @page
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
def set_title
|
|
180
|
-
@title = "Form Engine"
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
end
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
module Fe::AnswerPagesControllerConcern
|
|
2
|
-
extend ActiveSupport::Concern
|
|
3
|
-
|
|
4
|
-
begin
|
|
5
|
-
included do
|
|
6
|
-
before_filter :get_answer_sheet, :only => [:edit, :update, :save_file, :index]
|
|
7
|
-
end
|
|
8
|
-
rescue ActiveSupport::Concern::MultipleIncludedBlocks
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def edit
|
|
12
|
-
@elements = @presenter.questions_for_page(params[:id]).elements
|
|
13
|
-
@page = Fe::Page.find(params[:id]) || Fe::Page.find_by_number(1)
|
|
14
|
-
|
|
15
|
-
render :partial => 'answer_page', :locals => { :show_first => nil }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# validate and save captured data for a given page
|
|
19
|
-
# PUT /answer_sheets/1/pages/1
|
|
20
|
-
def update
|
|
21
|
-
@page = Fe::Page.find(params[:id])
|
|
22
|
-
questions = @presenter.all_questions_for_page(params[:id])
|
|
23
|
-
questions.post(answer_params, @answer_sheet)
|
|
24
|
-
|
|
25
|
-
questions.save
|
|
26
|
-
|
|
27
|
-
@elements = questions.elements
|
|
28
|
-
|
|
29
|
-
# Save references
|
|
30
|
-
|
|
31
|
-
if params[:reference].present?
|
|
32
|
-
params[:reference].keys.each do |id|
|
|
33
|
-
reference_params = params.fetch(:reference)[id].permit(:relationship, :title, :first_name, :last_name, :phone, :email, :is_staff)
|
|
34
|
-
|
|
35
|
-
ref = @answer_sheet.reference_sheets.find(id)
|
|
36
|
-
# if the email address has changed, we have to trash the old reference answers
|
|
37
|
-
ref.attributes = reference_params
|
|
38
|
-
ref.save(:validate => false)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
@presenter.active_page = nil
|
|
42
|
-
@answer_sheet.touch
|
|
43
|
-
respond_to do |format|
|
|
44
|
-
format.js
|
|
45
|
-
#format.html
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def save_file
|
|
50
|
-
params.permit(:Filedata)
|
|
51
|
-
|
|
52
|
-
if params[:Filedata]
|
|
53
|
-
@page = Fe::Page.find(params[:id])
|
|
54
|
-
@presenter.active_page = @page
|
|
55
|
-
question = Fe::Element.find(params[:question_id])
|
|
56
|
-
answer = Fe::Answer.where(:answer_sheet_id => @answer_sheet.id, :question_id => question.id).first
|
|
57
|
-
question.answers = [answer] if answer
|
|
58
|
-
|
|
59
|
-
@answer = question.save_file(@answer_sheet, params[:Filedata])
|
|
60
|
-
|
|
61
|
-
render action: :update
|
|
62
|
-
else
|
|
63
|
-
respond_to do |format|
|
|
64
|
-
format.js { head :ok }
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
protected
|
|
70
|
-
|
|
71
|
-
def get_answer_sheet
|
|
72
|
-
@answer_sheet = answer_sheet_type.find(params[:answer_sheet_id])
|
|
73
|
-
@presenter = Fe::AnswerPagesPresenter.new(self, @answer_sheet, params[:a])
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def answer_sheet_type
|
|
77
|
-
(params[:answer_sheet_type] || Fe.answer_sheet_class || 'AnswerSheet').constantize
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def answer_params
|
|
81
|
-
params.fetch(:answers, {}).permit!
|
|
82
|
-
end
|
|
83
|
-
end
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
# gather payment information from Applicant
|
|
2
|
-
module Fe
|
|
3
|
-
class PaymentsController < ApplicationController
|
|
4
|
-
prepend_before_filter :ssm_login_required, :except => [:edit, :update]
|
|
5
|
-
prepend_before_filter :cas_filter, :authentication_filter, :only => [:edit, :update]
|
|
6
|
-
before_filter :setup, :except => [:edit, :update, :approve]
|
|
7
|
-
|
|
8
|
-
# Allow applicant to edit payment
|
|
9
|
-
# /applications/1/payment_page/edit
|
|
10
|
-
# js: provide a partial to replace the answer_sheets page area
|
|
11
|
-
def edit
|
|
12
|
-
@payment = Fe::Payment.find(params[:id])
|
|
13
|
-
@application = @payment.answer_sheet
|
|
14
|
-
# if this isn't a staff payment they shouldn't be here for this staff person
|
|
15
|
-
unless 'Staff' == @payment.payment_type && current_person.isStaff?
|
|
16
|
-
render('no_access') and return
|
|
17
|
-
end
|
|
18
|
-
@payment.status = "Approved" # set the status so a default radio button will be selected
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def create
|
|
22
|
-
Fe::Payment.transaction do
|
|
23
|
-
@payment = @application.payments.new(payment_params)
|
|
24
|
-
if @application.payments.non_denied.length > 0
|
|
25
|
-
@payment.errors.add(:base, "You have already submitted a payment for this application.")
|
|
26
|
-
render :action => "error"
|
|
27
|
-
else
|
|
28
|
-
@payment.amount = Fe.cost
|
|
29
|
-
@payment.status = 'Pending'
|
|
30
|
-
if @payment.valid?
|
|
31
|
-
case @payment.payment_type
|
|
32
|
-
when "Credit Card"
|
|
33
|
-
card_type = params[:payment][:card_type]
|
|
34
|
-
|
|
35
|
-
creditcard = ActiveMerchant::Billing::CreditCard.new(
|
|
36
|
-
:brand => card_type,
|
|
37
|
-
:number => @payment.card_number,
|
|
38
|
-
:month => @payment.expiration_month,
|
|
39
|
-
:year => @payment.expiration_year,
|
|
40
|
-
:verification_value => @payment.security_code,
|
|
41
|
-
:first_name => @payment.first_name,
|
|
42
|
-
:last_name => @payment.last_name
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
if creditcard.valid?
|
|
46
|
-
response = GATEWAY.purchase(@payment.amount * 100, creditcard)
|
|
47
|
-
|
|
48
|
-
if response.success?
|
|
49
|
-
@payment.approve!
|
|
50
|
-
# TODO: Send notification email
|
|
51
|
-
else
|
|
52
|
-
@payment.errors.add(:base, "Credit card transaction failed: #{response.message}")
|
|
53
|
-
#Send email this way instead of raising error in order to still give an error message to user.
|
|
54
|
-
# Fe::Notifier.notification('programmers@cojourners.com', # RECIPIENTS
|
|
55
|
-
# "sp_error@uscm.org", # FROM
|
|
56
|
-
# "Credit Card Error", # LIQUID TEMPLATE NAME
|
|
57
|
-
# {'error' => "Credit card transaction failed: #{response.message} \n #{response.inspect} \n #{creditcard.inspect}"}).deliver
|
|
58
|
-
end
|
|
59
|
-
else
|
|
60
|
-
@payment.errors.add(:card_number, "is invalid. Check the number and/or the expiration date.")
|
|
61
|
-
end
|
|
62
|
-
when "Mail"
|
|
63
|
-
@payment.approve!
|
|
64
|
-
when "Staff"
|
|
65
|
-
@payment.save
|
|
66
|
-
send_staff_payment_request(@payment)
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def update
|
|
74
|
-
@payment = Fe::Payment.includes({:application => :applicant}).find(params[:id])
|
|
75
|
-
@application = @payment.answer_sheet
|
|
76
|
-
@person = @application.applicant
|
|
77
|
-
@payment.status = params[:payment][:status]
|
|
78
|
-
staff_approval
|
|
79
|
-
@payment.save!
|
|
80
|
-
staff_payment_processed_email(@payment)
|
|
81
|
-
@payment.answer_sheet.complete
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def approve
|
|
85
|
-
@payment = Fe::Payment.find(params[:id])
|
|
86
|
-
@application = @payment.answer_sheet
|
|
87
|
-
@payment.auth_code = si_user.user.person.account_no
|
|
88
|
-
case @payment.payment_type
|
|
89
|
-
when 'Staff'
|
|
90
|
-
staff_approval
|
|
91
|
-
staff_payment_processed_email(@payment)
|
|
92
|
-
when 'Mail'
|
|
93
|
-
Fe::Notifier.notification(@application.email, # RECIPIENTS
|
|
94
|
-
Fe.from_email, # FROM
|
|
95
|
-
"Check Received", # LIQUID TEMPLATE NAME
|
|
96
|
-
{'name' => @application.applicant.informal_full_name}).deliver
|
|
97
|
-
end
|
|
98
|
-
@payment.approve!
|
|
99
|
-
@payment.application.complete
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
# TODO this be moved to a decorotor or cru_lib as per Josh's instructions not to have Staff code in FE
|
|
103
|
-
def staff_search
|
|
104
|
-
#@payment = @application.payments.new(params[:payment].slice(:payment_type, :payment_account_no, :auth_code))
|
|
105
|
-
@payment = @application.payments.new(staff_search_payment_params)
|
|
106
|
-
if @payment.staff_first.to_s.strip.empty? || @payment.staff_last.to_s.strip.empty?
|
|
107
|
-
render; return
|
|
108
|
-
end
|
|
109
|
-
@results = Staff.order('"lastName", "firstName"').where("(\"firstName\" like ? OR \"preferredName\" like ?) AND \"lastName\" like ? and \"removedFromPeopleSoft\" <> 'Y'", @payment.staff_first+'%', @payment.staff_first+'%', @payment.staff_last+'%')
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def destroy
|
|
113
|
-
@payment = @application.payments.find(params[:id])
|
|
114
|
-
@payment.destroy
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
protected
|
|
118
|
-
|
|
119
|
-
def setup
|
|
120
|
-
if app_user && app_user.can_su_application?
|
|
121
|
-
@answer_sheet = @application = Fe.answer_sheet_class.constantize.find(params[:application_id])
|
|
122
|
-
else
|
|
123
|
-
@answer_sheet = @application = current_person.applications.find(params[:application_id])
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
def send_staff_payment_request(payment)
|
|
128
|
-
@person = @application.applicant
|
|
129
|
-
staff = Staff.find_by(accountNo: payment.payment_account_no)
|
|
130
|
-
raise "Invalid staff payment request: " + payment.inspect if staff.nil?
|
|
131
|
-
Fe::Notifier.notification(staff.email, # RECIPIENTS
|
|
132
|
-
Fe.from_email, # FROM
|
|
133
|
-
"Staff Payment Request", # LIQUID TEMPLATE NAME
|
|
134
|
-
{'staff_full_name' => staff.informal_full_name, # HASH OF VALUES FOR REPLACEMENT IN LIQUID TEMPLATE
|
|
135
|
-
'applicant_full_name' => @person.informal_full_name,
|
|
136
|
-
'applicant_email' => @person.email,
|
|
137
|
-
'applicant_home_phone' => @person.current_address.home_phone,
|
|
138
|
-
'payment_request_url' => url_for(:action => :edit, :application_id => @application.id, :id => @payment.id)},
|
|
139
|
-
{:format => :html}).deliver
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
def staff_approval
|
|
143
|
-
@payment.auth_code = current_person.account_no
|
|
144
|
-
if @payment.status == "Other Account"
|
|
145
|
-
@payment.payment_account_no = params[:other_account]
|
|
146
|
-
@payment.approve!
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
def staff_payment_processed_email(payment)
|
|
151
|
-
# Send appropriate email
|
|
152
|
-
if payment.approved?
|
|
153
|
-
# Send receipt to applicant
|
|
154
|
-
Fe::Notifier.notification(@application.applicant.email, # RECIPIENTS
|
|
155
|
-
Fe.from_email, # FROM
|
|
156
|
-
"Applicant Staff Payment Receipt", # LIQUID TEMPLATE NAME
|
|
157
|
-
{'applicant_full_name' => @application.applicant.informal_full_name}).deliver
|
|
158
|
-
# Send notice to Tool Owner
|
|
159
|
-
Fe::Notifier.notification(Fe.from_email, # RECIPIENTS - HARD CODED!
|
|
160
|
-
Fe.from_email, # FROM
|
|
161
|
-
"Tool Owner Payment Confirmation", # LIQUID TEMPLATE NAME
|
|
162
|
-
{'payment_amount' => "$" + @payment.amount.to_s,
|
|
163
|
-
'payment_account_no' => @payment.payment_account_no,
|
|
164
|
-
'payment_auth_code' => @payment.auth_code,
|
|
165
|
-
'payment_id' => @payment.id}).deliver
|
|
166
|
-
else
|
|
167
|
-
# Sent notice to applicant that payment was declined
|
|
168
|
-
Fe::Notifier.notification(@application.email, # RECIPIENTS
|
|
169
|
-
Fe.from_email, # FROM
|
|
170
|
-
"Payment Refusal", # LIQUID TEMPLATE NAME
|
|
171
|
-
{'applicant_full_name' => @application.applicant.informal_full_name}).deliver
|
|
172
|
-
end
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
def payment_params
|
|
176
|
-
params.require(:payment).permit(:payment_type, :payment_account_no, :auth_code, :first_name, :last_name, :address,
|
|
177
|
-
:city, :state, :zip, :card_number, :card_type, :expiration_month, :expiration_year, :security_code)
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
def staff_search_payment_params
|
|
181
|
-
params.require(:payment).permit(:payment_type, :staff_first, :staff_last)
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
end
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
module Fe
|
|
2
|
-
module AnswerSheetConcern
|
|
3
|
-
extend ActiveSupport::Concern
|
|
4
|
-
|
|
5
|
-
begin
|
|
6
|
-
included do
|
|
7
|
-
has_many :answer_sheet_question_sheets, :foreign_key => 'answer_sheet_id'
|
|
8
|
-
has_many :question_sheets, :through => :answer_sheet_question_sheets
|
|
9
|
-
has_many :answers, :foreign_key => 'answer_sheet_id'
|
|
10
|
-
has_many :reference_sheets, :foreign_key => "applicant_answer_sheet_id"
|
|
11
|
-
has_many :payments, :foreign_key => "application_id"
|
|
12
|
-
end
|
|
13
|
-
rescue ActiveSupport::Concern::MultipleIncludedBlocks
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def complete?
|
|
17
|
-
!completed_at.nil?
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# answers for this sheet, grouped by question id
|
|
21
|
-
def answers_by_question
|
|
22
|
-
@answers_by_question ||= answers.group_by { |answer| answer.question_id }
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# Convenience method if there is only one question sheet in your system
|
|
26
|
-
def question_sheet
|
|
27
|
-
question_sheets.first
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def pages
|
|
31
|
-
Page.where(:question_sheet_id => question_sheets.collect(&:id))
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def completely_filled_out?
|
|
35
|
-
pages.all? {|p| p.complete?(self)}
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def has_answer_for?(question_id)
|
|
39
|
-
!answers_by_question[question_id].nil?
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def reference?
|
|
43
|
-
false
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def percent_complete
|
|
47
|
-
num_questions = question_sheets.inject(0.0) { |sum, qs| qs.nil? ? sum : qs.questions.length + sum }
|
|
48
|
-
return 0 if num_questions == 0
|
|
49
|
-
num_answers = answers.where("value IS NOT NULL && value != ''").select("DISTINCT question_id").count
|
|
50
|
-
[ [ (num_answers.to_f / num_questions.to_f * 100.0).to_i, 100 ].min, 0 ].max
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def collat_title() "" end
|
|
54
|
-
end
|
|
55
|
-
end
|
data/app/models/fe/payment.rb
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
module Fe
|
|
2
|
-
class Payment < ActiveRecord::Base
|
|
3
|
-
self.table_name = self.table_name.sub('fe_', Fe.table_name_prefix)
|
|
4
|
-
|
|
5
|
-
attr_accessor :first_name, :last_name, :address, :city, :state, :zip, :card_number,
|
|
6
|
-
:expiration_month, :expiration_year, :security_code, :staff_first, :staff_last, :card_type
|
|
7
|
-
|
|
8
|
-
belongs_to :application, class_name: Fe.answer_sheet_class
|
|
9
|
-
|
|
10
|
-
scope :non_denied, -> { where("(status <> 'Denied' AND status <> 'Errored') OR status is null") }
|
|
11
|
-
|
|
12
|
-
after_save :check_app_complete
|
|
13
|
-
|
|
14
|
-
validate :credit_card_validation
|
|
15
|
-
validate :staff_email_present_if_staff_payment
|
|
16
|
-
|
|
17
|
-
def answer_sheet() application; end
|
|
18
|
-
|
|
19
|
-
def credit_card_validation
|
|
20
|
-
if credit?
|
|
21
|
-
errors.add_on_empty([:first_name, :last_name, :address, :city, :state, :zip, :card_number,
|
|
22
|
-
:expiration_month, :expiration_year, :security_code])
|
|
23
|
-
errors.add(:card_number, "is invalid.") if get_card_type.nil?
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# TODO move all staff methods to decorators as per instructions from Josh
|
|
28
|
-
def staff_email_present_if_staff_payment
|
|
29
|
-
if staff? && !payment_account_no.include?('/') # Don't try to validate chart fields
|
|
30
|
-
staff = Staff.find_by(accountNo: payment_account_no)
|
|
31
|
-
unless staff
|
|
32
|
-
errors.add(:base, "We couldn't find a staff member with that account number")
|
|
33
|
-
return false
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
unless staff.email.present?
|
|
37
|
-
errors.add(:base, "The staff member you've picked doesn't have an address on file for us to send the request to.")
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def to_s
|
|
43
|
-
"#{payment_type}: #{amount} on #{created_at}"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def check_app_complete
|
|
47
|
-
if self.approved?
|
|
48
|
-
self.answer_sheet.complete
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def credit?
|
|
53
|
-
self.payment_type == 'Credit Card'
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def staff?
|
|
57
|
-
self.payment_type == 'Staff'
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def approved?
|
|
61
|
-
self.status == 'Approved'
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def approve!
|
|
65
|
-
self.status = 'Approved'
|
|
66
|
-
self.auth_code ||= card_number[-4..-1] if card_number.present?
|
|
67
|
-
self.save!
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def get_card_type
|
|
71
|
-
card = ActiveMerchant::Billing::CreditCard.new(:number => card_number)
|
|
72
|
-
card.valid?
|
|
73
|
-
card.brand
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Fe
|
|
2
|
-
class PaymentQuestion < Question
|
|
3
|
-
|
|
4
|
-
def response(answer_sheet=nil)
|
|
5
|
-
return Payment.new unless answer_sheet
|
|
6
|
-
answer_sheet.payments || [Payment.new(:answer_sheetlication_id => answer_sheet.id) ]
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def display_response(answer_sheet=nil)
|
|
10
|
-
response(answer_sheet).to_s
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def has_response?(answer_sheet = nil)
|
|
14
|
-
if answer_sheet
|
|
15
|
-
answer_sheet.payments.length > 0
|
|
16
|
-
else
|
|
17
|
-
false
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= render 'admin/panels/common_fields', :f => f %>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<% if user_signed_in? %><%= link_to "Log Out", destroy_user_session_path, { :method => :delete, :style => "color: #fff;", :id => "link-log-out" } %><% end %>
|