summaryrefslogtreecommitdiff
path: root/users/app
diff options
context:
space:
mode:
Diffstat (limited to 'users/app')
-rw-r--r--users/app/controllers/users_controller.rb3
-rw-r--r--users/app/models/user.rb7
-rw-r--r--users/app/views/users/_email_aliases.html.haml20
-rw-r--r--users/app/views/users/edit.html.haml2
4 files changed, 20 insertions, 12 deletions
diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb
index 4921a4a..5055f4e 100644
--- a/users/app/controllers/users_controller.rb
+++ b/users/app/controllers/users_controller.rb
@@ -30,7 +30,8 @@ class UsersController < ApplicationController
end
def update
- if @user.update_attributes(params[:user])
+ @user.attributes = params[:user]
+ if @user.changed? and @user.save
flash[:notice] = t(:user_updated_successfully)
end
respond_with @user, :location => edit_user_path(@user)
diff --git a/users/app/models/user.rb b/users/app/models/user.rb
index 81d5262..3ad69c7 100644
--- a/users/app/models/user.rb
+++ b/users/app/models/user.rb
@@ -75,6 +75,13 @@ class User < CouchRest::Model::Base
APP_CONFIG['admins'].include? self.login
end
+ def email_aliases_attributes=(attrs)
+ if attrs
+ email_alias = EmailAlias.new(attrs.values.first)
+ email_aliases << email_alias
+ end
+ end
+
protected
def password
password_verifier
diff --git a/users/app/views/users/_email_aliases.html.haml b/users/app/views/users/_email_aliases.html.haml
index 54eac0f..41d4f9e 100644
--- a/users/app/views/users/_email_aliases.html.haml
+++ b/users/app/views/users/_email_aliases.html.haml
@@ -1,10 +1,10 @@
-%legend= t(:email_aliases)
-%ul
- - @user.email_aliases.each do |email|
- %li= email
-= email_alias_form do |f|
- =f.input :email, :placeholder => "alias@#{request.domain}"
- .pull-right
- %button{:type => :submit, :class => 'btn'}
- %i.icon-plus
- Add Email Alias
+.span6
+ %ul.unstyled
+ - @user.email_aliases.each do |email_alias|
+ %li.pull-right
+ %code= email_alias.email
+ %i.icon-remove
+ .clearfix
+.clearfix
+= f.simple_fields_for :email_aliases, EmailAlias.new do |e|
+ = e.input :email, :placeholder => "alias@#{request.domain}"
diff --git a/users/app/views/users/edit.html.haml b/users/app/views/users/edit.html.haml
index eb1bca4..92ab71b 100644
--- a/users/app/views/users/edit.html.haml
+++ b/users/app/views/users/edit.html.haml
@@ -14,4 +14,4 @@
.tab-pane#email
= user_form_with 'email_field', :legend => :set_email_address
= user_form_with 'email_forward_field', :legend => :forward_email
- = render 'email_aliases'
+ = user_form_with 'email_aliases', :legend => :add_email_alias