diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index 002c5dc..c4c750b 100755 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -82,13 +82,17 @@ class ContactsController < ApplicationController tmp_file.flush tmp_file.rewind tmp_file.readlines.each do |line| + next if line =~ /^#/ Contact.import(@current_user,line) end - rescue Exception => e - flash[:error] = e.to_s + rescue ActiveRecord::RecordInvalid => e + flash[:error] = {:title => e.to_s,:info => e.record.inspect + e.record.errors.inspect} + rescue Exception => e + flash[:error] = e.to_s + else + flash[:notice] = t(:were_imported,:scope=>:contact) end end - flash[:notice] = t(:were_imported,:scope=>:contact) if not flash[:error] redirect_to :action => 'index' end diff --git a/app/models/contact.rb b/app/models/contact.rb index 4291ba8..4af64b7 100755 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -4,14 +4,14 @@ class Contact < ActiveRecord::Base validates_length_of :first_name,:last_name, :within => 3..20 validates_length_of :email, :within => 5..50 validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i - validates_length_of :info, :maximum => 50 + validates_length_of :info, :maximum => 100 validate :check_unique_nick, :on => :create + default_scope :order => 'nick ASC' belongs_to :user def self.getPageForUser(user,page,sort_field,sort_dir) - order = 'last_name asc' if sort_field if Contact.attribute_method?(sort_field) == true order = sort_field @@ -44,11 +44,11 @@ class Contact < ActiveRecord::Base def self.import(user,line) fields = line.split(/;/) - contact = user.contacts.build( :nick => fields[0], - :first_name => fields[1], - :last_name => fields[2], - :email => fields[3], - :info => fields[4]) + contact = user.contacts.build( :nick => fields[0].strip, + :first_name => fields[1].strip, + :last_name => fields[2].strip, + :email => fields[3].strip, + :info => fields[4].strip) contact.save! end end diff --git a/app/models/event.rb b/app/models/event.rb deleted file mode 100755 index 3a829fd..0000000 --- a/app/models/event.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Event < ActiveRecord::Base -end diff --git a/themes/olive/stylesheets/style.css b/themes/olive/stylesheets/style.css index 6e8a6a8..c87ce20 100755 --- a/themes/olive/stylesheets/style.css +++ b/themes/olive/stylesheets/style.css @@ -583,3 +583,8 @@ div.logo { div#logo { background-color: #EFF3E4; } + +div.flash p.info { + text-align: left; + font-size: 10px; +} diff --git a/themes/olive/views/contacts/_external.html.erb b/themes/olive/views/contacts/_external.html.erb index 0145a2a..f945a6a 100755 --- a/themes/olive/views/contacts/_external.html.erb +++ b/themes/olive/views/contacts/_external.html.erb @@ -2,6 +2,10 @@ <%= form_tag(contacts_external_path, :multipart => true) %> :  <%= file_field 'upload', 'datafile' %> +<% if @contacts.size.zero? %> +<%= raw single_action('import','contact','right.png') %> +<% else %> <%= raw group_action(@ei_buttons) %> +<% end %> diff --git a/themes/olive/views/layouts/application.html.erb b/themes/olive/views/layouts/application.html.erb index 9951d00..1605793 100755 --- a/themes/olive/views/layouts/application.html.erb +++ b/themes/olive/views/layouts/application.html.erb @@ -28,14 +28,7 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <%= yield :sidebar %>
-
- <% flash.each do |key, msg| %> - <% unless msg.blank? %> - <%= content_tag(:div,(content_tag :p, msg), :class => "message #{key.to_s}" )%> - <%= flash[key.to_sym]='' %> - <% end %> - <% end %> -
+ <%= render :partial=>'layouts/flash', :object => flash %> <%= yield %>