Permalink
Browse files

Add initial notification settings

  • Loading branch information...
1 parent 7107327 commit 818a1a4b51578138195cc0343d7234bccb0c3d9d @proglottis committed Mar 21, 2013
@@ -1,5 +1,21 @@
class SettingsController < ApplicationController
+ before_filter :authenticate_user!
+ before_filter :find_user_and_services
+
def show
+ end
+
+ def update
+ if @user.update_attributes(params.require(:user).permit(:game_confirmed_email))
+ redirect_to setting_path, :notice => I18n.t('settings.update.updated')
+ else
+ render :show
+ end
+ end
+
+ private
+
+ def find_user_and_services
@user = current_user
@services = current_user.services
end
@@ -4,23 +4,43 @@
</div>
<ul class="nav nav-tabs">
- <li class="active"><%= link_to Service.model_name.human.pluralize, setting_path %></li>
+ <li class="active"><%= link_to t('.notifications'), '#notifications', :'data-toggle' => 'tab' %></li>
+ <li><%= link_to Service.model_name.human.pluralize, '#services', :'data-toggle' => 'tab' %></li>
</ul>
-<div class="row">
- <%= div_for @services, :class => 'span6' do |service| %>
- <div class="thumbnail">
- <div class="caption">
- <h3><%= service.provider.humanize %></h3>
- <dl class="dl-horizontal">
- <dt><%= Service.human_attribute_name('uid') %></dt>
- <dd><%= service.uid %></dd>
- <dt><%= Service.human_attribute_name('name') %></dt>
- <dd><%= service.name || t('.unknown') %></dd>
- <dt><%= Service.human_attribute_name('email') %></dt>
- <dd><%= service.email || t('.unknown') %></dd>
- </dl>
+<div class="tab-content">
+ <div class="tab-pane active" id="notifications">
+ <%= form_for current_user, :url => setting_path, :html => {:class => 'form-horizontal'} do |f| %>
+ <div class="control-group">
+ <div class="controls">
+ <label class="checkbox"><%= f.check_box :game_confirmed_email %> <%= User.human_attribute_name('game_confirmed_email') %></label>
+ </div>
</div>
+ <div class="control-group">
+ <div class="controls">
+ <%= f.submit :class => 'btn btn-primary' %>
+ <%= cancel_link :back %>
+ </div>
+ </div>
+ <% end %>
+ </div>
+ <div class="tab-pane" id="services">
+ <div class="row">
+ <%= div_for @services, :class => 'span6' do |service| %>
+ <div class="thumbnail">
+ <div class="caption">
+ <h3><%= service.provider.humanize %></h3>
+ <dl class="dl-horizontal">
+ <dt><%= Service.human_attribute_name('uid') %></dt>
+ <dd><%= service.uid %></dd>
+ <dt><%= Service.human_attribute_name('name') %></dt>
+ <dd><%= service.name || t('.unknown') %></dd>
+ <dt><%= Service.human_attribute_name('email') %></dt>
+ <dd><%= service.email || t('.unknown') %></dd>
+ </dl>
+ </div>
+ </div>
+ <% end %>
</div>
- <% end %>
+ </div>
</div>
View
@@ -37,6 +37,8 @@ en:
settings:
show:
title: Settings
+ update:
+ updated: Settings have been updated
homes:
show:
@@ -0,0 +1,5 @@
+class AddGameConfirmedEmailToUser < ActiveRecord::Migration
+ def change
+ add_column :users, :game_confirmed_email, :boolean, :null => false, :default => true
+ end
+end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130307021205) do
+ActiveRecord::Schema.define(:version => 20130321043242) do
create_table "challenges", :force => true do |t|
t.integer "tournament_id", :null => false
@@ -116,9 +116,10 @@
create_table "users", :force => true do |t|
t.string "name"
t.string "email"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
t.integer "preferred_service_id"
+ t.boolean "game_confirmed_email", :default => true, :null => false
end
add_index "users", ["preferred_service_id"], :name => "index_users_on_preferred_service_id"

0 comments on commit 818a1a4

Please sign in to comment.