From 5fe31e6333e6b59d6c4fc2ba31158acbda88e67d Mon Sep 17 00:00:00 2001 From: Liv Galendez Date: Tue, 2 Jun 2015 18:03:16 +1000 Subject: [PATCH 01/11] Added asterisks to required fields in new enterprise creation form. --- app/views/admin/enterprises/_new_form.html.haml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/admin/enterprises/_new_form.html.haml b/app/views/admin/enterprises/_new_form.html.haml index a76c8ec31c..4b0679e554 100644 --- a/app/views/admin/enterprises/_new_form.html.haml +++ b/app/views/admin/enterprises/_new_form.html.haml @@ -1,6 +1,7 @@ .row .three.columns.alpha = f.label :name + %span.required * .nine.columns.omega = f.text_field :name, { placeholder: "eg. Professor Plum's Biodynamic Truffles", class: "fullwidth" } @@ -51,6 +52,7 @@ .row .alpha.three.columns = f.label :email + %span.required * .omega.nine.columns = f.text_field :email, { placeholder: "eg. gustav@truffles.com", "ng-model" => "Enterprise.email" } .alert-box @@ -72,6 +74,7 @@ .row .three.columns.alpha = af.label :address1 + %span.required * .nine.columns.omega = af.text_field :address1, { placeholder: "eg. 123 High Street"} .row @@ -84,6 +87,7 @@ = af.label :city, 'Suburb' \/ = af.label :zipcode, 'Postcode' + %span.required * .four.columns = af.text_field :city, { placeholder: "eg. Northcote"} .five.columns.omega From db19303f1abcab87a65d713b0ef1efd54587cc31 Mon Sep 17 00:00:00 2001 From: Liv Galendez Date: Tue, 2 Jun 2015 18:23:41 +1000 Subject: [PATCH 02/11] Added asterisk to new field Owner since it seems to be required also --- app/views/admin/enterprises/_new_form.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/admin/enterprises/_new_form.html.haml b/app/views/admin/enterprises/_new_form.html.haml index 4b0679e554..7aa35417df 100644 --- a/app/views/admin/enterprises/_new_form.html.haml +++ b/app/views/admin/enterprises/_new_form.html.haml @@ -9,6 +9,7 @@ .row{ ng: { app: "admin.users" } } .three.columns.alpha =f.label :owner_id, 'Owner' + %span.required * .with-tip{'data-powertip' => "The primary user responsible for this enterprise."} %a What's this? .nine.columns.omega From e551a6b9f57264abac139767eaf05fb7c21cf1f8 Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Tue, 5 Jan 2016 08:36:23 +1100 Subject: [PATCH 03/11] Updating translations for fr.yml and nb.yml --- config/locales/fr.yml | 30 ++++++++++++++++++++++++++---- config/locales/nb.yml | 28 +++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 7ddd01655a..6dcca0f58b 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -17,7 +17,30 @@ fr: producers: Producteurs & hubs producers_join: Les producteurs et autres hubs basés en France sont invités à rejoindre Open Food France. charges_sales_tax: Soumis à la TVA? - print: "Imprimer" + print_invoice: "Imprimer la facture" + send_invoice: "Envoyer la facture" + resend_confirmation: "Renvoyer la confirmation" + view_order: "Voir la commande" + edit_order: "Editer la commande" + ship_order: "Envoyer la commande" + cancel_order: "Annuler la commande" + confirm_send_invoice: "La facture de cette commande va être transmise au client. Etes-vous sûr de vouloir continuer ?" + confirm_resend_order_confirmation: "Etes-vous sûr de vouloir renvoyer le mail de confirmation de commande ?" + must_have_valid_business_number: "%{enterprise_name} doit avoir un SIRET valide avant que les factures puissent être envoyées." + invoice: "Facture" + percentage_of_sales: "%{percentage} des ventes" + percentage_of_turnover: "Pourcentage du chiffre d'affaire" + monthly_cap_excl_tax: "Cumul mensuel (sans TVA)" + capped_at_cap: "plafonné à %{cap}" + per_month: "par mois" + free: "gratuit" + plus_tax: "plus TVA" + total_monthly_bill_incl_tax: "Facture mensuelle totale (taxes incluses)" + sort_order_cycles_on_shopfront_by: "Trier les cycles de vente par" + invoice_column_item: "Produit" + invoice_column_qty: "Qté" + invoice_column_tax: "TVA" + invoice_column_price: "Prix" logo: "Logo (640x130)" logo_mobile: "Logo smartphone (75x26)" logo_mobile_svg: "Logo smartphone (SVG)" @@ -34,7 +57,6 @@ fr: footer_links_md: "Liens" footer_about_url: "A propos URL" footer_tos_url: "Conditions d'utilisation URL" - invoice: "Facture" name: Nom first_name: Prénom last_name: Nom de famille @@ -210,7 +232,7 @@ fr: email_payment_paid: RÉGLÉ email_payment_not_paid: NON RÉGLÉ email_payment_summary: Résumé du paiement - email_payment_method: "Payé via:" + email_payment_method: "Payer via :" email_shipping_delivery_details: Détails de livraison email_shipping_delivery_time: "Livré le:" email_shipping_delivery_address: "Adresse de livraison:" @@ -576,4 +598,4 @@ fr: fundraising_fee: "Frais recherche de financement" price_graph: "Légende détail du prix" included_tax: "Inclut TVA" - remove_tax: "Afficher prix HT" + remove_tax: "Retirer TVA" diff --git a/config/locales/nb.yml b/config/locales/nb.yml index 079ef67eb9..d9e29a0f28 100644 --- a/config/locales/nb.yml +++ b/config/locales/nb.yml @@ -17,7 +17,30 @@ nb: producers: Norske Produsenter producers_join: Norske produsenter er nå velkommen til å bli med i Open Food Network. charges_sales_tax: MVA-pliktig? - print: "Print" + print_invoice: "Skriv ut Faktura" + send_invoice: "Send Faktura" + resend_confirmation: "Send Bekreftelse på nytt" + view_order: "Se Bestilling" + edit_order: "Rediger Bestilling" + ship_order: "Send Bestilling" + cancel_order: "Avbryt Bestilling" + confirm_send_invoice: "En faktura for denne bestillingen vil bli sendt til kunden. Er du sikker på at du vil fortsette?" + confirm_resend_order_confirmation: "Er du sikker på at du vil sende ordrebekreftelse via epost på nytt?" + must_have_valid_business_number: "%{enterprise_name} må ha et gyldig ORG nr. før fakturaer kan sendes." + invoice: "Faktura" + percentage_of_sales: "%{percentage} av handel" + percentage_of_turnover: "Prosent av omsetning" + monthly_cap_excl_tax: "månedlig tak (eks. MVA)" + capped_at_cap: "tak på %{cap}" + per_month: "pr. måned" + free: "gratis" + plus_tax: "pluss MVA" + total_monthly_bill_incl_tax: "Total månedlig regning (Inkl. Avgift)" + sort_order_cycles_on_shopfront_by: "Sorter Bestillingsrunder i Nettbutikk etter" + invoice_column_item: "Vare" + invoice_column_qty: "Mengde" + invoice_column_tax: "MVA" + invoice_column_price: "Pris" logo: "Logo (640x130)" logo_mobile: "Mobil logo (75x26)" logo_mobile_svg: "Mobil logo (SVG)" @@ -34,7 +57,6 @@ nb: footer_links_md: "Linker" footer_about_url: "Om URL" footer_tos_url: "Vilkår URL" - invoice: "Faktura" name: Navn first_name: Fornavn last_name: Etternavn @@ -575,4 +597,4 @@ nb: fundraising_fee: "Pengeinnsamlingsgebyr" price_graph: "Prisgraf" included_tax: "inkludert avgift" - remove_tax: "Fjern MVA" + remove_tax: "Fjern avgift" From 4feb7c893bfd90eb36fd49ee757b75f8b23d22c6 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 24 Feb 2016 15:14:07 +1100 Subject: [PATCH 04/11] Introduce contact email address for enterprises Add a new column email_address to enterprises. Use this new field for public display of contact details. The old field enterprise.email is still used internally. It is still displayed on orders and emails sent to customers. A new enterprise has the owner's email address by default now. Fix GH #757 --- .../templates/partials/contact.html.haml | 8 +++--- .../templates/registration/contact.html.haml | 13 --------- app/models/enterprise.rb | 5 ++++ app/serializers/api/enterprise_serializer.rb | 6 ++--- .../admin/enterprises/_new_form.html.haml | 8 ++---- .../admin/enterprises/form/_contact.html.haml | 18 ++----------- .../admin/enterprises/form/_users.html.haml | 27 +++++++++++++++++++ app/views/json/partials/_enterprise.rabl | 4 +-- .../order_cycles/_orders_closed.html.haml | 2 +- app/views/producers/_fat.html.haml | 8 +++--- app/views/shopping_shared/_contact.html.haml | 8 +++--- ...044930_add_email_address_to_enterprises.rb | 5 ++++ ...0212092908_set_enterprise_email_address.rb | 8 ++++++ db/schema.rb | 3 ++- 14 files changed, 69 insertions(+), 54 deletions(-) create mode 100644 db/migrate/20160205044930_add_email_address_to_enterprises.rb create mode 100644 db/migrate/20160212092908_set_enterprise_email_address.rb diff --git a/app/assets/javascripts/templates/partials/contact.html.haml b/app/assets/javascripts/templates/partials/contact.html.haml index bdde30b8bb..12aa5ff061 100644 --- a/app/assets/javascripts/templates/partials/contact.html.haml +++ b/app/assets/javascripts/templates/partials/contact.html.haml @@ -1,11 +1,11 @@ %div.contact-container{bindonce: true} - %div.modal-centered{"bo-if" => "enterprise.email || enterprise.website || enterprise.phone"} + %div.modal-centered{"bo-if" => "enterprise.email_address || enterprise.website || enterprise.phone"} %p.modal-header {{'contact' | t}} %p{"bo-if" => "enterprise.phone", "bo-text" => "enterprise.phone"} - %p.word-wrap{"ng-if" => "enterprise.email"} - %a{"bo-href" => "enterprise.email | stripUrl", target: "_blank", mailto: true} - %span.email{"bo-bind" => "enterprise.email | stripUrl"} + %p.word-wrap{"ng-if" => "enterprise.email_address"} + %a{"bo-href" => "enterprise.email_address | stripUrl", target: "_blank", mailto: true} + %span.email{"bo-bind" => "enterprise.email_address | stripUrl"} %p.word-wrap{"ng-if" => "enterprise.website"} %a{"bo-href-i" => "http://{{enterprise.website | stripUrl}}", target: "_blank", "bo-bind" => "enterprise.website | stripUrl"} diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index b2a2164910..6e7389d73a 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -26,19 +26,6 @@ %label{ for: 'enterprise_phone' } {{'enterprise_phone' | t}}: %input.chunky.small-12.columns{ id: 'enterprise_phone', name: 'phone', placeholder: "eg. (03) 1234 5678", ng: { model: 'enterprise.phone' } } .small-12.medium-12.large-5.hide-for-small-only - / %h6 - / Contact display - / %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your contact details on the Open Food Network."} - / .row - / .small-12.columns - / %label.indent-checkbox - / %input{ type: 'checkbox', id: 'contact_name_profile', ng: { model: 'enterprise.name_in_profile' } }   Display name in profile - / .small-12.columns - / %label.indent-checkbox - / %input{ type: 'checkbox', id: 'contact_email_profile', ng: { model: 'enterprise.email_in_profile' } }   Display email in profile - / .small-12.columns - / %label.indent-checkbox - / %input{ type: 'checkbox', id: 'contact_phone_profile', ng: { model: 'enterprise.phone_in_profile' } }   Display phone in profile .row.buttons .small-12.columns diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 34a5d22f5b..033b4b79d7 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -75,6 +75,7 @@ class Enterprise < ActiveRecord::Base before_validation :initialize_permalink, if: lambda { permalink.nil? } before_validation :ensure_owner_is_manager, if: lambda { owner_id_changed? && !owner_id.nil? } + before_validation :ensure_email_set before_validation :set_unused_address_fields after_validation :geocode_address @@ -395,6 +396,10 @@ class Enterprise < ActiveRecord::Base users << owner unless users.include?(owner) || owner.admin? end + def ensure_email_set + self.email = owner.email if email.blank? + end + def enforce_ownership_limit unless owner.can_own_more_enterprises? errors.add(:owner, "^#{owner.email} is not permitted to own any more enterprises (limit is #{owner.enterprise_limit}).") diff --git a/app/serializers/api/enterprise_serializer.rb b/app/serializers/api/enterprise_serializer.rb index 287ebfe872..3210c1d2af 100644 --- a/app/serializers/api/enterprise_serializer.rb +++ b/app/serializers/api/enterprise_serializer.rb @@ -41,7 +41,7 @@ class Api::CachedEnterpriseSerializer < ActiveModel::Serializer attributes :name, :id, :description, :latitude, :longitude, :long_description, :website, :instagram, :linkedin, :twitter, :facebook, :is_primary_producer, :is_distributor, :phone, :visible, - :email, :hash, :logo, :promo_image, :path, :pickup, :delivery, + :email_address, :hash, :logo, :promo_image, :path, :pickup, :delivery, :icon, :icon_font, :producer_icon_font, :category, :producers, :hubs attributes :taxons, :supplied_taxons @@ -67,8 +67,8 @@ class Api::CachedEnterpriseSerializer < ActiveModel::Serializer services ? services[:delivery] : false end - def email - object.email.to_s.reverse + def email_address + object.email_address.to_s.reverse end def hash diff --git a/app/views/admin/enterprises/_new_form.html.haml b/app/views/admin/enterprises/_new_form.html.haml index 3ab9392712..fbb5a6efc1 100644 --- a/app/views/admin/enterprises/_new_form.html.haml +++ b/app/views/admin/enterprises/_new_form.html.haml @@ -50,13 +50,9 @@ = f.text_field :contact, { placeholder: "eg. Gustav Plum"} .row .alpha.three.columns - = f.label :email + = f.label :email_address .omega.nine.columns - = f.text_field :email, { placeholder: "eg. gustav@truffles.com", "ng-model" => "Enterprise.email" } - .alert-box - %i.icon-info-sign - If we don't recognise this email address we'll send you a confirmation email to make sure it belongs to you. You'll need to use the link in the email we send to fully activate your new enterprise. - %a.close{ href: "" } × + = f.text_field :email_address, { placeholder: "eg. gustav@truffles.com", "ng-model" => "Enterprise.email_address" } .row .alpha.three.columns = f.label :phone diff --git a/app/views/admin/enterprises/form/_contact.html.haml b/app/views/admin/enterprises/form/_contact.html.haml index df28b6a921..28bbd6014b 100644 --- a/app/views/admin/enterprises/form/_contact.html.haml +++ b/app/views/admin/enterprises/form/_contact.html.haml @@ -1,11 +1,3 @@ --if @enterprise.pending_any_confirmation? - .alert-box - - email = @enterprise.confirmed? ? @enterprise.unconfirmed_email : @enterprise.email - Email confirmation is pending. - We've sent a confirmation email to - %strong= "#{email}." - = link_to('Resend', main_app.enterprise_confirmation_path(enterprise: { id: @enterprise.id, email: email } ), method: :post) - %a.close{ href: "#" } × .row .alpha.three.columns = f.label :contact, 'Name' @@ -13,15 +5,9 @@ = f.text_field :contact, { placeholder: "eg. Gustav Plum"} .row .alpha.three.columns - = f.label :email - %span.required * + = f.label :email_address .omega.eight.columns - = f.text_field :email, { placeholder: "eg. gustav@truffles.com", "ng-model" => "Enterprise.email" } -.row{ ng: { hide: "pristineEmail == null || pristineEmail == Enterprise.email"} } - .alpha.three.columns -   - .omega.eight.columns - Note: A new email address may need to be confirmed prior to use + = f.text_field :email_address, { placeholder: "eg. gustav@truffles.com" } .row .alpha.three.columns = f.label :phone diff --git a/app/views/admin/enterprises/form/_users.html.haml b/app/views/admin/enterprises/form/_users.html.haml index 289a85d7a1..42e25fad0a 100644 --- a/app/views/admin/enterprises/form/_users.html.haml +++ b/app/views/admin/enterprises/form/_users.html.haml @@ -1,6 +1,15 @@ - owner_email = @enterprise.andand.owner.andand.email || "" - full_permissions = (spree_current_user.admin? || spree_current_user == @enterprise.andand.owner) +-if @enterprise.pending_any_confirmation? + .alert-box + - email = @enterprise.confirmed? ? @enterprise.unconfirmed_email : @enterprise.email + Email confirmation is pending. + We've sent a confirmation email to + %strong= "#{email}." + = link_to('Resend', main_app.enterprise_confirmation_path(enterprise: { id: @enterprise.id, email: email } ), method: :post) + %a.close{ href: "#" } × + .row .three.columns.alpha =f.label :owner_id, 'Owner' @@ -14,6 +23,24 @@ - else = owner_email +.row + .three.columns.alpha + = f.label :email, 'Notifications' + - if full_permissions + %span.required * + .with-tip{'data-powertip' => "Notifications about orders will be send to this email address."} + %a What's this? + .eight.columns.omega + - if full_permissions + = f.text_field :email, { placeholder: "eg. gustav@truffles.com", "ng-model" => "Enterprise.email" } + - else + = @enterprise.email +.row{ ng: { hide: "pristineEmail == null || pristineEmail == Enterprise.email"} } + .alpha.three.columns +   + .omega.eight.columns + Note: A new email address may need to be confirmed prior to use + .row .three.columns.alpha =f.label :user_ids, 'Managers' diff --git a/app/views/json/partials/_enterprise.rabl b/app/views/json/partials/_enterprise.rabl index 6e17cf3c58..ca99b9d14c 100644 --- a/app/views/json/partials/_enterprise.rabl +++ b/app/views/json/partials/_enterprise.rabl @@ -1,7 +1,7 @@ attributes :name, :id, :description, :latitude, :longitude, :long_description, :website, :instagram, :linkedin, :twitter, :facebook, :is_primary_producer, :is_distributor, :phone -node :email do |enterprise| - enterprise.email.to_s.reverse +node :email_address do |enterprise| + enterprise.email_address.to_s.reverse end child :address do diff --git a/app/views/order_cycles/_orders_closed.html.haml b/app/views/order_cycles/_orders_closed.html.haml index ae0568ae2d..782c680add 100644 --- a/app/views/order_cycles/_orders_closed.html.haml +++ b/app/views/order_cycles/_orders_closed.html.haml @@ -12,6 +12,6 @@ = t :ocs_closed_opens, time: distance_of_time_in_words_to_now(next_oc.orders_open_at) %p - = t(:ocs_closed_email, email: current_distributor.email) if current_distributor.email + = t(:ocs_closed_email, email: current_distributor.email_address) if current_distributor.email_address %br/ = t(:ocs_closed_phone, phone: current_distributor.phone) if current_distributor.phone diff --git a/app/views/producers/_fat.html.haml b/app/views/producers/_fat.html.haml index c1de090978..9faa239c02 100644 --- a/app/views/producers/_fat.html.haml +++ b/app/views/producers/_fat.html.haml @@ -23,7 +23,7 @@ %div.show-for-medium-up{"ng-if" => "producer.supplied_taxons.length==0"}   - %div{"bo-if" => "producer.email || producer.website || producer.phone"} + %div{"bo-if" => "producer.email_address || producer.website || producer.phone"} %label = t :producers_contact @@ -31,9 +31,9 @@ = t :producers_contact_phone %span{"bo-text" => "producer.phone"} - %p.word-wrap{"bo-if" => "producer.email"} - %a{"bo-href" => "producer.email | stripUrl", target: "_blank", mailto: true} - %span.email{"bo-bind" => "producer.email | stripUrl"} + %p.word-wrap{"bo-if" => "producer.email_address"} + %a{"bo-href" => "producer.email_address | stripUrl", target: "_blank", mailto: true} + %span.email{"bo-bind" => "producer.email_address | stripUrl"} %p.word-wrap{"bo-if" => "producer.website"} %a{"bo-href-i" => "http://{{producer.website | stripUrl}}", target: "_blank" } diff --git a/app/views/shopping_shared/_contact.html.haml b/app/views/shopping_shared/_contact.html.haml index a88c421270..100d64d958 100644 --- a/app/views/shopping_shared/_contact.html.haml +++ b/app/views/shopping_shared/_contact.html.haml @@ -18,7 +18,7 @@ = current_distributor.address.zipcode .small-12.large-4.columns - - if current_distributor.website || current_distributor.email + - if current_distributor.website || current_distributor.email_address %div.center .header = t :shopping_contact_web @@ -27,10 +27,10 @@ %a{href: "http://#{current_distributor.website}", target: "_blank" } = current_distributor.website %br - - unless current_distributor.email.blank? - %a{href: current_distributor.email.reverse, mailto: true} + - unless current_distributor.email_address.blank? + %a{href: current_distributor.email_address.reverse, mailto: true} %span.email - = current_distributor.email.reverse + = current_distributor.email_address.reverse .small-12.large-4.columns - if current_distributor.twitter.present? || current_distributor.facebook.present? || current_distributor.linkedin.present? || current_distributor.instagram.present? diff --git a/db/migrate/20160205044930_add_email_address_to_enterprises.rb b/db/migrate/20160205044930_add_email_address_to_enterprises.rb new file mode 100644 index 0000000000..b1047fe4b8 --- /dev/null +++ b/db/migrate/20160205044930_add_email_address_to_enterprises.rb @@ -0,0 +1,5 @@ +class AddEmailAddressToEnterprises < ActiveRecord::Migration + def change + add_column :enterprises, :email_address, :string + end +end diff --git a/db/migrate/20160212092908_set_enterprise_email_address.rb b/db/migrate/20160212092908_set_enterprise_email_address.rb new file mode 100644 index 0000000000..a43591624a --- /dev/null +++ b/db/migrate/20160212092908_set_enterprise_email_address.rb @@ -0,0 +1,8 @@ +class SetEnterpriseEmailAddress < ActiveRecord::Migration + def up + Enterprise.all.each do |enterprise| + enterprise.email_address = enterprise.email + enterprise.save + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 465530b949..57fbf4f52d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20151128185900) do +ActiveRecord::Schema.define(:version => 20160212092908) do create_table "account_invoices", :force => true do |t| t.integer "user_id", :null => false @@ -346,6 +346,7 @@ ActiveRecord::Schema.define(:version => 20151128185900) do t.boolean "producer_profile_only", :default => false t.string "permalink", :null => false t.boolean "charges_sales_tax", :default => false, :null => false + t.string "email_address" end add_index "enterprises", ["address_id"], :name => "index_enterprises_on_address_id" From a7e3b2d9dfca7e79af7dd23e2106d30582d42ab9 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 24 Feb 2016 16:21:18 +1100 Subject: [PATCH 05/11] Update enterprise email tests --- app/models/enterprise.rb | 2 +- spec/features/admin/enterprises_spec.rb | 6 +++--- spec/models/enterprise_spec.rb | 9 +++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 033b4b79d7..93cfcfe5df 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -397,7 +397,7 @@ class Enterprise < ActiveRecord::Base end def ensure_email_set - self.email = owner.email if email.blank? + self.email = owner.email if email.blank? && owner.present? end def enforce_ownership_limit diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index aed96b5a91..46a0105bb4 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -47,7 +47,7 @@ feature %q{ fill_in 'enterprise_contact', :with => 'Kirsten or Ren' fill_in 'enterprise_phone', :with => '0413 897 321' - fill_in 'enterprise_email', :with => 'info@eaterprises.com.au' + fill_in 'enterprise_email_address', :with => 'info@eaterprises.com.au' fill_in 'enterprise_website', :with => 'http://eaterprises.com.au' fill_in 'enterprise_address_attributes_address1', :with => '35 Ballantyne St' @@ -130,7 +130,7 @@ feature %q{ click_link "Contact" fill_in 'enterprise_contact', :with => 'Kirsten or Ren' fill_in 'enterprise_phone', :with => '0413 897 321' - fill_in 'enterprise_email', :with => 'info@eaterprises.com.au' + fill_in 'enterprise_email_address', :with => 'info@eaterprises.com.au' fill_in 'enterprise_website', :with => 'http://eaterprises.com.au' click_link "Social" @@ -286,7 +286,7 @@ feature %q{ click_link 'Enterprises' click_link 'New Enterprise' fill_in 'enterprise_name', with: 'zzz' - fill_in 'enterprise_email', with: 'bob@example.com' + fill_in 'enterprise_email_address', with: 'bob@example.com' fill_in 'enterprise_address_attributes_address1', with: 'z' fill_in 'enterprise_address_attributes_city', with: 'z' fill_in 'enterprise_address_attributes_zipcode', with: 'z' diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index 08c10dd31e..b8360094ec 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -180,7 +180,6 @@ describe Enterprise do describe "validations" do subject { FactoryGirl.create(:distributor_enterprise) } it { should validate_presence_of(:name) } - it { should validate_presence_of(:email) } it { should validate_uniqueness_of(:permalink) } it { should ensure_length_of(:description).is_at_most(255) } @@ -210,9 +209,15 @@ describe Enterprise do end it "does not prohibit the saving of an enterprise with no name clash" do - enterprise.email = 'new@email.com' enterprise.should be_valid end + + it "takes the owner's email address as default email" do + enterprise.email = nil + enterprise.should be_valid + enterprise.email.should be_present + enterprise.email.should eq owner.email + end end describe "preferred_shopfront_taxon_order" do From 098d3131636f0c869d49954787c03cf94344b64c Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 24 Feb 2016 16:33:31 +1100 Subject: [PATCH 06/11] Using `should` syntax in payment method spec --- spec/features/admin/payment_method_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/admin/payment_method_spec.rb b/spec/features/admin/payment_method_spec.rb index aa7caa2e0b..5c16f886e5 100644 --- a/spec/features/admin/payment_method_spec.rb +++ b/spec/features/admin/payment_method_spec.rb @@ -44,7 +44,7 @@ feature %q{ select2_select "PayPal Express", from: "payment_method_type" click_button 'Update' - expect(flash_message).to eq 'Payment Method has been successfully updated!' + flash_message.should eq 'Payment Method has been successfully updated!' payment_method = Spree::PaymentMethod.find_by_name('New PM Name') expect(payment_method.distributors).to include @distributors[1], @distributors[2] From 23a1c2a7723682a1fc802348625ae29ba3ff77ba Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 2 Mar 2016 10:40:45 +1100 Subject: [PATCH 07/11] Remove scroll bar from enterprise modal description Multiple scroll bars within a modal were confusing. The inner scroll bar for the long enterprise description got removed. The general modal scroll bar persists. Fix #806 Full profile modal about section copy display improvement --- app/assets/stylesheets/darkswarm/modal-enterprises.css.sass | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass b/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass index e0090ca163..e4724a13f5 100644 --- a/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass +++ b/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass @@ -62,10 +62,8 @@ // ABOUT Enterprise .about-container - max-height: 200px min-height: 20px margin-bottom: 0.5rem - overflow-y: scroll overflow-x: hidden border-bottom: 1px solid $light-grey @include box-shadow(0 2px 2px -2px $light-grey) From 6300f879872c1e87b9e405a0174999fd80d01e17 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 4 Mar 2016 10:23:13 +1100 Subject: [PATCH 08/11] Use have_no_selector in VO spec --- spec/features/admin/variant_overrides_spec.rb | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/spec/features/admin/variant_overrides_spec.rb b/spec/features/admin/variant_overrides_spec.rb index fe74d9eb2d..6f59b78aec 100644 --- a/spec/features/admin/variant_overrides_spec.rb +++ b/spec/features/admin/variant_overrides_spec.rb @@ -84,7 +84,7 @@ feature %q{ expect(page).to have_selector "#v_#{variant_related.id}" select2_select producer.name, from: 'producer_filter' expect(page).to have_selector "#v_#{variant.id}" - expect(page).to_not have_selector "#v_#{variant_related.id}" + expect(page).to have_no_selector "#v_#{variant_related.id}" select2_select 'All', from: 'producer_filter' # Filters based on the quick search box @@ -92,7 +92,7 @@ feature %q{ expect(page).to have_selector "#v_#{variant_related.id}" fill_in 'query', with: product.name expect(page).to have_selector "#v_#{variant.id}" - expect(page).to_not have_selector "#v_#{variant_related.id}" + expect(page).to have_no_selector "#v_#{variant_related.id}" fill_in 'query', with: '' # Clears the filters @@ -100,8 +100,8 @@ feature %q{ expect(page).to have_selector "tr#v_#{variant_related.id}" select2_select producer.name, from: 'producer_filter' fill_in 'query', with: product_related.name - expect(page).to_not have_selector "tr#v_#{variant.id}" - expect(page).to_not have_selector "tr#v_#{variant_related.id}" + expect(page).to have_no_selector "tr#v_#{variant.id}" + expect(page).to have_no_selector "tr#v_#{variant_related.id}" click_button 'Clear All' expect(page).to have_selector "tr#v_#{variant.id}" expect(page).to have_selector "tr#v_#{variant_related.id}" @@ -113,15 +113,15 @@ feature %q{ expect(page).to have_selector "tr#v_#{variant.id}" expect(page).to have_selector "tr#v_#{variant_related.id}" within "tr#v_#{variant.id}" do click_button 'Hide' end - expect(page).to_not have_selector "tr#v_#{variant.id}" + expect(page).to have_no_selector "tr#v_#{variant.id}" expect(page).to have_selector "tr#v_#{variant_related.id}" first("div#views-dropdown").click first("div#views-dropdown div.menu div.menu_item", text: "Hidden Products").click expect(page).to have_selector "tr#v_#{variant.id}" - expect(page).to_not have_selector "tr#v_#{variant_related.id}" + expect(page).to have_no_selector "tr#v_#{variant_related.id}" within "tr#v_#{variant.id}" do click_button 'Add' end - expect(page).to_not have_selector "tr#v_#{variant.id}" - expect(page).to_not have_selector "tr#v_#{variant_related.id}" + expect(page).to have_no_selector "tr#v_#{variant.id}" + expect(page).to have_no_selector "tr#v_#{variant_related.id}" first("div#views-dropdown").click first("div#views-dropdown div.menu div.menu_item", text: "Inventory Products").click expect(page).to have_selector "tr#v_#{variant.id}" @@ -319,8 +319,8 @@ feature %q{ end it "alerts the user to the presence of new products, and allows them to be added or hidden" do - expect(page).to_not have_selector "table#variant-overrides tr#v_#{variant1.id}" - expect(page).to_not have_selector "table#variant-overrides tr#v_#{variant2.id}" + expect(page).to have_no_selector "table#variant-overrides tr#v_#{variant1.id}" + expect(page).to have_no_selector "table#variant-overrides tr#v_#{variant2.id}" expect(page).to have_selector '.alert-row span.message', text: "There are 1 new products available to add to your inventory." click_button "Review Now" @@ -330,17 +330,17 @@ feature %q{ expect(page).to have_selector "table#new-products tr#v_#{variant2.id}" within "table#new-products tr#v_#{variant1.id}" do click_button 'Add' end within "table#new-products tr#v_#{variant2.id}" do click_button 'Hide' end - expect(page).to_not have_selector "table#new-products tr#v_#{variant1.id}" - expect(page).to_not have_selector "table#new-products tr#v_#{variant2.id}" + expect(page).to have_no_selector "table#new-products tr#v_#{variant1.id}" + expect(page).to have_no_selector "table#new-products tr#v_#{variant2.id}" click_button "Back to my inventory" expect(page).to have_selector "table#variant-overrides tr#v_#{variant1.id}" - expect(page).to_not have_selector "table#variant-overrides tr#v_#{variant2.id}" + expect(page).to have_no_selector "table#variant-overrides tr#v_#{variant2.id}" first("div#views-dropdown").click first("div#views-dropdown div.menu div.menu_item", text: "Hidden Products").click - expect(page).to_not have_selector "table#hidden-products tr#v_#{variant1.id}" + expect(page).to have_no_selector "table#hidden-products tr#v_#{variant1.id}" expect(page).to have_selector "table#hidden-products tr#v_#{variant2.id}" end end From 28e2d4041f8a359f645004b6c0c989ba2d483099 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 4 Mar 2016 14:24:24 +1100 Subject: [PATCH 09/11] Hide create-enterprise-group button from non-admins Only admin users can create groups. The button was still displayed for users that owned a group. Unused HTML attributes were removed from that button as well. --- app/views/admin/enterprise_groups/index.html.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/admin/enterprise_groups/index.html.haml b/app/views/admin/enterprise_groups/index.html.haml index 13bc19e364..e78dadc72c 100644 --- a/app/views/admin/enterprise_groups/index.html.haml +++ b/app/views/admin/enterprise_groups/index.html.haml @@ -1,9 +1,9 @@ = content_for :page_title do Enterprise Groups -= content_for :page_actions do - %li#new_enterprise_group_link - = button_link_to "New Enterprise Group", main_app.new_admin_enterprise_group_path, :icon => 'add', :id => 'admin_new_enterprise_group_link' +- if admin_user? + = content_for :page_actions do + %li= button_link_to "New Enterprise Group", main_app.new_admin_enterprise_group_path %table.index#listing_enterprise_groups %thead From c1647ccd2cd1efa58a20e8a09f968d6cb55898db Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 4 Mar 2016 17:50:04 +1100 Subject: [PATCH 10/11] Set public enterprise.email_address at registration Sets the public email address to the given email address as well as the internal enterprise.email (notification email address). The field is not mandatory any more since enterprise.email is populated from the owner's email address if no value was given. --- .../services/enterprise_registration_service.js.coffee | 3 ++- .../javascripts/templates/registration/contact.html.haml | 6 ++---- config/locales/en.yml | 3 +-- spec/features/consumer/registration_spec.rb | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee index 102da60f19..68c2d74391 100644 --- a/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee @@ -2,7 +2,7 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService, new class EnterpriseRegistrationService enterprise: user_ids: [CurrentUser.id] - email: CurrentUser.email + email_address: CurrentUser.email address: {} country: availableCountries[0] @@ -55,6 +55,7 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService, excluded = [ 'address', 'country', 'id' ] for key, value of @enterprise when key not in excluded enterprise[key] = value + enterprise.email = enterprise.email_address enterprise.address_attributes = @enterprise.address if @enterprise.address? enterprise.address_attributes.country_id = @enterprise.country.id if @enterprise.country? enterprise diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index 6e7389d73a..a22b0677a7 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -17,10 +17,8 @@ {{'enterprise_contact_required' | t}} .row .small-12.columns.field - %label{ for: 'enterprise_email' } {{'enterprise_email' | t}}: - %input.chunky.small-12.columns{ id: 'enterprise_email', name: 'email', type: 'email', required: true, placeholder: "eg. charlie@thefarm.com", ng: { model: 'enterprise.email' } } - %span.error.small-12.columns{ ng: { show: "(contact.email.$error.email || contact.email.$error.required) && submitted" } } - {{'enterprise_email_required' | t}} + %label{ for: 'enterprise_email_address' } {{'enterprise_email_address' | t}}: + %input.chunky.small-12.columns{ id: 'enterprise_email_address', name: 'email_address', type: 'email', placeholder: "eg. charlie@thefarm.com", ng: { model: 'enterprise.email_address' } } .row .small-12.columns.field %label{ for: 'enterprise_phone' } {{'enterprise_phone' | t}}: diff --git a/config/locales/en.yml b/config/locales/en.yml index 7603457981..323288edc2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -602,8 +602,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using who_is_managing_enterprise: "Who is responsible for managing %{enterprise}?" enterprise_contact: "Primary Contact" enterprise_contact_required: "You need to enter a primary contact." - enterprise_email: "Email address" - enterprise_email_required: "You need to enter valid email address." + enterprise_email_address: "Email address" enterprise_phone: "Phone number" back: "Back" continue: "Continue" diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index d36cd48f7d..0e54011f1c 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -38,7 +38,7 @@ feature "Registration", js: true do # Filling in Contact Details expect(page).to have_content 'Who is responsible for managing My Awesome Enterprise?' fill_in 'enterprise_contact', with: 'Saskia Munroe' - page.should have_field 'enterprise_email', with: user.email + page.should have_field 'enterprise_email_address', with: user.email fill_in 'enterprise_phone', with: '12 3456 7890' click_button 'Continue' From 61fb34e738276dd2a5d431d68a9b56a4922cdf69 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 9 Mar 2016 14:52:52 +1100 Subject: [PATCH 11/11] Use user's email address as enterprise.email During registration, use the given email address only as public visible profile email address. Set the internal notification email address `enterprise.email` to the owner's email address. That can be changed later. --- .../darkswarm/services/enterprise_registration_service.js.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee index 68c2d74391..a7d6a657fa 100644 --- a/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee @@ -55,7 +55,6 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService, excluded = [ 'address', 'country', 'id' ] for key, value of @enterprise when key not in excluded enterprise[key] = value - enterprise.email = enterprise.email_address enterprise.address_attributes = @enterprise.address if @enterprise.address? enterprise.address_attributes.country_id = @enterprise.country.id if @enterprise.country? enterprise