Skip to content

Commit

Permalink
refs #96 Use user's timezone.
Browse files Browse the repository at this point in the history
  • Loading branch information
volontarian committed Oct 23, 2015
1 parent c02edcd commit 5af50a7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/controllers/concerns/voluntary/v1/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module BaseController

helper_method :parent, :application_navigation, :navigation_product_path, :navigation_product_name, :voluntary_application_stylesheets
helper_method :voluntary_application_javascripts

before_filter :set_timezone
end

def voluntary_application_stylesheets
Expand Down Expand Up @@ -77,6 +79,10 @@ def response_with_standard(format = nil, error = nil)

private

def set_timezone
Time.zone = current_user.try(:timezone) || 'UTC'
end

def current_namespace
controller_name_segments = params[:controller].split('/')
controller_name_segments.pop
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def stories; Story.where(offeror_id: id); end
attr_accessible :name, :password, :password_confirmation, :remember_me, :text, :language, :first_name, :last_name,
:salutation, :marital_status, :family_status, :date_of_birth, :place_of_birth, :citizenship,
:email, :country, :language, :interface_language, :foreign_language_tokens, :profession_id,
:employment_relationship, :area_tokens, :remember_me
:employment_relationship, :area_tokens, :remember_me, :timezone

# :timeoutable, :token_authenticatable, :lockable,
# :lock_strategy => :none, :unlock_strategy => :nones
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/resources/user/form_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def attributes
list += [:password, :password_confirmation] if resource.new_record? && resource.provider.blank?

list += [
:country, :language, :interface_language, :foreign_language_tokens, :profession,
:country, :language, :interface_language, :foreign_language_tokens, :timezone, :profession,
:employment_relationship, :area_tokens
]

Expand Down
2 changes: 2 additions & 0 deletions app/views/users/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
f.input attribute, collection: available_language_options
when :foreign_language_tokens
f.input attribute, as: :string, input_html: { data: { load: resource.foreign_language_tokens } } unless Rails.env == 'test'
when :timezone
f.input attribute, as: :time_zone
when :profession
autocomplete_input(f, attribute)
when :employment_relationship
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20151022163015_add_timezone_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddTimezoneToUsers < ActiveRecord::Migration
def change
add_column :users, :timezone, :string
end
end

0 comments on commit 5af50a7

Please sign in to comment.