diff --git a/plugins/orders/lib/ext/profile.rb b/plugins/orders/lib/ext/profile.rb index 03cdcff..fdf2186 100644 --- a/plugins/orders/lib/ext/profile.rb +++ b/plugins/orders/lib/ext/profile.rb @@ -12,10 +12,7 @@ subclass.class_eval do has_many :ordered_items, -> { order 'name ASC' }, through: :orders, source: :items has_many :sales_consumers, through: :sales, source: :consumer - has_many :purchases_consumers, through: :sales, source: :consumer - - has_many :sales_profiles, through: :sales, source: :profile - has_many :purchases_profiles, through: :sales, source: :profile + has_many :purchases_suppliers, through: :purchases, source: :profile end end @@ -30,12 +27,12 @@ class Profile def sales_all_consumers consumers = self.sales_consumers.order 'name ASC' - consumers.concat self.suppliers.except_self.order('name ASC') if self.respond_to? :suppliers + consumers.concat self.consumers.except_self.order('name ASC') if self.respond_to? :consumers consumers.uniq end - def purchases_all_consumers - consumers = self.purchases_consumers.order 'name ASC' - consumers.concat self.consumers.except_self.order('name ASC') if self.respond_to? :consumers + def purchases_all_suppliers + consumers = self.purchases_suppliers.order 'name ASC' + consumers.concat self.suppliers.except_self.order('name ASC') if self.respond_to? :suppliers consumers.uniq end diff --git a/plugins/orders/views/orders_plugin/mailer/order_confirmation.html.erb b/plugins/orders/views/orders_plugin/mailer/order_confirmation.html.erb index 5ee63eb..aa78ba4 100644 --- a/plugins/orders/views/orders_plugin/mailer/order_confirmation.html.erb +++ b/plugins/orders/views/orders_plugin/mailer/order_confirmation.html.erb @@ -28,10 +28,11 @@ <%= render "orders_plugin_order/show_simple", order: @order, actor_name: :consumer %> +

<%= t('orders_plugin.views.mailer.order_confirmation.your_order_can_be_che') %>
<%= link_to t('orders_plugin.views.mailer.order_confirmation.order_code_of_profile') % {code: @order.code, name: @profile.name }, - {controller: :orders_cycle_plugin_order, action: :edit, profile: @profile.identifier, id: @order.id, protocol: "http"} %> + {controller: :orders_plugin_order, action: :edit, profile: @profile.identifier, id: @order.id, protocol: "http"} %>

diff --git a/plugins/orders/views/orders_plugin_admin/_index.html.erb b/plugins/orders/views/orders_plugin_admin/_index.html.erb deleted file mode 100644 index 12ca3ce..0000000 --- a/plugins/orders/views/orders_plugin_admin/_index.html.erb +++ /dev/null @@ -1,26 +0,0 @@ -

<%= t('orders_plugin.lib.plugin.panel_button') %>

- -<%= button :back, _('Back to control panel'), controller: 'profile_editor' %> - -
- <% if @purchases.present? and @sales.present? %> - - <% end %> - - <% if @purchases.present? %> -
- <%= render 'orders_plugin_admin/purchases', actors: profile.sales_all_consumers, - orders_owner: profile, orders: @purchases, month: @purchases_month, year: @purchases_year, wireframe_size: false %> -
- <% end %> - - <% if @sales.present? %> -
- <%= render 'orders_plugin_admin/sales', actors: profile.purchases_all_consumers, - orders_owner: profile, orders: @sales, month: @sales_month, year: @purchases_year, wireframe_size: false %> -
- <% end %> -
diff --git a/plugins/orders/views/orders_plugin_admin/_index.html.slim b/plugins/orders/views/orders_plugin_admin/_index.html.slim new file mode 100644 index 0000000..7c4fff5 --- /dev/null +++ b/plugins/orders/views/orders_plugin_admin/_index.html.slim @@ -0,0 +1,22 @@ +h1 + = t('orders_plugin.lib.plugin.panel_button') + += button :back, _('Back to control panel'), controller: 'profile_editor' + +div + - if @purchases.present? and @sales.present? + ul#orders-tabs.nav.nav-pills data-tabs="orders-tabs" + li.active data-toggle="orders-tabs" + a href="#purchases" = t('orders_plugin.terms.purchase.plural') + li class=("#{'active' if @purchases.blank?}") data-toggle="orders-tabs" + a href="#sales" = t('orders_plugin.terms.sale.plural') + + - if @purchases.present? + #purchases.tab-pane + = render 'orders_plugin_admin/purchases', actors: profile.purchases_all_suppliers, + orders_owner: profile, orders: @purchases, month: @purchases_month, year: @purchases_year, wireframe_size: false + + - if @sales.present? + #sales.tab-pane + = render 'orders_plugin_admin/sales', actors: profile.sales_all_consumers, + orders_owner: profile, orders: @sales, month: @sales_month, year: @purchases_year, wireframe_size: false diff --git a/plugins/orders/views/orders_plugin_admin/_order.html.erb b/plugins/orders/views/orders_plugin_admin/_order.html.erb deleted file mode 100644 index 6b1bc73..0000000 --- a/plugins/orders/views/orders_plugin_admin/_order.html.erb +++ /dev/null @@ -1,29 +0,0 @@ -<% other_actor_name = if actor_name == :supplier then :consumer else :supplier end %> -<% edit = true if edit.nil? %> - -
-
-
<%= check_box_tag "order_ids[]", order.id %>
- -
- <%= order.code %> - <%= order.send("#{other_actor_name}_data")[:name] %> - <%= datetime_full order.created_at %> - <%= datetime_full order.updated_at %> - <%= order.total_price_as_currency_number actor_name %> - <%= order_situation order %> -
- - <%= edit_arrow "#order-row-#{order.id}", true, class: 'actions' %> - -
-
- -
- <% if edit %> - <%= render 'orders_plugin_admin/edit', order: order, actor_name: actor_name, other_actor_name: other_actor_name %> - <% end %> -
- -
-
diff --git a/plugins/orders/views/orders_plugin_admin/index.html.erb b/plugins/orders/views/orders_plugin_admin/index.html.erb deleted file mode 120000 index 4cc79b4..0000000 --- a/plugins/orders/views/orders_plugin_admin/index.html.erb +++ /dev/null @@ -1 +0,0 @@ -_index.html.erb \ No newline at end of file diff --git a/plugins/orders/views/orders_plugin_admin/index.html.slim b/plugins/orders/views/orders_plugin_admin/index.html.slim new file mode 120000 index 0000000..1329d8a --- /dev/null +++ b/plugins/orders/views/orders_plugin_admin/index.html.slim @@ -0,0 +1 @@ +_index.html.slim \ No newline at end of file diff --git a/plugins/shopping_cart/features/delivery_client.feature b/plugins/shopping_cart/features/delivery_client.feature index 31fb8f0..35bb4ba 100644 --- a/plugins/shopping_cart/features/delivery_client.feature +++ b/plugins/shopping_cart/features/delivery_client.feature @@ -37,7 +37,7 @@ Feature: delivery client And I should see "Show basket" And I follow "Show basket" And I follow "Shopping checkout" - And I fill in "Contact phone" with "123456789" + And I fill in "order_consumer_data_contact_phone" with "123456789" When I select "Bike ($8.00)" from "Option" Then I should see "My good old bike." within ".instructions" And I should see "Address" @@ -51,7 +51,7 @@ Feature: delivery client And I should see "Show basket" And I follow "Show basket" And I follow "Shopping checkout" - And I fill in "Contact phone" with "123456789" + And I fill in "order_consumer_data_contact_phone" with "123456789" When I select "Bar" from "Option" Then I should see "Come to my bar and drink it!" within ".instructions" And I should not see "Address" @@ -69,7 +69,7 @@ Feature: delivery client And I should see "Show basket" And I follow "Show basket" And I follow "Shopping checkout" - And I fill in "Contact phone" with "123456789" + And I fill in "order_consumer_data_contact_phone" with "123456789" When I select "Bike ($8.00)" from "Option" Then I should see "My good old bike." within ".instructions" And I should see "Address" diff --git a/plugins/shopping_cart/features/purchases.feature b/plugins/shopping_cart/features/purchases.feature index a4019e5..f57335d 100644 --- a/plugins/shopping_cart/features/purchases.feature +++ b/plugins/shopping_cart/features/purchases.feature @@ -108,7 +108,7 @@ Feature: purchases And I follow "Purchases made" And I should see "Moes Tavern" within any ".actor-name" And I should see "First Church of Springfield" within any ".actor-name" - And I select "Moes Tavern" from "supplier" + And I select "Moes Tavern" from "supplier_id" When I press "Filter" Then I should see "Moes Tavern" within any ".actor-name" And I should not see "First Church of Springfield" within any ".actor-name" @@ -125,7 +125,7 @@ Feature: purchases And I follow "Add to basket" And I follow "Show basket" And I follow "Shopping checkout" - And I fill in "Contact phone" with "123456789" + And I fill in "order_consumer_data_contact_phone" with "123456789" And I select "Bike ($8.00)" from "Option" And I press "Send buy request" And I go to homer's control panel diff --git a/plugins/shopping_cart/features/sales.feature b/plugins/shopping_cart/features/sales.feature index c850e31..0101c3e 100644 --- a/plugins/shopping_cart/features/sales.feature +++ b/plugins/shopping_cart/features/sales.feature @@ -98,7 +98,7 @@ Feature: sales And I follow "Purchases and Sales" And I should see "Homer" within any ".actor-name" And I should see "Reverend Lovejoy" within any ".actor-name" - And I select "Homer" from "consumer" + And I select "Homer" from "consumer_id" When I press "Filter" Then I should see "Homer" within any ".actor-name" And I should not see "Reverend Lovejoy" within any ".actor-name" diff --git a/plugins/shopping_cart/test/functional/shopping_cart_plugin_controller_test.rb b/plugins/shopping_cart/test/functional/shopping_cart_plugin_controller_test.rb index 632c031..71d20df 100644 --- a/plugins/shopping_cart/test/functional/shopping_cart_plugin_controller_test.rb +++ b/plugins/shopping_cart/test/functional/shopping_cart_plugin_controller_test.rb @@ -16,11 +16,11 @@ class ShoppingCartPluginControllerTest < ActionController::TestCase should 'force cookie expiration with explicit path for an empty cart' do get :get, id: product.id - assert @response.headers['Set-Cookie'] =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart; expires=.*1970.*/ + assert @response.headers['Set-Cookie'] =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart/ get :add, id: product.id get :remove, id: product.id - assert @response.headers['Set-Cookie'] =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart; expires=.*1970.*/ + assert @response.headers['Set-Cookie'] =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart/ end should 'add a new product to cart' do -- libgit2 0.21.2