Skip to content

Commit

Permalink
refactor: first_name and last_name move from questionnaire to `…
Browse files Browse the repository at this point in the history
…user` (#241)

* Initial move: first/last name; user->quesitonnaire

- Models adjusted
- Migration made (needs to be updated to a MOVE, not a delete)
- Updated SOME tests and factories
- Create account works

* refactor: Attempt to fix backend params

Includes fixing any discrepancies on routes like `/manage`

* refactor: Make HoundBot a little happier

* feat: Admin list shows first/last names

* inprog on stats page

- Actually retreive first/last names on questionnaires page

* Refactored stats datatable and controller

- Checkin datatable also tweaked to work.
- Removed resumes; #244

* Migration is now backwards compatible with pre-2.0

Needs to be added to 2.0 migration guide!

* 4space->2space 😡 #downwith2spaces

* Fix various first_name/last_name bugs

Most annoying one is in the questionnaire edit screen...

* Fixed remainder of tests for name refactor

* Fix datatable style and count ranges

* Fix some more style bugs

* Viewing bus list w/ passengers now works

* Adds Users & Staff support for #222

* Adds #222 support to stats, fixes stats layout

* Fixes Hound issues

* Removes Hound whitespace issues

* History audit bugfix

No longer nil as we don’t check the type of the previous history and just show both, risking a nil visible on the questionnaire page if value is set for the first time

* Add nil check back, whoops. This works better.

* Squashed commit of the following:

commit 4d1b4e2
Author: Chris Baudouin, Jr <cjb5326@rit.edu>
Date:   Wed Jul 1 01:08:19 2020 -0400

    Back merge master (#273)

    * fix(dashboard): Fixes security vulnerability that allowed event_tracking role to access Dashboard (#215)

    * chore(release): 1.22.3 [skip ci]

    ## [1.22.3](v1.22.2...v1.22.3) (2020-05-16)

    ### Bug Fixes

    * **dashboard:** Fixes security vulnerability that allowed event_tracking role to access Dashboard ([#215](#215)) ([](74a40ad))

    ### Styles

    * **check-in:** Changes table header to be more descriptive ([#207](#207)) ([](889fbd0))
    * **config:** Removes unused event_is_over flag ([#208](#208)) ([](0c73e66))

    * build(deps): Upgrade yarn (#212)

    * build(deps): Upgrade yarn

    * build(deps): Upgrade gems

    * build(deps): Remove obsolete gems

    * v0.0.0

    * build(deps): Update semantic-release

    * fix(questionnaire): visual bug in school autocomplete school dropdown

    the css was set for an "a" tag when the list was made up of divs so I
    switched the css to work for the "div" tag in the autocomplete

    * fix(questionnaire): visual bug in school autocomplete school dropdown

    the css was set for an "a" tag when the list was made up of divs so I
    switched the css to work for the "div" tag in the autocomplete. I also
    hide a element that was not present earlier

    * build(deps): Upgrades Rails to 5.2.4.3

    * build(deps): Upgrades gems

    Co-authored-by: Jeremy Rudman <jeremyrudman@gmail.com>

    * build(deps): Bump puma from 4.3.4 to 4.3.5 (#219)

    Bumps [puma](https://github.com/puma/puma) from 4.3.4 to 4.3.5.
    - [Release notes](https://github.com/puma/puma/releases)
    - [Changelog](https://github.com/puma/puma/blob/master/History.md)
    - [Commits](https://github.com/puma/puma/commits)

    Signed-off-by: dependabot[bot] <support@github.com>

    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    * build(deps): Upgrades Puma cache (#221)

    * fix(questionnaire): Fixes error when trying to view a questionnaire modified by a deleted admin (#236)

    * chore(release): 1.22.4 [skip ci]

    ## [1.22.4](v1.22.3...v1.22.4) (2020-05-26)

    ### Bug Fixes

    * **questionnaire:** Fixes error when trying to view a questionnaire modified by a deleted admin ([#236](#236)) ([](2ffe116))

    * build(deps): Bump websocket-extensions from 0.1.4 to 0.1.5 (#250)

    * build(deps): Bump websocket-extensions from 0.1.4 to 0.1.5

    Bumps [websocket-extensions](https://github.com/faye/websocket-extensions-ruby) from 0.1.4 to 0.1.5.
    - [Release notes](https://github.com/faye/websocket-extensions-ruby/releases)
    - [Changelog](https://github.com/faye/websocket-extensions-ruby/blob/master/CHANGELOG.md)
    - [Commits](faye/websocket-extensions-ruby@0.1.4...0.1.5)

    Signed-off-by: dependabot[bot] <support@github.com>

    * build(deps): Updates websocket-extensions gem cache

    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Chris Baudouin, Jr <chrisbaudouinjr@icloud.com>

    * build(deps): Bump rack from 2.2.2 to 2.2.3 (#268)

    * build(deps): Bump rack from 2.2.2 to 2.2.3

    Bumps [rack](https://github.com/rack/rack) from 2.2.2 to 2.2.3.
    - [Release notes](https://github.com/rack/rack/releases)
    - [Changelog](https://github.com/rack/rack/blob/master/CHANGELOG.md)
    - [Commits](rack/rack@v2.2.2...2.2.3)

    Signed-off-by: dependabot[bot] <support@github.com>

    * Adds rack gem cache

    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Chris Baudouin, Jr <chrisbaudouinjr@icloud.com>

    Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
    Co-authored-by: Jeremy Rudman <jeremyrudman@gmail.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Peter Kos <pkos91@icloud.com>

commit 513e1c2
Author: Chris Baudouin, Jr <cjb5326@rit.edu>
Date:   Tue Jun 30 18:45:42 2020 -0400

    fix(login): Removes always visible login error (#263)

    * fix(login): Removes always visible login error

    * Fixes Hound spacing requirement

commit 58601a1
Author: Chris Baudouin, Jr <cjb5326@rit.edu>
Date:   Sun Jun 28 19:16:08 2020 -0400

    build(deps): Updates gems (#275)

commit d1a01f8
Author: Peter Kos <pkos91@icloud.com>
Date:   Sat Jun 20 19:26:53 2020 -0400

    docs: Add guide for local API setup, update api-usage slightly (#235)

    * docs: Add API/OAuth 2 setup guide

    Also rename api to api-usage

    * docs: Cleanup api-usage page, add notes about 2.0

    * docs: Apply suggestions from code review

    Co-authored-by: Stuart Olivera <stuart@stuartolivera.com>

    * docs: Reword API introduction to be more friendly

    - Clarifies what Postman and Paw are, with links to their product pages
    - Notes that this process works for remote instances as well, not just localhost
    - Removed trailing whitespace and extra newlines
    - Fixed a single typo

    * Verbiage and HM typo fixes

    * Added .DS_Store to .gitignore

    Co-authored-by: Stuart Olivera <stuart@stuartolivera.com>

commit 82a7ff4
Author: Chris Baudouin, Jr <cjb5326@rit.edu>
Date:   Thu Jun 18 08:58:35 2020 -0400

    fix(config): Removes disable_account_registration from database (#247)

    * fix(config): Removes disable_account_registration from database

    * fix(config): Saves new config item, adds extra precautionary check

commit f07ec28
Author: Chris Baudouin, Jr <cjb5326@rit.edu>
Date:   Thu Jun 11 17:35:16 2020 -0400

    fix(questionnaire): Fixes error when trying to view a questionnaire modified by a deleted admin (#238)

    * fix(dashboard): Fixes security vulnerability that allowed event_tracking role to access Dashboard (#215)

    * chore(release): 1.22.3 [skip ci]

    ## [1.22.3](v1.22.2...v1.22.3) (2020-05-16)

    ### Bug Fixes

    * **dashboard:** Fixes security vulnerability that allowed event_tracking role to access Dashboard ([#215](#215)) ([](74a40ad))

    ### Styles

    * **check-in:** Changes table header to be more descriptive ([#207](#207)) ([](889fbd0))
    * **config:** Removes unused event_is_over flag ([#208](#208)) ([](0c73e66))

    * build(deps): Upgrade yarn (#212)

    * build(deps): Upgrade yarn

    * build(deps): Upgrade gems

    * build(deps): Remove obsolete gems

    * v0.0.0

    * build(deps): Update semantic-release

    * fix(questionnaire): visual bug in school autocomplete school dropdown

    the css was set for an "a" tag when the list was made up of divs so I
    switched the css to work for the "div" tag in the autocomplete

    * fix(questionnaire): visual bug in school autocomplete school dropdown

    the css was set for an "a" tag when the list was made up of divs so I
    switched the css to work for the "div" tag in the autocomplete. I also
    hide a element that was not present earlier

    * build(deps): Upgrades Rails to 5.2.4.3

    * build(deps): Upgrades gems

    Co-authored-by: Jeremy Rudman <jeremyrudman@gmail.com>

    * build(deps): Bump puma from 4.3.4 to 4.3.5 (#219)

    Bumps [puma](https://github.com/puma/puma) from 4.3.4 to 4.3.5.
    - [Release notes](https://github.com/puma/puma/releases)
    - [Changelog](https://github.com/puma/puma/blob/master/History.md)
    - [Commits](https://github.com/puma/puma/commits)

    Signed-off-by: dependabot[bot] <support@github.com>

    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    * build(deps): Upgrades Puma cache (#221)

    * fix(questionnaire): Fixes error when trying to view a questionnaire modified by a deleted admin

    * refactor(tests): Cleans verbage of tests to match

    Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
    Co-authored-by: Jeremy Rudman <jeremyrudman@gmail.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fix undefined err on bus list info

* Fix bus captain bug, update schema

* Squashed commit of the following:

commit ede300f
Author: Chris Baudouin, Jr <cjb5326@rit.edu>
Date:   Sat Aug 29 21:05:53 2020 -0400

    feat: Updates MyMLH to V3 (#329)

    * feat: Updates MyMLH to V3

    * fix(User): Adds missing provider field

    * refactor: Updates MyMLH branding

    * Autofill MyMLH provider if info is missing

    * houndbot

    Co-authored-by: Peter Kos <pkos91@icloud.com>

commit 675b3f6
Author: Chris Baudouin, Jr <cjb5326@rit.edu>
Date:   Sun Aug 23 22:43:48 2020 -0400

    refactor: Changes "Applications" to "Questionnaires" in map (#326)

commit 388c9bd
Author: Chris Baudouin, Jr <cjb5326@rit.edu>
Date:   Sun Aug 23 22:08:26 2020 -0400

    fix(Dashboard): Fixes missing location data in map (#324)

commit a062140
Author: Chris Baudouin, Jr <cjb5326@rit.edu>
Date:   Wed Aug 19 11:02:07 2020 -0400

    feat(docs): Initial documentation for 2.0 (#291)

    * feat(docs): Initial documentation for 2.0

    * refactor: Updates maintenance.md for verbage changes

    * refactor: Refactors structure of navigation

commit 79831f6
Author: JeremyRudman <38338616+JeremyRudman@users.noreply.github.com>
Date:   Sat Jul 25 12:47:35 2020 -0400

    feat(messages): Adds a confirmation modal to send messages (#272)

    * feat(message): added a confirmation modal to send messages

    added a modal for when you send a message that displays the number of
    people you are sending it to in large red text.

    * fix: houndci formatting errors

    * fix(messages): fixed error and made changes to text

    made "send message" singular and made only the the number red. I also
    fixed the variable not loading properly

    * fix: houndci styling changes

    * feat: made email modal text black instead of red

    the email confirmation modal displays the number in black instead of red

    * refactor: Adds number delimiter to recipients, changes cancel outline

    Co-authored-by: Chris Baudouin, Jr <cjb5326@rit.edu>

commit e4169a7
Author: JeremyRudman <38338616+JeremyRudman@users.noreply.github.com>
Date:   Thu Jul 9 00:39:23 2020 -0400

    fix(questionnaire): School autocomplete matches form field width (#278)

    * fix(questionnaire): school autocomplete matchs fourm field width

    * fix(questionnaires): added ellipsis to autocomplete

    when the forum field is smaller the school name the autocomplete goes
    beyond the width the field and this causes the text to ellipsis in thet
    case

* Actually assign current_user

* mymlh working

* Refactor questionnnaire new to be nicer to read

* Patch condition error for info refactor

Was attempting to use potentially nil value before checking if the value was nil

ALso cleaned up part of the test in questionnaires controler to create the entire user object as we need both first/last name, as well as email. #goodcodestyle #pleasehiremegoogle

Co-authored-by: Chris Baudouin, Jr <chrisbaudouinjr@icloud.com>
Co-authored-by: Chris Baudouin, Jr <cjb5326@rit.edu>
  • Loading branch information
3 people authored Aug 30, 2020
1 parent ede300f commit 6266f5a
Show file tree
Hide file tree
Showing 49 changed files with 584 additions and 340 deletions.
88 changes: 79 additions & 9 deletions app/assets/javascripts/manage/lib/setupDataTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ var setupDataTables = function () {
});

$('.datatable.users').DataTable({
order: [5, 'desc'],
order: [8, 'desc'],
columns: [
{ orderable: true, data: 'id', visible: false },
{ orderable: true, data: 'email' },
{ orderable: false, data: 'link' },
{ orderable: true, data: 'first_name' },
{ orderable: true, data: 'last_name' },
{ orderable: true, data: 'email', visible: false },
{ orderable: true, data: 'role' },
{ orderable: false, data: 'questionnaire'},
{ orderable: true, data: 'active' },
Expand All @@ -34,15 +37,18 @@ var setupDataTables = function () {
});

$('.datatable.admins').DataTable({
order: [1, 'asc'],
order: [2, 'asc'],
columns: [
{ orderable: true, data: 'id', visible: false },
{ orderable: true, data: 'email' },
{ orderable: false, data: 'link' },
{ orderable: true, data: 'first_name' },
{ orderable: true, data: 'last_name' },
{ orderable: true, data: 'email', visible: false },
{ orderable: true, data: 'role' },
{ orderable: true, data: 'active' },
{ orderable: true, data: 'receive_weekly_report' },
{ orderable: true, data: 'created_at' },
{ orderable: true, data: 'current_sign_in_at' },
{ orderable: true, data: 'created_at', visible: false },
{ orderable: true, data: 'current_sign_in_at', visible: false },
{ orderable: true, data: 'last_sign_in_at', visible: false },
{ orderable: true, data: 'current_sign_in_ip', visible: false },
{ orderable: true, data: 'last_sign_in_ip', visible: false },
Expand Down Expand Up @@ -75,8 +81,72 @@ var setupDataTables = function () {
],
});

$('.datatable.stats').DataTable({
processing: false,
serverSide: false,
// MARK: Datatables for the stats

$('.datatable.stats-dietary').DataTable({
order: [1, 'asc'],
columns: [
{ orderable: true, data: 'id', visible: false },
{ orderable: true, data: 'first_name' },
{ orderable: true, data: 'last_name' },
{ orderable: true, data: 'email' },
{ orderable: true, data: 'phone', visible: false },
{ orderable: false, data: 'questionnaire' },
{ orderable: true, data: 'checked_in_at', visible: false },
{ orderable: true, data: 'dietary_restrictions' },
{ orderable: true, data: 'special_needs' }
]
});

$('.datatable.stats-notschooltravel').DataTable({
order: [1, 'asc'],
columns: [
{ orderable: true, data: 'id', visible: false },
{ orderable: true, data: 'first_name' },
{ orderable: true, data: 'last_name' },
{ orderable: true, data: 'email' },
{ orderable: true, data: 'phone', visible: false },
{ orderable: false, data: 'questionnaire' },
{ orderable: true, data: 'travel_location' },
{ orderable: true, data: 'acc_status' }
]
});

$('.datatable.stats-attendeeinfo').DataTable({
columns: [
{ orderable: true, data: 'id', visible: false },
{ orderable: true, data: 'first_name' },
{ orderable: true, data: 'last_name' },
{ orderable: true, data: 'email' },
{ orderable: true, data: 'school_name' },
{ orderable: true, data: 'vcs_url' },
{ orderable: true, data: 'portfolio_url' }
]
});

$('.datatable.stats-mlhinfo-applied').DataTable({
order: [1, 'asc'],
columns: [
{ orderable: true, data: 'id', visible: false },
{ orderable: true, data: 'first_name' },
{ orderable: true, data: 'last_name' },
{ orderable: true, data: 'email' },
{ orderable: true, data: 'phone', visible: false },
{ orderable: true, data: 'school_name' }
]
});

$('.datatable.stats-mlhinfo-checkedin').DataTable({
order: [1, 'asc'],
columns: [
{ orderable: true, data: 'id', visible: false },
{ orderable: true, data: 'first_name' },
{ orderable: true, data: 'last_name' },
{ orderable: true, data: 'email' },
{ orderable: true, data: 'phone' },
{ orderable: true, data: 'school_name' }
]
});


};
4 changes: 2 additions & 2 deletions app/controllers/manage/bus_lists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ def toggle_bus_captain
is_bus_captain = params[:bus_captain] == "1"
@questionnaire.update_attribute(:is_bus_captain, is_bus_captain)
if @questionnaire.reload.is_bus_captain
flash[:notice] = "#{@questionnaire.full_name} has been promoted to a bus captain."
flash[:notice] = "#{@questionnaire.user.full_name} has been promoted to a bus captain."
Message.queue_for_trigger("bus_list.new_captain_confirmation", @questionnaire.user.id)
else
flash[:notice] = "#{@questionnaire.full_name} has been removed as a bus captain."
flash[:notice] = "#{@questionnaire.user.full_name} has been removed as a bus captain."
end
redirect_to [:manage, @bus_list]
end
Expand Down
14 changes: 11 additions & 3 deletions app/controllers/manage/questionnaires_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ def create
def update
update_params = questionnaire_params
email = update_params.delete(:email)
# Take our nested user object out as a whole
user_params = params[:questionnaire][:user]
if user_params
@questionnaire.user.update_attributes(first_name: user_params[:first_name])
@questionnaire.user.update_attributes(last_name: user_params[:last_name])
end
@questionnaire.user.update_attributes(email: email) if email.present?
update_params = convert_school_name_to_id(update_params)
update_params = convert_boarded_bus_param(update_params, @questionnaire)
Expand All @@ -76,11 +82,11 @@ def check_in
end
@questionnaire.update_attribute(:checked_in_at, Time.now)
@questionnaire.update_attribute(:checked_in_by_id, current_user.id)
flash[:notice] = "Checked in #{@questionnaire.full_name}."
flash[:notice] = "Checked in #{@questionnaire.user.full_name}."
elsif params[:check_in] == "false"
@questionnaire.update_attribute(:checked_in_at, nil)
@questionnaire.update_attribute(:checked_in_by_id, current_user.id)
flash[:notice] = "#{@questionnaire.full_name} no longer checked in."
flash[:notice] = "#{@questionnaire.user.full_name} no longer checked in."
else
flash[:alert] = "No check-in action provided!"
redirect_to show_redirect_path
Expand Down Expand Up @@ -147,8 +153,10 @@ def message_events
private

def questionnaire_params
# Note that this ONLY considers parameters for the questionnaire, not the user.
# TODO: Refactor "email" out to user as first_name and last_name were
params.require(:questionnaire).permit(
:email, :experience, :first_name, :last_name, :gender,
:email, :experience, :gender,
:date_of_birth, :interest, :school_id, :school_name, :major, :level_of_study,
:shirt_size, :dietary_restrictions, :special_needs, :international,
:portfolio_url, :vcs_url, :agreement_accepted, :bus_captain_interest,
Expand Down
134 changes: 11 additions & 123 deletions app/controllers/manage/stats_controller.rb
Original file line number Diff line number Diff line change
@@ -1,137 +1,25 @@
class Manage::StatsController < Manage::ApplicationController
def index
end

def dietary_special_needs
data = Rails.cache.fetch(cache_key_for_questionnaires("dietary_special_needs")) do
select_attributes = [
:first_name,
:last_name,
:phone,
:checked_in_at,
:dietary_restrictions,
:special_needs,
:user_id
]
json_attributes = [
:first_name,
:last_name,
:email,
:phone,
:checked_in_at,
:dietary_restrictions,
:special_needs
]
data = Questionnaire.where("dietary_restrictions != '' AND acc_status = 'rsvp_confirmed' OR special_needs != '' AND acc_status = 'rsvp_confirmed'").select(select_attributes)
to_json_array(data, json_attributes)
end
render json: { data: data }
end
respond_to :html, :json

def sponsor_info
data = Rails.cache.fetch(cache_key_for_questionnaires("sponsor_info")) do
select_attributes = [
:id,
:first_name,
:last_name,
:vcs_url,
:portfolio_url,
:user_id,
:school_id
]
json_attributes = [
:first_name,
:last_name,
:email,
:school_name,
:vcs_url,
:portfolio_url
]
data = Questionnaire.where("can_share_info = '1' AND checked_in_at != 0").joins(:resume_attachment).select(select_attributes)
json = to_json_array(data, json_attributes)
json.map.with_index { |item, index| item.insert(6, data[index].resume.attached? ? url_for(data[index].resume) : '') }
end
render json: { data: data }
def dietary_restrictions_special_needs_datatable
render json: DietarySpecialNeedsDatatable.new(params, view_context: view_context)
end

def alt_travel
data = Rails.cache.fetch(cache_key_for_questionnaires("alt_travel")) do
select_attributes = [
:id,
:first_name,
:last_name,
:travel_location,
:acc_status,
:user_id,
:school_id
]
json_attributes = [
:id,
:first_name,
:last_name,
:email,
:travel_location,
:acc_status
]
data = Questionnaire.where("travel_not_from_school = '1'").select(select_attributes)
json = to_json_array(data, json_attributes)
json.each do |e|
e[0] = view_context.link_to("View &raquo;".html_safe, manage_questionnaire_path(e[0]))
end
end
render json: { data: data }
def alt_travel_datatable
render json: AltTravelDatatable.new(params, view_context: view_context)
end

def mlh_info_applied
data = Rails.cache.fetch(cache_key_for_questionnaires("mlh_info_applied")) do
select_attributes = [
:first_name,
:last_name,
:user_id,
:school_id
]
json_attributes = [
:first_name,
:last_name,
:email,
:school_name
]
data = Questionnaire.joins(:school).select(select_attributes)
to_json_array(data, json_attributes)
end
render json: { data: data }
def attendee_sponsor_info_datatable
render json: AttendeeSponsorInfoDatatable.new(params, view_context: view_context)
end

def mlh_info_checked_in
data = Rails.cache.fetch(cache_key_for_questionnaires("mlh_info_checked_in")) do
select_attributes = [
:first_name,
:last_name,
:user_id,
:school_id
]
json_attributes = [
:first_name,
:last_name,
:email,
:school_name
]
data = Questionnaire.joins(:school).select(select_attributes).where('checked_in_at > 0')
to_json_array(data, json_attributes)
end
render json: { data: data }
def mlh_applied_datatable
render json: MLHAppliedDatatable.new(params, view_context: view_context)
end


private

def to_json_array(data, attributes)
data.map { |e| attributes.map { |a| e.send(a) } }
def mlh_checked_in_datatable
render json: MLHCheckedInDatatable.new(params, view_context: view_context)
end

def cache_key_for_questionnaires(id)
count = Questionnaire.count
max_updated_at = Questionnaire.maximum(:updated_at).try(:utc).try(:to_s, :number)
"stats/all-#{count}-#{max_updated_at}-#{id}"
end
end
2 changes: 1 addition & 1 deletion app/controllers/manage/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def destroy

def user_params
params.require(:user).permit(
:email, :password, :password_confirmation, :remember_me, :role, :is_active, :receive_weekly_report
:first_name, :last_name, :email, :password, :password_confirmation, :remember_me, :role, :is_active, :receive_weekly_report
)
end

Expand Down
15 changes: 7 additions & 8 deletions app/controllers/questionnaires_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ def new
@questionnaire = Questionnaire.new

if session["devise.provider_data"] && session["devise.provider_data"]["info"]
info = session["devise.provider_data"]["info"]
@skip_my_mlh_fields = true
@questionnaire.tap do |q|
q.first_name = session["devise.provider_data"]["info"]["first_name"]
q.last_name = session["devise.provider_data"]["info"]["last_name"]
q.phone = session["devise.provider_data"]["info"]["phone_number"]
q.level_of_study = session["devise.provider_data"]["info"]["level_of_study"]
q.major = session["devise.provider_data"]["info"]["major"]
q.date_of_birth = session["devise.provider_data"]["info"]["date_of_birth"]
q.gender = session["devise.provider_data"]["info"]["gender"]
q.phone = info["phone_number"]
q.level_of_study = info["level_of_study"]
q.major = info["major"]
q.date_of_birth = info["date_of_birth"]
q.gender = info["gender"]

school = School.where(name: session["devise.provider_data"]["info"]["school"]["name"]).first_or_create do |s|
s.name = session["devise.provider_data"]["info"]["school"]["name"]
Expand Down Expand Up @@ -116,7 +115,7 @@ def schools

def questionnaire_params
params.require(:questionnaire).permit(
:email, :experience, :first_name, :last_name, :gender,
:email, :experience, :gender,
:date_of_birth, :interest, :school_id, :school_name, :major, :level_of_study,
:shirt_size, :dietary_restrictions, :special_needs, :international,
:portfolio_url, :vcs_url, :agreement_accepted, :bus_captain_interest,
Expand Down
25 changes: 13 additions & 12 deletions app/controllers/users/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Users::RegistrationsController < Devise::RegistrationsController
# before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]
before_action :configure_sign_up_params, only: [:create]
before_action :configure_account_update_params, only: [:update]

# GET /resource/sign_up
def new
Expand Down Expand Up @@ -28,6 +28,17 @@ def destroy
super
end

# Permit adding custom parameters for sign up
# (Devise gives us email and password by default, but we want some more.)
def configure_sign_up_params
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name])
end

# Permit updating custom parameters for sign up
def configure_account_update_params
devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name])
end

# GET /resource/cancel
# Forces the session data which is usually expired after sign
# in to be expired now. This is useful if the user wants to
Expand All @@ -39,16 +50,6 @@ def destroy

# protected

# You can put the params you want to permit in the empty array.
# def configure_sign_up_params
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
# end

# You can put the params you want to permit in the empty array.
# def configure_account_update_params
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
# end

# The path used after sign up.
# def after_sign_up_path_for(resource)
# super(resource)
Expand Down
Loading

0 comments on commit 6266f5a

Please sign in to comment.