spree_account_recurring 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. data/LICENSE +26 -0
  2. data/README.md +108 -0
  3. data/app/assets/javascripts/admin/spree_account_recurring.js +1 -0
  4. data/app/assets/javascripts/store/spree_account_recurring.js +1 -0
  5. data/app/assets/javascripts/store/stripe.js +53 -0
  6. data/app/assets/stylesheets/admin/spree_account_recurring.css +3 -0
  7. data/app/assets/stylesheets/store/spree_account_recurring.css +3 -0
  8. data/app/controllers/concerns/spree/admin/ransack_date_search.rb +47 -0
  9. data/app/controllers/spree/admin/plans_controller.rb +63 -0
  10. data/app/controllers/spree/admin/recurrings_controller.rb +66 -0
  11. data/app/controllers/spree/admin/subscription_events_controller.rb +14 -0
  12. data/app/controllers/spree/admin/subscriptions_controller.rb +14 -0
  13. data/app/controllers/spree/plans_controller.rb +7 -0
  14. data/app/controllers/spree/recurring_hooks_controller.rb +53 -0
  15. data/app/controllers/spree/subscriptions_controller.rb +69 -0
  16. data/app/models/concerns/before_each.rb +21 -0
  17. data/app/models/concerns/restrictive_destroyer.rb +44 -0
  18. data/app/models/concerns/spree/plan/api_handler.rb +46 -0
  19. data/app/models/concerns/spree/recurring/stripe_recurring/api_handler.rb +28 -0
  20. data/app/models/concerns/spree/recurring/stripe_recurring/api_handler/plan_api_handler.rb +49 -0
  21. data/app/models/concerns/spree/recurring/stripe_recurring/api_handler/subscription_api_handler.rb +20 -0
  22. data/app/models/concerns/spree/recurring/stripe_recurring/api_handler/subscription_event_api_handler.rb +19 -0
  23. data/app/models/concerns/spree/subscription/api_handler.rb +38 -0
  24. data/app/models/concerns/spree/subscription/role_subscriber.rb +36 -0
  25. data/app/models/spree/plan.rb +31 -0
  26. data/app/models/spree/recurring.rb +27 -0
  27. data/app/models/spree/recurring/stripe_recurring.rb +16 -0
  28. data/app/models/spree/subscriber_ability.rb +17 -0
  29. data/app/models/spree/subscription.rb +33 -0
  30. data/app/models/spree/subscription_event.rb +11 -0
  31. data/app/models/spree/user_decorator.rb +14 -0
  32. data/app/overrides/admin/view_decorator.rb +27 -0
  33. data/app/views/spree/admin/plans/_form.html.erb +47 -0
  34. data/app/views/spree/admin/plans/destroy.js.erb +0 -0
  35. data/app/views/spree/admin/plans/edit.html.erb +22 -0
  36. data/app/views/spree/admin/plans/index.html.erb +70 -0
  37. data/app/views/spree/admin/plans/new.html.erb +22 -0
  38. data/app/views/spree/admin/recurrings/_form.html.erb +42 -0
  39. data/app/views/spree/admin/recurrings/destroy.js.erb +0 -0
  40. data/app/views/spree/admin/recurrings/edit.html.erb +23 -0
  41. data/app/views/spree/admin/recurrings/index.html.erb +48 -0
  42. data/app/views/spree/admin/recurrings/new.html.erb +22 -0
  43. data/app/views/spree/admin/subscription_events/index.html.erb +72 -0
  44. data/app/views/spree/admin/subscriptions/index.html.erb +76 -0
  45. data/app/views/spree/plans/index.html.erb +14 -0
  46. data/app/views/spree/subscriptions/new.html.erb +36 -0
  47. data/app/views/spree/subscriptions/show.html.erb +4 -0
  48. data/config/initializers/stripe.rb +2 -0
  49. data/config/locales/en.yml +43 -0
  50. data/config/routes.rb +24 -0
  51. data/db/migrate/20131119054112_create_spree_recurring.rb +13 -0
  52. data/db/migrate/20131119054212_create_spree_plan.rb +21 -0
  53. data/db/migrate/20131119054322_create_spree_subscription.rb +16 -0
  54. data/db/migrate/20131125123820_create_spree_subscription_events.rb +14 -0
  55. data/db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb +15 -0
  56. data/db/migrate/20140301141327_add_stripe_customer_id_to_spree_users.rb +6 -0
  57. data/db/migrate/20140303072857_add_default_to_spree_plans.rb +6 -0
  58. data/db/migrate/20140319092254_add_response_to_spree_subscription_events.rb +5 -0
  59. data/lib/generators/spree_account_recurring/install/install_generator.rb +31 -0
  60. data/lib/spree_account_recurring.rb +2 -0
  61. data/lib/spree_account_recurring/engine.rb +22 -0
  62. data/lib/spree_account_recurring/factories.rb +6 -0
  63. data/lib/spree_account_recurring/testing_support/ransack_date_search_helper.rb +125 -0
  64. metadata +188 -0
@@ -0,0 +1,16 @@
1
+ module Spree
2
+ class Recurring < ActiveRecord::Base
3
+ class StripeRecurring < Recurring
4
+ include ApiHandler
5
+
6
+ WEBHOOKS = ['customer.subscription.deleted', 'customer.subscription.created', 'customer.subscription.updated', 'invoice.payment_succeeded', 'invoice.payment_failed', 'charge.succeeded', 'charge.failed', 'charge.refunded', 'charge.captured', 'plan.created', 'plan.updated', 'plan.deleted']
7
+
8
+ INTERVAL = { week: 'Weekly', month: 'Monthly', year: 'Annually' }
9
+ CURRENCY = { usd: 'USD', gbp: 'GBP', jpy: 'JPY', eur: 'EUR', aud: 'AUD', hkd: 'HKD', sek: 'SEK', nok: 'NOK', dkk: 'DKK', pen: 'PEN', cad: 'CAD'}
10
+
11
+ def before_each
12
+ set_api_key
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ module Spree
2
+ class SubscriberAbility
3
+ include CanCan::Ability
4
+
5
+ def initialize(user)
6
+ # if user.respond_to?(:has_spree_role?) && user.has_spree_role?('subscriber')
7
+ # can :create, Order
8
+ # can :update, Order do |order, token|
9
+ # order.user == user || order.token && token == order.token
10
+ # end
11
+ # else
12
+ # cannot :create, Order
13
+ # cannot :update, Order
14
+ # end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,33 @@
1
+ module Spree
2
+ class Subscription < ActiveRecord::Base
3
+ include RoleSubscriber
4
+ include RestrictiveDestroyer
5
+ include ApiHandler
6
+
7
+ acts_as_restrictive_destroyer column: :unsubscribed_at
8
+ attr_accessor :card_token
9
+
10
+ belongs_to :plan
11
+ belongs_to :user
12
+ has_many :events, class_name: 'Spree::SubscriptionEvent'
13
+
14
+ validates :plan_id, :email, :user_id, presence: true
15
+ validates :plan_id, uniqueness: { scope: [:user_id, :unsubscribed_at] }
16
+ validates :user_id, uniqueness: { scope: :unsubscribed_at }
17
+
18
+ delegate_belongs_to :plan, :api_plan_id
19
+ before_validation :set_email, on: :create
20
+
21
+ validate :verify_plan, on: :create
22
+
23
+ private
24
+
25
+ def set_email
26
+ self.email = user.try(:email)
27
+ end
28
+
29
+ def verify_plan
30
+ errors.add :plan_id, "is not active." unless plan.try(:visible?)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,11 @@
1
+ module Spree
2
+ class SubscriptionEvent < ActiveRecord::Base
3
+ serialize :response
4
+
5
+ belongs_to :subscription
6
+ validates :event_id, :subscription_id, presence: true
7
+ validates :event_id, uniqueness: true
8
+
9
+ attr_readonly :event_id, :subscription_id, :request_type
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ Spree::User.class_eval do
2
+ has_many :subscriptions
3
+
4
+ def find_or_create_stripe_customer(token)
5
+ return api_customer if stripe_customer_id?
6
+ customer = Stripe::Customer.create(description: email, email: email, card: token)
7
+ update_column(:stripe_customer_id, customer.id)
8
+ customer
9
+ end
10
+
11
+ def api_customer
12
+ Stripe::Customer.retrieve(stripe_customer_id)
13
+ end
14
+ end
@@ -0,0 +1,27 @@
1
+ Deface::Override.new(
2
+ :virtual_path => "spree/admin/shared/_configuration_menu",
3
+ :name => "add_recurring_tab_to_configuration_sidebar",
4
+ :insert_bottom => "[data-hook='admin_configurations_sidebar_menu']",
5
+ :text => "<%= configurations_sidebar_menu_item Spree.t(:recurrings), admin_recurrings_path %>",
6
+ :disabled => false)
7
+
8
+ Deface::Override.new(
9
+ :virtual_path => "spree/admin/reports/index",
10
+ :name => "add_subscriptions_reports_index",
11
+ :insert_after => "table.index tbody",
12
+ :text => %q{<tr data-hook='reports_row'>
13
+ <td class='align-center'><%= link_to Spree.t(:subscriptions), admin_subscriptions_url %></td>
14
+ <td style="padding-left:1em">View Recurring Subscriptions</td>
15
+ </tr>
16
+ <tr data-hook='reports_row'>
17
+ <td class='align-center'><%= link_to Spree.t(:subscription_events), admin_subscription_events_url %></td>
18
+ <td style="padding-left:1em">View Recurring Subscription Events</td>
19
+ </tr>},
20
+ :disabled => false)
21
+
22
+ Deface::Override.new(
23
+ :virtual_path => "spree/admin/shared/_tabs",
24
+ :name => "select_reports_when_subscriptions",
25
+ :replace => %q{erb[loud]:contains("tab :reports, :icon => 'icon-file'")},
26
+ :text => %q{<%= tab :reports, :subscriptions, :icon => 'icon-file'%>},
27
+ :disabled => false)
@@ -0,0 +1,47 @@
1
+ <div data-hook="admin_plan_form_fields">
2
+
3
+ <div data-hook="plan">
4
+ <div class="alpha four columns">
5
+ <div class="field">
6
+ <%= f.label :interval, Spree.t(:interval) %>
7
+ <%= f.select :interval, @recurring.class::INTERVAL.collect{|k, v| [v, k]}, {}, {:disabled => @plan.persisted?, class: 'select2 fullwidth'} %>
8
+ </div>
9
+
10
+ <div class="field">
11
+ <%= f.label :interval_count, Spree.t(:every) %>
12
+ <%= f.select :interval_count, (1..11).collect {|i| [i, i]}, {}, {:disabled => @plan.persisted?, class: 'select2 fullwidth'} %>
13
+ </div>
14
+
15
+ <div class="field">
16
+ <%= f.label :currency, Spree.t(:currency) %>
17
+ <%= f.select :currency, @recurring.class::CURRENCY.collect{|k, v| [v, k]}, {}, {:disabled => @plan.persisted?, class: 'select2 fullwidth'} %>
18
+ </div>
19
+ </div>
20
+
21
+ <div class="omega eight columns">
22
+ <div class="field">
23
+ <%= f.label :name, Spree.t(:name) %>
24
+ <%= f.text_field :name %>
25
+ </div>
26
+
27
+ <div class="field">
28
+ <%= f.label :amount, Spree.t(:amount) %>
29
+ <%= f.text_field :amount, :disabled => @plan.persisted? %>
30
+ </div>
31
+
32
+ <div class="field">
33
+ <%= f.label :trial_period_days, Spree.t(:trial_period_days) %>
34
+ <%= f.text_field :trial_period_days, :disabled => @plan.persisted? %>
35
+ </div>
36
+
37
+ <div class="field">
38
+ <%= f.label :active, Spree.t(:active) %>
39
+ <%= f.check_box :active %>&nbsp;&nbsp;&nbsp;&nbsp;
40
+ <%= f.label :default, Spree.t(:default) %>
41
+ <%= f.check_box :default %>
42
+ </div>
43
+ </div>
44
+ </div>
45
+ </div>
46
+
47
+ <div class="clear"></div>
File without changes
@@ -0,0 +1,22 @@
1
+ <%= render :partial => 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t(:editing_plan) %> <i class="icon-arrow-right"></i> <%= @plan.name %>
5
+ <% end %>
6
+
7
+ <% content_for :page_actions do %>
8
+ <li>
9
+ <%= button_link_to Spree.t(:back_to_plans_list), admin_recurring_plans_path(@recurring), :icon => 'icon-arrow-left' %>
10
+ </li>
11
+ <% end %>
12
+
13
+ <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @plan } %>
14
+
15
+ <%= form_for @plan, :url => admin_recurring_plan_url(@recurring, @plan) do |f| %>
16
+ <fieldset class="no-border-top">
17
+ <%= render :partial => 'form', :locals => { :f => f } %>
18
+ <div data-hook="buttons" class="filter-actions actions">
19
+ <%= button Spree.t('actions.update'), 'icon-ok' %>
20
+ </div>
21
+ </fieldset>
22
+ <% end %>
@@ -0,0 +1,70 @@
1
+ <%= render :partial => 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t(:editing_recurring) %> <i class="icon-arrow-right"></i> <%= @recurring.name %> <i class="icon-arrow-right"></i> <%= Spree.t(:plans) %>
5
+ <% end %>
6
+
7
+ <% content_for :page_actions do %>
8
+ <li>
9
+ <%= button_link_to Spree.t(:new_plan), new_admin_recurring_plan_path(@recurring), :icon => 'icon-plus', :id => 'admin_new_recurring_plans_link' %>
10
+ </li>
11
+ <% end %>
12
+
13
+ <% if @plans.present? %>
14
+ <table class="index" id='listing_recurring_plans'>
15
+ <colgroup>
16
+ <col style="width: 10%">
17
+ <col style="width: 15%">
18
+ <col style="width: 10%">
19
+ <col style="width: 10%">
20
+ <col style="width: 10%">
21
+ <col style="width: 10%">
22
+ <col style="width: 10%">
23
+ <col style="width: 5%">
24
+ <col style="width: 5%">
25
+ <col style="width: 15%">
26
+ </colgroup>
27
+ <thead>
28
+ <tr data-hook="admin_recurring_plans_index_headers">
29
+ <th><%= Spree.t(:api_plan_id) %></th>
30
+ <th><%= Spree.t(:name) %></th>
31
+ <th><%= Spree.t(:amount) %></th>
32
+ <th><%= Spree.t(:interval) %></th>
33
+ <th><%= Spree.t(:interval_count) %></th>
34
+ <th><%= Spree.t(:currency) %></th>
35
+ <th><%= Spree.t(:trial_period_days) %></th>
36
+ <th><%= Spree.t(:active) %></th>
37
+ <th><%= Spree.t(:default) %></th>
38
+ <th data-hook="admin_recurring_plans_index_header_actions" class="actions"></th>
39
+ </tr>
40
+ </thead>
41
+ <tbody>
42
+ <% @plans.each do |plan|%>
43
+ <tr id="<%= spree_dom_id plan %>" data-hook="admin_recurring_plans_index_rows" class="<%= cycle('odd', 'even')%>">
44
+ <td class="align-center"><%= plan.api_plan_id %></td>
45
+ <td class="align-center"><%= plan.name %></td>
46
+ <td class="align-center"><%= plan.amount %></td>
47
+ <td class="align-center"><%= @recurring.class::INTERVAL[plan.interval.to_sym] %></td>
48
+ <td class="align-center"><%= plan.interval_count %></td>
49
+ <td class="align-center"><%= @recurring.class::CURRENCY[plan.currency.to_sym] %></td>
50
+ <td class="align-center"><%= plan.trial_period_days %></td>
51
+ <td class="align-center"><%= plan.active ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>
52
+ <td class="align-center"><%= plan.default ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>
53
+ <td data-hook="admin_recurring_plans_index_row_actions" class="actions">
54
+ <%= link_to_edit_url edit_admin_recurring_plan_url(@recurring, plan), :no_text => true %>
55
+ <%= link_to_delete plan, url: admin_recurring_plan_url(@recurring, plan), :no_text => true %>
56
+ </td>
57
+ </tr>
58
+ <% end %>
59
+ </tbody>
60
+ </table>
61
+ <% else %>
62
+ <div class="alpha twelve columns no-objects-found">
63
+ <%= Spree.t(:no_resource_found, resource: I18n.t(:other, scope: 'activerecord.models.spree/plan')) %>,
64
+ <%= link_to Spree.t(:add_one), spree.new_admin_recurring_plan_path(@recurring) %>!
65
+ </div>
66
+ <% end %>
67
+
68
+ <div data-hook="buttons" class="filter-actions actions">
69
+ <%= button_link_to Spree.t(:back), edit_admin_recurring_url(@recurring) %>
70
+ </div>
@@ -0,0 +1,22 @@
1
+ <%= render :partial => 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t(:new_plan) %>
5
+ <% end %>
6
+
7
+ <% content_for :page_actions do %>
8
+ <li>
9
+ <%= button_link_to Spree.t(:back_to_plans_list), admin_recurring_plans_path(@recurring), :icon => 'icon-arrow-left' %>
10
+ </li>
11
+ <% end %>
12
+
13
+ <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @plan } %>
14
+
15
+ <%= form_for @plan, :url => admin_recurring_plans_path(@recurring) do |f| %>
16
+ <fieldset class="no-border-top">
17
+ <%= render :partial => 'form', :locals => { :f => f } %>
18
+ <div data-hook="buttons" class="filter-actions actions">
19
+ <%= button Spree.t(:create), 'icon-ok' %>
20
+ </div>
21
+ </fieldset>
22
+ <% end %>
@@ -0,0 +1,42 @@
1
+ <div data-hook="admin_recurring_form_fields">
2
+
3
+ <div data-hook="recurring">
4
+
5
+ <div class="alpha four columns">
6
+ <div id="preference-settings" data-hook class="field">
7
+ <%= label_tag nil, Spree.t(:provider) %>
8
+ <%= select(:recurring, :type, Spree::Recurring.subclasses.collect {|pro| [pro.display_name, pro]}, {}, {disabled: !@recurring.new_record?, class: 'select2 fullwidth'}) %>
9
+
10
+ <% unless @recurring.new_record? %>
11
+ <%= preference_fields(@recurring, f) %>
12
+
13
+ <% if @recurring.respond_to?(:preferences) %>
14
+ <div id="gateway-settings-warning" class="info warning"><%= Spree.t(:provider_settings_warning) %></div>
15
+ <% end %>
16
+ <% end %>
17
+ </div>
18
+ <div data-hook="active" class="field">
19
+ <ul>
20
+ <li>
21
+ <%= label_tag :nil, Spree.t(:active) %>
22
+ <%= check_box :recurring, :active %>
23
+ </li>
24
+ </ul>
25
+ </div>
26
+ </div>
27
+
28
+ <div class="omega eight columns">
29
+ <div data-hook="name" class="field">
30
+ <%= label_tag nil, Spree.t(:name) %>
31
+ <%= text_field :recurring, :name, :class => 'fullwidth' %>
32
+ </div>
33
+ <div data-hook="description" class="field">
34
+ <%= label_tag nil, Spree.t(:description) %>
35
+ <%= text_area :recurring, :description, {:cols => 60, :rows => 6, :class => 'fullwidth'} %>
36
+ </div>
37
+ </div>
38
+
39
+ </div>
40
+ </div>
41
+
42
+ <div class="clear"></div>
File without changes
@@ -0,0 +1,23 @@
1
+ <%= render :partial => 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t(:editing_recurring) %> <i class="icon-arrow-right"></i> <%= @recurring.name %>
5
+ <% end %>
6
+
7
+ <% content_for :page_actions do %>
8
+ <li>
9
+ <%= button_link_to Spree.t(:back_to_recurrings_list), spree.admin_recurrings_path, :icon => 'icon-arrow-left' %>
10
+ </li>
11
+ <% end %>
12
+
13
+ <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @recurring } %>
14
+
15
+ <%= form_for @recurring, :url => admin_recurring_path(@recurring) do |f| %>
16
+ <fieldset class="no-border-top">
17
+ <%= render :partial => 'form', :locals => { :f => f } %>
18
+ <div data-hook="buttons" class="filter-actions actions">
19
+ <%= button_link_to Spree.t(:manage_plans), admin_recurring_plans_url(@recurring) %>
20
+ <%= button Spree.t('actions.update'), 'icon-refresh' %>
21
+ </div>
22
+ </fieldset>
23
+ <% end %>
@@ -0,0 +1,48 @@
1
+ <%= render 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t(:recurring) %>
5
+ <% end %>
6
+
7
+ <% content_for :page_actions do %>
8
+ <li>
9
+ <%= button_link_to Spree.t(:new_recurring), new_admin_recurring_url, :icon => 'icon-plus', :id => 'admin_new_recurring_link' %>
10
+ </li>
11
+ <% end %>
12
+
13
+ <% if @recurrings.any? %>
14
+ <table class="index" id='listing_recurrings'>
15
+ <colgroup>
16
+ <col style="width: 30%">
17
+ <col style="width: 25%">
18
+ <col style="width: 25%">
19
+ <col style="width: 20%">
20
+ </colgroup>
21
+ <thead>
22
+ <tr data-hook="admin_payment_methods_index_headers">
23
+ <th><%= Spree.t(:name) %></th>
24
+ <th><%= Spree.t(:provider) %></th>
25
+ <th><%= Spree.t(:active) %></th>
26
+ <th data-hook="admin_payment_methods_index_header_actions" class="actions"></th>
27
+ </tr>
28
+ </thead>
29
+ <tbody>
30
+ <% @recurrings.each do |recurring|%>
31
+ <tr id="<%= spree_dom_id recurring %>" data-hook="admin_recurrings_index_rows" class="<%= cycle('odd', 'even')%>">
32
+ <td class="align-center"><%= recurring.name %></td>
33
+ <td class="align-center"><%= recurring.class.display_name %></td>
34
+ <td class="align-center"><%= recurring.active ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>
35
+ <td data-hook="admin_recurrings_index_row_actions" class="actions">
36
+ <%= link_to_edit_url edit_admin_recurring_url(recurring), :no_text => true %>
37
+ <%= link_to_delete recurring, url: admin_recurring_url(recurring), :no_text => true %>
38
+ </td>
39
+ </tr>
40
+ <% end %>
41
+ </tbody>
42
+ </table>
43
+ <% else %>
44
+ <div class="alpha twelve columns no-objects-found">
45
+ <%= Spree.t(:no_resource_found, resource: I18n.t(:other, scope: 'activerecord.models.spree/recurring')) %>,
46
+ <%= link_to Spree.t(:add_one), spree.new_admin_recurring_url %>!
47
+ </div>
48
+ <% end %>
@@ -0,0 +1,22 @@
1
+ <%= render :partial => 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t(:new_recurring) %>
5
+ <% end %>
6
+
7
+ <% content_for :page_actions do %>
8
+ <li>
9
+ <%= button_link_to Spree.t(:back_to_recurrings_list), admin_recurrings_url, :icon => 'icon-arrow-left' %>
10
+ </li>
11
+ <% end %>
12
+
13
+ <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @recurring } %>
14
+
15
+ <%= form_for @recurring, :url => admin_recurrings_url do |f| %>
16
+ <fieldset class="no-border-top">
17
+ <%= render :partial => 'form', :locals => { :f => f } %>
18
+ <div data-hook="buttons" class="filter-actions actions">
19
+ <%= button Spree.t(:create), 'icon-ok' %>
20
+ </div>
21
+ </fieldset>
22
+ <% end %>
@@ -0,0 +1,72 @@
1
+ <% content_for :page_title do %>
2
+ <%= Spree.t(:subscription_events) %>
3
+ <% end %>
4
+
5
+ <% content_for :page_actions do %>
6
+ <li><%= link_to_with_icon 'icon-arrow-left', Spree.t(:back_to_reports_list), spree.admin_reports_url, :class => 'button' %></li>
7
+ <% end %>
8
+
9
+ <% content_for :table_filter_title do %>
10
+ <%= Spree.t(:subscription_event_search) %>
11
+ <% end %>
12
+
13
+ <% content_for :table_filter do %>
14
+ <%= search_form_for @search, :url => spree.admin_subscription_events_url do |s| %>
15
+ <div class="date-range-filter field align-center">
16
+ <%= label_tag nil, Spree.t(:start), :class => 'inline' %>
17
+ <%= s.text_field :created_at_gt, :class => 'datepicker datepicker-from', :value => datepicker_field_value(params[:q][:created_at_gt]) %>
18
+
19
+ <span class="range-divider">
20
+ <i class="icon-arrow-right"></i>
21
+ </span>
22
+
23
+ <%= s.text_field :created_at_lt, :class => 'datepicker datepicker-to', :value => datepicker_field_value(params[:q][:created_at_lt]) %>
24
+ <%= label_tag nil, Spree.t(:end), :class => 'inline' %>
25
+ </div>
26
+
27
+ <div class="date-range-filter field align-center">
28
+ <%= label_tag nil, Spree.t(:email), :class => 'inline' %>
29
+ <%= s.text_field :subscription_email_eq, style: "width:240px" %>
30
+ </div>
31
+
32
+ <div class="actions filter-actions">
33
+ <%= button Spree.t(:search), 'icon-search' %>
34
+ </div>
35
+ <% end %>
36
+ <% end %>
37
+
38
+ <% if @subscription_events.any? %>
39
+ <table class="index" id='listing_subscription_events'>
40
+ <colgroup>
41
+ <col style="width: 30%">
42
+ <col style="width: 25%">
43
+ <col style="width: 25%">
44
+ <col style="width: 20%">
45
+ </colgroup>
46
+ <thead>
47
+ <tr data-hook="admin_subscription_events_index_headers">
48
+ <th><%= Spree.t(:email) %></th>
49
+ <th><%= Spree.t(:plan) %></th>
50
+ <th><%= Spree.t(:request_type) %></th>
51
+ <th><%= Spree.t(:created_at) %></th>
52
+ </tr>
53
+ </thead>
54
+ <tbody>
55
+ <% @subscription_events.each do |subscription_event|%>
56
+ <% plan = subscription_event.subscription.plan %>
57
+ <tr data-hook="admin_subscription_events_index_rows" class="<%= cycle('odd', 'even')%>">
58
+ <td class="align-center"><%= subscription_event.subscription.email %></td>
59
+ <td class="align-center"><%= link_to plan.api_plan_id, edit_admin_recurring_plan_url(plan.recurring, plan) %></td>
60
+ <td class="align-center"><%= subscription_event.request_type %></td>
61
+ <td class="align-center"><%= subscription_event.created_at.try(:strftime, '%d-%h-%Y') %></td>
62
+ </tr>
63
+ <% end %>
64
+ </tbody>
65
+ </table>
66
+
67
+ <%= paginate @subscription_events %>
68
+ <% else %>
69
+ <div class="alpha sixteen columns no-objects-found">
70
+ <%= Spree.t(:no_resource_found, resource: I18n.t(:other, scope: 'activerecord.models.spree/subscription_event')) %>
71
+ </div>
72
+ <% end %>