cirandas.net

commit 500c6928489028e6d50c1fdad2116da16570bf28

Author: Braulio Bhavamitra <braulio@prout.io>

Merge branch 'master' of https://github.com/samasti/noosfero into samasti

%!v(PANIC=String method: strings: negative Repeat count)


diff --git a/plugins/orders_cycle/lib/orders_cycle_plugin/mailer.rb b/plugins/orders_cycle/lib/orders_cycle_plugin/mailer.rb
index 06629b08e48303f35a2ccbc42b57ba9762bbf6d0..3022924220a1aa497821a5ca6e2a858af9be2819 100644
--- a/plugins/orders_cycle/lib/orders_cycle_plugin/mailer.rb
+++ b/plugins/orders_cycle/lib/orders_cycle_plugin/mailer.rb
@@ -15,7 +15,7 @@     @cycle = cycle
     @message = message
 
     mail bcc: organization_members(@profile),
-      to: envionment.noreply_email,
+      to: environment.noreply_email,
       from: environment.noreply_email,
       reply_to: profile_recipients(@profile),
       subject: t('lib.mailer.profile_subject') % {profile: profile.name, subject: subject}




diff --git a/plugins/suppliers/controllers/myprofile/suppliers_plugin/product_controller.rb b/plugins/suppliers/controllers/myprofile/suppliers_plugin/product_controller.rb
index aad63f8165131283815a8c7d4f0f72fb0d959591..b3e793f5115898dc630fd550320bf8d319a9b930 100644
--- a/plugins/suppliers/controllers/myprofile/suppliers_plugin/product_controller.rb
+++ b/plugins/suppliers/controllers/myprofile/suppliers_plugin/product_controller.rb
@@ -24,9 +24,9 @@   end
 
   def edit
     @product = profile.products.supplied.find params[:id]
-    @product.update params.require(:product).permit(:name, :product_category_id, :margin_percentage, :available, :unit_id, :supplier_price)
+    @product.update params.require(:product).permit(:name, :description, :product_category_id, :margin_percentage, :available, :unit_id, :supplier_price)
 
-    render nothing: true
+    render json: @product.reload, serializer: SuppliersPlugin::ProductSerializer
   end
 
   def set_image




diff --git a/plugins/suppliers/locales/en-US.yml b/plugins/suppliers/locales/en-US.yml
index 3d0b88aa9d30e326bb040eb8cdf7cab109cc968b..ff1a9f70de96f664bbadd2dc298c46e800391a07 100644
--- a/plugins/suppliers/locales/en-US.yml
+++ b/plugins/suppliers/locales/en-US.yml
@@ -225,6 +225,8 @@         validation_error_supplier_id: "Validation error: Please, fill the field Supplier"
         validation_error_name: "Validation error: Please, fill the field Name"
         validation_error_supplier_price: "Validation error: Please, fill the field Supplier Price"
         validation_error_margin_percentage: "Validation error: Please, fill the field Margin"
+        supplier_product_name: "Product name to the supplier: "
+        name_change_warning: "WARNING: Changing the product name doesn't change the supplier product name. To avoid issues with orders history and name divergences between ordered and delived, prefer to create another product with the right name and disable this."
         import:
           action: "Import spreadsheet"
           help: "Format your spreadsheet to have exactly the fields bellow with header. Then, save it choosing the CSV file type (.csv extension)."




diff --git a/plugins/suppliers/locales/pt-BR.yml b/plugins/suppliers/locales/pt-BR.yml
index 6011f80e53add5dd209be85071eb5156de39bc52..a8b15602ebee8efcb57e1edc3fefd23fb35500f9 100644
--- a/plugins/suppliers/locales/pt-BR.yml
+++ b/plugins/suppliers/locales/pt-BR.yml
@@ -231,6 +231,8 @@         validation_error_supplier_id: "Erro de validação: Por favor preencher o campo Fornecedor"
         validation_error_name: "Erro de validação: Por favor preencher o campo Nome"
         validation_error_supplier_price: "Erro de validação: Por favor preencher o campo preço do fornecedor"
         validation_error_margin_percentage: "Erro de validação: Por favor preencher o campo margem"
+        supplier_product_name: "Nome do produto para o fornecedor: "
+        name_change_warning: "CUIDADO: Ao mudar o nome do produto, ele continua igual para o fornecedor. Para não estragar o histórico de pedidos e criar divergências entre o produto pedido e o entregue, prefira criar um novo produto com o nome correto e desabilitar esse."
         import:
           action: "Importar planilha"
           help: "Formate sua planilha para que tenha exatamente os campos abaixo com cabeçalho. Depois, salve-a escolhendo o tipo de arquivo CSV (extensão .csv)."




diff --git a/plugins/suppliers/public/javascripts/views/product-item.tag.slim b/plugins/suppliers/public/javascripts/views/product-item.tag.slim
index 1b598696fe28901a9be46196164a3600d318e9f9..bd2eb840f8e3994abcf445ea2f50dff4d26bb162 100644
--- a/plugins/suppliers/public/javascripts/views/product-item.tag.slim
+++ b/plugins/suppliers/public/javascripts/views/product-item.tag.slim
@@ -11,9 +11,8 @@     .switch show="{product.edition}"
       input.cmn-toggle.cmn-toggle-round type="checkbox" name='available' checked="{product.available}" id="{'available-'+product.id}"
       label for="{'available-'+product.id}"
   .name
-    span show="{!product.edition}"
+    span
       |{product.name}
-    input type="text" value="{product.name}" show="{product.edition}" name='name'
   .supplier
     .overflow
       |{supplier}




diff --git a/plugins/suppliers/public/javascripts/views/product-modal.tag.slim b/plugins/suppliers/public/javascripts/views/product-modal.tag.slim
index 424b2e658e7bc4223f05097a8df0146dda4b59d2..73853576501c7b53af095a2386bf4ba071d02f3b 100644
--- a/plugins/suppliers/public/javascripts/views/product-modal.tag.slim
+++ b/plugins/suppliers/public/javascripts/views/product-modal.tag.slim
@@ -29,8 +29,13 @@
               .form-group
                 label for="p-name"
                   |{t("views.product.product_name")}
+                small.title if="{product.id}"
+                  |{t("views.product.name_change_warning")}
                 input type="text" value="{product.name}" id="p-name"
-
+                small.supplier_product_name show="{product.supplier_product_name != product.name && product.supplier_product_name != undefined}"
+                  strong
+                    |{t("views.product.supplier_product_name")}
+                  |{this.product.supplier_product_name}
               .form-group
                 select name="supplier_id" id="p-supplier_id" if="{!product.id}"
                   option each="{id,name in parent.active_suppliers}" value="{id}"




diff --git a/plugins/suppliers/public/javascripts/views/product-page.tag.slim b/plugins/suppliers/public/javascripts/views/product-page.tag.slim
index 13754128116d3d10fd945f72b391890ab03481ca..8c3f4bbbd3c98247e55f893e3a8f677d4c7fd967 100644
--- a/plugins/suppliers/public/javascripts/views/product-page.tag.slim
+++ b/plugins/suppliers/public/javascripts/views/product-page.tag.slim
@@ -251,6 +251,8 @@     completeEdition(product, productItem) {
       this.tags['product-modal'].product = product
       this.tags['product-modal'].productItem = productItem
       this.tags['product-modal'].update()
+      // riot is buggy!!
+      $("#p-description").val(this.tags['product-modal'].product.description)
     }
 
     typeaheadCategoryInit (input, selected) {
@@ -288,9 +290,15 @@     }
 
     add() {
       var product = {
+        name: " ",
         available: true,
-        margin_percentage: 0,
-        supplier_price: 0
+        margin_percentage: " ",
+        supplier_price: " ",
+        product_category_id: " ",
+        supplier_id: " ",
+        unit_id: " ",
+        category: " ",
+        unit: " "
       }
       this.completeEdition(product, {update: function(){}, product: {}})
     }




diff --git a/plugins/suppliers/public/stylesheets/product.scss b/plugins/suppliers/public/stylesheets/product.scss
index 42b12fbeedea859f36f57720fd504d68850fd480..5f6871269502ba0a02044c818c30c87c7e135557 100644
--- a/plugins/suppliers/public/stylesheets/product.scss
+++ b/plugins/suppliers/public/stylesheets/product.scss
@@ -394,6 +394,12 @@           width: 100%;
           min-height: 100px;
         }
       }
+      small.title {
+        color: orange;
+      }
+      small.supplier_product_name {
+        color: red;
+      }
       .change_image {
         position: relative;
         top: -30px;




diff --git a/plugins/suppliers/serializers/suppliers_plugin/product_serializer.rb b/plugins/suppliers/serializers/suppliers_plugin/product_serializer.rb
index 22e7093787ee612b1e6971dae0e11ce46bfa8eba..091c63d78efceb2f013ca85b38763ba17524e0b9 100644
--- a/plugins/suppliers/serializers/suppliers_plugin/product_serializer.rb
+++ b/plugins/suppliers/serializers/suppliers_plugin/product_serializer.rb
@@ -10,6 +10,7 @@
     attribute :unit_id
     attribute :price
     attribute :supplier_price
+    attribute :supplier_product_name
     attribute :margin_percentage
 
     attribute :stored
@@ -27,11 +28,18 @@
     def name
       product[:name] || product[:from_product_name]
     end
+    def description
+      product[:description] || product[:from_product_description]
+    end
     def unit_id
       product[:unit_id] || product[:from_product_unit_id]
     end
     def supplier_price
       product[:from_product_price] || product.supplier_price
+    end
+
+    def supplier_product_name
+      product[:from_product_name] || (product.supplier_product && product.supplier_product.name)
     end
 
     def available