mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-24 05:38:52 +00:00
Merge master (with primary taxons restored)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
Darkswarm.controller "AccordionCtrl", ($scope, storage) ->
|
||||
Darkswarm.controller "AccordionCtrl", ($scope, storage, $timeout) ->
|
||||
$scope.accordion =
|
||||
details: true
|
||||
shipping: false
|
||||
@@ -9,3 +9,8 @@ Darkswarm.controller "AccordionCtrl", ($scope, storage) ->
|
||||
$scope.show = (name)->
|
||||
$scope.accordion[name] = true
|
||||
|
||||
$timeout =>
|
||||
if $scope.checkout.$valid
|
||||
for k, v of $scope.accordion
|
||||
$scope.accordion[k] = false
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
Darkswarm.controller "DetailsCtrl", ($scope) ->
|
||||
angular.extend(this, new FieldsetMixin($scope))
|
||||
|
||||
$scope.name = "details"
|
||||
$scope.nextPanel = "billing"
|
||||
|
||||
@@ -11,11 +12,3 @@ Darkswarm.controller "DetailsCtrl", ($scope) ->
|
||||
$scope.fullName = ->
|
||||
[$scope.order.bill_address.firstname ? null,
|
||||
$scope.order.bill_address.lastname ? null].join(" ").trim()
|
||||
|
||||
|
||||
#$scope.$watch ->
|
||||
#$scope.detailsValid()
|
||||
#, (valid)->
|
||||
#if valid
|
||||
#$scope.show("billing")
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
Darkswarm.factory 'CheckoutFormState', ()->
|
||||
# Just a singleton place to store data about the form statr
|
||||
# Just a singleton place to store data about the form state
|
||||
new class CheckoutFormState
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
margin-right: 12px
|
||||
location
|
||||
font-family: "AvenirBla_IE", "AvenirBla"
|
||||
padding-right: 16px
|
||||
@media all and (max-width: 768px)
|
||||
location, location + small
|
||||
display: block
|
||||
@@ -58,21 +57,23 @@
|
||||
@media all and (max-width: 768px)
|
||||
font-size: 1.2em
|
||||
select
|
||||
width: 280px
|
||||
width: inherit
|
||||
display: inline-block
|
||||
vackground: transparent
|
||||
border-width: 2px
|
||||
border-color: #666666
|
||||
border-width: 1px
|
||||
border-color: #999
|
||||
color: #666
|
||||
font-size: 1em
|
||||
margin-bottom: 0
|
||||
padding: 8px 0px 8px 12px
|
||||
padding: 8px 20px 8px 12px
|
||||
@media all and (max-width: 768px)
|
||||
font-size: 1.2em
|
||||
width: 180px
|
||||
// width: 180px
|
||||
closing
|
||||
font-size: 0.875em
|
||||
color: black
|
||||
font-size: 1.5em
|
||||
display: block
|
||||
padding-top: 14px
|
||||
padding-bottom: 20px
|
||||
|
||||
products
|
||||
display: block
|
||||
|
||||
@@ -4,6 +4,11 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
include EnterprisesHelper
|
||||
|
||||
def redirect_to(options = {}, response_status = {})
|
||||
::Rails.logger.error("Redirected by #{caller(1).first rescue "unknown"}")
|
||||
super(options, response_status)
|
||||
end
|
||||
|
||||
def after_sign_in_path_for(resource)
|
||||
if request.referer and referer_path = URI(request.referer).path
|
||||
[main_app.checkout_path].include?(referer_path) ? referer_path : root_path
|
||||
|
||||
@@ -11,4 +11,16 @@ Spree::Admin::BaseController.class_eval do
|
||||
authorize! :admin, record
|
||||
authorize! action, record
|
||||
end
|
||||
|
||||
# This is in Spree::Core::ControllerHelpers::Auth
|
||||
# But you can't easily reopen modules in Ruby
|
||||
def unauthorized
|
||||
if try_spree_current_user
|
||||
flash[:error] = t(:authorization_failure)
|
||||
redirect_to '/unauthorized'
|
||||
else
|
||||
store_location
|
||||
redirect_to root_path(anchor: "login?after_login=#{request.env['PATH_INFO']}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,11 +15,10 @@ Spree::Admin::OrdersController.class_eval do
|
||||
per(params[:per_page] || Spree::Config[:orders_per_page])
|
||||
} } }
|
||||
|
||||
|
||||
private
|
||||
|
||||
def load_spree_api_key
|
||||
current_user.generate_spree_api_key! unless spree_current_user.spree_api_key
|
||||
@spree_api_key = spree_current_user.spree_api_key
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,16 +4,5 @@ Spree::Admin::OverviewController.class_eval do
|
||||
@product_count = Spree::Product.active.managed_by(spree_current_user).count
|
||||
@order_cycle_count = OrderCycle.active.managed_by(spree_current_user).count
|
||||
end
|
||||
|
||||
# This is in Spree::Core::ControllerHelpers::Auth
|
||||
# But you can't easily reopen modules in Ruby
|
||||
def unauthorized
|
||||
if try_spree_current_user
|
||||
flash[:error] = t(:authorization_failure)
|
||||
redirect_to '/unauthorized'
|
||||
else
|
||||
store_location
|
||||
redirect_to root_path(anchor: "login?after_login=#{spree.admin_path}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -15,11 +15,12 @@ class Enterprise < ActiveRecord::Base
|
||||
has_and_belongs_to_many :payment_methods, join_table: 'distributors_payment_methods', class_name: 'Spree::PaymentMethod', foreign_key: 'distributor_id'
|
||||
has_and_belongs_to_many :shipping_methods, join_table: 'distributors_shipping_methods', class_name: 'Spree::ShippingMethod', foreign_key: 'distributor_id'
|
||||
|
||||
|
||||
delegate :latitude, :longitude, :city, :state_name, :to => :address
|
||||
|
||||
accepts_nested_attributes_for :address
|
||||
has_attached_file :logo, :styles => { :medium => "300x300>", :thumb => "100x100>" }
|
||||
has_attached_file :promo_image, :styles => { :large => "260x1200#", :thumb => "100x100>" }
|
||||
has_attached_file :promo_image, :styles => { :large => "1200x260#", :thumb => "100x100>" }
|
||||
|
||||
validates_presence_of :name
|
||||
validates_presence_of :address
|
||||
|
||||
@@ -9,7 +9,7 @@ class EnterpriseGroup < ActiveRecord::Base
|
||||
attr_accessible :name, :description, :long_description, :on_front_page, :enterprise_ids
|
||||
|
||||
attr_accessible :promo_image
|
||||
has_attached_file :promo_image, styles: {large: "260x1200#"}
|
||||
has_attached_file :promo_image, styles: {large: "1200x260#"}
|
||||
validates_attachment_content_type :promo_image, :content_type => /\Aimage\/.*\Z/
|
||||
|
||||
attr_accessible :logo
|
||||
|
||||
10
app/models/spree/classification_decorator.rb
Normal file
10
app/models/spree/classification_decorator.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
Spree::Classification.class_eval do
|
||||
before_destroy :dont_destroy_if_primary_taxon
|
||||
|
||||
def dont_destroy_if_primary_taxon
|
||||
if product.primary_taxon == taxon
|
||||
errors.add :base, "Taxon #{taxon.name} is the primary taxon of #{product.name} and cannot be deleted"
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -5,6 +5,7 @@ Spree::Product.class_eval do
|
||||
has_many :option_types, :through => :product_option_types, :dependent => :destroy
|
||||
|
||||
belongs_to :supplier, :class_name => 'Enterprise'
|
||||
belongs_to :primary_taxon, class_name: 'Spree::Taxon'
|
||||
|
||||
has_many :product_distributions, :dependent => :destroy
|
||||
has_many :distributors, :through => :product_distributions
|
||||
@@ -13,9 +14,10 @@ Spree::Product.class_eval do
|
||||
delegate_belongs_to :master, :unit_value, :unit_description
|
||||
delegate :images_attributes=, to: :master
|
||||
|
||||
attr_accessible :supplier_id, :distributor_ids, :product_distributions_attributes, :group_buy, :group_buy_unit_size, :variant_unit, :variant_unit_scale, :variant_unit_name, :unit_value, :unit_description, :notes, :images_attributes
|
||||
attr_accessible :supplier_id, :primary_taxon_id, :distributor_ids, :product_distributions_attributes, :group_buy, :group_buy_unit_size, :variant_unit, :variant_unit_scale, :variant_unit_name, :unit_value, :unit_description, :notes, :images_attributes
|
||||
|
||||
validates_presence_of :supplier
|
||||
validates_presence_of :primary_taxon
|
||||
|
||||
validates_presence_of :variant_unit, if: :has_variants?
|
||||
validates_presence_of :variant_unit_scale,
|
||||
@@ -25,6 +27,7 @@ Spree::Product.class_eval do
|
||||
|
||||
after_initialize :set_available_on_to_now, :if => :new_record?
|
||||
after_save :update_units
|
||||
before_save :add_primary_taxon_to_taxons
|
||||
|
||||
|
||||
# -- Joins
|
||||
@@ -124,10 +127,6 @@ Spree::Product.class_eval do
|
||||
order_cycle.variants_distributed_by(distributor).where(product_id: self)
|
||||
end
|
||||
|
||||
def primary_taxon
|
||||
self.taxons.order.first
|
||||
end
|
||||
|
||||
# Build a product distribution for each distributor
|
||||
def build_product_distributions_for_user user
|
||||
Enterprise.is_distributor.managed_by(user).each do |distributor|
|
||||
@@ -163,6 +162,10 @@ Spree::Product.class_eval do
|
||||
end
|
||||
end
|
||||
|
||||
def add_primary_taxon_to_taxons
|
||||
taxons << primary_taxon unless taxons.find_by_id(primary_taxon)
|
||||
end
|
||||
|
||||
def self.all_variant_unit_option_types
|
||||
Spree::OptionType.where('name LIKE ?', 'unit_%%')
|
||||
end
|
||||
|
||||
4
app/overrides/add_primary_taxon_to_admin_product.rb
Normal file
4
app/overrides/add_primary_taxon_to_admin_product.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
Deface::Override.new(:virtual_path => "spree/admin/products/_form",
|
||||
:insert_top => "[data-hook='admin_product_form_right']",
|
||||
:partial => "spree/admin/products/primary_taxon_form",
|
||||
:name => "add_primary_taxon_to_admin_product")
|
||||
4
app/overrides/add_primary_taxon_to_admin_product_new.rb
Normal file
4
app/overrides/add_primary_taxon_to_admin_product_new.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
Deface::Override.new(:virtual_path => "spree/admin/products/new",
|
||||
:insert_before => "[data-hook='new_product_attrs']",
|
||||
:partial => "spree/admin/products/primary_taxon_form",
|
||||
:name => "add_primary_taxon_to_admin_product_new")
|
||||
@@ -4,4 +4,3 @@
|
||||
= f.label :notes, t(:notes)
|
||||
= f.text_area :notes, { :class => 'fullwidth', rows: 5 }
|
||||
= f.error_message_on :notes
|
||||
|
||||
|
||||
@@ -177,5 +177,5 @@
|
||||
%a What's this?
|
||||
|
||||
.omega.eight.columns
|
||||
= image_tag @object.promo_image.url if @object.promo_image.present?
|
||||
= image_tag @object.promo_image(:large) if @object.promo_image.present?
|
||||
= f.file_field :promo_image
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
%fieldset#billing
|
||||
%ng-form{"ng-controller" => "BillingCtrl", name: "billing"}
|
||||
|
||||
%h5{"ng-class" => "{valid: billing.$valid, dirty: details.$dirty}"}
|
||||
%h5{"ng-class" => "{valid: billing.$valid, dirty: billing.$dirty}"}
|
||||
%span.right
|
||||
%label.label.round.alert
|
||||
%i.fi-x
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
%fieldset#payment
|
||||
%ng-form{"ng-controller" => "PaymentCtrl", name: "payment"}
|
||||
|
||||
%h5{"ng-class" => "{valid: payment.$valid, dirty: details.$dirty}"}
|
||||
%h5{"ng-class" => "{valid: payment.$valid, dirty: payment.$dirty}"}
|
||||
%span.right
|
||||
%label.label.round.alert
|
||||
%i.fi-x
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
%fieldset#shipping
|
||||
%ng-form{"ng-controller" => "ShippingCtrl", name: "shipping"}
|
||||
|
||||
%h5{"ng-class" => "{valid: shipping.$valid, dirty: details.$dirty}"}
|
||||
%h5{"ng-class" => "{valid: shipping.$valid, dirty: shipping.$dirty}"}
|
||||
%span.right
|
||||
%label.label.round.alert
|
||||
%i.fi-x
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
%div{"bo-if" => "hasVariants"}
|
||||
= render partial: "shop/products/variants"
|
||||
|
||||
.variant.row{"bo-if" => "!hasVariants"}
|
||||
.variants.row{"bo-if" => "!hasVariants"}
|
||||
= render partial: "shop/products/master"
|
||||
|
||||
.row
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.small-1.column
|
||||
.small-1.columns
|
||||
%span.bulk{"bo-if" => "product.group_buy"} bulk
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.row.summary
|
||||
.small-1.column
|
||||
.small-1.columns
|
||||
%img{"bo-src" => "product.master.images[0].small_url"}
|
||||
|
||||
.small-4.columns.summary-header
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.row.variants{bindonce: true,
|
||||
"ng-repeat" => "variant in product.variants"}
|
||||
|
||||
.small-1.column
|
||||
.small-1.columns
|
||||
%span.bulk{"bo-if" => "product.group_buy"} bulk
|
||||
|
||||
|
||||
|
||||
@@ -2,15 +2,20 @@
|
||||
- content_for :order_cycle_form do
|
||||
|
||||
%div{"ng-controller" => "OrderCycleChangeCtrl"}
|
||||
%strong.avenir Ready for
|
||||
%closing{"ng-if" => "OrderCycle.selected()"}
|
||||
Next order closing
|
||||
%strong {{ OrderCycle.orders_close_at() | date_in_words }}
|
||||
|
||||
%span Ready for pickup
|
||||
|
||||
/ Will this label should be a variable to reflect pickup or delivery as appropriate
|
||||
|
||||
%select.avenir#order_cycle_id{"ng-model" => "order_cycle.order_cycle_id",
|
||||
"ng-change" => "changeOrderCycle()",
|
||||
"ng-options" => "oc.id as oc.time for oc in #{@order_cycles.map {|oc| {time: pickup_time(oc), id: oc.id}}.to_json}",
|
||||
"popover-placement" => "bottom", "popover" => "When do you want to get your order?", "popover-trigger" => "openTrigger"}
|
||||
|
||||
%closing{"ng-if" => "OrderCycle.selected()"}
|
||||
Orders close
|
||||
%strong {{ OrderCycle.orders_close_at() | date_in_words }}
|
||||
|
||||
|
||||
= render partial: "shopping_shared/details"
|
||||
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
%distributor.details.row
|
||||
#distributor_title
|
||||
%img.left{src: current_distributor.logo.url(:thumb)}
|
||||
%h4
|
||||
%h3
|
||||
= current_distributor.name
|
||||
%location= current_distributor.address.city
|
||||
%small
|
||||
%a{href: "/"} Change location
|
||||
/ Will this needs to be a drop-down to choose either pick-up point or delivery once shipping methods are implemented
|
||||
|
||||
= render partial: "shopping_shared/order_cycles"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#tabs{"ng-controller" => "TabsCtrl"}
|
||||
.row
|
||||
%tabset
|
||||
- for name, heading in { about: "About Us",
|
||||
- for name, heading in { about: "About #{current_distributor.name}",
|
||||
producers: "Producers",
|
||||
groups: "Groups",
|
||||
contact: "Contact"}
|
||||
|
||||
Reference in New Issue
Block a user