From 231b1e1d1cf8d405efc15d7da26c122f16fc16fa Mon Sep 17 00:00:00 2001 From: Emilio Blanco Date: Sun, 27 Mar 2011 15:53:06 -0300 Subject: [PATCH] Multiple fixes in contacts --- app/controllers/contacts_controller.rb | 15 +++++++-------- app/models/contact.rb | 10 +++++----- app/views/contacts/add_multiple.rhtml | 22 +++++++++++----------- app/views/contacts/import_preview.rhtml | 4 ++-- app/views/contacts/index.html.erb | 10 ++++++---- config/locales/es-ES.yml | 12 ++++++++++++ config/routes.rb | 2 +- 7 files changed, 44 insertions(+), 31 deletions(-) diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index d5e7db4..7e530aa 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -249,7 +249,7 @@ class ContactsController < ApplicationController contact_group.contacts.delete(contact) end } - redirect_to(:action=>"list", :id=>group_id, :params=>{"mode"=>params["mode"]}) + redirect_to(:action=>"index", :id=>group_id, :params=>{"mode"=>params["mode"]}) end def edit @@ -273,12 +273,11 @@ class ContactsController < ApplicationController @groups[g.id] = 0 # unchecked end } - render :action => "add" + render :action => "new" end # Insert or update def create - logger.info("BEGIN") if params["contact"]["id"] == "" # New contact @contact = Contact.create(params["contact"]) @@ -311,10 +310,10 @@ class ContactsController < ApplicationController end } if @contact.save - if params["paction"] == _('Save') - redirect_to :controller => "/contacts/contact", :action =>"list" + if params["paction"] == t(:save) + redirect_to :action =>:index else - redirect_to :controller => "/contacts/contact", :action =>"add" + redirect_to :action => :new end else loadLists @@ -326,13 +325,13 @@ class ContactsController < ApplicationController @groups[g.id] = 0 end } - redirect_to contacts_path + render :action => :new end end def delete Contact.destroy(params['id']) - redirect_to(:action=>'list') + redirect_to(:action=>'index') end protected diff --git a/app/models/contact.rb b/app/models/contact.rb index a181864..a039675 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -47,23 +47,23 @@ class Contact < ActiveRecord::Base protected def validate - errors.add 'fname', _('Please enter your first name (2 to 20 characters).') unless self.fname =~ /^.{2,20}$/i - errors.add 'lname', _('Please enter your surname (2 to 20 characters).') unless self.lname =~ /^.{2,20}$/i + errors.add 'fname', I18n.t(:validate_fname_error) unless self.fname =~ /^.{2,20}$/i + errors.add 'lname', I18n.t(:validate_lname_error) unless self.lname =~ /^.{2,20}$/i # Contact e-mail cannot be changed unless self.new_record? old_record = Contact.find(self.id) - errors.add 'email', _('Contacts email cannot be changed.') unless old_record.email == self.email + errors.add 'email', I18n.t(:contacto_cannot_be_changed) unless old_record.email == self.email end end def validate_on_create # Contact e-mail cannot be changed, so we only need to validate it on create - errors.add 'email', _('Please enter a valid email address.') unless valid_email?(self.email) + errors.add 'email', I18n.t(:validate_email_error) unless valid_email?(self.email) # Already existing e-mail in contacts for this user is not allowed if self.new_record? if Contact.find :first, :conditions => {:email => email, :customer_id => customer_id} - errors.add('email', _('An account for your email address already exists.')) + errors.add('email', I18n.t(:email_exists)) end end end diff --git a/app/views/contacts/add_multiple.rhtml b/app/views/contacts/add_multiple.rhtml index 4bfcf3c..8ab1494 100644 --- a/app/views/contacts/add_multiple.rhtml +++ b/app/views/contacts/add_multiple.rhtml @@ -1,26 +1,26 @@ -

<%=_('Add multiple contacts')%>

-<% if @flash["errors"] and not @flash["errors"].empty?%> - <%= _('Errors')%> +

<%=t :add_multiple_contacts %>

+<% if flash["errors"] and not flash["errors"].empty?%> + <%= t(:errors)%> <% end %>
- <%= radio_button("contact", "file_type", "1")%> <%= _('Comma-separated (CSV) file')%> - <%= radio_button("contact", "file_type", "2")%> <%= _('Tab-delimited text file')%> + <%= radio_button("contact", "file_type", "1")%> <%= t(:csv_file)%> + <%= radio_button("contact", "file_type", "2")%> <%= t(:tab_file)%> - +
- - - + + +
-
\ No newline at end of file + diff --git a/app/views/contacts/import_preview.rhtml b/app/views/contacts/import_preview.rhtml index 3077b94..b972081 100644 --- a/app/views/contacts/import_preview.rhtml +++ b/app/views/contacts/import_preview.rhtml @@ -1,9 +1,9 @@

<%= _('Contacts You Are About To Import')%>

-<% if @flash["errors"] and not @flash["errors"].empty?%> +<% if flash["errors"] and not flash["errors"].empty?%> <%= _('Errors')%> diff --git a/app/views/contacts/index.html.erb b/app/views/contacts/index.html.erb index ae1f735..342d52a 100644 --- a/app/views/contacts/index.html.erb +++ b/app/views/contacts/index.html.erb @@ -8,7 +8,7 @@
  • <%= t :contacts %>