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 | 78 | country |
79 | 79 | tag_list |
80 | 80 | template_id |
81 | + district | |
82 | + address_reference | |
81 | 83 | ] |
82 | 84 | |
83 | 85 | def self.fields |
... | ... | @@ -96,8 +98,8 @@ class Organization < Profile |
96 | 98 | [] |
97 | 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 | 104 | validates_format_of :foundation_year, :with => Noosfero::Constants::INTEGER_FORMAT |
103 | 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 | 148 | contact_information |
149 | 149 | description |
150 | 150 | image |
151 | + district | |
152 | + address_reference | |
151 | 153 | ] |
152 | 154 | |
153 | 155 | validates_multiparameter_assignments |
... | ... | @@ -201,8 +203,8 @@ class Person < Profile |
201 | 203 | N_('Education'); N_('Custom education'); N_('Custom area of study'); |
202 | 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 | 209 | extend SetProfileRegionFromCityState::ClassMethods |
208 | 210 | set_profile_region_from_city_state | ... | ... |
app/models/profile.rb
... | ... | @@ -231,7 +231,7 @@ class Profile < ActiveRecord::Base |
231 | 231 | if myregion |
232 | 232 | myregion.hierarchy.reverse.first(2).map(&:name).join(separator) |
233 | 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 | 235 | end |
236 | 236 | end |
237 | 237 | |
... | ... | @@ -696,7 +696,7 @@ private :generate_url, :url_options |
696 | 696 | def custom_footer_expanded |
697 | 697 | footer = custom_footer |
698 | 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 | 700 | if self.respond_to?(att) && footer.match(/\{[^{]*#{att}\}/) |
701 | 701 | if !self.send(att).nil? && !self.send(att).blank? |
702 | 702 | footer = footer.gsub(/\{([^{]*)#{att}\}/, '\1' + self.send(att)) | ... | ... |
app/views/profile_editor/_person_form.rhtml
... | ... | @@ -21,6 +21,8 @@ |
21 | 21 | <%= optional_field(@person, 'city', f.text_field(:city, :rel => _('City'))) %> |
22 | 22 | <%= optional_field(@person, 'zip_code', labelled_form_field(_('ZIP code'), text_field(:profile_data, :zip_code, :rel => _('ZIP code')))) %> |
23 | 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 | 27 | <% optional_field(@person, 'schooling') do %> |
26 | 28 | <div class="formfieldline"> | ... | ... |
app/views/shared/_organization_custom_fields.rhtml
... | ... | @@ -10,6 +10,8 @@ |
10 | 10 | <%= optional_field(profile, 'economic_activity', f.text_field(:economic_activity)) %> |
11 | 11 | <%= optional_field(profile, 'management_information', f.text_area(:management_information, :rows => 5)) %> |
12 | 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 | 15 | <%= optional_field(profile, 'zip_code', labelled_form_field(_('ZIP code'), text_field(object_name, :zip_code))) %> |
14 | 16 | <%= optional_field(profile, 'city', f.text_field(:city)) %> |
15 | 17 | <%= optional_field(profile, 'state', f.text_field(:state)) %> | ... | ... |
plugins/shopping_cart/public/buy.js
plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb
... | ... | @@ -17,19 +17,29 @@ |
17 | 17 | <li><b><%= _('Full name') %>: </b><%= @customer[:name] %></li> |
18 | 18 | <li><b><%= _('Email') %>: </b><%= @customer[:email] %></li> |
19 | 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 | 25 | <li><b><%= _('Address') %>:</b> |
22 | 26 | <% end %> |
23 | 27 | <% if !@customer[:address].blank? %> |
24 | 28 | <%= @customer[:address] %><br \> |
25 | 29 | <% end %> |
30 | + <% if !@customer[:district].blank? %> | |
31 | + <%= @customer[:district] %><br \> | |
32 | + <% end %> | |
26 | 33 | <% if !@customer[:city].blank? %> |
27 | 34 | <%= @customer[:city] %><br \> |
28 | 35 | <% end %> |
29 | 36 | <% if !@customer[:zip_code].blank? %> |
30 | 37 | <%= @customer[:zip_code] %> |
31 | 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 | 43 | </li> |
34 | 44 | <% end %> |
35 | 45 | </ul> | ... | ... |
plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb
... | ... | @@ -15,19 +15,29 @@ |
15 | 15 | <li><b><%= _('Full name') %>: </b><%= @customer[:name] %></li> |
16 | 16 | <li><b><%= _('Email') %>: </b><%= @customer[:email] %></li> |
17 | 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 | 23 | <li><b><%= _('Address') %>:</b> |
20 | 24 | <% end %> |
21 | 25 | <% if !@customer[:address].blank? %> |
22 | 26 | <%= @customer[:address] %><br \> |
23 | 27 | <% end %> |
28 | + <% if !@customer[:district].blank? %> | |
29 | + <%= @customer[:district] %><br \> | |
30 | + <% end %> | |
24 | 31 | <% if !@customer[:city].blank? %> |
25 | 32 | <%= @customer[:city] %><br \> |
26 | 33 | <% end %> |
27 | 34 | <% if !@customer[:zip_code].blank? %> |
28 | 35 | <%= @customer[:zip_code] %> |
29 | 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 | 41 | </li> |
32 | 42 | <% end %> |
33 | 43 | </ul> | ... | ... |
plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb
... | ... | @@ -7,10 +7,14 @@ |
7 | 7 | <%= labelled_form_field('* ' + _("Email"), f.text_field(:email, :class => 'required email') ) %> |
8 | 8 | <%= labelled_form_field('* ' + _("Contact phone"), f.text_field(:contact_phone, :class => 'required') ) %> |
9 | 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 | 12 | </div> |
11 | 13 | <% if @settings.delivery %> |
12 | 14 | <fieldset><legend><%=_('Delivery Address')%></legend> |
13 | 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 | 18 | <%= labelled_form_field( _("City"), f.text_field(:city)) %> |
15 | 19 | <%= labelled_form_field(_('ZIP code'), f.text_field(:zip_code)) %> |
16 | 20 | </fieldset> | ... | ... |
test/unit/person_test.rb
... | ... | @@ -64,7 +64,7 @@ class PersonTest < ActiveSupport::TestCase |
64 | 64 | |
65 | 65 | should "have person info fields" do |
66 | 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 | 68 | assert_respond_to p, i |
69 | 69 | end |
70 | 70 | end | ... | ... |