Skip to content

Commit 6266f5a

Browse files
refactor: first_name and last_name move from questionnaire to 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>
1 parent ede300f commit 6266f5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+584
-340
lines changed

app/assets/javascripts/manage/lib/setupDataTables.js

Lines changed: 79 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ var setupDataTables = function () {
1717
});
1818

1919
$('.datatable.users').DataTable({
20-
order: [5, 'desc'],
20+
order: [8, 'desc'],
2121
columns: [
2222
{ orderable: true, data: 'id', visible: false },
23-
{ orderable: true, data: 'email' },
23+
{ orderable: false, data: 'link' },
24+
{ orderable: true, data: 'first_name' },
25+
{ orderable: true, data: 'last_name' },
26+
{ orderable: true, data: 'email', visible: false },
2427
{ orderable: true, data: 'role' },
2528
{ orderable: false, data: 'questionnaire'},
2629
{ orderable: true, data: 'active' },
@@ -34,15 +37,18 @@ var setupDataTables = function () {
3437
});
3538

3639
$('.datatable.admins').DataTable({
37-
order: [1, 'asc'],
40+
order: [2, 'asc'],
3841
columns: [
3942
{ orderable: true, data: 'id', visible: false },
40-
{ orderable: true, data: 'email' },
43+
{ orderable: false, data: 'link' },
44+
{ orderable: true, data: 'first_name' },
45+
{ orderable: true, data: 'last_name' },
46+
{ orderable: true, data: 'email', visible: false },
4147
{ orderable: true, data: 'role' },
4248
{ orderable: true, data: 'active' },
4349
{ orderable: true, data: 'receive_weekly_report' },
44-
{ orderable: true, data: 'created_at' },
45-
{ orderable: true, data: 'current_sign_in_at' },
50+
{ orderable: true, data: 'created_at', visible: false },
51+
{ orderable: true, data: 'current_sign_in_at', visible: false },
4652
{ orderable: true, data: 'last_sign_in_at', visible: false },
4753
{ orderable: true, data: 'current_sign_in_ip', visible: false },
4854
{ orderable: true, data: 'last_sign_in_ip', visible: false },
@@ -75,8 +81,72 @@ var setupDataTables = function () {
7581
],
7682
});
7783

78-
$('.datatable.stats').DataTable({
79-
processing: false,
80-
serverSide: false,
84+
// MARK: Datatables for the stats
85+
86+
$('.datatable.stats-dietary').DataTable({
87+
order: [1, 'asc'],
88+
columns: [
89+
{ orderable: true, data: 'id', visible: false },
90+
{ orderable: true, data: 'first_name' },
91+
{ orderable: true, data: 'last_name' },
92+
{ orderable: true, data: 'email' },
93+
{ orderable: true, data: 'phone', visible: false },
94+
{ orderable: false, data: 'questionnaire' },
95+
{ orderable: true, data: 'checked_in_at', visible: false },
96+
{ orderable: true, data: 'dietary_restrictions' },
97+
{ orderable: true, data: 'special_needs' }
98+
]
99+
});
100+
101+
$('.datatable.stats-notschooltravel').DataTable({
102+
order: [1, 'asc'],
103+
columns: [
104+
{ orderable: true, data: 'id', visible: false },
105+
{ orderable: true, data: 'first_name' },
106+
{ orderable: true, data: 'last_name' },
107+
{ orderable: true, data: 'email' },
108+
{ orderable: true, data: 'phone', visible: false },
109+
{ orderable: false, data: 'questionnaire' },
110+
{ orderable: true, data: 'travel_location' },
111+
{ orderable: true, data: 'acc_status' }
112+
]
81113
});
114+
115+
$('.datatable.stats-attendeeinfo').DataTable({
116+
columns: [
117+
{ orderable: true, data: 'id', visible: false },
118+
{ orderable: true, data: 'first_name' },
119+
{ orderable: true, data: 'last_name' },
120+
{ orderable: true, data: 'email' },
121+
{ orderable: true, data: 'school_name' },
122+
{ orderable: true, data: 'vcs_url' },
123+
{ orderable: true, data: 'portfolio_url' }
124+
]
125+
});
126+
127+
$('.datatable.stats-mlhinfo-applied').DataTable({
128+
order: [1, 'asc'],
129+
columns: [
130+
{ orderable: true, data: 'id', visible: false },
131+
{ orderable: true, data: 'first_name' },
132+
{ orderable: true, data: 'last_name' },
133+
{ orderable: true, data: 'email' },
134+
{ orderable: true, data: 'phone', visible: false },
135+
{ orderable: true, data: 'school_name' }
136+
]
137+
});
138+
139+
$('.datatable.stats-mlhinfo-checkedin').DataTable({
140+
order: [1, 'asc'],
141+
columns: [
142+
{ orderable: true, data: 'id', visible: false },
143+
{ orderable: true, data: 'first_name' },
144+
{ orderable: true, data: 'last_name' },
145+
{ orderable: true, data: 'email' },
146+
{ orderable: true, data: 'phone' },
147+
{ orderable: true, data: 'school_name' }
148+
]
149+
});
150+
151+
82152
};

app/controllers/manage/bus_lists_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def toggle_bus_captain
4444
is_bus_captain = params[:bus_captain] == "1"
4545
@questionnaire.update_attribute(:is_bus_captain, is_bus_captain)
4646
if @questionnaire.reload.is_bus_captain
47-
flash[:notice] = "#{@questionnaire.full_name} has been promoted to a bus captain."
47+
flash[:notice] = "#{@questionnaire.user.full_name} has been promoted to a bus captain."
4848
Message.queue_for_trigger("bus_list.new_captain_confirmation", @questionnaire.user.id)
4949
else
50-
flash[:notice] = "#{@questionnaire.full_name} has been removed as a bus captain."
50+
flash[:notice] = "#{@questionnaire.user.full_name} has been removed as a bus captain."
5151
end
5252
redirect_to [:manage, @bus_list]
5353
end

app/controllers/manage/questionnaires_controller.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ def create
5151
def update
5252
update_params = questionnaire_params
5353
email = update_params.delete(:email)
54+
# Take our nested user object out as a whole
55+
user_params = params[:questionnaire][:user]
56+
if user_params
57+
@questionnaire.user.update_attributes(first_name: user_params[:first_name])
58+
@questionnaire.user.update_attributes(last_name: user_params[:last_name])
59+
end
5460
@questionnaire.user.update_attributes(email: email) if email.present?
5561
update_params = convert_school_name_to_id(update_params)
5662
update_params = convert_boarded_bus_param(update_params, @questionnaire)
@@ -76,11 +82,11 @@ def check_in
7682
end
7783
@questionnaire.update_attribute(:checked_in_at, Time.now)
7884
@questionnaire.update_attribute(:checked_in_by_id, current_user.id)
79-
flash[:notice] = "Checked in #{@questionnaire.full_name}."
85+
flash[:notice] = "Checked in #{@questionnaire.user.full_name}."
8086
elsif params[:check_in] == "false"
8187
@questionnaire.update_attribute(:checked_in_at, nil)
8288
@questionnaire.update_attribute(:checked_in_by_id, current_user.id)
83-
flash[:notice] = "#{@questionnaire.full_name} no longer checked in."
89+
flash[:notice] = "#{@questionnaire.user.full_name} no longer checked in."
8490
else
8591
flash[:alert] = "No check-in action provided!"
8692
redirect_to show_redirect_path
@@ -147,8 +153,10 @@ def message_events
147153
private
148154

149155
def questionnaire_params
156+
# Note that this ONLY considers parameters for the questionnaire, not the user.
157+
# TODO: Refactor "email" out to user as first_name and last_name were
150158
params.require(:questionnaire).permit(
151-
:email, :experience, :first_name, :last_name, :gender,
159+
:email, :experience, :gender,
152160
:date_of_birth, :interest, :school_id, :school_name, :major, :level_of_study,
153161
:shirt_size, :dietary_restrictions, :special_needs, :international,
154162
:portfolio_url, :vcs_url, :agreement_accepted, :bus_captain_interest,
Lines changed: 11 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,25 @@
11
class Manage::StatsController < Manage::ApplicationController
2-
def index
3-
end
42

5-
def dietary_special_needs
6-
data = Rails.cache.fetch(cache_key_for_questionnaires("dietary_special_needs")) do
7-
select_attributes = [
8-
:first_name,
9-
:last_name,
10-
:phone,
11-
:checked_in_at,
12-
:dietary_restrictions,
13-
:special_needs,
14-
:user_id
15-
]
16-
json_attributes = [
17-
:first_name,
18-
:last_name,
19-
:email,
20-
:phone,
21-
:checked_in_at,
22-
:dietary_restrictions,
23-
:special_needs
24-
]
25-
data = Questionnaire.where("dietary_restrictions != '' AND acc_status = 'rsvp_confirmed' OR special_needs != '' AND acc_status = 'rsvp_confirmed'").select(select_attributes)
26-
to_json_array(data, json_attributes)
27-
end
28-
render json: { data: data }
29-
end
3+
respond_to :html, :json
304

31-
def sponsor_info
32-
data = Rails.cache.fetch(cache_key_for_questionnaires("sponsor_info")) do
33-
select_attributes = [
34-
:id,
35-
:first_name,
36-
:last_name,
37-
:vcs_url,
38-
:portfolio_url,
39-
:user_id,
40-
:school_id
41-
]
42-
json_attributes = [
43-
:first_name,
44-
:last_name,
45-
:email,
46-
:school_name,
47-
:vcs_url,
48-
:portfolio_url
49-
]
50-
data = Questionnaire.where("can_share_info = '1' AND checked_in_at != 0").joins(:resume_attachment).select(select_attributes)
51-
json = to_json_array(data, json_attributes)
52-
json.map.with_index { |item, index| item.insert(6, data[index].resume.attached? ? url_for(data[index].resume) : '') }
53-
end
54-
render json: { data: data }
5+
def dietary_restrictions_special_needs_datatable
6+
render json: DietarySpecialNeedsDatatable.new(params, view_context: view_context)
557
end
568

57-
def alt_travel
58-
data = Rails.cache.fetch(cache_key_for_questionnaires("alt_travel")) do
59-
select_attributes = [
60-
:id,
61-
:first_name,
62-
:last_name,
63-
:travel_location,
64-
:acc_status,
65-
:user_id,
66-
:school_id
67-
]
68-
json_attributes = [
69-
:id,
70-
:first_name,
71-
:last_name,
72-
:email,
73-
:travel_location,
74-
:acc_status
75-
]
76-
data = Questionnaire.where("travel_not_from_school = '1'").select(select_attributes)
77-
json = to_json_array(data, json_attributes)
78-
json.each do |e|
79-
e[0] = view_context.link_to("View &raquo;".html_safe, manage_questionnaire_path(e[0]))
80-
end
81-
end
82-
render json: { data: data }
9+
def alt_travel_datatable
10+
render json: AltTravelDatatable.new(params, view_context: view_context)
8311
end
8412

85-
def mlh_info_applied
86-
data = Rails.cache.fetch(cache_key_for_questionnaires("mlh_info_applied")) do
87-
select_attributes = [
88-
:first_name,
89-
:last_name,
90-
:user_id,
91-
:school_id
92-
]
93-
json_attributes = [
94-
:first_name,
95-
:last_name,
96-
:email,
97-
:school_name
98-
]
99-
data = Questionnaire.joins(:school).select(select_attributes)
100-
to_json_array(data, json_attributes)
101-
end
102-
render json: { data: data }
13+
def attendee_sponsor_info_datatable
14+
render json: AttendeeSponsorInfoDatatable.new(params, view_context: view_context)
10315
end
10416

105-
def mlh_info_checked_in
106-
data = Rails.cache.fetch(cache_key_for_questionnaires("mlh_info_checked_in")) do
107-
select_attributes = [
108-
:first_name,
109-
:last_name,
110-
:user_id,
111-
:school_id
112-
]
113-
json_attributes = [
114-
:first_name,
115-
:last_name,
116-
:email,
117-
:school_name
118-
]
119-
data = Questionnaire.joins(:school).select(select_attributes).where('checked_in_at > 0')
120-
to_json_array(data, json_attributes)
121-
end
122-
render json: { data: data }
17+
def mlh_applied_datatable
18+
render json: MLHAppliedDatatable.new(params, view_context: view_context)
12319
end
12420

125-
126-
private
127-
128-
def to_json_array(data, attributes)
129-
data.map { |e| attributes.map { |a| e.send(a) } }
21+
def mlh_checked_in_datatable
22+
render json: MLHCheckedInDatatable.new(params, view_context: view_context)
13023
end
13124

132-
def cache_key_for_questionnaires(id)
133-
count = Questionnaire.count
134-
max_updated_at = Questionnaire.maximum(:updated_at).try(:utc).try(:to_s, :number)
135-
"stats/all-#{count}-#{max_updated_at}-#{id}"
136-
end
13725
end

app/controllers/manage/users_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def destroy
3838

3939
def user_params
4040
params.require(:user).permit(
41-
:email, :password, :password_confirmation, :remember_me, :role, :is_active, :receive_weekly_report
41+
:first_name, :last_name, :email, :password, :password_confirmation, :remember_me, :role, :is_active, :receive_weekly_report
4242
)
4343
end
4444

app/controllers/questionnaires_controller.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ def new
2626
@questionnaire = Questionnaire.new
2727

2828
if session["devise.provider_data"] && session["devise.provider_data"]["info"]
29+
info = session["devise.provider_data"]["info"]
2930
@skip_my_mlh_fields = true
3031
@questionnaire.tap do |q|
31-
q.first_name = session["devise.provider_data"]["info"]["first_name"]
32-
q.last_name = session["devise.provider_data"]["info"]["last_name"]
33-
q.phone = session["devise.provider_data"]["info"]["phone_number"]
34-
q.level_of_study = session["devise.provider_data"]["info"]["level_of_study"]
35-
q.major = session["devise.provider_data"]["info"]["major"]
36-
q.date_of_birth = session["devise.provider_data"]["info"]["date_of_birth"]
37-
q.gender = session["devise.provider_data"]["info"]["gender"]
32+
q.phone = info["phone_number"]
33+
q.level_of_study = info["level_of_study"]
34+
q.major = info["major"]
35+
q.date_of_birth = info["date_of_birth"]
36+
q.gender = info["gender"]
3837

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

117116
def questionnaire_params
118117
params.require(:questionnaire).permit(
119-
:email, :experience, :first_name, :last_name, :gender,
118+
:email, :experience, :gender,
120119
:date_of_birth, :interest, :school_id, :school_name, :major, :level_of_study,
121120
:shirt_size, :dietary_restrictions, :special_needs, :international,
122121
:portfolio_url, :vcs_url, :agreement_accepted, :bus_captain_interest,

app/controllers/users/registrations_controller.rb

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Users::RegistrationsController < Devise::RegistrationsController
2-
# before_action :configure_sign_up_params, only: [:create]
3-
# before_action :configure_account_update_params, only: [:update]
2+
before_action :configure_sign_up_params, only: [:create]
3+
before_action :configure_account_update_params, only: [:update]
44

55
# GET /resource/sign_up
66
def new
@@ -28,6 +28,17 @@ def destroy
2828
super
2929
end
3030

31+
# Permit adding custom parameters for sign up
32+
# (Devise gives us email and password by default, but we want some more.)
33+
def configure_sign_up_params
34+
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name])
35+
end
36+
37+
# Permit updating custom parameters for sign up
38+
def configure_account_update_params
39+
devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name])
40+
end
41+
3142
# GET /resource/cancel
3243
# Forces the session data which is usually expired after sign
3344
# in to be expired now. This is useful if the user wants to
@@ -39,16 +50,6 @@ def destroy
3950

4051
# protected
4152

42-
# You can put the params you want to permit in the empty array.
43-
# def configure_sign_up_params
44-
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
45-
# end
46-
47-
# You can put the params you want to permit in the empty array.
48-
# def configure_account_update_params
49-
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
50-
# end
51-
5253
# The path used after sign up.
5354
# def after_sign_up_path_for(resource)
5455
# super(resource)

0 commit comments

Comments
 (0)