Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ gem 'bootsnap', '>= 1.1.0', require: false

# Authentication
gem 'devise', '~> 4.7'
gem 'omniauth-mlh', '~> 0.1'
gem 'omniauth-mlh', '~> 0.4.1'
gem 'doorkeeper', '~> 5.0'
gem 'devise-doorkeeper'
gem 'omniauth-rails_csrf_protection'
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ GEM
minitest (>= 5.0)
ruby-progressbar
msgpack (1.3.3)
multi_json (1.14.1)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
mustache (1.1.1)
Expand All @@ -254,7 +254,7 @@ GEM
omniauth (1.9.1)
hashie (>= 3.4.6)
rack (>= 1.6.2, < 3)
omniauth-mlh (0.3.1)
omniauth-mlh (0.4.1)
activesupport
omniauth (~> 1.0)
omniauth-oauth2 (~> 1.3.1)
Expand Down Expand Up @@ -466,7 +466,7 @@ DEPENDENCIES
minitest-reporters
mustache (~> 1.0)
mysql2 (>= 0.4.4, < 0.6.0)
omniauth-mlh (~> 0.1)
omniauth-mlh (~> 0.4.1)
omniauth-rails_csrf_protection
puma (~> 4.3)
rails (~> 5.2.4.3)
Expand Down
3 changes: 0 additions & 3 deletions app/controllers/questionnaires_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ def new
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.shirt_size = session["devise.provider_data"]["info"]["shirt_size"]
q.dietary_restrictions = session["devise.provider_data"]["info"]["dietary_restrictions"]
q.special_needs = session["devise.provider_data"]["info"]["special_needs"]
q.gender = session["devise.provider_data"]["info"]["gender"]

school = School.where(name: session["devise.provider_data"]["info"]["school"]["name"]).first_or_create do |s|
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def mlh
if @user.persisted?
sign_in_and_redirect @user, event: :authentication # this will throw if @user is not activated
session["devise.provider_data"] = request.env["omniauth.auth"]
set_flash_message(:notice, :success, kind: "My MLH") if is_navigational_format?
set_flash_message(:notice, :success, kind: "MyMLH") if is_navigational_format?
else
redirect_to new_user_registration_url
end
Expand Down
9 changes: 8 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,18 @@ def full_name
def self.from_omniauth(auth)
matching_provider = where(provider: auth.provider, uid: auth.uid)
matching_email = where(email: auth.info.email)
matching_provider.or(matching_email).first_or_create do |user|
current_user = matching_provider.or(matching_email).first_or_create do |user|
user.uid = auth.uid
user.provider = auth.provider
user.email = auth.info.email
user.password = Devise.friendly_token[0, 20]
end
# Autofill MyMLH provider if provider info is missing
# (as we are executing this from OAuth)
if current_user.provider.blank?
current_user.provider = auth.provider
end
current_user
end

def self.non_admins
Expand Down
20 changes: 10 additions & 10 deletions app/views/application/_questionnaire_summary.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@
%p
%b Traveling from:
= @questionnaire.travel_not_from_school ? "Somewhere else (#{@questionnaire.travel_location})" : "My school (#{@questionnaire.school.full_name})"
%p
%b Shirt size:
= @questionnaire.shirt_size
%p
%b Dietary restrictions
= @questionnaire.dietary_restrictions || "<i>(none)</i>".html_safe
%p
%b Special needs
= @questionnaire.special_needs || "<i>(none)</i>".html_safe

%fieldset
- if @questionnaire.user.provider == 'mlh'
%legend Provided by My MLH
%legend Provided by MyMLH
%p
%b First name:
= @questionnaire.first_name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self: another place to refactor on 222...

Expand Down Expand Up @@ -48,12 +57,3 @@
%p
%b Level of study:
= @questionnaire.level_of_study
%p
%b Shirt size:
= @questionnaire.shirt_size
%p
%b Dietary restrictions
= @questionnaire.dietary_restrictions || "<i>(none)</i>".html_safe
%p
%b Special needs
= @questionnaire.special_needs || "<i>(none)</i>".html_safe
4 changes: 2 additions & 2 deletions app/views/manage/questionnaires/_overview.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
= @questionnaire.age_at_time_of_event / 1.year
%dt.col-md-4 Gender
%dd.col-md-8= @questionnaire.gender
%dt.col-md-4 Shirt size
%dd.col-md-8= @questionnaire.shirt_size

= render 'checkin_compliance_card'

Expand All @@ -33,6 +31,8 @@
.card-header Special notices
.card-body
.row
%dt.col-md-4 Shirt size
%dd.col-md-8= @questionnaire.shirt_size
%dt.col-md-4 Dietary restrictions
%dd.col-md-8
- if @questionnaire.dietary_restrictions.present?
Expand Down
8 changes: 4 additions & 4 deletions app/views/questionnaires/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
= f.input :level_of_study, collection: collection_or_text(@questionnaire.level_of_study, Questionnaire::POSSIBLE_LEVELS_OF_STUDY), include_blank: "(select one...)", input_html: { "data-validate" => "presence" }, wrapper_html: { class: 'input--half' }
= f.input :major, input_html: { "data-validate" => "presence" }, wrapper_html: { class: 'input--half' }
= f.input :gender, collection: collection_or_text(@questionnaire.gender, Questionnaire::POSSIBLE_GENDERS), include_blank: "(select one...)", input_html: { "data-validate" => "presence" }, wrapper_html: { class: 'input--half' }
= f.input :shirt_size, as: :select, collection: Questionnaire::POSSIBLE_SHIRT_SIZES, include_blank: "(select one...)", input_html: { "data-validate" => "presence" }, wrapper_html: { class: 'input--half' }
= f.input :dietary_restrictions, as: :text, label: "Health restrictions", wrapper_html: { class: 'input--half' }, maxlength: Questionnaire::DIETARY_SPECIAL_NEEDS_MAX_LENGTH
= f.input :special_needs, as: :text, label: "Special needs", wrapper_html: { class: 'input--half' }, maxlength: Questionnaire::DIETARY_SPECIAL_NEEDS_MAX_LENGTH

.right
%button.button{ type: "button", "data-wizard" => "next" } Next

Expand All @@ -46,6 +42,10 @@
= f.input :travel_not_from_school, as: :radio_buttons, collection: { " My school" => false, " Somewhere else" => true }, label: "I am traveling from..."
= f.input :travel_location, input_html: { "data-validate" => "presence", disabled: !travel_state }, wrapper_html: { style: travel_state ? "" : "display: none" }, label: "Where are you traveling from?", placeholder: "New York City"

= f.input :shirt_size, as: :select, collection: Questionnaire::POSSIBLE_SHIRT_SIZES, include_blank: "(select one...)", input_html: { "data-validate" => "presence" }
= f.input :dietary_restrictions, as: :text, label: "Health restrictions", wrapper_html: { class: 'input--half' }, maxlength: Questionnaire::DIETARY_SPECIAL_NEEDS_MAX_LENGTH
= f.input :special_needs, as: :text, label: "Special needs", wrapper_html: { class: 'input--half' }, maxlength: Questionnaire::DIETARY_SPECIAL_NEEDS_MAX_LENGTH

%hr

.form-inputs
Expand Down