Skip to content
This repository has been archived by the owner on Dec 26, 2019. It is now read-only.

WIP: User may choose check in reminder email time #265

Closed
wants to merge 2 commits into from
Closed
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
7 changes: 6 additions & 1 deletion app/controllers/account/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def create
end
end

def update
byebug
super
end

# GET /resource/edit
# def edit
# super
Expand Down Expand Up @@ -54,7 +59,7 @@ def configure_sign_up_params

# You can put the params you want to permit in the empty array.
def configure_account_update_params
devise_parameter_sanitizer.for(:account_update) << [:name, :time_zone]
devise_parameter_sanitizer.for(:account_update) << [:name, :time_zone, settings_attributes: [:check_in_reminder_time] ]
end

# The path used after sign up.
Expand Down
4 changes: 4 additions & 0 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Account < ActiveRecord::Base
validates :name, presence: true

serialize :features, Features
serialize :settings, Settings

def enable_feature(feature)
features.send(:"#{feature}=", true)
Expand All @@ -45,4 +46,7 @@ def remaining_recent_capacity
def remaining_weekly_capacity
weekly_expected_capacity - total_weekly_capacity
end

def settings_attributes=(attributes)
end
end
17 changes: 17 additions & 0 deletions app/models/settings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Settings
include Virtus.model

attribute :check_in_reminder_time, Integer, default: 6

def self.dump(settings)
settings.to_hash
end

def self.load(settings)
new(settings)
end

def persisted?
false
end
end
7 changes: 7 additions & 0 deletions app/views/devise/registrations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
<%= f.label :time_zone %>
<%= f.time_zone_select :time_zone, ActiveSupport::TimeZone.all.sort %>

<div class="field">
<%= f.fields_for :settings do |settings_fields| %>
<%= settings_fields.label :check_in_reminder_time %>
<%= settings_fields.time_select(:check_in_reminder_time, ampm: true, discard_minute: true) %>
<% end %>
</div>

<div class="field">
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i>
<%= f.password_field :password, autocomplete: "off" %>
Expand Down
6 changes: 6 additions & 0 deletions db/migrate/20160518181634_add_settings_to_account.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddSettingsToAccount < ActiveRecord::Migration
def change
enable_extension "citext"
add_column :accounts, :settings, :jsonb, null: false, default: "{}"
end
end
20 changes: 11 additions & 9 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,32 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160511170833) do
ActiveRecord::Schema.define(version: 20160518181634) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension "uuid-ossp"
enable_extension "hstore"
enable_extension "citext"

create_table "accounts", id: :uuid, default: "uuid_generate_v4()", force: :cascade do |t|
t.string "name", default: "", null: false
t.string "email", default: "", null: false
t.string "encrypted_password", null: false
t.string "name", default: "", null: false
t.string "email", default: "", null: false
t.string "encrypted_password", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.inet "current_sign_in_ip"
t.inet "last_sign_in_ip"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "weekly_expected_capacity", default: 0, null: false
t.string "time_zone", default: "Central Time (US & Canada)", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "weekly_expected_capacity", default: 0, null: false
t.string "time_zone", limit: 255, default: "UTC", null: false
t.hstore "features"
t.jsonb "settings", default: {}, null: false
end

add_index "accounts", ["created_at"], name: "index_accounts_on_created_at", using: :btree
Expand Down