Skip to content

Commit

Permalink
Merge pull request #594 from simonv3/master
Browse files Browse the repository at this point in the history
Confirmation Non Manditory
  • Loading branch information
simonv3 committed Apr 10, 2015
2 parents 2392069 + d8ba3fe commit b361fd2
Show file tree
Hide file tree
Showing 22 changed files with 144 additions and 273 deletions.
10 changes: 5 additions & 5 deletions app/assets/stylesheets/styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ $of-orange: #e69138;
$of-blue: #3c78d8;
$of-purple: #674ea7;
$of-green: #6aa84f;
$of-green2: #5E9546;
$of-blue-grey: #ECEFF0;
$of-green2: #5e9546;
$of-blue-grey: #eCeff0;
$of-red: #cc0000;
$of-yellow: #f1c232;
$of-dark: #4a4a4a;
Expand All @@ -22,11 +22,11 @@ $white: #ffffff;
$gray-bg: #f9f9f9;

// We use these as default colors throughout
$primary-color: #99B36C; // #008CBA;
$primary-color: #99b36c; // #008CBA;
$secondary-color: #e7e7e7;
$alert-color: #ff6666;
$success-color: #74E29D;
$warning-color: #f08a24;
$success-color: #74e29d;
$warning-color: #f5c18c;
$info-color: #eecb91;

// OpenFarm Colors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
.home-alert-wrapper{
height: 0;
}

.warning {
color: $of-dark;
}
24 changes: 19 additions & 5 deletions app/assets/stylesheets/styles/components/users/_sign_up.css.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.infos{
.infos {
text-align: center;
font-size: 1.2rem;
margin-bottom: 4rem;

.image{
.image {
height: 80px;
margin-bottom: 1rem;
position: relative;
}

img{
img {
margin: 0;
position: absolute;
top: 50%;
Expand All @@ -18,14 +18,28 @@
transform: translate(-50%, -50%)
}

p{
p {
width: 80%;
line-height: 1.2;
color: $of-dark;
margin: 0 auto;
}
}

.sign-in{
input + small {
top: -1rem;
position: relative;
}

.sign-in {
margin-bottom: 4rem;
}

.button-wrapper {
text-align: center;
}

.sign-up {
margin-top: 1rem;
text-align: right;
}
8 changes: 7 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ApplicationController < ActionController::Base
# Allow certain fields for devise - needed in Rails 4.0+
before_filter :update_sanitized_params, if: :devise_controller?

before_action :set_locale
before_action :set_locale, :check_for_confirmation

def default_url_options(options = {})
{ locale: I18n.locale }
Expand All @@ -17,6 +17,12 @@ def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end

def check_for_confirmation
if current_user && !current_user.confirmed?
flash[:warning] = I18n.t('users.need_confirmation')
end
end

protected

# This method allows devise to pass non standard attributes through and
Expand Down
28 changes: 13 additions & 15 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@ def destroy

protected

# TODO: this isn't relevant anymore now that confirmation
# emails are getting sent on sign up. There must be a way to
# figure this out though:
# have a look at: http://stackoverflow.com/questions/6499589/devise-redirect-page-after-confirmation

# https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-up-(registration)
# def after_sign_up_path_for(resource)
# # stored resource gets cleared after it gets called apparently
# go_to = stored_location_for(resource)
# if go_to
# go_to || request.referer || root_path
# else
# url_for(controller: 'users',
# action: 'finish')
# end
# end
def after_sign_up_path_for(resource)
# stored resource gets cleared after it gets called apparently
go_to = stored_location_for(resource)
if !resource.confirmed?
resource.send_confirmation_instructions
end
if go_to
go_to || request.referer || root_path
else
url_for(controller: 'users',
action: 'finish')
end
end
end
23 changes: 0 additions & 23 deletions app/controllers/requirements_controller.rb

This file was deleted.

7 changes: 7 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ class UsersController < ApplicationController

def update
authorize current_user

user_settings = {
units: params[:units],
location: params[:location]
}

@outcome = Users::UpdateUser.run(
user: params,
user_setting: user_settings,
id: "#{current_user._id}")

if @outcome.errors
Expand Down
10 changes: 0 additions & 10 deletions app/models/requirement.rb

This file was deleted.

9 changes: 0 additions & 9 deletions app/models/requirement_option.rb

This file was deleted.

6 changes: 6 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,10 @@ class User
def user_setting
UserSetting.find_or_create_by(user: self)
end

protected

def confirmation_required?
false
end
end
47 changes: 0 additions & 47 deletions app/mutations/requirements/create_requirement.rb

This file was deleted.

31 changes: 0 additions & 31 deletions app/mutations/requirements/destroy_requirement.rb

This file was deleted.

37 changes: 0 additions & 37 deletions app/mutations/requirements/update_requirement.rb

This file was deleted.

30 changes: 12 additions & 18 deletions app/mutations/users/update_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,29 @@ class UpdateUser < Mutations::Command
hash :user do
optional do
string :display_name
string :location
string :years_experience
string :mailing_list
string :help_list
string :units
string :is_private
end
end
end

# optional do

# end
optional do
hash :user_setting do
optional do
string :location
string :years_experience
string :units
end
end
end

def execute
@user = User.find(id)
if user_setting
@user.user_setting.update_attributes(user_setting)
end
@user.update_attributes(user)
@user.save
# set_valid_params
end

# def set_valid_params
# # TODO: Probably a DRYer way of doing this.
# user.location = location if location.present?
# user.display_name = display_name if display_name.present?
# user.mailing_list = mailing_list if mailing_list.present?
# user.units = units if units.present?
# user.is_private = is_private if is_private.present?
# user.save
# end
end
end
4 changes: 2 additions & 2 deletions app/views/devise/shared/_links.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<span class="devise-links">
<div class="devise-links center">
<%- if controller_name != 'sessions' %>
<%= link_to t('application.log_in'), new_session_path(resource_name) %><br/>
<% end -%>
Expand All @@ -25,4 +25,4 @@
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br/>
<% end -%>
<% end -%>
</span>
</div>
Loading

0 comments on commit b361fd2

Please sign in to comment.