From 0c99007323b285db28c6ed0ebf964743c814a6c1 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 26 Sep 2014 17:45:15 +1000 Subject: [PATCH 01/48] Tweak the modal styling for register modals --- .../darkswarm/directives/registration_limit_modal.js.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/darkswarm/directives/registration_limit_modal.js.coffee b/app/assets/javascripts/darkswarm/directives/registration_limit_modal.js.coffee index 1fecfbf804..2b38b3d31f 100644 --- a/app/assets/javascripts/darkswarm/directives/registration_limit_modal.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/registration_limit_modal.js.coffee @@ -3,7 +3,7 @@ Darkswarm.directive "ofnRegistrationLimitModal", (Navigation, $modal, Loading) - link: (scope, elem, attr)-> scope.modalInstance = $modal.open templateUrl: 'registration/limit_reached.html' - windowClass: "login-modal large" + windowClass: "login-modal register-modal xlarge" backdrop: 'static' scope.modalInstance.result.then scope.close, scope.close From 83f9867632c85a2ba5ad0f19b6e636816806213d Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 9 Oct 2014 13:15:19 +1100 Subject: [PATCH 02/48] Move registration login into own folder, reinstate ofn-inline-alert --- .../{ => registration}/registration_controller.js.coffee | 0 .../{ => registration}/registration_form_controller.js.coffee | 0 .../directives/{inline_flash.js.coffee => inline_alert.js.coffee} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename app/assets/javascripts/darkswarm/controllers/{ => registration}/registration_controller.js.coffee (100%) rename app/assets/javascripts/darkswarm/controllers/{ => registration}/registration_form_controller.js.coffee (100%) rename app/assets/javascripts/darkswarm/directives/{inline_flash.js.coffee => inline_alert.js.coffee} (100%) diff --git a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration/registration_controller.js.coffee similarity index 100% rename from app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee rename to app/assets/javascripts/darkswarm/controllers/registration/registration_controller.js.coffee diff --git a/app/assets/javascripts/darkswarm/controllers/registration_form_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration/registration_form_controller.js.coffee similarity index 100% rename from app/assets/javascripts/darkswarm/controllers/registration_form_controller.js.coffee rename to app/assets/javascripts/darkswarm/controllers/registration/registration_form_controller.js.coffee diff --git a/app/assets/javascripts/darkswarm/directives/inline_flash.js.coffee b/app/assets/javascripts/darkswarm/directives/inline_alert.js.coffee similarity index 100% rename from app/assets/javascripts/darkswarm/directives/inline_flash.js.coffee rename to app/assets/javascripts/darkswarm/directives/inline_alert.js.coffee From 49c8e2f8cba89f0207b7d24a78178bf7bddda713 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 9 Oct 2014 13:16:09 +1100 Subject: [PATCH 03/48] Remove used styling for inline flash --- .../darkswarm/registration.css.sass | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index 3261fc0fd4..547f834406 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -16,24 +16,6 @@ .buttons - ofn-inline-flash - display: block - padding: 15px - position: relative - margin-bottom: 10px - &.brick - background-color: $clr-brick-light - border: 2px solid $clr-brick - color: $clr-brick - &.turquoise - background-color: $clr-turquoise-light - border: 2px solid $clr-turquoise - color: $clr-turquoise - .close-button - position: absolute - top: 0px - right: 0px - .field margin-bottom: 15px From 31c4aad9e167ef5241d7df1e80a66b4083f25399 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 9 Oct 2014 13:21:30 +1100 Subject: [PATCH 04/48] JS for closing alerts works --- .../darkswarm/directives/inline_alert.js.coffee | 13 +++++++------ .../templates/registration/about.html.haml | 9 ++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/darkswarm/directives/inline_alert.js.coffee b/app/assets/javascripts/darkswarm/directives/inline_alert.js.coffee index 46550b854f..9b37934375 100644 --- a/app/assets/javascripts/darkswarm/directives/inline_alert.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/inline_alert.js.coffee @@ -1,6 +1,7 @@ -Darkswarm.directive "ofnInlineFlash", -> - restrict: 'E' - controller: ($scope) -> - $scope.visible = true - $scope.closeFlash = -> - $scope.visible = false +Darkswarm.directive "ofnInlineAlert", -> + restrict: 'A' + scope: true + link: (scope, elem, attrs) -> + scope.visible = true + scope.close = -> + scope.visible = false diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index d014c96d90..704a7e3815 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -12,13 +12,12 @@ %form{ name: 'about', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "update('images',about)" } } .row .small-12.columns - .alert-box.alert{"data-alert" => ""} + .alert-box.alert{ "ofn-inline-alert" => true, ng: { show: "visible" } } {{ enterprise.name }} won't be visible on the Open Food Network until you enter a long and short description. - %a.close{:href => "#"} × - - .alert-box.info{"data-alert" => ""} + %a.close{ ng: { click: "close()" } } × + .alert-box.info{ "ofn-inline-alert" => true, ng: { show: "visible" } } {{ enterprise.name }} has been created on the Open Food Network. If you leave at any point from here onwards, your enterprise will be saved, and you can always login to the admin section to update or continue filling out your enterprise details. - %a.close{:href => "#"} × + %a.close{ ng: { click: "close()" } } × .small-12.large-8.columns .row From fc3a132c12fe31a34e75e3944868517999141129 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 9 Oct 2014 13:46:32 +1100 Subject: [PATCH 05/48] Closing auth dialog on pages other than home returns the user to home --- .../darkswarm/services/authentication_service.js.coffee | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/darkswarm/services/authentication_service.js.coffee b/app/assets/javascripts/darkswarm/services/authentication_service.js.coffee index 5f5ae520e3..f2d7049e67 100644 --- a/app/assets/javascripts/darkswarm/services/authentication_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/authentication_service.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.factory "AuthenticationService", (Navigation, $modal, $location, Redirections)-> +Darkswarm.factory "AuthenticationService", (Navigation, $modal, $location, Redirections, Loading)-> new class AuthenticationService selectedPath: "/login" @@ -25,4 +25,9 @@ Darkswarm.factory "AuthenticationService", (Navigation, $modal, $location, Redir active: Navigation.active close: -> - Navigation.navigate "/" + if location.pathname == "/" + Navigation.navigate "/" + else + Loading.message = "Taking you back to the home page" + location.hash = "" + location.pathname = "/" From d1e3f74c03149a9cd57de0c82cfa28a57c827cf0 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 9 Oct 2014 15:56:54 +1100 Subject: [PATCH 06/48] Add loading gif to image uploaders --- .../templates/registration/images/logo.html.haml | 8 ++++++-- .../templates/registration/images/promo.html.haml | 8 ++++++-- app/assets/stylesheets/darkswarm/registration.css.sass | 8 +++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/templates/registration/images/logo.html.haml b/app/assets/javascripts/templates/registration/images/logo.html.haml index 803b103a58..4b19c14cff 100644 --- a/app/assets/javascripts/templates/registration/images/logo.html.haml +++ b/app/assets/javascripts/templates/registration/images/logo.html.haml @@ -36,6 +36,10 @@ .row.pad-top .small-12.columns.center #image-placeholder.logo - %img{ ng: { show: "imageSrc()", src: '{{ imageSrc() }}' } } - .message{ ng: { hide: "imageSrc()" } } + %img{ ng: { show: "imageSrc() && !imageUploader.isUploading", src: '{{ imageSrc() }}' } } + .message{ ng: { hide: "imageSrc() || imageUploader.isUploading" } } Your logo will appear here for review once uploaded + .loading{ ng: { hide: "!imageUploader.isUploading" } } + %img.spinner{ src: "/assets/loading.gif" } + %br/ + Uploading... diff --git a/app/assets/javascripts/templates/registration/images/promo.html.haml b/app/assets/javascripts/templates/registration/images/promo.html.haml index f134834d5c..d98721dc6d 100644 --- a/app/assets/javascripts/templates/registration/images/promo.html.haml +++ b/app/assets/javascripts/templates/registration/images/promo.html.haml @@ -34,6 +34,10 @@ .row.pad-top .small-12.columns.center #image-placeholder.promo - %img{ ng: { show: "imageSrc()", src: '{{ imageSrc() }}' } } - .message{ ng: { hide: "imageSrc()" } } + %img{ ng: { show: "imageSrc() && !imageUploader.isUploading", src: '{{ imageSrc() }}' } } + .message{ ng: { hide: "imageSrc() || imageUploader.isUploading" } } Your logo will appear here for review once uploaded + .loading{ ng: { hide: "!imageUploader.isUploading" } } + %img.spinner{ src: "/assets/loading.gif" } + %br/ + Uploading... diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index 547f834406..707d5a93e7 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -92,19 +92,25 @@ font-size: 18px font-weight: bold color: #373737 - background-color: #e1e1e1 + background-color: #f1f1f1 text-align: center border: 3px dashed #494949 margin-left: auto margin-right: auto + .spinner + width: 100px &.logo .message padding-top: 6em + .loading + padding-top: 4em width: 306px height: 306px &.promo .message padding-top: 4em + .loading + padding-top: 1em width: 726px height: 166px From 9b275cc5f03825436572a462e843c4a82c980a21 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 9 Oct 2014 17:26:31 +1100 Subject: [PATCH 07/48] WIP: Shuffling around order of cards in registration --- .../registration_controller.js.coffee | 2 +- .../templates/registration/address.html.haml | 60 --------------- .../templates/registration/contact.html.haml | 9 ++- .../templates/registration/details.html.haml | 74 ++++++++++++------- .../templates/registration/steps.html.haml | 2 - .../templates/registration/type.html.haml | 42 +++++++++++ .../darkswarm/registration.css.sass | 2 +- spec/features/consumer/registration_spec.rb | 13 ++-- 8 files changed, 103 insertions(+), 101 deletions(-) delete mode 100644 app/assets/javascripts/templates/registration/address.html.haml create mode 100644 app/assets/javascripts/templates/registration/type.html.haml diff --git a/app/assets/javascripts/darkswarm/controllers/registration/registration_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration/registration_controller.js.coffee index 2fcc0f32fd..3be0378619 100644 --- a/app/assets/javascripts/darkswarm/controllers/registration/registration_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/registration/registration_controller.js.coffee @@ -3,7 +3,7 @@ Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, Enterpris $scope.enterprise = EnterpriseRegistrationService.enterprise $scope.select = RegistrationService.select - $scope.steps = ['details','address','contact','about','images','social'] + $scope.steps = ['details','contact','type','about','images','social'] $scope.countries = availableCountries diff --git a/app/assets/javascripts/templates/registration/address.html.haml b/app/assets/javascripts/templates/registration/address.html.haml deleted file mode 100644 index 6fe39e9285..0000000000 --- a/app/assets/javascripts/templates/registration/address.html.haml +++ /dev/null @@ -1,60 +0,0 @@ -.container#registration-address - .header - %h2 - Greetings - %span{ ng: { class: "{brick: enterprise.is_distributor, turquoise: !enterprise.is_distributor}" } } - {{ enterprise.name }} - - %h5 Now we need to know where you are - %ng-include{ src: "'registration/steps.html'" } - %form{ name: 'address', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "selectIfValid('contact',address)" } } - .row.content - .small-12.medium-12.large-7.columns - .row - .small-12.columns.field - %label{ for: 'enterprise_address' } Address: - %input.chunky.small-12.columns{ id: 'enterprise_address', name: 'address1', required: true, placeholder: "eg. 123 Cranberry Drive", required: true, ng: { model: 'enterprise.address.address1' } } - %span.error.small-12.columns{ ng: { show: "address.address1.$error.required && submitted" } } - You need to enter an address. - .row - .small-12.large-8.columns.field - %label{ for: 'enterprise_city' } Suburb: - %input.chunky.small-12.columns{ id: 'enterprise_city', name: 'city', required: true, placeholder: "eg. Northcote", ng: { model: 'enterprise.address.city' } } - %span.error.small-12.columns{ ng: { show: "address.city.$error.required && submitted" } } - You need to enter a suburb. - .small-12.large-4.columns.field - %label{ for: 'enterprise_zipcode' } Postcode: - %input.chunky.small-12.columns{ id: 'enterprise_zipcode', name: 'zipcode', required: true, placeholder: "eg. 3070", ng: { model: 'enterprise.address.zipcode' } } - %span.error.small-12.columns{ ng: { show: "address.zipcode.$error.required && submitted" } } - You need to enter a postcode. - .row - .small-12.large-8.columns.field - %label{ for: 'enterprise_country' } Country: - %select.chunky.small-12.columns{ id: 'enterprise_country', name: 'country', required: true, ng: { model: 'enterprise.country', options: 'c as c.name for c in countries' } } - %span.error.small-12.columns{ ng: { show: "address.country.$error.required && submitted" } } - You need to enter a country. - .small-12.large-4.columns.field - %label{ for: 'enterprise_state' } State: - %select.chunky.small-12.columns{ id: 'enterprise_state', name: 'state', ng: { model: 'enterprise.address.state_id', options: 's.id as s.abbr for s in enterprise.country.states', show: 'countryHasStates()', required: 'countryHasStates()' } } - %span.error.small-12.columns{ ng: { show: "address.state.$error.required && submitted" } } - You need to enter a state. - .small-12.medium-12.large-5.hide-for-small-only - // This is the location area - / %h6 - / Location display - / %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your enterprise's address on the Open Food Network. By default, full location is shown everywhere including street name and number."} - / .row - / .small-12.columns - / %label.indent-checkbox - / %input{ type: 'checkbox', id: 'enterpise_suburb_only', ng: { model: 'enterprise.suburb_only' } } - / Hide my street name and street number from the public (ie. only show the suburb) - / .small-12.columns - / %label.indent-checkbox - / %input{ type: 'checkbox', id: 'enterprise_on_map', ng: { model: 'enterprise.on_map' } } - / Blur my location on the map (show an approximate, not exact pin) - - .row.buttons - .small-12.columns - %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('details')" } } -   - %input.button.primary{ type: "submit", value: "Continue" } diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index c7262248d0..87272cdd5a 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -1,12 +1,12 @@ .container#registration-contact .header - %h2 Last step to create your enterprise! + %h2 Greetings! %h5 Who is responsible for managing - %span{ ng: { class: "{brick: enterprise.is_distributor, turquoise: !enterprise.is_distributor}" } } + %span.turquoise {{ enterprise.name }}? %ng-include{ src: "'registration/steps.html'" } - %form{ name: 'contact', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "create(contact)" } } + %form{ name: 'contact', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "selectIfValid('type',contact)" } } .row.content .small-12.medium-12.large-7.columns .row @@ -39,8 +39,9 @@ / .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 - %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('address')" } } + %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('details')" } }   %input.button.primary{ type: "submit", value: "Continue" } diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml index bb358a1864..a3ff0676c4 100644 --- a/app/assets/javascripts/templates/registration/details.html.haml +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -1,10 +1,10 @@ .container#registration-details{bindonce: true} .header %h2 Let's Get Started - %h5{ bo: { if: "enterprise.type != 'single'" } } Woot! First we need to know what sort of enterprise you are: - %h5{ bo: { if: "enterprise.type == 'single'" } } Woot! First we need to know the name of your farm: + %h5{ bo: { if: "enterprise.type != 'single'" } } Woot! First we need to know a little bit about your enterprise: + %h5{ bo: { if: "enterprise.type == 'single'" } } Woot! First we need to know a little bit about your farm: %ng-include{ src: "'registration/steps.html'" } - %form{ name: 'details', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "selectIfValid('address',details)" } } + %form{ name: 'details', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "selectIfValid('contact',details)" } } .row .small-12.columns.field %label{ for: 'enterprise_name', bo: { if: "enterprise.type != 'single'" } } Enterprise Name: @@ -12,31 +12,51 @@ %input.chunky.small-12.columns{ id: 'enterprise_name', name: 'name', placeholder: "eg. Charlie's Awesome Farm", required: true, ng: { model: 'enterprise.name' } } %span.error.small-12.columns{ ng: { show: "details.name.$error.required && submitted" } } You need to enter a name for your enterprise! + .row + .small-12.medium-12.large-7.columns + .row + .small-12.columns.field + %label{ for: 'enterprise_address' } Address: + %input.chunky.small-12.columns{ id: 'enterprise_address', name: 'address1', required: true, placeholder: "eg. 123 Cranberry Drive", required: true, ng: { model: 'enterprise.address.address1' } } + %span.error.small-12.columns{ ng: { show: "details.address1.$error.required && submitted" } } + You need to enter an address. + .row + .small-12.large-8.columns.field + %label{ for: 'enterprise_city' } Suburb: + %input.chunky.small-12.columns{ id: 'enterprise_city', name: 'city', required: true, placeholder: "eg. Northcote", ng: { model: 'enterprise.address.city' } } + %span.error.small-12.columns{ ng: { show: "details.city.$error.required && submitted" } } + You need to enter a suburb. + .small-12.large-4.columns.field + %label{ for: 'enterprise_zipcode' } Postcode: + %input.chunky.small-12.columns{ id: 'enterprise_zipcode', name: 'zipcode', required: true, placeholder: "eg. 3070", ng: { model: 'enterprise.address.zipcode' } } + %span.error.small-12.columns{ ng: { show: "details.zipcode.$error.required && submitted" } } + You need to enter a postcode. + .row + .small-12.large-8.columns.field + %label{ for: 'enterprise_country' } Country: + %select.chunky.small-12.columns{ id: 'enterprise_country', name: 'country', required: true, ng: { model: 'enterprise.country', options: 'c as c.name for c in countries' } } + %span.error.small-12.columns{ ng: { show: "details.country.$error.required && submitted" } } + You need to enter a country. + .small-12.large-4.columns.field + %label{ for: 'enterprise_state' } State: + %select.chunky.small-12.columns{ id: 'enterprise_state', name: 'state', ng: { model: 'enterprise.address.state_id', options: 's.id as s.abbr for s in enterprise.country.states', show: 'countryHasStates()', required: 'countryHasStates()' } } + %span.error.small-12.columns{ ng: { show: "details.state.$error.required && submitted" } } + You need to enter a state. + .small-12.medium-12.large-5.hide-for-small-only + // This is the location area + / %h6 + / Location display + / %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your enterprise's address on the Open Food Network. By default, full location is shown everywhere including street name and number."} + / .row + / .small-12.columns + / %label.indent-checkbox + / %input{ type: 'checkbox', id: 'enterpise_suburb_only', ng: { model: 'enterprise.suburb_only' } } + / Hide my street name and street number from the public (ie. only show the suburb) + / .small-12.columns + / %label.indent-checkbox + / %input{ type: 'checkbox', id: 'enterprise_on_map', ng: { model: 'enterprise.on_map' } } + / Blur my location on the map (show an approximate, not exact pin) - .row#enterprise-types{ 'data-equalizer' => true, bo: { if: "enterprise.type != 'single'" } } - .small-12.columns.field - .row - .small-12.columns - %label Choose one: - .row - .small-12.medium-4.large-4.columns{ 'data-equalizer-watch' => true } - %a.panel#producer-panel{ href: "#", ng: { click: "enterprise.is_distributor = false; enterprise.is_primary_producer = true", class: "{selected: (!enterprise.is_distributor && enterprise.is_primary_producer)}" } } - .left - / %render-svg{ path: "/assets/map-icon-producer.svg" } - %h4 I'm A Producer - %p Producers make yummy things to eat &/or drink. You're a producer if you grow it, raise it, brew it, bake it, ferment it, milk it or mould it. - .small-12.medium-4.large-4.columns{ 'data-equalizer-watch' => true } - %a.panel#hub-panel{ href: "#", ng: { click: "enterprise.is_distributor = true; enterprise.is_primary_producer = false", class: "{selected: (enterprise.is_distributor && !enterprise.is_primary_producer)}" } } - .left - / %render-svg{ path: "/assets/map-icon-hub.svg" } - %h4 I'm A Hub - %p Hubs connect the producer to the eater. Hubs can be co-ops, independent retailers, buying groups, wholesalers, CSA box schemes, farm-gate stalls, etc. - .small-12.medium-4.large-4.columns{ 'data-equalizer-watch' => true } - %a.panel#both-panel{ href: "#", ng: { click: "enterprise.is_distributor = true; enterprise.is_primary_producer = true", class: "{selected: (enterprise.is_distributor && enterprise.is_primary_producer)}" } } - .left - / %render-svg{path: "/assets/map-icon-both.svg"} - %h4 I'm Both - %p Hey there, Jack-of-all-trades! Not only do you produce things to eat &/or drink, you also want to sell your yummies through an Open Food Network shopfront. .row.buttons .small-12.columns %input.button.primary.right{ type: "submit", value: "Continue" } diff --git a/app/assets/javascripts/templates/registration/steps.html.haml b/app/assets/javascripts/templates/registration/steps.html.haml index 65e3cb6b48..8b420de293 100644 --- a/app/assets/javascripts/templates/registration/steps.html.haml +++ b/app/assets/javascripts/templates/registration/steps.html.haml @@ -1,5 +1,3 @@ .row#progress-bar .small-12.medium-2.columns.item{ ng: { repeat: 'step in steps', class: "{active: (currentStep() == step),'show-for-medium-up': (currentStep() != step)}" } } {{ $index+1 + ". " + step }} - - \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/type.html.haml b/app/assets/javascripts/templates/registration/type.html.haml new file mode 100644 index 0000000000..0834bf1528 --- /dev/null +++ b/app/assets/javascripts/templates/registration/type.html.haml @@ -0,0 +1,42 @@ +.container#registration-type{bindonce: true} + .header + %h2 + Last step to create your enterprise! + + %h5 + Is + %span{ ng: { class: "{brick: enterprise.is_distributor, turquoise: !enterprise.is_distributor}" } } + {{ enterprise.name }} + a primary producer? + %ng-include{ src: "'registration/steps.html'" } + %form{ name: 'type', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "create(type)" } } + .row#enterprise-types{ 'data-equalizer' => true, bo: { if: "enterprise.type != 'single'" } } + .small-12.columns.field + .row + .small-12.columns + %label Choose one: + .row + .small-12.medium-4.large-4.columns{ 'data-equalizer-watch' => true } + %a.panel#producer-panel{ href: "#", ng: { click: "enterprise.is_distributor = false; enterprise.is_primary_producer = true", class: "{selected: (!enterprise.is_distributor && enterprise.is_primary_producer)}" } } + .left + / %render-svg{ path: "/assets/map-icon-producer.svg" } + %h4 I'm A Producer + %p Producers make yummy things to eat &/or drink. You're a producer if you grow it, raise it, brew it, bake it, ferment it, milk it or mould it. + .small-12.medium-4.large-4.columns{ 'data-equalizer-watch' => true } + %a.panel#hub-panel{ href: "#", ng: { click: "enterprise.is_distributor = true; enterprise.is_primary_producer = false", class: "{selected: (enterprise.is_distributor && !enterprise.is_primary_producer)}" } } + .left + / %render-svg{ path: "/assets/map-icon-hub.svg" } + %h4 I'm A Hub + %p Hubs connect the producer to the eater. Hubs can be co-ops, independent retailers, buying groups, wholesalers, CSA box schemes, farm-gate stalls, etc. + .small-12.medium-4.large-4.columns{ 'data-equalizer-watch' => true } + %a.panel#both-panel{ href: "#", ng: { click: "enterprise.is_distributor = true; enterprise.is_primary_producer = true", class: "{selected: (enterprise.is_distributor && enterprise.is_primary_producer)}" } } + .left + / %render-svg{path: "/assets/map-icon-both.svg"} + %h4 I'm Both + %p Hey there, Jack-of-all-trades! Not only do you produce things to eat &/or drink, you also want to sell your yummies through an Open Food Network shopfront. + + .row.buttons + .small-12.columns + %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('contact')" } } +   + %input.button.primary{ type: "submit", value: "Continue" } diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index 707d5a93e7..08568007f2 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -115,7 +115,7 @@ height: 166px -#registration-details +#registration-type #enterprise-types a.panel display: block diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index 7ac46a8970..ebcea88a89 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -22,13 +22,10 @@ feature "Registration", js: true do expect(URI.parse(current_url).path).to eq registration_path # Done reading introduction - click_button_and_ensure_content "Let's get started!", "Woot! First we need to know what sort of enterprise you are:" + click_button_and_ensure_content "Let's get started!", "Woot! First we need to know a little bit about your enterprise:" # Filling in details fill_in 'enterprise_name', with: "My Awesome Enterprise" - click_link 'both-panel' - - click_button_and_ensure_content "Continue", "Greetings My Awesome Enterprise" # Filling in address fill_in 'enterprise_address', with: '123 Abc Street' @@ -45,6 +42,11 @@ feature "Registration", js: true do fill_in 'enterprise_phone', with: '12 3456 7890' click_button 'Continue' + # Choosing a type + expect(page).to have_content 'Last step to create your enterprise!' + click_link 'both-panel' + click_button 'Continue' + # Enterprise should be created expect(page).to have_content 'Nice one!' e = Enterprise.find_by_name('My Awesome Enterprise') @@ -109,10 +111,9 @@ feature "Registration", js: true do expect(URI.parse(current_url).path).to eq store_registration_path # Done reading introduction - click_button_and_ensure_content "Let's get started!", "Woot! First we need to know the name of your farm:" + click_button_and_ensure_content "Let's get started!", "Woot! First we need to know a little bit about your farm:" # Details Page - expect(page).to have_content "Woot! First we need to know the name of your farm:" expect(page).to_not have_selector '#enterprise-types' # Everything from here should be covered in 'profile' spec From d5ea2a0206c648a9098a0efc12250a47befbde7f Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 10 Oct 2014 15:40:05 +1100 Subject: [PATCH 08/48] Make Enterprise and EnterpriseGroup promo images jpg format --- app/models/enterprise.rb | 2 +- app/models/enterprise_group.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index dfb7945878..b5a89339ac 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -34,7 +34,7 @@ class Enterprise < ActiveRecord::Base path: 'public/images/enterprises/logos/:id/:style/:basename.:extension' has_attached_file :promo_image, - styles: { large: "1200x260#", medium: "720x156#", thumb: "100x100>" }, + styles: { large: ["1200x260#", :jpg], medium: ["720x156#", :jpg], thumb: ["100x100>", :jpg] }, url: '/images/enterprises/promo_images/:id/:style/:basename.:extension', path: 'public/images/enterprises/promo_images/:id/:style/:basename.:extension' diff --git a/app/models/enterprise_group.rb b/app/models/enterprise_group.rb index cdc9d9932a..6e61b1a564 100644 --- a/app/models/enterprise_group.rb +++ b/app/models/enterprise_group.rb @@ -15,7 +15,7 @@ class EnterpriseGroup < ActiveRecord::Base path: 'public/images/enterprise_groups/logos/:id/:style/:basename.:extension' has_attached_file :promo_image, - styles: {large: "1200x260#"}, + styles: {large: ["1200x260#", :jpg]}, url: '/images/enterprise_groups/promo_images/:id/:style/:basename.:extension', path: 'public/images/enterprise_groups/promo_images/:id/:style/:basename.:extension' From b8b19368dff6ac8908e3fec3d5616951d81c0fa8 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 10 Oct 2014 16:54:38 +1100 Subject: [PATCH 09/48] WIP: Making enterprise emails confirmable --- app/models/enterprise.rb | 2 ++ ...141010043405_add_confirmable_to_enterprise.rb | 16 ++++++++++++++++ db/schema.rb | 7 ++++++- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20141010043405_add_confirmable_to_enterprise.rb diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index dfb7945878..e5b92b0382 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -2,6 +2,8 @@ class Enterprise < ActiveRecord::Base TYPES = %w(full single profile) ENTERPRISE_SEARCH_RADIUS = 100 + devise :confirmable, reconfirmable: true + self.inheritance_column = nil acts_as_gmappable :process_geocoding => false diff --git a/db/migrate/20141010043405_add_confirmable_to_enterprise.rb b/db/migrate/20141010043405_add_confirmable_to_enterprise.rb new file mode 100644 index 0000000000..22203fe419 --- /dev/null +++ b/db/migrate/20141010043405_add_confirmable_to_enterprise.rb @@ -0,0 +1,16 @@ +class AddConfirmableToEnterprise < ActiveRecord::Migration + def up + add_column :enterprises, :confirmation_token, :string + add_column :enterprises, :confirmed_at, :datetime + add_column :enterprises, :confirmation_sent_at, :datetime + add_column :enterprises, :unconfirmed_email, :string + add_index :enterprises, :confirmation_token, :unique => true + + # Existing enterprises are assumed to be confirmed + Enterprise.update_all(:confirmed_at => Time.now) + end + + def down + remove_columns :enterprises, :confirmation_token, :confirmed_at, :confirmation_sent_at, :unconfirmed_email + end +end diff --git a/db/schema.rb b/db/schema.rb index 73f10210a7..ee364758d7 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 => 20140904003026) do +ActiveRecord::Schema.define(:version => 20141010043405) do create_table "adjustment_metadata", :force => true do |t| t.integer "adjustment_id" @@ -266,9 +266,14 @@ ActiveRecord::Schema.define(:version => 20140904003026) do t.string "linkedin" t.string "type", :default => "profile", :null => false t.integer "owner_id", :null => false + t.string "confirmation_token" + t.datetime "confirmed_at" + t.datetime "confirmation_sent_at" + t.string "unconfirmed_email" end add_index "enterprises", ["address_id"], :name => "index_enterprises_on_address_id" + add_index "enterprises", ["confirmation_token"], :name => "index_enterprises_on_confirmation_token", :unique => true add_index "enterprises", ["owner_id"], :name => "index_enterprises_on_owner_id" create_table "exchange_fees", :force => true do |t| From d4318263f600f0688bfebd4a68c28a059ff7a92b Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 10 Oct 2014 18:18:33 +1100 Subject: [PATCH 10/48] Registration modals styling WIP --- .../darkswarm/registration.css.sass | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index 08568007f2..b0d0757720 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -2,26 +2,25 @@ @import mixins #registration-modal - .header + header text-align: center - background-color: #efefef - padding-bottom: 1rem + // background-color: #efefef + @media all and (max-width: 64em) + text-align: left .container background-color: #ffffff - .content - // margin-bottom: 15px i font-size: 150% - .buttons - .field - margin-bottom: 15px + margin-bottom: 1em - input.chunky + .chunky padding: 8px - font-size: 105% + font-size: 1rem + margin: 0 + width: 100% label.indent-checkbox display: block @@ -33,9 +32,9 @@ label margin-bottom: 3px - ol, ul - // font-size: 80% + ol, ul, p font-size: 0.875rem + ol, ul padding: 0 margin: 0 ol @@ -44,22 +43,24 @@ .highlight-box background: white padding: 1rem 1.2rem - @media all and (max-width: 640px) + @media all and (max-width: 64em) margin-top: 1rem #progress-bar margin-bottom: 15px .item - padding: 12px 0px + font-size: 0.75rem + padding: 10px 0px text-transform: uppercase text-align: center - background-color: #333 - border: 2px solid #333 + background-color: $clr-blue + border: 2px solid $clr-blue color: #fff .item.active - background-color: #cccccc - border: 2px solid #333 - color: #333 + background-color: $disabled-light + border: 2px solid $clr-blue + color: $clr-blue + font-weight: 700 @include box-shadow(inset 0 0 1px 0 #fff) From 89a51bf1da9fafe86565906cb16bbe44830fb50f Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 10 Oct 2014 18:19:42 +1100 Subject: [PATCH 11/48] Adjustments to layout, responsive logic, simplify column structure --- .../templates/registration/details.html.haml | 116 ++++++++++-------- 1 file changed, 65 insertions(+), 51 deletions(-) diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml index a3ff0676c4..d4b0abc4f8 100644 --- a/app/assets/javascripts/templates/registration/details.html.haml +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -1,62 +1,76 @@ .container#registration-details{bindonce: true} - .header - %h2 Let's Get Started - %h5{ bo: { if: "enterprise.type != 'single'" } } Woot! First we need to know a little bit about your enterprise: - %h5{ bo: { if: "enterprise.type == 'single'" } } Woot! First we need to know a little bit about your farm: %ng-include{ src: "'registration/steps.html'" } + .row + .small-12.columns + %header + %h2 Let's Get Started + %h5{ bo: { if: "enterprise.type != 'single'" } } Woot! First we need to know a little bit about your enterprise: + %h5{ bo: { if: "enterprise.type == 'single'" } } Woot! First we need to know a little bit about your farm: + %form{ name: 'details', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "selectIfValid('contact',details)" } } + .row - .small-12.columns.field - %label{ for: 'enterprise_name', bo: { if: "enterprise.type != 'single'" } } Enterprise Name: - %label{ for: 'enterprise_name', bo: { if: "enterprise.type == 'single'" } } Farm Name: - %input.chunky.small-12.columns{ id: 'enterprise_name', name: 'name', placeholder: "eg. Charlie's Awesome Farm", required: true, ng: { model: 'enterprise.name' } } - %span.error.small-12.columns{ ng: { show: "details.name.$error.required && submitted" } } - You need to enter a name for your enterprise! + .small-12.medium-9.large-12.columns.end + .field + %label{ for: 'enterprise_name', bo: { if: "enterprise.type != 'single'" } } Enterprise Name: + %label{ for: 'enterprise_name', bo: { if: "enterprise.type == 'single'" } } Farm Name: + %input.chunky{ id: 'enterprise_name', name: 'name', placeholder: "e.g. Charlie's Awesome Farm", required: true, ng: { model: 'enterprise.name' } } + %span.error{ ng: { show: "details.name.$error.required && submitted" } } + Please choose a unique name for your enterprise + .row - .small-12.medium-12.large-7.columns + .small-12.medium-9.large-6.columns + .field + %label{ for: 'enterprise_address' } Address line 1: + %input.chunky{ id: 'enterprise_address', name: 'address1', required: true, placeholder: "e.g. 123 Cranberry Drive", required: true, ng: { model: 'enterprise.address.address1' } } + %span.error{ ng: { show: "details.address1.$error.required && submitted" } } + Please enter an address + .field + %label{ for: 'enterprise_address2' } Address line 2: + %input.chunky{ id: 'enterprise_address2', name: 'address2', required: false, placeholder: "", required: false, ng: { model: 'enterprise.address.address2' } } + + .small-12.medium-9.large-6.columns.end .row - .small-12.columns.field - %label{ for: 'enterprise_address' } Address: - %input.chunky.small-12.columns{ id: 'enterprise_address', name: 'address1', required: true, placeholder: "eg. 123 Cranberry Drive", required: true, ng: { model: 'enterprise.address.address1' } } - %span.error.small-12.columns{ ng: { show: "details.address1.$error.required && submitted" } } - You need to enter an address. + .small-12.medium-8.large-8.columns + .field + %label{ for: 'enterprise_city' } Suburb: + %input.chunky{ id: 'enterprise_city', name: 'city', required: true, placeholder: "e.g. Northcote", ng: { model: 'enterprise.address.city' } } + %span.error{ ng: { show: "details.city.$error.required && submitted" } } + Please enter a suburb + .small-12.medium-4.large-4.columns + .field + %label{ for: 'enterprise_zipcode' } Postcode: + %input.chunky{ id: 'enterprise_zipcode', name: 'zipcode', required: true, placeholder: "e.g. 3070", ng: { model: 'enterprise.address.zipcode' } } + %span.error{ ng: { show: "details.zipcode.$error.required && submitted" } } + Postcode required .row - .small-12.large-8.columns.field - %label{ for: 'enterprise_city' } Suburb: - %input.chunky.small-12.columns{ id: 'enterprise_city', name: 'city', required: true, placeholder: "eg. Northcote", ng: { model: 'enterprise.address.city' } } - %span.error.small-12.columns{ ng: { show: "details.city.$error.required && submitted" } } - You need to enter a suburb. - .small-12.large-4.columns.field - %label{ for: 'enterprise_zipcode' } Postcode: - %input.chunky.small-12.columns{ id: 'enterprise_zipcode', name: 'zipcode', required: true, placeholder: "eg. 3070", ng: { model: 'enterprise.address.zipcode' } } - %span.error.small-12.columns{ ng: { show: "details.zipcode.$error.required && submitted" } } - You need to enter a postcode. - .row - .small-12.large-8.columns.field - %label{ for: 'enterprise_country' } Country: - %select.chunky.small-12.columns{ id: 'enterprise_country', name: 'country', required: true, ng: { model: 'enterprise.country', options: 'c as c.name for c in countries' } } - %span.error.small-12.columns{ ng: { show: "details.country.$error.required && submitted" } } - You need to enter a country. - .small-12.large-4.columns.field - %label{ for: 'enterprise_state' } State: - %select.chunky.small-12.columns{ id: 'enterprise_state', name: 'state', ng: { model: 'enterprise.address.state_id', options: 's.id as s.abbr for s in enterprise.country.states', show: 'countryHasStates()', required: 'countryHasStates()' } } - %span.error.small-12.columns{ ng: { show: "details.state.$error.required && submitted" } } - You need to enter a state. - .small-12.medium-12.large-5.hide-for-small-only - // This is the location area - / %h6 - / Location display - / %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your enterprise's address on the Open Food Network. By default, full location is shown everywhere including street name and number."} - / .row - / .small-12.columns - / %label.indent-checkbox - / %input{ type: 'checkbox', id: 'enterpise_suburb_only', ng: { model: 'enterprise.suburb_only' } } - / Hide my street name and street number from the public (ie. only show the suburb) - / .small-12.columns - / %label.indent-checkbox - / %input{ type: 'checkbox', id: 'enterprise_on_map', ng: { model: 'enterprise.on_map' } } - / Blur my location on the map (show an approximate, not exact pin) + .small-12.medium-4.large-4.columns + .field + %label{ for: 'enterprise_state' } State: + %select.chunky{ id: 'enterprise_state', name: 'state', ng: { model: 'enterprise.address.state_id', options: 's.id as s.abbr for s in enterprise.country.states', show: 'countryHasStates()', required: 'countryHasStates()' } } + %span.error{ ng: { show: "details.state.$error.required && submitted" } } + State required + .small-12.medium-8.large-8.columns + .field + %label{ for: 'enterprise_country' } Country: + %select.chunky{ id: 'enterprise_country', name: 'country', required: true, ng: { model: 'enterprise.country', options: 'c as c.name for c in countries' } } + %span.error{ ng: { show: "details.country.$error.required && submitted" } } + Please select a country + / .small-12.medium-12.large-5.hide-for-small-only + / %h6 + / Location display + / %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your enterprise's address on the Open Food Network. By default, full location is shown everywhere including street name and number."} + / .row + / .small-12.columns + / %label.indent-checkbox + / %input{ type: 'checkbox', id: 'enterpise_suburb_only', ng: { model: 'enterprise.suburb_only' } } + / Hide my street name and street number from the public (ie. only show the suburb) + / .small-12.columns + / %label.indent-checkbox + / %input{ type: 'checkbox', id: 'enterprise_on_map', ng: { model: 'enterprise.on_map' } } + / Blur my location on the map (show an approximate, not exact pin) .row.buttons .small-12.columns + %hr %input.button.primary.right{ type: "submit", value: "Continue" } From a4e72f6fbc32db94a33e5966e20bf42233f31cf5 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 10 Oct 2014 18:20:38 +1100 Subject: [PATCH 12/48] Making the header more semantically meaningful for HTML5. Add in row to make spacing consistent. Steps bar moves to top --- .../templates/registration/about.html.haml | 20 +++-- .../templates/registration/contact.html.haml | 15 ++-- .../templates/registration/finished.html.haml | 19 +++-- .../templates/registration/images.html.haml | 9 +- .../registration/introduction.html.haml | 82 ++++++++++--------- .../registration/limit_reached.html.haml | 31 +++---- .../templates/registration/social.html.haml | 11 ++- .../templates/registration/type.html.haml | 20 +++-- 8 files changed, 117 insertions(+), 90 deletions(-) diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index 704a7e3815..160a2012d3 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -1,14 +1,16 @@ .container#registration-about - .header - %h2 Nice one! - %h5 - Now let's flesh out the details about - %span.brick{"ng-show" => "enterprise.is_distributor"} - {{ enterprise.name }} - %span.turquoise{"ng-show" => "!enterprise.is_distributor" } - {{ enterprise.name }} - %ng-include{ src: "'registration/steps.html'" } + .row + .small-12.columns + %header + %h2 Nice one! + %h5 + Now let's flesh out the details about + %span.brick{"ng-show" => "enterprise.is_distributor"} + {{ enterprise.name }} + %span.turquoise{"ng-show" => "!enterprise.is_distributor" } + {{ enterprise.name }} + %form{ name: 'about', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "update('images',about)" } } .row .small-12.columns diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index 87272cdd5a..fdb606da25 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -1,11 +1,14 @@ .container#registration-contact - .header - %h2 Greetings! - %h5 - Who is responsible for managing - %span.turquoise - {{ enterprise.name }}? %ng-include{ src: "'registration/steps.html'" } + .row + .small-12.columns + %header + %h2 Greetings! + %h5 + Who is responsible for managing + %span.turquoise + {{ enterprise.name }}? + %form{ name: 'contact', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "selectIfValid('type',contact)" } } .row.content .small-12.medium-12.large-7.columns diff --git a/app/assets/javascripts/templates/registration/finished.html.haml b/app/assets/javascripts/templates/registration/finished.html.haml index 75489c607a..b26e623b84 100644 --- a/app/assets/javascripts/templates/registration/finished.html.haml +++ b/app/assets/javascripts/templates/registration/finished.html.haml @@ -1,12 +1,15 @@ .container#registration-finished - .header - %h2 Well done! - %h5 - You have successfully completed the profile for - %span.brick{"ng-show" => "enterprise.is_distributor"} - {{ enterprise.name }} - %span.turquoise{"ng-show" => "!enterprise.is_distributor" } - {{ enterprise.name }} + .row + .small-12.columns + %header + %h2 Well done! + %h5 + You have successfully completed the profile for + %span.brick{"ng-show" => "enterprise.is_distributor"} + {{ enterprise.name }} + %span.turquoise{"ng-show" => "!enterprise.is_distributor" } + {{ enterprise.name }} + .content{ style: 'text-align: center'} %h3 Why not check it out on the Open Food Network? %a.button.primary{ type: "button", href: "/map" } Go to Map Page > diff --git a/app/assets/javascripts/templates/registration/images.html.haml b/app/assets/javascripts/templates/registration/images.html.haml index 889bc4596f..b2a5dcfd08 100644 --- a/app/assets/javascripts/templates/registration/images.html.haml +++ b/app/assets/javascripts/templates/registration/images.html.haml @@ -1,8 +1,11 @@ .container#registration-images{ 'nv-file-drop' => true, uploader: "imageUploader", options:"{ alias: imageStep }", ng: { controller: "EnterpriseImageCtrl" } } - .header - %h2 Thanks! - %h5 Let's upload some pretty pictures so your profile looks great! :) %ng-include{ src: "'registration/steps.html'" } + .row + .small-12.columns + %header + %h2 Thanks! + %h5 Let's upload some pretty pictures so your profile looks great! :) + %form{ name: 'images', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "select('social')" } } .row{ ng: { repeat: 'image_step in imageSteps', show: "imageStep == image_step" } } %ng-include{ src: "'registration/images/'+ image_step + '.html'" } diff --git a/app/assets/javascripts/templates/registration/introduction.html.haml b/app/assets/javascripts/templates/registration/introduction.html.haml index ccefdefbe0..60a8547b4a 100644 --- a/app/assets/javascripts/templates/registration/introduction.html.haml +++ b/app/assets/javascripts/templates/registration/introduction.html.haml @@ -1,39 +1,45 @@ -%div - .header - %h2 Hi there! - %h4 This wizard will step you through creating a profile - .row - .small-12.medium-3.large-2.columns.text-right.hide-for-small-only - %img{:src => "/assets/potatoes.png"} - .small-12.medium-9.large-10.columns - %p - Your profile gives you an online presence on the - %strong Open Food Network, - allowing you to easily connect with potential customers or partners. You can always choose to update your info later, as well as choose to upgrade your Profile to and Online Store, where you can sell products, track orders and receive payments. Creating a profile takes about 5-10 minutes. - .row{ 'data-equalizer' => true } - .small-12.medium-6.large-6.columns.pad-top{ 'data-equalizer-watch' => true } - %h5 You'll need the following: - %ul.check-list - %li - Your enterprise address and contact details - %li - Your logo image - %li - A pretty picture for your profile header - %li - Some 'About Us' text - - .small-12.medium-6.large-6.columns{ 'data-equalizer-watch' => true} - .highlight-box - %h5 Your profile entitles you to: - %ul.small-block-grid-1 - %li - %i.ofn-i_020-search - A searchable listing - %li - %i.ofn-i_040-hub - A pin on the OFN map - .row - .small-12.columns +.row + .small-12.columns + %header + %h2 Hi there! + %h4 + %small + %i.ofn-i_040-hub + Create your enterprise profile + .hide-for-large-up %hr - %input.button.primary{ type: "button", value: "Let's get started!", ng: { click: "select('details')" } } + %input.button.small.primary{ type: "button", value: "Let's get started!", ng: { click: "select('details')" } } + %hr + +.row{ 'data-equalizer' => true } + .small-12.medium-12.large-6.columns.pad-top{ 'data-equalizer-watch' => true } + %h5 You'll need: + %ul.check-list + %li + 5-10 minutes + %li + Enterprise address + %li + Primary contact details + %li + Your logo image + %li + Landscape image for your profile + %li + 'About Us' text + + .small-9.medium-8.large-5.columns.pad-top.end{ 'data-equalizer-watch' => true} + %h5 + What do I get? + %p + Your profile helps people + %strong find + and + %strong contact + you on the Open Food Network. + %p Use this space to tell the story of your enterprise, to help drive connections to your social and online presence. + +.row.show-for-large-up + .small-12.columns + %hr + %input.button.primary.right{ type: "button", value: "Let's get started!", ng: { click: "select('details')" } } diff --git a/app/assets/javascripts/templates/registration/limit_reached.html.haml b/app/assets/javascripts/templates/registration/limit_reached.html.haml index e2131c1727..778d980289 100644 --- a/app/assets/javascripts/templates/registration/limit_reached.html.haml +++ b/app/assets/javascripts/templates/registration/limit_reached.html.haml @@ -1,15 +1,16 @@ -%div - .header.center - %h2 Oh no! - %h4 You have reached the limit! - .row - .small-12.medium-3.large-2.columns.text-right.hide-for-small-only - %img{:src => "/assets/potatoes.png"} - .small-12.medium-9.large-10.columns - %p - You have reached the limit for the number of enterprises you are allowed to own on the - %strong Open Food Network. - .row - .small-12.columns - %hr - %input.button.primary{ type: "button", value: "Return to the homepage", ng: { click: "close()" } } +.row + .small-12.columns + %header + %h2 Oh no! + %h4 You have reached the limit! +.row + .small-12.medium-3.large-2.columns.text-right.hide-for-small-only + %img{:src => "/assets/potatoes.png"} + .small-12.medium-9.large-10.columns + %p + You have reached the limit for the number of enterprises you are allowed to own on the + %strong Open Food Network. +.row + .small-12.columns + %hr + %input.button.primary{ type: "button", value: "Return to the homepage", ng: { click: "close()" } } diff --git a/app/assets/javascripts/templates/registration/social.html.haml b/app/assets/javascripts/templates/registration/social.html.haml index 1b3490ffa0..a2053ea189 100644 --- a/app/assets/javascripts/templates/registration/social.html.haml +++ b/app/assets/javascripts/templates/registration/social.html.haml @@ -1,8 +1,13 @@ .container#registration-social - .header - %h2 Last step! - %h5 How can people find {{ enterprise.name }} online? + %ng-include{ src: "'registration/steps.html'" } + + .row + .small-12.columns + %header + %h2 Last step! + %h5 How can people find {{ enterprise.name }} online? + %form{ name: 'social', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "update('finished',social)" } } .row.content .small-12.large-7.columns diff --git a/app/assets/javascripts/templates/registration/type.html.haml b/app/assets/javascripts/templates/registration/type.html.haml index 0834bf1528..1586f4e6e2 100644 --- a/app/assets/javascripts/templates/registration/type.html.haml +++ b/app/assets/javascripts/templates/registration/type.html.haml @@ -1,14 +1,18 @@ .container#registration-type{bindonce: true} - .header - %h2 - Last step to create your enterprise! - %h5 - Is - %span{ ng: { class: "{brick: enterprise.is_distributor, turquoise: !enterprise.is_distributor}" } } - {{ enterprise.name }} - a primary producer? %ng-include{ src: "'registration/steps.html'" } + + .row + .small-12.columns + %header + %h2 + Last step to create your enterprise! + %h5 + Is + %span{ ng: { class: "{brick: enterprise.is_distributor, turquoise: !enterprise.is_distributor}" } } + {{ enterprise.name }} + a primary producer? + %form{ name: 'type', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "create(type)" } } .row#enterprise-types{ 'data-equalizer' => true, bo: { if: "enterprise.type != 'single'" } } .small-12.columns.field From 908c242d36b01c29350671f74e40f72df6b8b42f Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 15 Oct 2014 10:48:05 +1100 Subject: [PATCH 13/48] Confirmation email when creating enterprise --- app/mailers/enterprise_mailer.rb | 8 ++++++++ app/mailers/spree/user_mailer_decorator.rb | 2 +- app/models/enterprise.rb | 6 ++++++ .../enterprise_mailer/confirmation_instructions.html.haml | 5 +++++ config/routes.rb | 2 ++ 5 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 app/views/enterprise_mailer/confirmation_instructions.html.haml diff --git a/app/mailers/enterprise_mailer.rb b/app/mailers/enterprise_mailer.rb index 73c09e1e56..f5f92aed3f 100644 --- a/app/mailers/enterprise_mailer.rb +++ b/app/mailers/enterprise_mailer.rb @@ -1,10 +1,18 @@ +require 'devise/mailers/helpers' class EnterpriseMailer < Spree::BaseMailer + include Devise::Mailers::Helpers + def creation_confirmation(enterprise) find_enterprise(enterprise) subject = "#{@enterprise.name} is now on #{Spree::Config[:site_name]}" mail(:to => @enterprise.owner.email, :from => from_address, :subject => subject) end + def confirmation_instructions(record, token, opts={}) + @token = token + devise_mail(record, :confirmation_instructions, opts) + end + private def find_enterprise(enterprise) @enterprise = enterprise.is_a?(Enterprise) ? enterprise : Enterprise.find(enterprise) diff --git a/app/mailers/spree/user_mailer_decorator.rb b/app/mailers/spree/user_mailer_decorator.rb index ff8bdc4691..dd21a3d0d7 100644 --- a/app/mailers/spree/user_mailer_decorator.rb +++ b/app/mailers/spree/user_mailer_decorator.rb @@ -1,5 +1,5 @@ Spree::UserMailer.class_eval do - + def signup_confirmation(user) @user = user mail(:to => user.email, :from => from_address, diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index e5b92b0382..411f144f13 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -262,6 +262,12 @@ class Enterprise < ActiveRecord::Base select('DISTINCT spree_taxons.*') end + protected + + def devise_mailer + EnterpriseMailer + end + private def send_creation_email diff --git a/app/views/enterprise_mailer/confirmation_instructions.html.haml b/app/views/enterprise_mailer/confirmation_instructions.html.haml new file mode 100644 index 0000000000..277e27aae5 --- /dev/null +++ b/app/views/enterprise_mailer/confirmation_instructions.html.haml @@ -0,0 +1,5 @@ +%p= "Welcome #{@resource.contact}!" + +%p= "You can confirm this email address for #{@resource.name} using the link below:" + +%p= link_to 'Confirm this email address', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 3e063641dd..9cdac4142d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,6 +35,8 @@ Openfoodnetwork::Application.routes.draw do end end + devise_for :enterprise + namespace :admin do resources :order_cycles do post :bulk_update, on: :collection, as: :bulk_update From 6e699b2e8bb86c8ceddc78a3da332bbfd683f035 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 15 Oct 2014 11:52:04 +1100 Subject: [PATCH 14/48] Mailer tests --- spec/mailers/enterprise_mailer_spec.rb | 5 ++++ spec/models/enterprise_spec.rb | 35 ++++++++++++++++---------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/spec/mailers/enterprise_mailer_spec.rb b/spec/mailers/enterprise_mailer_spec.rb index 412870bad7..6b53d7d561 100644 --- a/spec/mailers/enterprise_mailer_spec.rb +++ b/spec/mailers/enterprise_mailer_spec.rb @@ -10,4 +10,9 @@ describe EnterpriseMailer do EnterpriseMailer.creation_confirmation(@enterprise).deliver ActionMailer::Base.deliveries.count.should == 1 end + + it "should send an email confirmation when given an enterprise" do + EnterpriseMailer.confirmation_instructions(@enterprise, 'token').deliver + ActionMailer::Base.deliveries.count.should == 1 + end end \ No newline at end of file diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index 241d1fafc7..4861157d87 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -3,6 +3,15 @@ require 'spec_helper' describe Enterprise do include AuthenticationWorkflow + describe "creation" do + it "should send a confirmation email" do + mail_message = double "Mail::Message" + EnterpriseMailer.should_receive(:confirmation_instructions).and_return mail_message + mail_message.should_receive :deliver + create(:enterprise) + end + end + describe "associations" do it { should belong_to(:owner) } it { should have_many(:supplied_products) } @@ -507,40 +516,40 @@ describe Enterprise do # Swap type values full > sell_all, single > sell_own profile > sell_none # swap is_distributor for new can_supply flag. - let(:producer_sell_all_can_supply) { + let(:producer_sell_all_can_supply) { create(:enterprise, is_primary_producer: true, type: "full", is_distributor: true) } - let(:producer_sell_all_cant_supply) { + let(:producer_sell_all_cant_supply) { create(:enterprise, is_primary_producer: true, type: "full", is_distributor: false) } - let(:producer_sell_own_can_supply) { + let(:producer_sell_own_can_supply) { create(:enterprise, is_primary_producer: true, type: "single", is_distributor: true) } - let(:producer_sell_own_cant_supply) { + let(:producer_sell_own_cant_supply) { create(:enterprise, is_primary_producer: true, type: "single", is_distributor: false) } - let(:producer_sell_none_can_supply) { + let(:producer_sell_none_can_supply) { create(:enterprise, is_primary_producer: true, type: "profile", is_distributor: true) } - let(:producer_sell_none_cant_supply) { + let(:producer_sell_none_cant_supply) { create(:enterprise, is_primary_producer: true, type: "profile", is_distributor: false) } let(:non_producer_sell_all_can_supply) { create(:enterprise, is_primary_producer: true, type: "full", is_distributor: true) } - let(:non_producer_sell_all_cant_supply) { + let(:non_producer_sell_all_cant_supply) { create(:enterprise, is_primary_producer: true, type: "full", is_distributor: false) } - let(:non_producer_sell_own_can_supply) { + let(:non_producer_sell_own_can_supply) { create(:enterprise, is_primary_producer: true, type: "single", is_distributor: true) } - let(:non_producer_sell_own_cant_supply) { + let(:non_producer_sell_own_cant_supply) { create(:enterprise, is_primary_producer: true, type: "single", is_distributor: false) } - let(:non_producer_sell_none_can_supply) { + let(:non_producer_sell_none_can_supply) { create(:enterprise, is_primary_producer: false, type: "profile", is_distributor: true) } - let(:non_producer_sell_none_cant_supply) { + let(:non_producer_sell_none_cant_supply) { create(:enterprise, is_primary_producer: false, type: "profile", is_distributor: false) } @@ -555,8 +564,8 @@ describe Enterprise do producer_sell_own_cant_supply.enterprise_category.should == "producer_shop" producer_sell_none_can_supply.enterprise_category.should == "producer" producer_sell_none_cant_supply.enterprise_category.should == "producer_profile" - non_producer_sell_all_can_supply.enterprise_category.should == "hub" - non_producer_sell_all_cant_supply.enterprise_category.should == "hub" + non_producer_sell_all_can_supply.enterprise_category.should == "hub" + non_producer_sell_all_cant_supply.enterprise_category.should == "hub" non_producer_sell_own_can_supply.enterprise_category.should == "hub" non_producer_sell_own_cant_supply.enterprise_category.should == "hub" non_producer_sell_none_can_supply.enterprise_category.should == "hub_profile" From 56f4d5af0fb8550170fd7f7925096c7228556767 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 15 Oct 2014 12:27:55 +1100 Subject: [PATCH 15/48] Visibility in the front end is contingent upon enterprise being confirmed --- app/serializers/api/enterprise_serializer.rb | 5 +++++ .../serializers/enterprise_serializer_spec.rb | 20 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/serializers/api/enterprise_serializer.rb b/app/serializers/api/enterprise_serializer.rb index 6841337024..ce3412ab10 100644 --- a/app/serializers/api/enterprise_serializer.rb +++ b/app/serializers/api/enterprise_serializer.rb @@ -102,6 +102,11 @@ class Api::CachedEnterpriseSerializer < ActiveModel::Serializer has_one :address, serializer: Api::AddressSerializer + def visible + binding.pry + object.visible && object.confirmed? + end + def pickup object.shipping_methods.where(:require_ship_address => false).present? end diff --git a/spec/serializers/enterprise_serializer_spec.rb b/spec/serializers/enterprise_serializer_spec.rb index 5fe57a99e2..f3409f2d57 100644 --- a/spec/serializers/enterprise_serializer_spec.rb +++ b/spec/serializers/enterprise_serializer_spec.rb @@ -13,9 +13,27 @@ describe Api::EnterpriseSerializer do serializer = Api::EnterpriseSerializer.new enterprise serializer.to_json.should match taxon.id.to_s end - + it "will render urls" do serializer = Api::EnterpriseSerializer.new enterprise serializer.to_json.should match "map_005-hub.svg" end + + describe "visibility" do + before do + enterprise.stub(:visible).and_return true + end + + it "is visible when confirmed" do + enterprise.stub(:confirmed?).and_return true + serializer = Api::EnterpriseSerializer.new enterprise + expect(serializer.to_json).to match "\"visible\":true" + end + + it "is not visible when unconfirmed" do + enterprise.stub(:confirmed?).and_return false + serializer = Api::EnterpriseSerializer.new enterprise + expect(serializer.to_json).to match "\"visible\":false" + end + end end From 1bdc55cb3356d946a564b5a1b49b6a31c43a18b6 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 15 Oct 2014 13:03:39 +1100 Subject: [PATCH 16/48] Adding confirmed scope to enterprises --- app/models/enterprise.rb | 1 + spec/models/enterprise_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 411f144f13..977b35390b 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -61,6 +61,7 @@ class Enterprise < ActiveRecord::Base scope :by_name, order('name') scope :visible, where(:visible => true) + scope :confirmed, where('confirmed_at IS NOT NULL') scope :is_primary_producer, where(:is_primary_producer => true) scope :is_distributor, where(:is_distributor => true) scope :supplying_variant_in, lambda { |variants| joins(:supplied_products => :variants_including_master).where('spree_variants.id IN (?)', variants).select('DISTINCT enterprises.*') } diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index 4861157d87..692509890d 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -111,6 +111,7 @@ describe Enterprise do it { should delegate(:city).to(:address) } it { should delegate(:state_name).to(:address) } end + describe "scopes" do describe 'active' do it 'find active enterprises' do @@ -120,6 +121,17 @@ describe Enterprise do end end + describe "confirmed" do + it "find enterprises with a confirmed date" do + s1 = create(:supplier_enterprise, confirmed_at: Time.now) + d1 = create(:distributor_enterprise, confirmed_at: Time.now) + s2 = create(:supplier_enterprise, confirmed_at: nil) + d2 = create(:distributor_enterprise, confirmed_at: nil) + expect(Enterprise.confirmed).to include s1, d1 + expect(Enterprise.confirmed).to_not include s2, d2 + end + end + describe "distributors_with_active_order_cycles" do it "finds active distributors by order cycles" do s = create(:supplier_enterprise) From c76a3815c03eac35f02f611beda7aeb2038c8290 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 15 Oct 2014 15:45:47 +1100 Subject: [PATCH 17/48] Add unconfirmed scope --- app/models/enterprise.rb | 1 + spec/models/enterprise_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 977b35390b..954667f3e1 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -62,6 +62,7 @@ class Enterprise < ActiveRecord::Base scope :by_name, order('name') scope :visible, where(:visible => true) scope :confirmed, where('confirmed_at IS NOT NULL') + scope :unconfirmed, where('confirmed_at IS NULL') scope :is_primary_producer, where(:is_primary_producer => true) scope :is_distributor, where(:is_distributor => true) scope :supplying_variant_in, lambda { |variants| joins(:supplied_products => :variants_including_master).where('spree_variants.id IN (?)', variants).select('DISTINCT enterprises.*') } diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index 692509890d..7dc1d986a1 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -132,6 +132,17 @@ describe Enterprise do end end + describe "unconfirmed" do + it "find enterprises without a confirmed date" do + s1 = create(:supplier_enterprise, confirmed_at: Time.now) + d1 = create(:distributor_enterprise, confirmed_at: Time.now) + s2 = create(:supplier_enterprise, confirmed_at: nil) + d2 = create(:distributor_enterprise, confirmed_at: nil) + expect(Enterprise.unconfirmed).to_not include s1, d1 + expect(Enterprise.unconfirmed).to include s2, d2 + end + end + describe "distributors_with_active_order_cycles" do it "finds active distributors by order cycles" do s = create(:supplier_enterprise) From c59662758caaf9f60a3899bedf06fc6c0975a4a1 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 15 Oct 2014 15:46:21 +1100 Subject: [PATCH 18/48] Add alerts for unconfirmed enterprises to overview page --- app/assets/stylesheets/admin/alert.css.sass | 10 +++++++++ .../admin/overview/_unconfirmed.html.haml | 4 ++++ .../spree/admin/overview/index.html.haml | 21 ++++++++++--------- 3 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 app/assets/stylesheets/admin/alert.css.sass create mode 100644 app/views/spree/admin/overview/_unconfirmed.html.haml diff --git a/app/assets/stylesheets/admin/alert.css.sass b/app/assets/stylesheets/admin/alert.css.sass new file mode 100644 index 0000000000..5404e1a0e2 --- /dev/null +++ b/app/assets/stylesheets/admin/alert.css.sass @@ -0,0 +1,10 @@ +.alert + border: 3px solid #DA5354 + border-radius: 6px + margin-bottom: 20px + color: #DA5354 + padding: 5px 10px + h6 + color: #DA5354 + .message + font-weight: bold diff --git a/app/views/spree/admin/overview/_unconfirmed.html.haml b/app/views/spree/admin/overview/_unconfirmed.html.haml new file mode 100644 index 0000000000..05c4df2a0d --- /dev/null +++ b/app/views/spree/admin/overview/_unconfirmed.html.haml @@ -0,0 +1,4 @@ +- @enterprises.unconfirmed.each do |enterprise| + .alert + %h6= "Action Required: Please confirm the email address for #{enterprise.name}." + %span.message= "We've sent a confirmation email to #{enterprise.email}, so please check there for further instructions. Thanks!" \ No newline at end of file diff --git a/app/views/spree/admin/overview/index.html.haml b/app/views/spree/admin/overview/index.html.haml index a46a31b404..0709ceb54f 100644 --- a/app/views/spree/admin/overview/index.html.haml +++ b/app/views/spree/admin/overview/index.html.haml @@ -1,17 +1,18 @@ %h1{ :style => 'margin-bottom: 30px'} Dashboard -- if @enterprises.empty? +- if @enterprises.unconfirmed.any? - = render partial: "spree/admin/overview/enterprises" + = render partial: "spree/admin/overview/unconfirmed" -- else - - if can? :admin, Spree::Product - = render partial: "spree/admin/overview/products" + %hr - %div.two.columns -   +- if can? :admin, Spree::Product + = render partial: "spree/admin/overview/products" - - if can? :admin, OrderCycle - = render partial: "spree/admin/overview/order_cycles" + %div.two.columns +   - = render partial: "spree/admin/overview/enterprises" +- if can? :admin, OrderCycle + = render partial: "spree/admin/overview/order_cycles" + += render partial: "spree/admin/overview/enterprises" From e0e8ba814f1f1122716a663c8b9c294ff572f273 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 15 Oct 2014 16:20:45 +1100 Subject: [PATCH 19/48] Show explanation of confirm process on final page of registration --- .../templates/registration/finished.html.haml | 16 +++++++++------- .../templates/registration/social.html.haml | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/templates/registration/finished.html.haml b/app/assets/javascripts/templates/registration/finished.html.haml index 75489c607a..3d0daf5633 100644 --- a/app/assets/javascripts/templates/registration/finished.html.haml +++ b/app/assets/javascripts/templates/registration/finished.html.haml @@ -2,17 +2,19 @@ .header %h2 Well done! %h5 - You have successfully completed the profile for + That's all of the details we need for %span.brick{"ng-show" => "enterprise.is_distributor"} {{ enterprise.name }} %span.turquoise{"ng-show" => "!enterprise.is_distributor" } {{ enterprise.name }} .content{ style: 'text-align: center'} - %h3 Why not check it out on the Open Food Network? - %a.button.primary{ type: "button", href: "/map" } Go to Map Page > - %br - %br + %h3 There's just one last thing we need you to do: + %h5 We've sent a confirmation email to {{ enterprise.email }}, so please follow the instructions there to finalise the creation of your enterprise. - %h3 Next step - add some products: - %a.button.primary{ type: "button", href: "/admin/products/new" } Add a Product > + -# perhaps a pretty picture here? + + %br/ + %br/ + + %a.button.primary{ type: "button", href: "/" } Take me home > diff --git a/app/assets/javascripts/templates/registration/social.html.haml b/app/assets/javascripts/templates/registration/social.html.haml index 1b3490ffa0..f9d958e7e8 100644 --- a/app/assets/javascripts/templates/registration/social.html.haml +++ b/app/assets/javascripts/templates/registration/social.html.haml @@ -1,6 +1,6 @@ .container#registration-social .header - %h2 Last step! + %h2 Almost there! %h5 How can people find {{ enterprise.name }} online? %ng-include{ src: "'registration/steps.html'" } %form{ name: 'social', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "update('finished',social)" } } From 0940af6b660e3d1673b3539e343176009be7ada5 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 15 Oct 2014 16:21:11 +1100 Subject: [PATCH 20/48] Remove bad pry --- app/serializers/api/enterprise_serializer.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/serializers/api/enterprise_serializer.rb b/app/serializers/api/enterprise_serializer.rb index ce3412ab10..d750704657 100644 --- a/app/serializers/api/enterprise_serializer.rb +++ b/app/serializers/api/enterprise_serializer.rb @@ -103,7 +103,6 @@ class Api::CachedEnterpriseSerializer < ActiveModel::Serializer has_one :address, serializer: Api::AddressSerializer def visible - binding.pry object.visible && object.confirmed? end From 20cb11a298ecd357fa18823e145f17481e131b62 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 15 Oct 2014 16:28:52 +1100 Subject: [PATCH 21/48] Update registration spec --- spec/features/consumer/registration_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index 7ac46a8970..e8a7e4aa09 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -75,7 +75,7 @@ feature "Registration", js: true do click_button 'Continue' # Filling in social - expect(page).to have_content 'Last step!' + expect(page).to have_content 'Almost there!' fill_in 'enterprise_website', with: 'www.shop.com' fill_in 'enterprise_facebook', with: 'FaCeBoOk' fill_in 'enterprise_linkedin', with: 'LiNkEdIn' @@ -84,7 +84,7 @@ feature "Registration", js: true do click_button 'Continue' # Done - expect(page).to have_content "You have successfully completed the profile for My Awesome Enterprise" + expect(page).to have_content "That's all of the details we need for My Awesome Enterprise" e.reload expect(e.website).to eq "www.shop.com" expect(e.facebook).to eq "FaCeBoOk" From 96878f5dcb373a9a900086525cbd5953e67c6cf7 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 15 Oct 2014 17:22:56 +1100 Subject: [PATCH 22/48] Don't require confirmation for enterprises where the email address has already been confirmed for another enterprise --- app/models/enterprise.rb | 6 ++++++ spec/models/enterprise_spec.rb | 22 ++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 954667f3e1..1bcd989f2a 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -8,6 +8,8 @@ class Enterprise < ActiveRecord::Base acts_as_gmappable :process_geocoding => false + before_create :check_email + after_create :send_creation_email has_and_belongs_to_many :groups, class_name: 'EnterpriseGroup' @@ -272,6 +274,10 @@ class Enterprise < ActiveRecord::Base private + def check_email + skip_confirmation! if owner.enterprises.confirmed.map(&:email).include?(email) + end + def send_creation_email EnterpriseMailer.creation_confirmation(self).deliver end diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index 7dc1d986a1..6f828b2f10 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -3,12 +3,22 @@ require 'spec_helper' describe Enterprise do include AuthenticationWorkflow - describe "creation" do - it "should send a confirmation email" do - mail_message = double "Mail::Message" - EnterpriseMailer.should_receive(:confirmation_instructions).and_return mail_message - mail_message.should_receive :deliver - create(:enterprise) + describe "sending emails" do + describe "on creation" do + let!(:user) { create_enterprise_user( enterprise_limit: 2 ) } + let!(:enterprise) { create(:enterprise, owner: user, confirmed_at: Time.now) } + + it "when the email address has not already been confirmed" do + mail_message = double "Mail::Message" + EnterpriseMailer.should_receive(:confirmation_instructions).and_return mail_message + mail_message.should_receive :deliver + create(:enterprise, owner: user, email: "unknown@email.com" ) + end + + it "when the email address has already been confirmed" do + EnterpriseMailer.should_not_receive(:confirmation_instructions) + e = create(:enterprise, owner: user, email: enterprise.email) + end end end From 63e50dc88cc8b49539395b0bb8d5fda8db16c721 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 16 Oct 2014 11:34:06 +1100 Subject: [PATCH 23/48] Fiddle with alert styling --- app/assets/stylesheets/admin/alert.css.sass | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/admin/alert.css.sass b/app/assets/stylesheets/admin/alert.css.sass index 5404e1a0e2..d86cb38f55 100644 --- a/app/assets/stylesheets/admin/alert.css.sass +++ b/app/assets/stylesheets/admin/alert.css.sass @@ -1,10 +1,15 @@ .alert - border: 3px solid #DA5354 + border: 3px solid #919191 border-radius: 6px margin-bottom: 20px - color: #DA5354 + color: #919191 padding: 5px 10px h6 - color: #DA5354 + color: #919191 .message font-weight: bold + &:hover + border-color: #DA5354 + color: #DA5354 + h6 + color: #DA5354 From 7e23479f3a0af1f79b1a9dae19124925d5964045 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 16 Oct 2014 12:08:12 +1100 Subject: [PATCH 24/48] Consistency --- spec/features/admin/variants_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/admin/variants_spec.rb b/spec/features/admin/variants_spec.rb index 1904f3d5af..19767d8ea2 100644 --- a/spec/features/admin/variants_spec.rb +++ b/spec/features/admin/variants_spec.rb @@ -1,4 +1,4 @@ -require "spec_helper" +require 'spec_helper' feature %q{ As an admin From 0e03b5f2097c619da588aeba282ffce58db2ef15 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 16 Oct 2014 12:41:11 +1100 Subject: [PATCH 25/48] Admin can change the format that Spree::Images are stored/served in --- .../image_settings_controller_decorator.rb | 11 +++++ app/helpers/admin/image_settings_helper.rb | 21 +++++++++ app/models/spree/image_decorator.rb | 23 ++++++++++ .../edit/add_image_format.html.haml.deface | 11 +++++ spec/features/admin/image_settings_spec.rb | 43 +++++++++++++++++++ spec/models/spree/image_spec.rb | 18 ++++++++ 6 files changed, 127 insertions(+) create mode 100644 app/controllers/spree/admin/image_settings_controller_decorator.rb create mode 100644 app/helpers/admin/image_settings_helper.rb create mode 100644 app/models/spree/image_decorator.rb create mode 100644 app/overrides/spree/admin/image_settings/edit/add_image_format.html.haml.deface create mode 100644 spec/features/admin/image_settings_spec.rb create mode 100644 spec/models/spree/image_spec.rb diff --git a/app/controllers/spree/admin/image_settings_controller_decorator.rb b/app/controllers/spree/admin/image_settings_controller_decorator.rb new file mode 100644 index 0000000000..5fe7dae551 --- /dev/null +++ b/app/controllers/spree/admin/image_settings_controller_decorator.rb @@ -0,0 +1,11 @@ +Spree::Admin::ImageSettingsController.class_eval do + # Spree stores attachent definitions in JSON. This converts the style name and format to + # strings. However, when paperclip encounters these, it doesn't recognise the format. + # Here we solve that problem by converting format and style name to symbols. + def update_paperclip_settings_with_format_styles + update_paperclip_settings_without_format_styles + Spree::Image.reformat_styles + end + + alias_method_chain :update_paperclip_settings, :format_styles +end diff --git a/app/helpers/admin/image_settings_helper.rb b/app/helpers/admin/image_settings_helper.rb new file mode 100644 index 0000000000..10c34fe372 --- /dev/null +++ b/app/helpers/admin/image_settings_helper.rb @@ -0,0 +1,21 @@ +module Admin + module ImageSettingsHelper + def admin_image_settings_format_options + [['Unchanged', ''], ['PNG', 'png'], ['JPEG', 'jpg']] + end + + def admin_image_settings_geometry_from_style(style) + geometry, format = admin_image_settings_split_style style + geometry + end + + def admin_image_settings_format_from_style(style) + geometry, format = admin_image_settings_split_style style + format + end + + def admin_image_settings_split_style(style) + [style, nil].flatten[0..1] + end + end +end diff --git a/app/models/spree/image_decorator.rb b/app/models/spree/image_decorator.rb new file mode 100644 index 0000000000..7d86aae3a6 --- /dev/null +++ b/app/models/spree/image_decorator.rb @@ -0,0 +1,23 @@ +Spree::Image.class_eval do + # Spree stores attachent definitions in JSON. This converts the style name and format to + # strings. However, when paperclip encounters these, it doesn't recognise the format. + # Here we solve that problem by converting format and style name to symbols. + # See also: ImageSettingsController decorator. + # + # eg. {'mini' => ['48x48>', 'png']} is converted to {mini: ['48x48>', :png]} + def self.format_styles(styles) + styles_a = styles.map do |name, style| + style[1] = style[1].to_sym if style.is_a? Array + [name.to_sym, style] + end + + Hash[styles_a] + end + + def self.reformat_styles + Spree::Image.attachment_definitions[:attachment][:styles] = + format_styles(Spree::Image.attachment_definitions[:attachment][:styles]) + end + + reformat_styles +end diff --git a/app/overrides/spree/admin/image_settings/edit/add_image_format.html.haml.deface b/app/overrides/spree/admin/image_settings/edit/add_image_format.html.haml.deface new file mode 100644 index 0000000000..deb79b5bbf --- /dev/null +++ b/app/overrides/spree/admin/image_settings/edit/add_image_format.html.haml.deface @@ -0,0 +1,11 @@ +/ replace_contents '#styles_list' + +- @styles.each_with_index do |(style_name, style_value), index| + .field.three.columns + = label_tag "attachment_styles[#{style_name}]", style_name + %a.destroy_style.with-tip{:alt => t(:destroy), :href => "#", :title => t(:destroy)} + %i.icon-trash + = text_field_tag "attachment_styles[#{style_name}][]", admin_image_settings_geometry_from_style(style_value), :class => 'fullwidth' + %br/ + - current_format = admin_image_settings_format_from_style(style_value) || '' + = select_tag "attachment_styles[#{style_name}][]", options_for_select(admin_image_settings_format_options, current_format), :class => 'fullwidth', :id => "attachment_styles_format_#{style_name}" diff --git a/spec/features/admin/image_settings_spec.rb b/spec/features/admin/image_settings_spec.rb new file mode 100644 index 0000000000..a83a072235 --- /dev/null +++ b/spec/features/admin/image_settings_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +feature %q{ + As an admin + I want to manage image formats +} do + include AuthenticationWorkflow + include WebHelper + + before(:all) do + styles = {"mini" => "48x48>", + "small" => "100x100>", + "product" => "240x240>", + "large" => "600x600>"} + + Spree::Config[:attachment_styles] = ActiveSupport::JSON.encode(styles) + Spree::Image.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(Spree::Config[:attachment_styles]) + Spree::Image.reformat_styles + end + + scenario "setting the image format for a paperclip style" do + # When I go to the image settings page + login_to_admin_section + visit spree.edit_admin_image_settings_path + + # All the styles should default to "Unchanged" + page.should have_select 'attachment_styles_format_mini', selected: 'Unchanged' + page.should have_select 'attachment_styles_format_small', selected: 'Unchanged' + page.should have_select 'attachment_styles_format_product', selected: 'Unchanged' + page.should have_select 'attachment_styles_format_large', selected: 'Unchanged' + + # When I change a style to "PNG" and save + select 'PNG', from: 'attachment_styles_format_mini' + click_button 'Update' + + # Then the change should be saved to the image formats + page.should have_content "Image Settings successfully updated." + page.should have_select 'attachment_styles_format_mini', selected: 'PNG' + + styles = Spree::Image.attachment_definitions[:attachment][:styles] + styles[:mini].should == ['48x48>', :png] + end +end diff --git a/spec/models/spree/image_spec.rb b/spec/models/spree/image_spec.rb new file mode 100644 index 0000000000..56665fa641 --- /dev/null +++ b/spec/models/spree/image_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +module Spree + describe Image do + describe "attachment definitions" do + let(:name_str) { {"mini" => "48x48>"} } + let(:formatted) { {mini: ["48x48>", "png"]} } + + it "converts style names to symbols" do + Image.format_styles(name_str).should == {:mini => "48x48>"} + end + + it "converts formats to symbols" do + Image.format_styles(formatted).should == {:mini => ["48x48>", :png]} + end + end + end +end From 7db68795a4c64dffb989ba2b00e9c23c3d0c63ab Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 16 Oct 2014 16:06:54 +1100 Subject: [PATCH 26/48] Redirect to admin root after confirmation --- .../devise/confirmations_controller_decorator.rb | 7 +++++++ .../devise/confirmation_controller_spec.rb | 15 +++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 app/controllers/devise/confirmations_controller_decorator.rb create mode 100644 spec/controllers/devise/confirmation_controller_spec.rb diff --git a/app/controllers/devise/confirmations_controller_decorator.rb b/app/controllers/devise/confirmations_controller_decorator.rb new file mode 100644 index 0000000000..ef34f28445 --- /dev/null +++ b/app/controllers/devise/confirmations_controller_decorator.rb @@ -0,0 +1,7 @@ +Devise::ConfirmationsController.class_eval do + protected + # Override of devise method in Devise::ConfirmationsController + def after_confirmation_path_for(resource_name, resource) + spree.admin_path + end +end \ No newline at end of file diff --git a/spec/controllers/devise/confirmation_controller_spec.rb b/spec/controllers/devise/confirmation_controller_spec.rb new file mode 100644 index 0000000000..eda5dc4823 --- /dev/null +++ b/spec/controllers/devise/confirmation_controller_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe Devise::ConfirmationsController do + context "after confirmation" do + before do + e = create(:enterprise) + @request.env["devise.mapping"] = Devise.mappings[:enterprise] + spree_get :show, confirmation_token: e.confirmation_token + end + + it "should redirect to admin root" do + expect(response).to redirect_to spree.admin_path + end + end +end \ No newline at end of file From 8d01bb7ebfe20897459927c7377488834a18cc97 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 16 Oct 2014 16:45:15 +1100 Subject: [PATCH 27/48] Pretty responsive email template!!!!!!!! --- .../confirmation_instructions.html.haml | 101 +++++++++++++++++- 1 file changed, 98 insertions(+), 3 deletions(-) diff --git a/app/views/enterprise_mailer/confirmation_instructions.html.haml b/app/views/enterprise_mailer/confirmation_instructions.html.haml index 277e27aae5..19bab3f5ee 100644 --- a/app/views/enterprise_mailer/confirmation_instructions.html.haml +++ b/app/views/enterprise_mailer/confirmation_instructions.html.haml @@ -1,5 +1,100 @@ -%p= "Welcome #{@resource.contact}!" +/ ORIGINAL & UGLY: +/ %p= "Welcome #{@resource.contact}!" +/ %p= "Please confirm your email address for #{@resource.name}." +/ %p= "Click the link below to activate your enterprise:" +/ %p= link_to 'Confirm this email address', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) -%p= "You can confirm this email address for #{@resource.name} using the link below:" -%p= link_to 'Confirm this email address', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) \ No newline at end of file +%html{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;", :xmlns => "http://www.w3.org/1999/xhtml"} + %head{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + / If you delete this meta tag, Half Life 3 will never be released. + %meta{:content => "width=device-width", :name => "viewport", :style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"}/ + %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type", :style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"}/ + %title{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} Open Food Network + %link{:href => "http://rohanmitchell.com/random/template/basic-email-template/stylesheets/email.css", :rel => "stylesheet", :style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;", :type => "text/css"}/ + %body{:bgcolor => "#FFFFFF", :style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;-webkit-font-smoothing: antialiased;-webkit-text-size-adjust: none;height: 100%;width: 100%!important;"} + / HEADER + %table.head-wrap{:bgcolor => "#333333", :style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;width: 100%;"} + %tr{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %td{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %td.header.container{:style => "margin: 0 auto!important;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;display: block!important;max-width: 600px!important;clear: both!important;"} + .content{:style => "margin: 0 auto;padding: 15px;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;max-width: 600px;display: block;"} + %table{:bgcolor => "#333333", :style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;width: 100%;"} + %tr{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %td{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %img{:src => "https://openfoodnetwork.org.au/assets/ofn_logo_beta-8e4dfc79deb25def2d107dea52dce492.png", :style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;max-width: 100%;", :width => "200"}/ + %td{:align => "right", :style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %h6.collapse{:style => "margin: 0!important;padding: 0;font-family: \"HelveticaNeue-Light\", \"Helvetica Neue Light\", \"Helvetica Neue\", Helvetica, Arial, \"Lucida Grande\", sans-serif;line-height: 1.1;margin-bottom: 15px;color: #999;font-weight: 900;font-size: 14px;text-transform: uppercase;"} Open Food Network + %td{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + / /HEADER + / BODY + %table.body-wrap{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;width: 100%;"} + %tr{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %td{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %td.container{:bgcolor => "#FFFFFF", :style => "margin: 0 auto!important;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;display: block!important;max-width: 600px!important;clear: both!important;"} + .content{:style => "margin: 0 auto;padding: 15px;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;max-width: 600px;display: block;"} + %table{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;width: 100%;"} + %tr{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %td{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %h3{:style => "margin: 0;padding: 0;font-family: \"HelveticaNeue-Light\", \"Helvetica Neue Light\", \"Helvetica Neue\", Helvetica, Arial, \"Lucida Grande\", sans-serif;line-height: 1.1;margin-bottom: 15px;color: #000;font-weight: 500;font-size: 27px;"}= "Welcome, #{@resource.contact}!" + %p.lead{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;margin-bottom: 10px;font-weight: normal;font-size: 17px;line-height: 1.6;"} + = "Please confirm email address for your enterprise " + %strong + = "#{@resource.name}." + %p   + / Callout Panel + %p.callout{:style => "margin: 0; padding: 15px;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;margin-bottom: 15px;font-weight: normal;font-size: 14px;line-height: 1.6;background-color: #e1f0f5;"} + = "Click the link below to confirm email and to activate your enterprise. This link can be used only once:" + %br + %strong + = link_to 'Confirm this email address »', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) + / /Callout Panel + %p   + %p{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;margin-bottom: 10px;font-weight: normal;font-size: 14px;line-height: 1.6;"}= "We're so excited that you're joining the Open Food Network! Don't hestitate to get in touch if you have any questions." + %p   + / social & contact + %table.social{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;background-color: #ebebeb;width: 100%;", :width => "100%"} + %tr{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %td{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + / column 1 + %table.column{:align => "left", :style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;width: 280px;float: left;min-width: 279px;"} + %tr{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %td{:style => "margin: 0;padding: 15px;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %h5{:style => "margin: 0;padding: 0;font-family: \"HelveticaNeue-Light\", \"Helvetica Neue Light\", \"Helvetica Neue\", Helvetica, Arial, \"Lucida Grande\", sans-serif;line-height: 1.1;margin-bottom: 15px;color: #000;font-weight: 900;font-size: 17px;"} Connect with Us: + %p{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;margin-bottom: 10px;font-weight: normal;font-size: 14px;line-height: 1.6;"} + %a.soc-btn.fb{:href => "https://www.facebook.com/OpenFoodNet", :style => "margin: 0;padding: 3px 7px;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;color: #FFF;font-size: 12px;margin-bottom: 10px;text-decoration: none;font-weight: bold;display: block;text-align: center;background-color: #3B5998!important;", :target => "_blank"} Facebook + %a.soc-btn.tw{:href => "https://twitter.com/OpenFoodNet", :style => "margin: 0;padding: 3px 7px;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;color: #FFF;font-size: 12px;margin-bottom: 10px;text-decoration: none;font-weight: bold;display: block;text-align: center;background-color: #1daced!important;", :target => "_blank"} Twitter + %a.soc-btn.li{:href => "http://www.linkedin.com/groups/Open-Food-Foundation-4743336", :style => "margin: 0;padding: 3px 7px;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;color: #FFF;font-size: 12px;margin-bottom: 10px;text-decoration: none;font-weight: bold;display: block;text-align: center;background-color: #0073b2!important;", :target => "_blank"} LinkedIn + / /column 1 + / column 2 + %table.column{:align => "left", :style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;width: 280px;float: left;min-width: 279px;"} + %tr{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %td{:style => "margin: 0;padding: 15px;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %h5{:style => "margin: 0;padding: 0;font-family: \"HelveticaNeue-Light\", \"Helvetica Neue Light\", \"Helvetica Neue\", Helvetica, Arial, \"Lucida Grande\", sans-serif;line-height: 1.1;margin-bottom: 15px;color: #000;font-weight: 900;font-size: 17px;"} Email us: + %p{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;margin-bottom: 10px;font-weight: normal;font-size: 14px;line-height: 1.6;"} + %strong{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %a{:href => "hello@openfoodnetwork.org", :style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;color: #0096ad;"} hello@openfoodnetwork.org + / /column 2 + %span.clear{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;display: block;clear: both;"} + / /social & contact + / /content + %td{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + / /BODY + / FOOTER + %table.footer-wrap{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;width: 100%;clear: both!important;"} + %tr{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %td{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %td.container{:style => "margin: 0 auto!important;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;display: block!important;max-width: 600px!important;clear: both!important;"} + / content + .content{:style => "margin: 0 auto;padding: 15px;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;max-width: 600px;display: block;"} + %table{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;width: 100%;"} + %tr{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %td{:align => "center", :style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + %p{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;margin-bottom: 10px;font-weight: normal;font-size: 14px;line-height: 1.6;"} + %a{:href => "https://openfoodnetwork.org.au/Terms-of-service.pdf", :style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;color: #0096ad;", :target => "_blank"} Terms of service + | + %a{:href => "http://www.openfoodnetwork.org.au", :style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;color: #0096ad;", :target => "_blank"} Open Food Network + / | Unsubscribe + / /content + %td{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} + / /FOOTER From 4defb38cf4eb9f35cbd1d2e315c0f6774fee92f5 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Fri, 17 Oct 2014 04:01:36 +1100 Subject: [PATCH 28/48] update karma config --- config/ng-test.conf.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/ng-test.conf.js b/config/ng-test.conf.js index eadaf984ae..f87aa3d48a 100644 --- a/config/ng-test.conf.js +++ b/config/ng-test.conf.js @@ -27,9 +27,16 @@ module.exports = function(config) { 'app/assets/javascripts/admin/util.js.erb' ], + preprocessors: { + '**/*.coffee': ['coffee'] + }, + coffeePreprocessor: { options: { sourceMap: true + }, + transformPath: function(path) { + return path.replace(/\.coffee$/, '.js'); } }, From 4884734ab5bbe10c23d93437b04df0009b2f0e09 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 17 Oct 2014 10:43:19 +1100 Subject: [PATCH 29/48] Align Continue buttons right consistently --- .../javascripts/templates/registration/about.html.haml | 4 +++- .../javascripts/templates/registration/contact.html.haml | 3 +-- .../javascripts/templates/registration/images.html.haml | 5 ++--- .../javascripts/templates/registration/social.html.haml | 3 +-- app/assets/javascripts/templates/registration/type.html.haml | 5 ++--- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index 160a2012d3..64ed3df0c1 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -40,6 +40,8 @@ .small-12.columns %label{ for: 'enterprise_acn' } ACN: %input.chunky.small-12.columns{ id: 'enterprise_acn', placeholder: "eg. 123 456 789", ng: { model: 'enterprise.acn' } } + .row.buttons.pad-top .small-12.columns - %input.button.primary{ type: "submit", value: "Continue" } + %input.button.primary.right{ type: "submit", value: "Continue" } + diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index fdb606da25..b87073431e 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -46,5 +46,4 @@ .row.buttons .small-12.columns %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('details')" } } -   - %input.button.primary{ type: "submit", value: "Continue" } + %input.button.primary.right{ type: "submit", value: "Continue" } diff --git a/app/assets/javascripts/templates/registration/images.html.haml b/app/assets/javascripts/templates/registration/images.html.haml index b2a5dcfd08..3c0615a216 100644 --- a/app/assets/javascripts/templates/registration/images.html.haml +++ b/app/assets/javascripts/templates/registration/images.html.haml @@ -18,6 +18,5 @@ .row.buttons.pad-top{ ng: { if: "imageStep == 'promo'" } } .small-12.columns - %input.button.primary{ type: "button", value: "Back", ng: { click: "imageSelect('logo')" } } -   - %input.button.primary{ type: "submit", value: "Continue" } + %input.button.secondary{ type: "button", value: "Back", ng: { click: "imageSelect('logo')" } } + %input.button.primary.right{ type: "submit", value: "Continue" } diff --git a/app/assets/javascripts/templates/registration/social.html.haml b/app/assets/javascripts/templates/registration/social.html.haml index 3195b97a29..ba07a28062 100644 --- a/app/assets/javascripts/templates/registration/social.html.haml +++ b/app/assets/javascripts/templates/registration/social.html.haml @@ -35,5 +35,4 @@ .row.buttons .small-12.columns %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('images')" } } -   - %input.button.primary{ type: "submit", value: "Continue" } + %input.button.primary.right{ type: "submit", value: "Continue" } diff --git a/app/assets/javascripts/templates/registration/type.html.haml b/app/assets/javascripts/templates/registration/type.html.haml index 164537d58e..aed5c9c3de 100644 --- a/app/assets/javascripts/templates/registration/type.html.haml +++ b/app/assets/javascripts/templates/registration/type.html.haml @@ -33,9 +33,8 @@ %h4 I'm A Hub %p Hubs connect the producer to the eater. Hubs can be co-ops, independent retailers, buying groups, wholesalers, CSA box schemes, farm-gate stalls, etc. - .row.buttons .small-12.columns %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('contact')" } } -   - %input.button.primary{ type: "submit", value: "Continue" } + %input.button.primary.right{ type: "submit", value: "Continue" } + From c4d47ccc2060207cb6b91a4b6adfcc4677af4145 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 17 Oct 2014 10:46:30 +1100 Subject: [PATCH 30/48] Change enterprise attributes defined in reg controller --- app/controllers/registration_controller.rb | 4 ++-- spec/features/consumer/registration_spec.rb | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/registration_controller.rb b/app/controllers/registration_controller.rb index 4fae68bb79..a7401abf60 100644 --- a/app/controllers/registration_controller.rb +++ b/app/controllers/registration_controller.rb @@ -7,11 +7,11 @@ class RegistrationController < BaseController layout 'registration' def index - @enterprise_attributes = { type: 'profile' } + @enterprise_attributes = { sells: 'none' } end def store - @enterprise_attributes = { is_distributor: true, is_primary_producer: true, type: 'single' } + @enterprise_attributes = { is_primary_producer: true, sells: 'own' } render :index end diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index 91bd92eb91..8c55ae3a68 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -3,8 +3,7 @@ require 'spec_helper' feature "Registration", js: true do include WebHelper - # TODO fix this after removal of is_distributor. - pending "Registering a Profile" do + describe "Registering a Profile" do let(:user) { create(:user, password: "password", password_confirmation: "password") } it "Allows a logged in user to register a profile" do @@ -18,7 +17,7 @@ feature "Registration", js: true do # Enter Login details fill_in "Email", with: user.email fill_in "Password", with: user.password - click_login_and_ensure_content "This wizard will step you through creating a profile" + click_login_and_ensure_content "Hi there!" expect(URI.parse(current_url).path).to eq registration_path @@ -45,8 +44,11 @@ feature "Registration", js: true do # Choosing a type expect(page).to have_content 'Last step to create your enterprise!' - click_link 'both-panel' + click_link 'producer-panel' click_button 'Continue' + sleep 2 + click_button 'Continue' + save_screenshot '/Users/rob/Desktop/ss.png' # Enterprise should be created expect(page).to have_content 'Nice one!' @@ -107,7 +109,7 @@ feature "Registration", js: true do # Enter Login details fill_in "Email", with: user.email fill_in "Password", with: user.password - click_login_and_ensure_content "This wizard will step you through creating a profile" + click_login_and_ensure_content "Hi there!" expect(URI.parse(current_url).path).to eq store_registration_path From 81715aaf5d06b49686cabef91f35f379d298f14e Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 17 Oct 2014 10:49:54 +1100 Subject: [PATCH 31/48] Remove unrequired store registration action --- app/controllers/registration_controller.rb | 7 +---- config/routes.rb | 1 - .../registration_controller_spec.rb | 12 --------- spec/features/consumer/registration_spec.rb | 27 ------------------- 4 files changed, 1 insertion(+), 46 deletions(-) diff --git a/app/controllers/registration_controller.rb b/app/controllers/registration_controller.rb index a7401abf60..5a21d28a44 100644 --- a/app/controllers/registration_controller.rb +++ b/app/controllers/registration_controller.rb @@ -2,7 +2,7 @@ require 'open_food_network/spree_api_key_loader' class RegistrationController < BaseController include OpenFoodNetwork::SpreeApiKeyLoader - before_filter :load_spree_api_key, only: [:index, :store] + before_filter :load_spree_api_key, only: [:index] before_filter :check_user, except: :authenticate layout 'registration' @@ -10,11 +10,6 @@ class RegistrationController < BaseController @enterprise_attributes = { sells: 'none' } end - def store - @enterprise_attributes = { is_primary_producer: true, sells: 'own' } - render :index - end - private def check_user diff --git a/config/routes.rb b/config/routes.rb index 9cdac4142d..ca4a6b59ff 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,7 +6,6 @@ Openfoodnetwork::Application.routes.draw do get "/map", to: "map#index", as: :map get "/register", to: "registration#index", as: :registration - get "/register/store", to: "registration#store", as: :store_registration get "/register/auth", to: "registration#authenticate", as: :registration_auth resource :shop, controller: "shop" do diff --git a/spec/controllers/registration_controller_spec.rb b/spec/controllers/registration_controller_spec.rb index e51a28f73a..8ef292dc68 100644 --- a/spec/controllers/registration_controller_spec.rb +++ b/spec/controllers/registration_controller_spec.rb @@ -7,11 +7,6 @@ describe RegistrationController do get :index response.should redirect_to registration_auth_path(anchor: "signup?after_login=/register") end - - it "store" do - get :store - response.should redirect_to registration_auth_path(anchor: "signup?after_login=/register/store") - end end describe "redirecting when user has reached enterprise ownership limit" do @@ -41,12 +36,5 @@ describe RegistrationController do expect(assigns(:spree_api_key)).to eq user.spree_api_key end end - - describe "store" do - it "loads the spree api key" do - get :store - expect(assigns(:spree_api_key)).to eq user.spree_api_key - end - end end end diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index 8c55ae3a68..551490363c 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -46,9 +46,6 @@ feature "Registration", js: true do expect(page).to have_content 'Last step to create your enterprise!' click_link 'producer-panel' click_button 'Continue' - sleep 2 - click_button 'Continue' - save_screenshot '/Users/rob/Desktop/ss.png' # Enterprise should be created expect(page).to have_content 'Nice one!' @@ -97,30 +94,6 @@ feature "Registration", js: true do expect(e.twitter).to eq "@TwItTeR" expect(e.instagram).to eq "@InStAgRaM" end - - it "Allows a logged in user to register a store" do - visit store_registration_path - - expect(URI.parse(current_url).path).to eq registration_auth_path - - page.has_selector? "dd", text: "Log in" - switch_to_login_tab - - # Enter Login details - fill_in "Email", with: user.email - fill_in "Password", with: user.password - click_login_and_ensure_content "Hi there!" - - expect(URI.parse(current_url).path).to eq store_registration_path - - # Done reading introduction - click_button_and_ensure_content "Let's get started!", "Woot! First we need to know a little bit about your farm:" - - # Details Page - expect(page).to_not have_selector '#enterprise-types' - - # Everything from here should be covered in 'profile' spec - end end def switch_to_login_tab From 2c5208ce6b9e8aaac7de6ac8a4b20436bf95ffec Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 17 Oct 2014 11:17:46 +1100 Subject: [PATCH 32/48] Change ent type page, simplify! --- .../templates/registration/type.html.haml | 36 ++++++++++--------- .../darkswarm/registration.css.sass | 18 ++++++++-- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/templates/registration/type.html.haml b/app/assets/javascripts/templates/registration/type.html.haml index aed5c9c3de..2c39f2a863 100644 --- a/app/assets/javascripts/templates/registration/type.html.haml +++ b/app/assets/javascripts/templates/registration/type.html.haml @@ -6,32 +6,34 @@ .small-12.columns %header %h2 - Last step to create your enterprise! - %h5 - Is + Last step to add %span{ ng: { class: "{brick: !enterprise.is_primary_producer, turquoise: enterprise.is_primary_producer}" } } {{ enterprise.name }} - a primary producer? + ! + %h4 + Are you a producer? %form{ name: 'type', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "create(type)" } } .row#enterprise-types{ 'data-equalizer' => true, bo: { if: "enterprise.type != 'own'" } } .small-12.columns.field .row - .small-12.columns - %label Choose one: + .small-12.medium-6.large-6.columns{ 'data-equalizer-watch' => true } + %a.btnpanel#producer-panel{ href: "#", ng: { click: "enterprise.is_primary_producer = true", class: "{selected: (enterprise.is_primary_producer)}" } } + %i.ofn-i_059-producer + %h4 Yes, I'm a producer + + .small-12.medium-6.large-6.columns{ 'data-equalizer-watch' => true } + %a.btnpanel#hub-panel{ href: "#", ng: { click: "enterprise.is_primary_producer = false", class: "{selected: (!enterprise.is_primary_producer)}" } } + %i.ofn-i_063-hub + %h4 No, I'm not a producer .row - .small-12.medium-6.large-6.columns{ 'data-equalizer-watch' => true } - %a.panel#producer-panel{ href: "#", ng: { click: "enterprise.is_primary_producer = true", class: "{selected: (enterprise.is_primary_producer)}" } } - .left - / %render-svg{ path: "/assets/map-icon-producer.svg" } - %h4 I'm A Producer + .small-12.columns + .panel.callout + .left + %i.ofn-i_013-help +   %p Producers make yummy things to eat &/or drink. You're a producer if you grow it, raise it, brew it, bake it, ferment it, milk it or mould it. - .small-12.medium-6.large-6.columns{ 'data-equalizer-watch' => true } - %a.panel#hub-panel{ href: "#", ng: { click: "enterprise.is_primary_producer = false", class: "{selected: (!enterprise.is_primary_producer)}" } } - .left - / %render-svg{ path: "/assets/map-icon-hub.svg" } - %h4 I'm A Hub - %p Hubs connect the producer to the eater. Hubs can be co-ops, independent retailers, buying groups, wholesalers, CSA box schemes, farm-gate stalls, etc. + / %p Hubs connect the producer to the eater. Hubs can be co-ops, independent retailers, buying groups, wholesalers, CSA box schemes, farm-gate stalls, etc. .row.buttons .small-12.columns diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index b0d0757720..f63eb30421 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -118,20 +118,32 @@ #registration-type #enterprise-types - a.panel + a.btnpanel display: block + padding: 1rem + margin-bottom: 1rem background-color: #efefef color: black - @media all and (min-width: 768px) - min-height: 200px + text-align: center + border: 1px solid transparent + i + font-size: 3rem + h4 + margin-top: 1rem + &:hover background-color: #fff + &#producer-panel:hover + border: 1px solid $clr-turquoise &, & * color: $clr-turquoise + &#hub-panel:hover, &#both-panel:hover + border: 1px solid $clr-brick &, & * color: $clr-brick + &.selected &, & * color: #fff From 4aa2aa5aee8f93d74c80ea26ad969899182f13b0 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 17 Oct 2014 11:56:25 +1100 Subject: [PATCH 33/48] Tweaking layout, text, styling for registration box --- .../templates/registration/about.html.haml | 32 ++++++++--------- .../templates/registration/images.html.haml | 4 +-- .../templates/registration/social.html.haml | 35 ++++++++++++------- .../templates/registration/type.html.haml | 3 +- 4 files changed, 42 insertions(+), 32 deletions(-) diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index 64ed3df0c1..5b7d2e6df6 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -6,40 +6,40 @@ %h2 Nice one! %h5 Now let's flesh out the details about - %span.brick{"ng-show" => "enterprise.is_distributor"} - {{ enterprise.name }} - %span.turquoise{"ng-show" => "!enterprise.is_distributor" } + %span{ ng: { class: "{brick: !enterprise.is_primary_producer, turquoise: enterprise.is_primary_producer}" } } {{ enterprise.name }} %form{ name: 'about', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "update('images',about)" } } .row .small-12.columns - .alert-box.alert{ "ofn-inline-alert" => true, ng: { show: "visible" } } - {{ enterprise.name }} won't be visible on the Open Food Network until you enter a long and short description. - %a.close{ ng: { click: "close()" } } × .alert-box.info{ "ofn-inline-alert" => true, ng: { show: "visible" } } - {{ enterprise.name }} has been created on the Open Food Network. If you leave at any point from here onwards, your enterprise will be saved, and you can always login to the admin section to update or continue filling out your enterprise details. + %h6 Success! {{ enterprise.name }} added to the Open Food Network + %span If you exit the wizard at any stage, login and go to admin to edit or update your enterprise details. %a.close{ ng: { click: "close()" } } × .small-12.large-8.columns .row .small-12.columns - %label{ for: 'enterprise_description' } Short Description: - %input.chunky.small-12.columns{ id: 'enterprise_description', placeholder: "A short sentence describing your enterprise", ng: { model: 'enterprise.description' } } + .field + %label{ for: 'enterprise_description' } Short Description: + %input.chunky{ id: 'enterprise_description', placeholder: "A short sentence describing your enterprise", ng: { model: 'enterprise.description' } } .row .small-12.columns - %label{ for: 'enterprise_long_desc' } Long Description: - %textarea.chunky.small-12.columns{ id: 'enterprise_long_desc', rows: 6, placeholder: "This is your opportunity to tell the story of your enterprise - what makes you different and wonderful? We'd suggest keeping your description to under 600 characters or 150 words.", ng: { model: 'enterprise.long_description' } } - %small {{ enterprise.long_description.length }} characters / up to 600 recommended + .field + %label{ for: 'enterprise_long_desc' } Long Description: + %textarea.chunky{ id: 'enterprise_long_desc', rows: 6, placeholder: "This is your opportunity to tell the story of your enterprise - what makes you different and wonderful? We'd suggest keeping your description to under 600 characters or 150 words.", ng: { model: 'enterprise.long_description' } } + %small {{ enterprise.long_description.length }} characters / up to 600 recommended .small-12.large-4.columns .row .small-12.columns - %label{ for: 'enterprise_abn' } ABN: - %input.chunky.small-12.columns{ id: 'enterprise_abn', placeholder: "eg. 99 123 456 789", ng: { model: 'enterprise.abn' } } + .field + %label{ for: 'enterprise_abn' } ABN: + %input.chunky{ id: 'enterprise_abn', placeholder: "eg. 99 123 456 789", ng: { model: 'enterprise.abn' } } .row .small-12.columns - %label{ for: 'enterprise_acn' } ACN: - %input.chunky.small-12.columns{ id: 'enterprise_acn', placeholder: "eg. 123 456 789", ng: { model: 'enterprise.acn' } } + .field + %label{ for: 'enterprise_acn' } ACN: + %input.chunky{ id: 'enterprise_acn', placeholder: "eg. 123 456 789", ng: { model: 'enterprise.acn' } } .row.buttons.pad-top .small-12.columns diff --git a/app/assets/javascripts/templates/registration/images.html.haml b/app/assets/javascripts/templates/registration/images.html.haml index 3c0615a216..5b2ac39b5a 100644 --- a/app/assets/javascripts/templates/registration/images.html.haml +++ b/app/assets/javascripts/templates/registration/images.html.haml @@ -12,9 +12,9 @@ .row.buttons.pad-top{ ng: { if: "imageStep == 'logo'" } } .small-12.columns - %input.button.primary{ type: "button", value: "Back", ng: { click: "select('about')" } } + %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('about')" } }   - %input.button.primary{ type: "button", value: "Continue", ng: { click: "imageSelect('promo')" } } + %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "imageSelect('promo')" } } .row.buttons.pad-top{ ng: { if: "imageStep == 'promo'" } } .small-12.columns diff --git a/app/assets/javascripts/templates/registration/social.html.haml b/app/assets/javascripts/templates/registration/social.html.haml index ba07a28062..4f448734f1 100644 --- a/app/assets/javascripts/templates/registration/social.html.haml +++ b/app/assets/javascripts/templates/registration/social.html.haml @@ -4,35 +4,46 @@ .row .small-12.columns %header - %h2 Almost there! - %h5 How can people find {{ enterprise.name }} online? + %h2 Final step! + %h5 + How can people find + %span{ ng: { class: "{brick: !enterprise.is_primary_producer, turquoise: enterprise.is_primary_producer}" } } + {{ enterprise.name }} + online? %form{ name: 'social', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "update('finished',social)" } } .row.content .small-12.large-7.columns .row .small-12.columns - %label{ for: 'enterprise_website' } Website: - %input.chunky.small-12.columns{ id: 'enterprise_website', placeholder: "eg. openfoodnetwork.org.au", ng: { model: 'enterprise.website' } } + .field + %label{ for: 'enterprise_website' } Website: + %input.chunky{ id: 'enterprise_website', placeholder: "eg. openfoodnetwork.org.au", ng: { model: 'enterprise.website' } } .row .small-12.columns - %label{ for: 'enterprise_facebook' } Facebook: - %input.chunky.small-12.columns{ id: 'enterprise_facebook', placeholder: "eg. www.facebook.com/PageNameHere", ng: { model: 'enterprise.facebook' } } + .field + %label{ for: 'enterprise_facebook' } Facebook: + %input.chunky{ id: 'enterprise_facebook', placeholder: "eg. www.facebook.com/PageNameHere", ng: { model: 'enterprise.facebook' } } .row .small-12.columns - %label{ for: 'enterprise_linkedin' } LinkedIn: - %input.chunky.small-12.columns{ id: 'enterprise_linkedin', placeholder: "eg. www.linkedin.com/YourNameHere", ng: { model: 'enterprise.linkedin' } } + .field + %label{ for: 'enterprise_linkedin' } LinkedIn: + %input.chunky{ id: 'enterprise_linkedin', placeholder: "eg. www.linkedin.com/YourNameHere", ng: { model: 'enterprise.linkedin' } } .small-12.large-5.columns .row .small-12.columns - %label{ for: 'enterprise_twitter' } Twitter: - %input.chunky.small-12.columns{ id: 'enterprise_twitter', placeholder: "eg. @twitter_handle", ng: { model: 'enterprise.twitter' } } + .field + %label{ for: 'enterprise_twitter' } Twitter: + %input.chunky{ id: 'enterprise_twitter', placeholder: "eg. @twitter_handle", ng: { model: 'enterprise.twitter' } } .row .small-12.columns - %label{ for: 'enterprise_instagram' } Instagram: - %input.chunky.small-12.columns{ id: 'enterprise_instagram', placeholder: "eg. @instagram_handle", ng: { model: 'enterprise.instagram' } } + .field + %label{ for: 'enterprise_instagram' } Instagram: + %input.chunky{ id: 'enterprise_instagram', placeholder: "eg. @instagram_handle", ng: { model: 'enterprise.instagram' } } .row.buttons .small-12.columns %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('images')" } } %input.button.primary.right{ type: "submit", value: "Continue" } + + diff --git a/app/assets/javascripts/templates/registration/type.html.haml b/app/assets/javascripts/templates/registration/type.html.haml index 2c39f2a863..c23d2c24e8 100644 --- a/app/assets/javascripts/templates/registration/type.html.haml +++ b/app/assets/javascripts/templates/registration/type.html.haml @@ -8,8 +8,7 @@ %h2 Last step to add %span{ ng: { class: "{brick: !enterprise.is_primary_producer, turquoise: enterprise.is_primary_producer}" } } - {{ enterprise.name }} - ! + {{ enterprise.name }}! %h4 Are you a producer? From 4abc59f66d6ce55534eb83d386b91e49ad0ba90a Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 17 Oct 2014 12:02:21 +1100 Subject: [PATCH 34/48] Change styling on the enterprise name because we dont know what type it is yet --- .../javascripts/templates/registration/contact.html.haml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index b87073431e..916a614c0b 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -5,9 +5,7 @@ %header %h2 Greetings! %h5 - Who is responsible for managing - %span.turquoise - {{ enterprise.name }}? + Who is responsible for managing {{ enterprise.name }}? %form{ name: 'contact', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "selectIfValid('type',contact)" } } .row.content From b671543a951243f9a74cb0d5d9ada66f7b4ea5e0 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 17 Oct 2014 12:25:04 +1100 Subject: [PATCH 35/48] Style and make pretty the finished step of profile creation --- .../templates/registration/finished.html.haml | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/templates/registration/finished.html.haml b/app/assets/javascripts/templates/registration/finished.html.haml index 5319e98baa..f647a2d8bb 100644 --- a/app/assets/javascripts/templates/registration/finished.html.haml +++ b/app/assets/javascripts/templates/registration/finished.html.haml @@ -1,23 +1,24 @@ .container#registration-finished .row - .small-12.columns + .small-12.columns.pad-top %header - %h2 Well done! - %h5 - That's all of the details we need for - %span.brick{"ng-show" => "enterprise.is_distributor"} - {{ enterprise.name }} - %span.turquoise{"ng-show" => "!enterprise.is_distributor" } - {{ enterprise.name }} + %h2 Finished! + .panel.callout + %p + Thanks for filling out the details for + %span{ ng: { class: "{brick: !enterprise.is_primary_producer, turquoise: enterprise.is_primary_producer}" } } + {{ enterprise.name }} + %p You can change or update your enterprise at any stage by logging into Open Food Network and going to Admin. + .row + .small-12.columns.text-center + %h4 + Activate + %span{ ng: { class: "{brick: !enterprise.is_primary_producer, turquoise: enterprise.is_primary_producer}" } } + {{ enterprise.name }} - .content{ style: 'text-align: center'} + %p + We've sent a confirmation email to + %strong {{ enterprise.email }}. + %br Please follow the instructions there to make your enterprise visible on the Open Food Network. - %h3 There's just one last thing we need you to do: - %h5 We've sent a confirmation email to {{ enterprise.email }}, so please follow the instructions there to finalise the creation of your enterprise. - - -# perhaps a pretty picture here? - - %br/ - %br/ - - %a.button.primary{ type: "button", href: "/" } Take me home > + %a.button.primary{ type: "button", href: "/" } Open Food Network home > From a6bc9e66f671f4ad6266479f526f645e85ed3f1d Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 17 Oct 2014 11:40:28 +1100 Subject: [PATCH 36/48] Only send one enterprise creation confirmation email --- app/mailers/enterprise_mailer.rb | 12 ++++++------ app/models/enterprise.rb | 6 ------ .../creation_confirmation.html.haml | 9 --------- spec/mailers/enterprise_mailer_spec.rb | 12 +++++------- 4 files changed, 11 insertions(+), 28 deletions(-) delete mode 100644 app/views/enterprise_mailer/creation_confirmation.html.haml diff --git a/app/mailers/enterprise_mailer.rb b/app/mailers/enterprise_mailer.rb index f5f92aed3f..4e37d112e0 100644 --- a/app/mailers/enterprise_mailer.rb +++ b/app/mailers/enterprise_mailer.rb @@ -2,14 +2,14 @@ require 'devise/mailers/helpers' class EnterpriseMailer < Spree::BaseMailer include Devise::Mailers::Helpers - def creation_confirmation(enterprise) - find_enterprise(enterprise) - subject = "#{@enterprise.name} is now on #{Spree::Config[:site_name]}" - mail(:to => @enterprise.owner.email, :from => from_address, :subject => subject) - end - def confirmation_instructions(record, token, opts={}) @token = token + find_enterprise(record) + opts = { + subject: "Please confirm your email for #{@enterprise.name}", + to: [ @enterprise.owner.email, @enterprise.email ].uniq, + from: from_address, + } devise_mail(record, :confirmation_instructions, opts) end diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 22182a4c9a..069c8860cc 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -10,8 +10,6 @@ class Enterprise < ActiveRecord::Base before_create :check_email - after_create :send_creation_email - has_and_belongs_to_many :groups, class_name: 'EnterpriseGroup' has_many :producer_properties, foreign_key: 'producer_id' has_many :supplied_products, :class_name => 'Spree::Product', :foreign_key => 'supplier_id', :dependent => :destroy @@ -272,10 +270,6 @@ class Enterprise < ActiveRecord::Base skip_confirmation! if owner.enterprises.confirmed.map(&:email).include?(email) end - def send_creation_email - EnterpriseMailer.creation_confirmation(self).deliver - end - def strip_url(url) url.andand.sub(/(https?:\/\/)?/, '') end diff --git a/app/views/enterprise_mailer/creation_confirmation.html.haml b/app/views/enterprise_mailer/creation_confirmation.html.haml deleted file mode 100644 index 0df3bf06a0..0000000000 --- a/app/views/enterprise_mailer/creation_confirmation.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -%h1 - = @enterprise.name + " has been created" - -%h3 - Why not check it out on - %a{ href: "#{map_url}" } - = Spree::Config[:site_name] + "?" - -If you have any questions, please get in touch with us at: hello@openfoodnetwork.org diff --git a/spec/mailers/enterprise_mailer_spec.rb b/spec/mailers/enterprise_mailer_spec.rb index 6b53d7d561..dd1e150eb7 100644 --- a/spec/mailers/enterprise_mailer_spec.rb +++ b/spec/mailers/enterprise_mailer_spec.rb @@ -1,18 +1,16 @@ require 'spec_helper' describe EnterpriseMailer do + let!(:enterprise) { create(:enterprise) } + before do - @enterprise = create(:enterprise) ActionMailer::Base.deliveries = [] end - it "should send an email when given an enterprise" do - EnterpriseMailer.creation_confirmation(@enterprise).deliver - ActionMailer::Base.deliveries.count.should == 1 - end - it "should send an email confirmation when given an enterprise" do - EnterpriseMailer.confirmation_instructions(@enterprise, 'token').deliver + EnterpriseMailer.confirmation_instructions(enterprise, 'token').deliver ActionMailer::Base.deliveries.count.should == 1 + mail = ActionMailer::Base.deliveries.first + expect(mail.subject).to eq "Please confirm your email for #{enterprise.name}" end end \ No newline at end of file From e9a3f8ce9175f943234c3321fca86291c3ac9a94 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 17 Oct 2014 12:14:33 +1100 Subject: [PATCH 37/48] Require user to choose producer or not --- .../templates/registration/type.html.haml | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/templates/registration/type.html.haml b/app/assets/javascripts/templates/registration/type.html.haml index c23d2c24e8..48d45cb66a 100644 --- a/app/assets/javascripts/templates/registration/type.html.haml +++ b/app/assets/javascripts/templates/registration/type.html.haml @@ -6,30 +6,36 @@ .small-12.columns %header %h2 - Last step to add + Last step to add %span{ ng: { class: "{brick: !enterprise.is_primary_producer, turquoise: enterprise.is_primary_producer}" } } {{ enterprise.name }}! %h4 - Are you a producer? + Are you a producer? %form{ name: 'type', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "create(type)" } } .row#enterprise-types{ 'data-equalizer' => true, bo: { if: "enterprise.type != 'own'" } } .small-12.columns.field .row .small-12.medium-6.large-6.columns{ 'data-equalizer-watch' => true } - %a.btnpanel#producer-panel{ href: "#", ng: { click: "enterprise.is_primary_producer = true", class: "{selected: (enterprise.is_primary_producer)}" } } + %a.btnpanel#producer-panel{ href: "#", ng: { click: "enterprise.is_primary_producer = true", class: "{selected: enterprise.is_primary_producer}" } } %i.ofn-i_059-producer %h4 Yes, I'm a producer - + .small-12.medium-6.large-6.columns{ 'data-equalizer-watch' => true } - %a.btnpanel#hub-panel{ href: "#", ng: { click: "enterprise.is_primary_producer = false", class: "{selected: (!enterprise.is_primary_producer)}" } } + %a.btnpanel#hub-panel{ href: "#", ng: { click: "enterprise.is_primary_producer = false", class: "{selected: enterprise.is_primary_producer == false}" } } %i.ofn-i_063-hub %h4 No, I'm not a producer + + .row + .small-12.columns + %input.chunky{ id: 'enterprise_is_primary_producer', name: 'is_primary_producer', hidden: true, required: true, ng: { model: 'enterprise.is_primary_producer' } } + %span.error{ ng: { show: "type.is_primary_producer.$error.required && submitted" } } + Please choose one. Are you are producer? .row .small-12.columns .panel.callout - .left - %i.ofn-i_013-help + .left + %i.ofn-i_013-help   %p Producers make yummy things to eat &/or drink. You're a producer if you grow it, raise it, brew it, bake it, ferment it, milk it or mould it. / %p Hubs connect the producer to the eater. Hubs can be co-ops, independent retailers, buying groups, wholesalers, CSA box schemes, farm-gate stalls, etc. @@ -38,4 +44,3 @@ .small-12.columns %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('contact')" } } %input.button.primary.right{ type: "submit", value: "Continue" } - From eda0b16a5f7b703633025ec5836464e260190054 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 17 Oct 2014 12:18:00 +1100 Subject: [PATCH 38/48] Make state abbreviations upper case --- app/serializers/api/state_serializer.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/serializers/api/state_serializer.rb b/app/serializers/api/state_serializer.rb index bcf9221ec5..7a76e340b4 100644 --- a/app/serializers/api/state_serializer.rb +++ b/app/serializers/api/state_serializer.rb @@ -1,3 +1,7 @@ class Api::StateSerializer < ActiveModel::Serializer attributes :id, :name, :abbr + + def abbr + object.abbr.upcase + end end \ No newline at end of file From 4d078feea24bab8bf0108f41b01e5d28a3778ee5 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 17 Oct 2014 16:12:51 +1100 Subject: [PATCH 39/48] Add default scope to devise to stop it from checking other devise enabled models (in this case :enterprise) --- config/initializers/devise.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 config/initializers/devise.rb diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb new file mode 100644 index 0000000000..9fef52fc8c --- /dev/null +++ b/config/initializers/devise.rb @@ -0,0 +1,5 @@ +Devise.setup do |config| + # Add a default scope to devise, to prevent it from checking + # whether other devise enabled models are signed into a session or not + config.default_scope = :spree_user +end \ No newline at end of file From e24a774d54f7d0d7042ecf0e88fe2670882a6328 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 17 Oct 2014 16:16:17 +1100 Subject: [PATCH 40/48] Adding schema --- db/schema.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index b62f63a725..974dc8ac9b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -263,12 +263,12 @@ ActiveRecord::Schema.define(:version => 20141010043405) do t.string "facebook" t.string "instagram" t.string "linkedin" - t.integer "owner_id", :null => false - t.string "sells", :default => "none", :null => false + t.integer "owner_id", :null => false t.string "confirmation_token" t.datetime "confirmed_at" t.datetime "confirmation_sent_at" t.string "unconfirmed_email" + t.string "sells", :default => "none", :null => false end add_index "enterprises", ["address_id"], :name => "index_enterprises_on_address_id" From 5b3ff9160dc2559236fe7e044e1cc1a3a51cf593 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 17 Oct 2014 17:15:16 +1100 Subject: [PATCH 41/48] Fix Registration spec --- spec/features/consumer/registration_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index 551490363c..ea09450467 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -32,7 +32,7 @@ feature "Registration", js: true do fill_in 'enterprise_city', with: 'Northcote' fill_in 'enterprise_zipcode', with: '3070' select 'Australia', from: 'enterprise_country' - select 'Vic', from: 'enterprise_state' + select 'VIC', from: 'enterprise_state' click_button 'Continue' # Filling in Contact Details @@ -43,7 +43,7 @@ feature "Registration", js: true do click_button 'Continue' # Choosing a type - expect(page).to have_content 'Last step to create your enterprise!' + expect(page).to have_content 'Last step to add My Awesome Enterprise!' click_link 'producer-panel' click_button 'Continue' @@ -77,7 +77,7 @@ feature "Registration", js: true do click_button 'Continue' # Filling in social - expect(page).to have_content 'Almost there!' + expect(page).to have_content 'How can people find My Awesome Enterprise online?' fill_in 'enterprise_website', with: 'www.shop.com' fill_in 'enterprise_facebook', with: 'FaCeBoOk' fill_in 'enterprise_linkedin', with: 'LiNkEdIn' @@ -86,7 +86,7 @@ feature "Registration", js: true do click_button 'Continue' # Done - expect(page).to have_content "That's all of the details we need for My Awesome Enterprise" + expect(page).to have_content "Finished!" e.reload expect(e.website).to eq "www.shop.com" expect(e.facebook).to eq "FaCeBoOk" From 338ba74652449f10df8242d6f690d690e41f69c8 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 17 Oct 2014 17:15:49 +1100 Subject: [PATCH 42/48] Only show enterprise partial when no enterprises exist --- .../spree/admin/overview/index.html.haml | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/views/spree/admin/overview/index.html.haml b/app/views/spree/admin/overview/index.html.haml index 0709ceb54f..d83a71bc40 100644 --- a/app/views/spree/admin/overview/index.html.haml +++ b/app/views/spree/admin/overview/index.html.haml @@ -6,13 +6,19 @@ %hr -- if can? :admin, Spree::Product - = render partial: "spree/admin/overview/products" +- if @enterprises.empty? - %div.two.columns -   + = render partial: "spree/admin/overview/enterprises" -- if can? :admin, OrderCycle - = render partial: "spree/admin/overview/order_cycles" +- else -= render partial: "spree/admin/overview/enterprises" + - if can? :admin, Spree::Product + = render partial: "spree/admin/overview/products" + + %div.two.columns +   + + - if can? :admin, OrderCycle + = render partial: "spree/admin/overview/order_cycles" + + = render partial: "spree/admin/overview/enterprises" From f499cc375be29b98ba925a7040a434821306fa4d Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 17 Oct 2014 17:32:27 +1100 Subject: [PATCH 43/48] Adding confirmed_at to enterprise factory --- spec/factories.rb | 1 + spec/features/consumer/producers_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/factories.rb b/spec/factories.rb index f9c65eb7ff..60b94b08c0 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -97,6 +97,7 @@ FactoryGirl.define do long_description '

Hello, world!

This is a paragraph.

' email 'enterprise@example.com' address { FactoryGirl.create(:address) } + confirmed_at { Time.now } end factory :supplier_enterprise, :parent => :enterprise do diff --git a/spec/features/consumer/producers_spec.rb b/spec/features/consumer/producers_spec.rb index 98bef7f084..6e09365195 100644 --- a/spec/features/consumer/producers_spec.rb +++ b/spec/features/consumer/producers_spec.rb @@ -3,14 +3,14 @@ require 'spec_helper' feature %q{ As a consumer I want to see a list of producers - So that I can shop at hubs distributing their products + So that I can shop at hubs distributing their products }, js: true do include UIComponentHelper let!(:producer) { create(:supplier_enterprise) } let!(:invisible_producer) { create(:supplier_enterprise, visible: false) } let(:taxon) { create(:taxon) } let!(:product) { create(:simple_product, supplier: producer, taxons: [taxon]) } - + before do visit producers_path end @@ -20,7 +20,7 @@ feature %q{ expand_active_table_node producer.name page.should have_content producer.supplied_taxons.first.name.split.map(&:capitalize).join(' ') end - + it "doesn't show invisible producers" do page.should_not have_content invisible_producer.name end From cae8d566df88fdc6ec270b8eeab14400988a63a3 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 17 Oct 2014 17:49:18 +1100 Subject: [PATCH 44/48] Explicit confirmed_at to ensure that confirmation emails are sent --- spec/models/enterprise_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index b6204c3fd3..151275ec71 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -6,18 +6,18 @@ describe Enterprise do describe "sending emails" do describe "on creation" do let!(:user) { create_enterprise_user( enterprise_limit: 2 ) } - let!(:enterprise) { create(:enterprise, owner: user, confirmed_at: Time.now) } + let!(:enterprise) { create(:enterprise, owner: user) } it "when the email address has not already been confirmed" do mail_message = double "Mail::Message" EnterpriseMailer.should_receive(:confirmation_instructions).and_return mail_message mail_message.should_receive :deliver - create(:enterprise, owner: user, email: "unknown@email.com" ) + create(:enterprise, owner: user, email: "unknown@email.com", confirmed_at: nil ) end it "when the email address has already been confirmed" do EnterpriseMailer.should_not_receive(:confirmation_instructions) - e = create(:enterprise, owner: user, email: enterprise.email) + e = create(:enterprise, owner: user, email: enterprise.email, confirmed_at: nil) end end end @@ -133,8 +133,8 @@ describe Enterprise do describe "confirmed" do it "find enterprises with a confirmed date" do - s1 = create(:supplier_enterprise, confirmed_at: Time.now) - d1 = create(:distributor_enterprise, confirmed_at: Time.now) + s1 = create(:supplier_enterprise) + d1 = create(:distributor_enterprise) s2 = create(:supplier_enterprise, confirmed_at: nil) d2 = create(:distributor_enterprise, confirmed_at: nil) expect(Enterprise.confirmed).to include s1, d1 @@ -144,8 +144,8 @@ describe Enterprise do describe "unconfirmed" do it "find enterprises without a confirmed date" do - s1 = create(:supplier_enterprise, confirmed_at: Time.now) - d1 = create(:distributor_enterprise, confirmed_at: Time.now) + s1 = create(:supplier_enterprise) + d1 = create(:distributor_enterprise) s2 = create(:supplier_enterprise, confirmed_at: nil) d2 = create(:distributor_enterprise, confirmed_at: nil) expect(Enterprise.unconfirmed).to_not include s1, d1 From 361116a9ec0ab14cfc3b883d40e6476ccae8e800 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 17 Oct 2014 18:31:35 +1100 Subject: [PATCH 45/48] Explicitly set confirmed_at for unconfirmed enterprise --- spec/controllers/devise/confirmation_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/controllers/devise/confirmation_controller_spec.rb b/spec/controllers/devise/confirmation_controller_spec.rb index eda5dc4823..b8719bbd8f 100644 --- a/spec/controllers/devise/confirmation_controller_spec.rb +++ b/spec/controllers/devise/confirmation_controller_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Devise::ConfirmationsController do context "after confirmation" do before do - e = create(:enterprise) + e = create(:enterprise, confirmed_at: nil) @request.env["devise.mapping"] = Devise.mappings[:enterprise] spree_get :show, confirmation_token: e.confirmation_token end From fec8f08966b4695a51a17867599c0c371fcbd685 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Sat, 18 Oct 2014 16:15:41 +1100 Subject: [PATCH 46/48] use sql for migration --- ...140927005043_enterprise_config_refactor.rb | 53 ++++++++++--------- db/schema.rb | 2 +- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/db/migrate/20140927005043_enterprise_config_refactor.rb b/db/migrate/20140927005043_enterprise_config_refactor.rb index f9e8c936ce..f497e62f10 100644 --- a/db/migrate/20140927005043_enterprise_config_refactor.rb +++ b/db/migrate/20140927005043_enterprise_config_refactor.rb @@ -4,8 +4,19 @@ class EnterpriseConfigRefactor < ActiveRecord::Migration add_index :enterprises, :sells add_index :enterprises, [:is_primary_producer, :sells] - Enterprise.all.each do |enterprise| - enterprise.update_attributes!({:sells => sells_what?(enterprise)}) + # Combine is_distributor and type into sells. + db.select_values("SELECT id FROM enterprises").each do |enterprise_id| + distributor = db.select_values("SELECT is_distributor FROM enterprises WHERE id = #{db.quote(enterprise_id)}") + primary_producer = db.select_value("SELECT is_distributor FROM enterprises WHERE id = #{db.quote(enterprise_id)}") + type = db.select_value("SELECT type FROM enterprises WHERE id = #{db.quote(enterprise_id)}") + if type == "single" && (distributor || primary_producer) + sells = "own" + elsif !distributor || type == "profile" + sells = "none" + else + sells = "any" + end + db.update("UPDATE enterprises SET sells = #{db.quote(sells)} WHERE id = #{db.quote(enterprise_id)}") end remove_column :enterprises, :type @@ -17,33 +28,25 @@ class EnterpriseConfigRefactor < ActiveRecord::Migration add_column :enterprises, :type, :string, null: false, default: 'profile' add_column :enterprises, :is_distributor, :boolean - Enterprise.all.each do |enterprise| - enterprise.update_attributes!({ - :type => type?(enterprise), - :is_distributor => distributes?(enterprise) - }) + # Combine is_distributor and type into sells. + db.select_values("SELECT id FROM enterprises").each do |enterprise_id| + sells = db.select_value("SELECT sells FROM enterprises WHERE id = #{db.quote(enterprise_id)}") + case sells + when "own" + type = "single" + when "any" + type = "full" + else + type = "profile" + end + distributor = sells != "none" + db.update("UPDATE enterprises SET type = #{db.quote(type)}, is_distributor = #{db.quote(distributor)} WHERE id = #{db.quote(enterprise_id)}") end remove_column :enterprises, :sells end - def sells_what?(enterprise) - is_distributor = enterprise.read_attribute(:is_distributor) - is_primary_producer = enterprise.read_attribute(:is_primary_producer) - type = enterprise.read_attribute(:type) - return "own" if type == "single" && (is_distributor || is_primary_producer) - return "none" if !is_distributor || type == "profile" - return "any" - end - - def distributes?(enterprise) - enterprise.read_attribute(:sells) != "none" - end - - def type?(enterprise) - sells = enterprise.read_attribute(:sells) - return "profile" if sells == "none" - return "single" if sells == "own" - return "full" + def db + ActiveRecord::Base.connection end end diff --git a/db/schema.rb b/db/schema.rb index 974dc8ac9b..114dcd6b73 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -264,11 +264,11 @@ ActiveRecord::Schema.define(:version => 20141010043405) do t.string "instagram" t.string "linkedin" t.integer "owner_id", :null => false + t.string "sells", :default => "none", :null => false t.string "confirmation_token" t.datetime "confirmed_at" t.datetime "confirmation_sent_at" t.string "unconfirmed_email" - t.string "sells", :default => "none", :null => false end add_index "enterprises", ["address_id"], :name => "index_enterprises_on_address_id" From 4308f7d09c4949ac1ee9de640e195567d19637f7 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 22 Oct 2014 09:43:10 +1100 Subject: [PATCH 47/48] Revert "use sql for migration" This reverts commit fec8f08966b4695a51a17867599c0c371fcbd685. --- ...140927005043_enterprise_config_refactor.rb | 53 +++++++++---------- db/schema.rb | 2 +- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/db/migrate/20140927005043_enterprise_config_refactor.rb b/db/migrate/20140927005043_enterprise_config_refactor.rb index f497e62f10..f9e8c936ce 100644 --- a/db/migrate/20140927005043_enterprise_config_refactor.rb +++ b/db/migrate/20140927005043_enterprise_config_refactor.rb @@ -4,19 +4,8 @@ class EnterpriseConfigRefactor < ActiveRecord::Migration add_index :enterprises, :sells add_index :enterprises, [:is_primary_producer, :sells] - # Combine is_distributor and type into sells. - db.select_values("SELECT id FROM enterprises").each do |enterprise_id| - distributor = db.select_values("SELECT is_distributor FROM enterprises WHERE id = #{db.quote(enterprise_id)}") - primary_producer = db.select_value("SELECT is_distributor FROM enterprises WHERE id = #{db.quote(enterprise_id)}") - type = db.select_value("SELECT type FROM enterprises WHERE id = #{db.quote(enterprise_id)}") - if type == "single" && (distributor || primary_producer) - sells = "own" - elsif !distributor || type == "profile" - sells = "none" - else - sells = "any" - end - db.update("UPDATE enterprises SET sells = #{db.quote(sells)} WHERE id = #{db.quote(enterprise_id)}") + Enterprise.all.each do |enterprise| + enterprise.update_attributes!({:sells => sells_what?(enterprise)}) end remove_column :enterprises, :type @@ -28,25 +17,33 @@ class EnterpriseConfigRefactor < ActiveRecord::Migration add_column :enterprises, :type, :string, null: false, default: 'profile' add_column :enterprises, :is_distributor, :boolean - # Combine is_distributor and type into sells. - db.select_values("SELECT id FROM enterprises").each do |enterprise_id| - sells = db.select_value("SELECT sells FROM enterprises WHERE id = #{db.quote(enterprise_id)}") - case sells - when "own" - type = "single" - when "any" - type = "full" - else - type = "profile" - end - distributor = sells != "none" - db.update("UPDATE enterprises SET type = #{db.quote(type)}, is_distributor = #{db.quote(distributor)} WHERE id = #{db.quote(enterprise_id)}") + Enterprise.all.each do |enterprise| + enterprise.update_attributes!({ + :type => type?(enterprise), + :is_distributor => distributes?(enterprise) + }) end remove_column :enterprises, :sells end - def db - ActiveRecord::Base.connection + def sells_what?(enterprise) + is_distributor = enterprise.read_attribute(:is_distributor) + is_primary_producer = enterprise.read_attribute(:is_primary_producer) + type = enterprise.read_attribute(:type) + return "own" if type == "single" && (is_distributor || is_primary_producer) + return "none" if !is_distributor || type == "profile" + return "any" + end + + def distributes?(enterprise) + enterprise.read_attribute(:sells) != "none" + end + + def type?(enterprise) + sells = enterprise.read_attribute(:sells) + return "profile" if sells == "none" + return "single" if sells == "own" + return "full" end end diff --git a/db/schema.rb b/db/schema.rb index 114dcd6b73..974dc8ac9b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -264,11 +264,11 @@ ActiveRecord::Schema.define(:version => 20141010043405) do t.string "instagram" t.string "linkedin" t.integer "owner_id", :null => false - t.string "sells", :default => "none", :null => false t.string "confirmation_token" t.datetime "confirmed_at" t.datetime "confirmation_sent_at" t.string "unconfirmed_email" + t.string "sells", :default => "none", :null => false end add_index "enterprises", ["address_id"], :name => "index_enterprises_on_address_id" From b75af8d9fff0955c9f1f8fc0c18d22f12b278562 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 22 Oct 2014 10:49:23 +1100 Subject: [PATCH 48/48] Fix sells column coming out all 'none' --- db/migrate/20140927005043_enterprise_config_refactor.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/db/migrate/20140927005043_enterprise_config_refactor.rb b/db/migrate/20140927005043_enterprise_config_refactor.rb index f9e8c936ce..6b51ac6e50 100644 --- a/db/migrate/20140927005043_enterprise_config_refactor.rb +++ b/db/migrate/20140927005043_enterprise_config_refactor.rb @@ -1,9 +1,15 @@ class EnterpriseConfigRefactor < ActiveRecord::Migration + class Enterprise < ActiveRecord::Base + self.inheritance_column = nil + end + def up add_column :enterprises, :sells, :string, null: false, default: 'none' add_index :enterprises, :sells add_index :enterprises, [:is_primary_producer, :sells] + Enterprise.reset_column_information + Enterprise.all.each do |enterprise| enterprise.update_attributes!({:sells => sells_what?(enterprise)}) end @@ -17,6 +23,8 @@ class EnterpriseConfigRefactor < ActiveRecord::Migration add_column :enterprises, :type, :string, null: false, default: 'profile' add_column :enterprises, :is_distributor, :boolean + Enterprise.reset_column_information + Enterprise.all.each do |enterprise| enterprise.update_attributes!({ :type => type?(enterprise),