adding new contact
This commit is contained in:
parent
155c766a29
commit
8f0577bf56
|
@ -46,7 +46,7 @@ class ContactsController < ApplicationController
|
||||||
render :action => "list"
|
render :action => "list"
|
||||||
end
|
end
|
||||||
|
|
||||||
def add
|
def new
|
||||||
@contact = Contact.new
|
@contact = Contact.new
|
||||||
@contact.customer_id = logged_user
|
@contact.customer_id = logged_user
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ class ContactsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# Insert or update
|
# Insert or update
|
||||||
def save
|
def create
|
||||||
logger.info("BEGIN")
|
logger.info("BEGIN")
|
||||||
if params["contact"]["id"] == ""
|
if params["contact"]["id"] == ""
|
||||||
# New contact
|
# New contact
|
||||||
|
@ -337,7 +337,7 @@ class ContactsController < ApplicationController
|
||||||
@groups[g.id] = 0
|
@groups[g.id] = 0
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
render :action => "add"
|
redirect_to contacts_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ module NavigationHelper
|
||||||
|
|
||||||
def link_import_preview() "/contacts/import_preview" end
|
def link_import_preview() "/contacts/import_preview" end
|
||||||
def link_main_index() "/" end
|
def link_main_index() "/" end
|
||||||
def link_contact_save() "/contacts/save" end
|
|
||||||
def link_contact_import() "/contacts/import" end
|
def link_contact_import() "/contacts/import" end
|
||||||
def link_contact_choose() "/contacts/contact/choose" end
|
def link_contact_choose() "/contacts/contact/choose" end
|
||||||
|
|
||||||
|
@ -34,7 +33,7 @@ module NavigationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_contact_add_one
|
def link_contact_add_one
|
||||||
link_to(_('Add one contact'), :controller => "/contacts/contact", :action => "add")
|
link_to(_('Add one contact'), new_contact_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_contact_add_multiple
|
def link_contact_add_multiple
|
||||||
|
|
|
@ -59,7 +59,7 @@ class Contact < ActiveRecord::Base
|
||||||
errors.add 'email', _('Please enter a valid email address.') unless valid_email?(self.email)
|
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
|
# Already existing e-mail in contacts for this user is not allowed
|
||||||
if self.new_record?
|
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.'))
|
errors.add('email', _('An account for your email address already exists.'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<li><span><%= _('Contacts') %></span>
|
<li><span><%= _('Contacts') %></span>
|
||||||
<ul id="secondary">
|
<ul id="secondary">
|
||||||
<li><%=link_contact_list%></li>
|
<li><%=link_contact_list%></li>
|
||||||
<% if ret = @session["return_to"] %>
|
<% if ret = session["return_to"] %>
|
||||||
<li><%=link_to(_('Back to message'), ret) %></li>
|
<li><%=link_to(_('Back to message'), ret) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -20,13 +20,7 @@
|
||||||
<div id="tab_content">
|
<div id="tab_content">
|
||||||
|
|
||||||
|
|
||||||
<%=
|
<% form_tag( contacts_path, 'method' => 'post', 'class' => 'two_columns') do %>
|
||||||
form_tag(
|
|
||||||
link_contact_save,
|
|
||||||
'method' => 'post',
|
|
||||||
'class' => 'two_columns'
|
|
||||||
)
|
|
||||||
%>
|
|
||||||
<%= form_input(:hidden_field, 'contact', 'id') %>
|
<%= form_input(:hidden_field, 'contact', 'id') %>
|
||||||
<%= form_input(:hidden_field, 'contact', 'customer_id') %>
|
<%= form_input(:hidden_field, 'contact', 'customer_id') %>
|
||||||
|
|
||||||
|
@ -74,6 +68,6 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<%= end_form_tag %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
Loading…
Reference in a new issue