diff options
author | Azul <azul@leap.se> | 2012-12-10 10:38:48 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-12-10 10:38:48 +0100 |
commit | e4c7f2fb8fa2833037508f1b88f802944855fd77 (patch) | |
tree | 0514506d3b64861b8a5877145e1a3212c76af4b9 /users/app | |
parent | 9d99d340cfd3c55f21d38c1ba9f3f4574e40c46c (diff) |
actually allow adding email aliases
Diffstat (limited to 'users/app')
-rw-r--r-- | users/app/controllers/users_controller.rb | 3 | ||||
-rw-r--r-- | users/app/models/user.rb | 7 | ||||
-rw-r--r-- | users/app/views/users/_email_aliases.html.haml | 20 | ||||
-rw-r--r-- | users/app/views/users/edit.html.haml | 2 |
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 |