adding new contact

This commit is contained in:
Eugene Korbut 2009-02-09 01:11:49 +10:00
parent 155c766a29
commit 8f0577bf56
4 changed files with 8 additions and 15 deletions

View file

@ -46,7 +46,7 @@ class ContactsController < ApplicationController
render :action => "list"
end
def add
def new
@contact = Contact.new
@contact.customer_id = logged_user
@ -288,7 +288,7 @@ class ContactsController < ApplicationController
end
# Insert or update
def save
def create
logger.info("BEGIN")
if params["contact"]["id"] == ""
# New contact
@ -337,7 +337,7 @@ class ContactsController < ApplicationController
@groups[g.id] = 0
end
}
render :action => "add"
redirect_to contacts_path
end
end

View file

@ -25,7 +25,6 @@ module NavigationHelper
def link_import_preview() "/contacts/import_preview" end
def link_main_index() "/" end
def link_contact_save() "/contacts/save" end
def link_contact_import() "/contacts/import" end
def link_contact_choose() "/contacts/contact/choose" end
@ -34,7 +33,7 @@ module NavigationHelper
end
def link_contact_add_one
link_to(_('Add one contact'), :controller => "/contacts/contact", :action => "add")
link_to(_('Add one contact'), new_contact_path)
end
def link_contact_add_multiple

View file

@ -59,7 +59,7 @@ class Contact < ActiveRecord::Base
errors.add 'email', _('Please enter a valid email address.') 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("email = '#{email}' and customer_id = #{customer_id}")
if Contact.find :first, :conditions => {:email => email, :customer_id => customer_id}
errors.add('email', _('An account for your email address already exists.'))
end
end

View file

@ -8,7 +8,7 @@
<li><span><%= _('Contacts') %></span>
<ul id="secondary">
<li><%=link_contact_list%></li>
<% if ret = @session["return_to"] %>
<% if ret = session["return_to"] %>
<li><%=link_to(_('Back to message'), ret) %></li>
<% end %>
</ul>
@ -20,13 +20,7 @@
<div id="tab_content">
<%=
form_tag(
link_contact_save,
'method' => 'post',
'class' => 'two_columns'
)
%>
<% form_tag( contacts_path, 'method' => 'post', 'class' => 'two_columns') do %>
<%= form_input(:hidden_field, 'contact', 'id') %>
<%= form_input(:hidden_field, 'contact', 'customer_id') %>
@ -74,6 +68,6 @@
</td>
</tr>
</table>
<%= end_form_tag %>
<% end %>
</div>
</div>