6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/decorators/controllers/solidus_pagy/admin/promotion_codes_controller_decorator.rb', line 6
def self.prepended(base)
base.class_eval do
def index
@promotion = ::Spree::Promotion.accessible_by(current_ability, :show)
.find(params[:promotion_id])
@promotion_codes = @promotion.promotion_codes.order(:value)
respond_to do |format|
format.html do
@result = pagy(
@promotion_codes,
page: params[:page],
items: 50
)
@pagy = @result.first
@promotion_codes = @result.second
end
format.csv do
filename = "promotion-code-list-#{@promotion.id}.csv"
["Content-Type"] = "text/csv"
["Content-disposition"] = "attachment; filename=\"#{filename}\""
end
end
end
end
end
|