Sha256: 38999862b73f1680179d3604fef382a73352a375e69640c444ed726eeecbbbeb

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

class Dash::PickupLocationsController < Dash::BaseController
  def new
    @pickup_locations = (current_user.supplier.pickup_locations + PickupLocation.locate).uniq
    @pickup_location = PickupLocation.new()
  end

  def business_hours
    days = {}
    ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].each do |day|
      days.merge!({day.downcase.to_sym => params["#{day}_begin"] + ":" + params["#{day}_begin_mins"] + " " + params["#{day}_begin_type"].upcase + " to " + params["#{day}_end"] + ":" + params["#{day}_end_mins"] + " " + params["#{day}_end_type"].upcase} )
      if params["#{day}_closed"] == "Closed"
        days.merge!({day.downcase.to_sym => "Closed"})
      end
    end
    days
  end

  def create 
    @pickup_location = current_user.supplier.pickup_locations.build(params[:pickup_location])
    if @pickup_location.save
      @pickup_location.hours.create(business_hours)
      redirect_to new_dash_pickup_location_path, :notice => "New location added"
    else
      render "new", :notice => "Failed to create location"
    end  
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_suppliers-0.0.1 app/controllers/dash/pickup_locations_controller.rb
spree_suppliers-0.60.3 app/controllers/dash/pickup_locations_controller.rb