-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from friendlycart/use-different-path-for-frien…
…dly-promotions Use different path for friendly promotions
- Loading branch information
Showing
23 changed files
with
110 additions
and
54 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
promotions/app/controllers/solidus_friendly_promotions/admin/base_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# frozen_string_literal: true | ||
|
||
module SolidusFriendlyPromotions | ||
module Admin | ||
class BaseController < Spree::Admin::ResourceController | ||
def parent | ||
@parent ||= self.class.parent_data[:model_class] | ||
.includes(self.class.parent_data[:includes]) | ||
.find_by!(self.class.parent_data[:find_by] => params["#{parent_model_name}_id"]) | ||
instance_variable_set("@#{parent_model_name}", @parent) | ||
rescue ActiveRecord::RecordNotFound => e | ||
resource_not_found(flash_class: e.model.constantize, redirect_url: routes_proxy.polymorphic_url([:admin, parent_model_name.pluralize.to_sym])) | ||
end | ||
|
||
def new_object_url(options = {}) | ||
if parent? | ||
routes_proxy.new_polymorphic_url([:admin, parent, model_class], options) | ||
else | ||
routes_proxy.new_polymorphic_url([:admin, model_class], options) | ||
end | ||
end | ||
|
||
def edit_object_url(object, options = {}) | ||
if parent? | ||
routes_proxy.polymorphic_url([:edit, :admin, parent, object], options) | ||
else | ||
routes_proxy.polymorphic_url([:edit, :admin, object], options) | ||
end | ||
end | ||
|
||
def object_url(object = nil, options = {}) | ||
target = object || @object | ||
|
||
if parent? | ||
routes_proxy.polymorphic_url([:admin, parent, target], options) | ||
else | ||
routes_proxy.polymorphic_url([:admin, target], options) | ||
end | ||
end | ||
|
||
def collection_url(options = {}) | ||
if parent? | ||
routes_proxy.polymorphic_url([:admin, parent, model_class], options) | ||
else | ||
routes_proxy.polymorphic_url([:admin, model_class], options) | ||
end | ||
end | ||
|
||
def routes_proxy | ||
solidus_friendly_promotions | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
promotions/app/views/solidus_friendly_promotions/admin/promotion_categories/edit.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
promotions/app/views/solidus_friendly_promotions/admin/promotion_categories/new.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
promotions/app/views/solidus_friendly_promotions/admin/promotion_codes/new.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
promotions/app/views/solidus_friendly_promotions/admin/promotion_rules/new.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...dus_friendly_promotions/admin/promotion_rules/rules/_first_repeat_purchase_since.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ons/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_nth_order.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
promotions/app/views/solidus_friendly_promotions/admin/promotions/new.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters