diff options
Diffstat (limited to 'users/app')
-rw-r--r-- | users/app/controllers/email_aliases_controller.rb (renamed from users/app/controllers/email_alias_controller.rb) | 7 | ||||
-rw-r--r-- | users/app/helpers/email_aliases_helper.rb | 11 | ||||
-rw-r--r-- | users/app/models/email_alias.rb | 6 | ||||
-rw-r--r-- | users/app/models/user.rb | 6 | ||||
-rw-r--r-- | users/app/views/users/_email_aliases.html.haml | 10 | ||||
-rw-r--r-- | users/app/views/users/edit.html.haml | 1 |
6 files changed, 37 insertions, 4 deletions
diff --git a/users/app/controllers/email_alias_controller.rb b/users/app/controllers/email_aliases_controller.rb index 979c8ad..751df85 100644 --- a/users/app/controllers/email_alias_controller.rb +++ b/users/app/controllers/email_aliases_controller.rb @@ -2,6 +2,8 @@ class EmailAliasesController < ApplicationController before_filter :fetch_user + respond_to :html + # get a list of email aliases for the given user? def index @aliases = @user.email_aliases @@ -11,20 +13,21 @@ class EmailAliasesController < ApplicationController def create @alias = @user.add_email_alias(params[:email_alias]) flash[:notice] = t(:email_alias_created_successfully) unless @alias.errors - respond_with @alias + respond_with @alias, :location => edit_user_path(@user, :anchor => :email) end def update @alias = @user.get_email_alias(params[:id]) @alias.set_email(params[:email_alias]) flash[:notice] = t(:email_alias_updated_successfully) unless @alias.errors - respond_with @alias + respond_with @alias, :location => edit_user_path(@user, :anchor => :email) end def destroy @alias = @user.get_email_alias(params[:id]) flash[:notice] = t(:email_alias_destroyed_successfully) @alias.destroy + redirect_to edit_user_path(@user, :anchor => :email) end protected diff --git a/users/app/helpers/email_aliases_helper.rb b/users/app/helpers/email_aliases_helper.rb new file mode 100644 index 0000000..b56b068 --- /dev/null +++ b/users/app/helpers/email_aliases_helper.rb @@ -0,0 +1,11 @@ +module EmailAliasesHelper + + def email_alias_form(options = {}) + simple_form_for [@user, EmailAlias.new()], + :html => {:class => "form-horizontal email-alias form"}, + :validate => true do |f| + yield f + end + end + +end diff --git a/users/app/models/email_alias.rb b/users/app/models/email_alias.rb new file mode 100644 index 0000000..25e4b27 --- /dev/null +++ b/users/app/models/email_alias.rb @@ -0,0 +1,6 @@ +class EmailAlias + include CouchRest::Model::Embeddable + + property :email, String + timestamps! +end diff --git a/users/app/models/user.rb b/users/app/models/user.rb index ae271ce..81d5262 100644 --- a/users/app/models/user.rb +++ b/users/app/models/user.rb @@ -1,11 +1,13 @@ class User < CouchRest::Model::Base property :login, String, :accessible => true - property :email, String, :accessible => true - property :email_forward, String, :accessible => true property :password_verifier, String, :accessible => true property :password_salt, String, :accessible => true + property :email, String, :accessible => true + property :email_forward, String, :accessible => true + property :email_aliases, [EmailAlias] + validates :login, :password_salt, :password_verifier, :presence => true diff --git a/users/app/views/users/_email_aliases.html.haml b/users/app/views/users/_email_aliases.html.haml new file mode 100644 index 0000000..54eac0f --- /dev/null +++ b/users/app/views/users/_email_aliases.html.haml @@ -0,0 +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 diff --git a/users/app/views/users/edit.html.haml b/users/app/views/users/edit.html.haml index b33c19b..eb1bca4 100644 --- a/users/app/views/users/edit.html.haml +++ b/users/app/views/users/edit.html.haml @@ -14,3 +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' |