Commit 7089039888e8f96cc667183192a979e32f77e868
1 parent
05d3db06
Exists in
master
and in
22 other branches
Adding new fields to shopping_cart
Showing
10 changed files
with
47 additions
and
11 deletions
Show diff stats
app/models/organization.rb
@@ -78,6 +78,8 @@ class Organization < Profile | @@ -78,6 +78,8 @@ class Organization < Profile | ||
78 | country | 78 | country |
79 | tag_list | 79 | tag_list |
80 | template_id | 80 | template_id |
81 | + district | ||
82 | + address_reference | ||
81 | ] | 83 | ] |
82 | 84 | ||
83 | def self.fields | 85 | def self.fields |
@@ -96,8 +98,8 @@ class Organization < Profile | @@ -96,8 +98,8 @@ class Organization < Profile | ||
96 | [] | 98 | [] |
97 | end | 99 | end |
98 | 100 | ||
99 | - N_('Display name'); N_('Description'); N_('Contact person'); N_('Contact email'); N_('Acronym'); N_('Foundation year'); N_('Legal form'); N_('Economic activity'); N_('Management information'); N_('Tag list') | ||
100 | - settings_items :display_name, :description, :contact_person, :contact_email, :acronym, :foundation_year, :legal_form, :economic_activity, :management_information | 101 | + N_('Display name'); N_('Description'); N_('Contact person'); N_('Contact email'); N_('Acronym'); N_('Foundation year'); N_('Legal form'); N_('Economic activity'); N_('Management information'); N_('Tag list'); N_('District'); N_('Address reference') |
102 | + settings_items :display_name, :description, :contact_person, :contact_email, :acronym, :foundation_year, :legal_form, :economic_activity, :management_information, :district, :address_reference | ||
101 | 103 | ||
102 | validates_format_of :foundation_year, :with => Noosfero::Constants::INTEGER_FORMAT | 104 | validates_format_of :foundation_year, :with => Noosfero::Constants::INTEGER_FORMAT |
103 | validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |org| !org.contact_email.blank? }) | 105 | validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |org| !org.contact_email.blank? }) |
app/models/person.rb
@@ -148,6 +148,8 @@ class Person < Profile | @@ -148,6 +148,8 @@ class Person < Profile | ||
148 | contact_information | 148 | contact_information |
149 | description | 149 | description |
150 | image | 150 | image |
151 | + district | ||
152 | + address_reference | ||
151 | ] | 153 | ] |
152 | 154 | ||
153 | validates_multiparameter_assignments | 155 | validates_multiparameter_assignments |
@@ -201,8 +203,8 @@ class Person < Profile | @@ -201,8 +203,8 @@ class Person < Profile | ||
201 | N_('Education'); N_('Custom education'); N_('Custom area of study'); | 203 | N_('Education'); N_('Custom education'); N_('Custom area of study'); |
202 | settings_items :formation, :custom_formation, :custom_area_of_study | 204 | settings_items :formation, :custom_formation, :custom_area_of_study |
203 | 205 | ||
204 | - N_('Contact information'); N_('City'); N_('State'); N_('Country'); N_('Sex'); N_('Zip code') | ||
205 | - settings_items :photo, :contact_information, :sex, :city, :state, :country, :zip_code | 206 | + N_('Contact information'); N_('City'); N_('State'); N_('Country'); N_('Sex'); N_('Zip code'); N_('District'); N_('Address reference') |
207 | + settings_items :photo, :contact_information, :sex, :city, :state, :country, :zip_code, :district, :address_reference | ||
206 | 208 | ||
207 | extend SetProfileRegionFromCityState::ClassMethods | 209 | extend SetProfileRegionFromCityState::ClassMethods |
208 | set_profile_region_from_city_state | 210 | set_profile_region_from_city_state |
app/models/profile.rb
@@ -231,7 +231,7 @@ class Profile < ActiveRecord::Base | @@ -231,7 +231,7 @@ class Profile < ActiveRecord::Base | ||
231 | if myregion | 231 | if myregion |
232 | myregion.hierarchy.reverse.first(2).map(&:name).join(separator) | 232 | myregion.hierarchy.reverse.first(2).map(&:name).join(separator) |
233 | else | 233 | else |
234 | - %w[address city state country_name zip_code ].map {|item| (self.respond_to?(item) && !self.send(item).blank?) ? self.send(item) : nil }.compact.join(separator) | 234 | + %w[address district city state country_name zip_code ].map {|item| (self.respond_to?(item) && !self.send(item).blank?) ? self.send(item) : nil }.compact.join(separator) |
235 | end | 235 | end |
236 | end | 236 | end |
237 | 237 | ||
@@ -696,7 +696,7 @@ private :generate_url, :url_options | @@ -696,7 +696,7 @@ private :generate_url, :url_options | ||
696 | def custom_footer_expanded | 696 | def custom_footer_expanded |
697 | footer = custom_footer | 697 | footer = custom_footer |
698 | if footer | 698 | if footer |
699 | - %w[contact_person contact_email contact_phone location address economic_activity city state country zip_code].each do |att| | 699 | + %w[contact_person contact_email contact_phone location address district address_reference economic_activity city state country zip_code].each do |att| |
700 | if self.respond_to?(att) && footer.match(/\{[^{]*#{att}\}/) | 700 | if self.respond_to?(att) && footer.match(/\{[^{]*#{att}\}/) |
701 | if !self.send(att).nil? && !self.send(att).blank? | 701 | if !self.send(att).nil? && !self.send(att).blank? |
702 | footer = footer.gsub(/\{([^{]*)#{att}\}/, '\1' + self.send(att)) | 702 | footer = footer.gsub(/\{([^{]*)#{att}\}/, '\1' + self.send(att)) |
app/views/profile_editor/_person_form.rhtml
@@ -21,6 +21,8 @@ | @@ -21,6 +21,8 @@ | ||
21 | <%= optional_field(@person, 'city', f.text_field(:city, :rel => _('City'))) %> | 21 | <%= optional_field(@person, 'city', f.text_field(:city, :rel => _('City'))) %> |
22 | <%= optional_field(@person, 'zip_code', labelled_form_field(_('ZIP code'), text_field(:profile_data, :zip_code, :rel => _('ZIP code')))) %> | 22 | <%= optional_field(@person, 'zip_code', labelled_form_field(_('ZIP code'), text_field(:profile_data, :zip_code, :rel => _('ZIP code')))) %> |
23 | <%= optional_field(@person, 'address', labelled_form_field(_('Address (street and number)'), text_field(:profile_data, :address, :rel => _('Address')))) %> | 23 | <%= optional_field(@person, 'address', labelled_form_field(_('Address (street and number)'), text_field(:profile_data, :address, :rel => _('Address')))) %> |
24 | +<%= optional_field(profile, 'address_reference', labelled_form_field(_('Address reference'), text_field(object_name, :address_reference, :rel => _('Address reference')))) %> | ||
25 | +<%= optional_field(@person, 'district', labelled_form_field(_('District'), text_field(:profile_data, :district, :rel => _('District')))) %> | ||
24 | 26 | ||
25 | <% optional_field(@person, 'schooling') do %> | 27 | <% optional_field(@person, 'schooling') do %> |
26 | <div class="formfieldline"> | 28 | <div class="formfieldline"> |
app/views/shared/_organization_custom_fields.rhtml
@@ -10,6 +10,8 @@ | @@ -10,6 +10,8 @@ | ||
10 | <%= optional_field(profile, 'economic_activity', f.text_field(:economic_activity)) %> | 10 | <%= optional_field(profile, 'economic_activity', f.text_field(:economic_activity)) %> |
11 | <%= optional_field(profile, 'management_information', f.text_area(:management_information, :rows => 5)) %> | 11 | <%= optional_field(profile, 'management_information', f.text_area(:management_information, :rows => 5)) %> |
12 | <%= optional_field(profile, 'address', labelled_form_field(_('Address (street and number)'), text_field(object_name, :address))) %> | 12 | <%= optional_field(profile, 'address', labelled_form_field(_('Address (street and number)'), text_field(object_name, :address))) %> |
13 | +<%= optional_field(profile, 'address_reference', labelled_form_field(_('Address reference'), text_field(object_name, :address_reference))) %> | ||
14 | +<%= optional_field(profile, 'district', labelled_form_field(_('District'), text_field(object_name, :district))) %> | ||
13 | <%= optional_field(profile, 'zip_code', labelled_form_field(_('ZIP code'), text_field(object_name, :zip_code))) %> | 15 | <%= optional_field(profile, 'zip_code', labelled_form_field(_('ZIP code'), text_field(object_name, :zip_code))) %> |
14 | <%= optional_field(profile, 'city', f.text_field(:city)) %> | 16 | <%= optional_field(profile, 'city', f.text_field(:city)) %> |
15 | <%= optional_field(profile, 'state', f.text_field(:state)) %> | 17 | <%= optional_field(profile, 'state', f.text_field(:state)) %> |
plugins/shopping_cart/public/buy.js
@@ -28,3 +28,7 @@ jQuery('#delivery_option').change(function(){ | @@ -28,3 +28,7 @@ jQuery('#delivery_option').change(function(){ | ||
28 | }, | 28 | }, |
29 | }); | 29 | }); |
30 | }); | 30 | }); |
31 | + | ||
32 | +jQuery('#customer_payment').change(function(){ | ||
33 | + jQuery(this).closest('.formfieldline').next().slideToggle('fast'); | ||
34 | +}); |
plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb
@@ -17,19 +17,29 @@ | @@ -17,19 +17,29 @@ | ||
17 | <li><b><%= _('Full name') %>: </b><%= @customer[:name] %></li> | 17 | <li><b><%= _('Full name') %>: </b><%= @customer[:name] %></li> |
18 | <li><b><%= _('Email') %>: </b><%= @customer[:email] %></li> | 18 | <li><b><%= _('Email') %>: </b><%= @customer[:email] %></li> |
19 | <li><b><%= _('Phone number') %>: </b><%= @customer[:contact_phone] %></li> | 19 | <li><b><%= _('Phone number') %>: </b><%= @customer[:contact_phone] %></li> |
20 | - <% if !@customer[:address].blank? || !@customer[:city].blank? || !@customer[:zip_code].blank? %> | 20 | + <li><b><%= _('Payment') %>: </b><%= @customer[:payment] == 'money' ? _('Money') : _('Check') %></li> |
21 | + <% if @customer[:payment] == 'money' %> | ||
22 | + <li><b><%= _('Change') %>: </b><%= @customer[:change] %></li> | ||
23 | + <% end %> | ||
24 | + <% if !@customer[:address].blank? || !@customer[:city].blank? || !@customer[:zip_code].blank? || !@customer[:district].blank? || !@customer[:address_reference].blank? %> | ||
21 | <li><b><%= _('Address') %>:</b> | 25 | <li><b><%= _('Address') %>:</b> |
22 | <% end %> | 26 | <% end %> |
23 | <% if !@customer[:address].blank? %> | 27 | <% if !@customer[:address].blank? %> |
24 | <%= @customer[:address] %><br \> | 28 | <%= @customer[:address] %><br \> |
25 | <% end %> | 29 | <% end %> |
30 | + <% if !@customer[:district].blank? %> | ||
31 | + <%= @customer[:district] %><br \> | ||
32 | + <% end %> | ||
26 | <% if !@customer[:city].blank? %> | 33 | <% if !@customer[:city].blank? %> |
27 | <%= @customer[:city] %><br \> | 34 | <%= @customer[:city] %><br \> |
28 | <% end %> | 35 | <% end %> |
29 | <% if !@customer[:zip_code].blank? %> | 36 | <% if !@customer[:zip_code].blank? %> |
30 | <%= @customer[:zip_code] %> | 37 | <%= @customer[:zip_code] %> |
31 | <% end %> | 38 | <% end %> |
32 | - <% if !@customer[:address].blank? || !@customer[:city].blank? || !@customer[:zip_code].blank? %> | 39 | + <% if !@customer[:address_reference].blank? %> |
40 | + <%= @customer[:address_reference] %><br \> | ||
41 | + <% end %> | ||
42 | + <% if !@customer[:address].blank? || !@customer[:city].blank? || !@customer[:zip_code].blank? || !@customer[:district].blank? || !@customer[:address_reference].blank? %> | ||
33 | </li> | 43 | </li> |
34 | <% end %> | 44 | <% end %> |
35 | </ul> | 45 | </ul> |
plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb
@@ -15,19 +15,29 @@ | @@ -15,19 +15,29 @@ | ||
15 | <li><b><%= _('Full name') %>: </b><%= @customer[:name] %></li> | 15 | <li><b><%= _('Full name') %>: </b><%= @customer[:name] %></li> |
16 | <li><b><%= _('Email') %>: </b><%= @customer[:email] %></li> | 16 | <li><b><%= _('Email') %>: </b><%= @customer[:email] %></li> |
17 | <li><b><%= _('Phone number') %>: </b><%= @customer[:contact_phone] %></li> | 17 | <li><b><%= _('Phone number') %>: </b><%= @customer[:contact_phone] %></li> |
18 | - <% if !@customer[:address].blank? || !@customer[:city].blank? || !@customer[:zip_code].blank? %> | 18 | + <li><b><%= _('Payment') %>: </b><%= @customer[:payment] == 'money' ? _('Money') : _('Check') %></li> |
19 | + <% if @customer[:payment] == 'money' %> | ||
20 | + <li><b><%= _('Change') %>: </b><%= @customer[:change] %></li> | ||
21 | + <% end %> | ||
22 | + <% if !@customer[:address].blank? || !@customer[:city].blank? || !@customer[:zip_code].blank? || !@customer[:district].blank? || !@customer[:address_reference].blank? %> | ||
19 | <li><b><%= _('Address') %>:</b> | 23 | <li><b><%= _('Address') %>:</b> |
20 | <% end %> | 24 | <% end %> |
21 | <% if !@customer[:address].blank? %> | 25 | <% if !@customer[:address].blank? %> |
22 | <%= @customer[:address] %><br \> | 26 | <%= @customer[:address] %><br \> |
23 | <% end %> | 27 | <% end %> |
28 | + <% if !@customer[:district].blank? %> | ||
29 | + <%= @customer[:district] %><br \> | ||
30 | + <% end %> | ||
24 | <% if !@customer[:city].blank? %> | 31 | <% if !@customer[:city].blank? %> |
25 | <%= @customer[:city] %><br \> | 32 | <%= @customer[:city] %><br \> |
26 | <% end %> | 33 | <% end %> |
27 | <% if !@customer[:zip_code].blank? %> | 34 | <% if !@customer[:zip_code].blank? %> |
28 | <%= @customer[:zip_code] %> | 35 | <%= @customer[:zip_code] %> |
29 | <% end %> | 36 | <% end %> |
30 | - <% if !@customer[:address].blank? || !@customer[:city].blank? || !@customer[:zip_code].blank? %> | 37 | + <% if !@customer[:address_reference].blank? %> |
38 | + <%= @customer[:address_reference] %><br \> | ||
39 | + <% end %> | ||
40 | + <% if !@customer[:address].blank? || !@customer[:city].blank? || !@customer[:zip_code].blank? || !@customer[:district].blank? || !@customer[:address_reference].blank? %> | ||
31 | </li> | 41 | </li> |
32 | <% end %> | 42 | <% end %> |
33 | </ul> | 43 | </ul> |
plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb
@@ -7,10 +7,14 @@ | @@ -7,10 +7,14 @@ | ||
7 | <%= labelled_form_field('* ' + _("Email"), f.text_field(:email, :class => 'required email') ) %> | 7 | <%= labelled_form_field('* ' + _("Email"), f.text_field(:email, :class => 'required email') ) %> |
8 | <%= labelled_form_field('* ' + _("Contact phone"), f.text_field(:contact_phone, :class => 'required') ) %> | 8 | <%= labelled_form_field('* ' + _("Contact phone"), f.text_field(:contact_phone, :class => 'required') ) %> |
9 | <%= labelled_form_field(_('Delivery option'), select_tag(:delivery_option, options_for_select(select_delivery_options(@settings.delivery_options, environment)), 'data-profile-identifier' => profile.identifier)) unless !@settings.delivery || (@settings.free_delivery_price && get_total(session[:cart][:items]) >= @settings.free_delivery_price) %> | 9 | <%= labelled_form_field(_('Delivery option'), select_tag(:delivery_option, options_for_select(select_delivery_options(@settings.delivery_options, environment)), 'data-profile-identifier' => profile.identifier)) unless !@settings.delivery || (@settings.free_delivery_price && get_total(session[:cart][:items]) >= @settings.free_delivery_price) %> |
10 | + <%= labelled_form_field(_('Payment'), select_tag('customer[payment]', options_for_select([[_("Money"), :money],[_('Check'), :check]]))) %> | ||
11 | + <%= labelled_form_field(_('Change'), text_field_tag('customer[change]')) %> | ||
10 | </div> | 12 | </div> |
11 | <% if @settings.delivery %> | 13 | <% if @settings.delivery %> |
12 | <fieldset><legend><%=_('Delivery Address')%></legend> | 14 | <fieldset><legend><%=_('Delivery Address')%></legend> |
13 | <%= labelled_form_field(_('Address (street and number)'), f.text_field(:address)) %> | 15 | <%= labelled_form_field(_('Address (street and number)'), f.text_field(:address)) %> |
16 | + <%= labelled_form_field(_('Address reference'), f.text_field(:address_reference)) %> | ||
17 | + <%= labelled_form_field(_('District'), f.text_field(:district)) %> | ||
14 | <%= labelled_form_field( _("City"), f.text_field(:city)) %> | 18 | <%= labelled_form_field( _("City"), f.text_field(:city)) %> |
15 | <%= labelled_form_field(_('ZIP code'), f.text_field(:zip_code)) %> | 19 | <%= labelled_form_field(_('ZIP code'), f.text_field(:zip_code)) %> |
16 | </fieldset> | 20 | </fieldset> |
test/unit/person_test.rb
@@ -64,7 +64,7 @@ class PersonTest < ActiveSupport::TestCase | @@ -64,7 +64,7 @@ class PersonTest < ActiveSupport::TestCase | ||
64 | 64 | ||
65 | should "have person info fields" do | 65 | should "have person info fields" do |
66 | p = Person.new(:environment => Environment.default) | 66 | p = Person.new(:environment => Environment.default) |
67 | - [ :name, :photo, :contact_information, :birth_date, :sex, :address, :city, :state, :country, :zip_code, :image ].each do |i| | 67 | + [ :name, :photo, :contact_information, :birth_date, :sex, :address, :city, :state, :country, :zip_code, :image, :district, :address_reference ].each do |i| |
68 | assert_respond_to p, i | 68 | assert_respond_to p, i |
69 | end | 69 | end |
70 | end | 70 | end |