Commit f836413359c86ac1c6692580520736980e2d1dac

Authored by Rodrigo Souto
1 parent 8f69c31b

Adding new attributes to purchase order

plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb
@@ -274,10 +274,14 @@ class ShoppingCartPluginController < PublicController @@ -274,10 +274,14 @@ class ShoppingCartPluginController < PublicController
274 :customer => user, 274 :customer => user,
275 :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED, 275 :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED,
276 :products_list => new_items, 276 :products_list => new_items,
  277 + :customer_delivery_option => params[:delivery_option],
  278 + :customer_payment => params[:customer][:payment],
  279 + :customer_change => params[:customer][:change],
277 :customer_name => params[:customer][:name], 280 :customer_name => params[:customer][:name],
278 :customer_email => params[:customer][:email], 281 :customer_email => params[:customer][:email],
279 :customer_contact_phone => params[:customer][:contact_phone], 282 :customer_contact_phone => params[:customer][:contact_phone],
280 :customer_address => params[:customer][:address], 283 :customer_address => params[:customer][:address],
  284 + :customer_district => params[:customer][:district],
281 :customer_city => params[:customer][:city], 285 :customer_city => params[:customer][:city],
282 :customer_zip_code => params[:customer][:zip_code] 286 :customer_zip_code => params[:customer][:zip_code]
283 ) 287 )
plugins/shopping_cart/lib/shopping_cart_plugin/purchase_order.rb
@@ -12,8 +12,12 @@ class ShoppingCartPlugin::PurchaseOrder < Noosfero::Plugin::ActiveRecord @@ -12,8 +12,12 @@ class ShoppingCartPlugin::PurchaseOrder < Noosfero::Plugin::ActiveRecord
12 settings_items :customer_email, :type => String 12 settings_items :customer_email, :type => String
13 settings_items :customer_contact_phone, :type => String 13 settings_items :customer_contact_phone, :type => String
14 settings_items :customer_address, :type => String 14 settings_items :customer_address, :type => String
  15 + settings_items :customer_district, :type => String
15 settings_items :customer_city, :type => String 16 settings_items :customer_city, :type => String
16 settings_items :customer_zip_code, :type => String 17 settings_items :customer_zip_code, :type => String
  18 + settings_items :customer_delivery_option, :type => String
  19 + settings_items :customer_payment, :type => String
  20 + settings_items :customer_change, :type => String
17 21
18 before_create do |order| 22 before_create do |order|
19 order.created_at = Time.now.utc 23 order.created_at = Time.now.utc
plugins/shopping_cart/views/shopping_cart_plugin_myprofile/_orders_list.html.erb
@@ -32,7 +32,9 @@ @@ -32,7 +32,9 @@
32 <td class="order-info" colspan="5"> 32 <td class="order-info" colspan="5">
33 <div style="display:none"> 33 <div style="display:none">
34 <ul class="customer-details"> 34 <ul class="customer-details">
35 - <% { 'name' =>_('Name'), 'email' => _('E-mail'), 'contact_phone' => _('Contact phone'), 'address' => _('Address'), 'city' => _('City'), 'zip_code' => _('Zip code')}.each do |attribute, name| %> 35 + <% [['name', _('Name')], ['email', _('E-mail')], ['contact_phone', _('Contact phone')], ['address', _('Address')], ['district', _('District')], ['city', _('City')], ['zip_code', _('Zip code')], ['delivery_option', _('Delivery option')], ['payment', _('Payment')], ['change', _('Change')]].each do |field| %>
  36 + <% attribute = field.first %>
  37 + <% name = field.last %>
36 <%= content_tag('li', content_tag('strong', name+': ') + order.send('customer_'+attribute)) if !order.send('customer_'+attribute).blank? %> 38 <%= content_tag('li', content_tag('strong', name+': ') + order.send('customer_'+attribute)) if !order.send('customer_'+attribute).blank? %>
37 <% end %> 39 <% end %>
38 </ul> 40 </ul>