Skip to content

Commit

Permalink
Modify alert styles, make confirmation non-manditory
Browse files Browse the repository at this point in the history
  • Loading branch information
simonv3 committed Apr 8, 2015
1 parent 2392069 commit 9fcb8f1
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 187 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $primary-color: #99B36C; // #008CBA;
$secondary-color: #e7e7e7;
$alert-color: #ff6666;
$success-color: #74E29D;
$warning-color: #f08a24;
$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;
}
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.

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.

5 changes: 5 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,9 @@ 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.

12 changes: 7 additions & 5 deletions app/views/devise/shared/_user_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@
<% if @user.new_record? %>
<%= f.label :password, I18n.t('users.password') %>
<%= f.password_field :password, autocomplete: "off" %>
<%= f.check_box :agree %><%= f.label :agree, t('users.tos_privacy_html',
tos_url: page_path('tos'),
privacy_url: page_path('privacy') ) %>
<small id="passwordhelp"><%= t('users.at_least_8_characters') %></small>
<%= f.password_field :password, autocomplete: "off", ariaDescribedby: "passwordhelp" %>
<%= f.hidden_field :agree, value: true %><%= f.label :agree, t('users.tos_privacy_html',
tos_url: page_path('tos'),
privacy_url: page_path('privacy') ) %>
<% else %>
<%= f.label :current_password, I18n.t('users.current_password') %>
<%= f.password_field :current_password, autocomplete: "off" %>
<%= f.label :password, I18n.t('users.password') + I18n.t('users.password_blank_ok') %>
<%= f.label :password, I18n.t('users.new_password') + I18n.t('users.password_blank_ok') %>
<%= f.password_field :password, autocomplete: "off" %>
<%= f.check_box :is_private %><%= f.label :is_private, I18n.t('users.is_private') %>
Expand Down
6 changes: 6 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@
<a href="#" class="close">&times;</a>
</div>
<% end %>
<% if flash[:warning] %>
<div data-alert class="alert-box warning radius columns large-4 small-centered">
<%= flash[:warning] %>
<a href="#" class="close">&times;</a>
</div>
<% end %>
<% if alert %>
<div data-alert class="alert-box alert radius columns large-4 small-centered">
<% if alert.is_a?(Array) %>
Expand Down
11 changes: 7 additions & 4 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,17 @@ en:
star_your_favorite_guides_and_crops: "Star your favorite crops and guides"
create: "Create"
share_your_knowledge_with_guide_creation: "Share your knowledge with guide creation"
email_address: "Email Address"
email_address: "Email Address:"
tos_privacy_html: |
I agree to the <a href='%{tos_url}'>Terms of Service</a> and the
<a href='%{privacy_url}'>Privacy Policy</a>
By signing up you agree to the <a href='%{tos_url}'>Terms of Service</a>
and the <a href='%{privacy_url}'>Privacy Policy</a>
is_private: "Check to keep your profile private."
account_information: "Account Information"
display_name: "Display Name:"
password: "New Password:"
password: "Password:"
at_least_8_characters: "At least 8 characters"
need_confirmation: "You need to confirm your account, check your email!"
new_password: "New Password:"
current_password: "Current Password (we need this to confirm your changes)"
password_blank_ok: " (leave blank if you don’t want to change it)"
create_account: "Join OpenFarm"
Expand Down
4 changes: 0 additions & 4 deletions spec/models/requirement_spec.rb

This file was deleted.

0 comments on commit 9fcb8f1

Please sign in to comment.