caboose-cms 0.8.78 → 0.8.79

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,60 @@
1
+
2
+ <%= render :partial => 'caboose/users/admin_header' %>
3
+ <input type='hidden' name='invoice_id' id='invoice_id' value='<%= @invoice.id %>' />
4
+
5
+ <h1>Edit Invoice #<%= @invoice.id %></h1>
6
+
7
+ <div id='overview_table'></div>
8
+ <div id='invoice_table'></div>
9
+ <div id='message'></div>
10
+ <div id='controls'></div>
11
+
12
+ <%= render :partial => 'caboose/users/admin_footer' %>
13
+
14
+ <!--
15
+ <p>
16
+ <input type='button' value='< Back' onclick="window.location='/admin/invoices';" />
17
+ <% if @invoice.financial_status == Caboose::Invoice::FINANCIAL_STATUS_AUTHORIZED && @invoice.total > 0.00 %>
18
+ <input type='button' value='Capture Funds' onclick="controller.capture_funds();" />
19
+ <input type='button' value='Void' onclick="controller.void_invoice();" />
20
+ <% end %>
21
+ <% if @invoice.financial_status == Caboose::Invoice::FINANCIAL_STATUS_CAPTURED && @invoice.total > 0.00 %>
22
+ <input type='button' value='Refund' onclick="refund_invoice(<%= @invoice.id %>);" />
23
+ <% end %>
24
+ <input type='button' value='Resend Confirmation' onclick="resend_confirmation(<%= @invoice.id %>)" />
25
+ <input type='button' value='Add Item' onclick="controller.add_variant();" />
26
+ <input type='button' value='Print Invoice' onclick="controller.print_invoice(<%= @invoice.id %>);" />
27
+
28
+ <% str = Caboose.plugin_hook('admin_edit_invoice_buttons', "", @invoice) %>
29
+ <% if str %><%= raw str %><% end %>
30
+ </p>
31
+ -->
32
+
33
+ <% content_for :caboose_js do %>
34
+ <%= javascript_include_tag 'caboose/model/all' %>
35
+ <%= javascript_include_tag 'caboose/admin_edit_invoice' %>
36
+ <script type='text/javascript'>
37
+
38
+ var controller = false;
39
+ $(document).ready(function() {
40
+ controller = new InvoiceController({
41
+ invoice_id: <%= raw Caboose.json(@invoice.id) %>,
42
+ authenticity_token: <%= raw Caboose.json(form_authenticity_token) %>
43
+ });
44
+ });
45
+
46
+ </script>
47
+ <% end %>
48
+
49
+ <% content_for :caboose_css do %>
50
+ <style type='text/css'>
51
+
52
+ table.shipping_address td,
53
+ table.billing_address td {
54
+ padding: 0 !important;
55
+ margin: 0 !important;
56
+ border: 0 !important;
57
+ }
58
+
59
+ </style>
60
+ <% end %>
@@ -1,81 +1,46 @@
1
- <%
2
- s = @subscription
3
- %>
4
1
 
5
- <h1>Edit Subscription</h1>
2
+ <%= render :partial => 'caboose/users/admin_header' %>
6
3
 
7
- <p><div id='subscription_<%= s.id %>_name' ></div></p>
8
- <p><div id='subscription_<%= s.id %>_description' ></div></p>
9
- <p><div id='subscription_<%= s.id %>_variant_id' ></div></p>
10
- <p><div id='subscription_<%= s.id %>_interval' ></div></p>
11
- <p><div id='subscription_<%= s.id %>_prorate' ></div></p>
12
- <p><div id='subscription_<%= s.id %>_prorate_method' ></div></p>
13
- <p><div id='subscription_<%= s.id %>_prorate_flat_amount' ></div></p>
14
-
15
- <p><code>def custom_prorate_function() {</code></p>
16
- <p><div id='subscription_<%= s.id %>_prorate_function' ></div></p>
17
- <p><code>
18
- # Returns the amount that should be prorated for the first invoice for a subscription.<br />
19
- # Note: self represents the user subscription object.<br />
20
- }</code></p>
21
- <p><div id='subscription_<%= s.id %>_start_on_day' ></div></p>
22
- <p><div id='subscription_<%= s.id %>_start_day' ></div></p>
23
- <p><div id='subscription_<%= s.id %>_start_month' ></div></p>
4
+ <p><div id='subscription_<%= @subscription.id %>_variant_id' ></div></p>
5
+ <p><div id='subscription_<%= @subscription.id %>_date_started' ></div></p>
6
+ <p><div id='subscription_<%= @subscription.id %>_date_started_full' ></div></p>
7
+ <p><div id='subscription_<%= @subscription.id %>_status' ></div></p>
24
8
 
25
9
  <div id='message'></div>
26
-
27
10
  <p>
28
- <input type='button' value='< Back' onclick="window.location='/admin/subscriptions';" />
29
- <input type='button' value='Delete Subscription' onclick="delete_subscription(<%= s.id %>);" />
30
- </p>
11
+ <input type='button' value='Create Invoices for this Subscription' onclick="create_subscription_invoices(<%= @subscription.id %>);" />
12
+
13
+ <%= render :partial => 'caboose/users/admin_footer' %>
31
14
 
32
15
  <% content_for :caboose_js do %>
33
- <%= javascript_include_tag 'caboose/model/all' %>
34
- <script type='text/javascript'>
16
+ <%= javascript_include_tag "caboose/model/all" %>
17
+ <script type="text/javascript">
35
18
 
36
19
  $(document).ready(function() {
37
20
  new ModelBinder({
38
21
  name: 'Subscription',
39
- id: <%= s.id %>,
40
- update_url: '/admin/subscriptions/<%= s.id %>',
22
+ id: <%= @subscription.id %>,
23
+ update_url: '/admin/users/<%= @edituser.id %>/subscriptions/<%= @subscription.id %>',
41
24
  authenticity_token: '<%= form_authenticity_token %>',
42
- attributes: [
43
- { name: 'name' , nice_name: 'Name' , type: 'text' , value: <%= raw Caboose.json(s.name )%>, width: 400, align: 'left' },
44
- { name: 'description' , nice_name: 'Description' , type: 'textarea' , value: <%= raw Caboose.json(s.description )%>, width: 400, align: 'left' , height: 75 },
45
- { name: 'variant_id' , nice_name: 'Variant ID' , type: 'text' , value: <%= raw Caboose.json(s.variant_id )%>, width: 400, align: 'left' },
46
- { name: 'interval' , nice_name: 'Interval' , type: 'select' , value: <%= raw Caboose.json(s.interval )%>, width: 400, align: 'left' , options_url: '/admin/subscriptions/interval-options' },
47
- { name: 'prorate' , nice_name: 'Prorate' , type: 'checkbox' , value: <%= raw Caboose.json(s.prorate )%>, width: 400, align: 'left' },
48
- { name: 'prorate_method' , nice_name: 'Prorate method' , type: 'select' , value: <%= raw Caboose.json(s.prorate_method )%>, width: 400, align: 'left' , options_url: '/admin/subscriptions/prorate-method-options' },
49
- { name: 'prorate_flat_amount' , nice_name: 'Prorate flat amount' , type: 'text' , value: <%= raw Caboose.json(s.prorate_flat_amount )%>, width: 400, align: 'left' },
50
- { name: 'prorate_function' , nice_name: 'Custom Prorate Function' , type: 'textarea' , value: <%= raw Caboose.json(s.prorate_function )%>, width: 400, align: 'left' , height: 100 },
51
- { name: 'start_on_day' , nice_name: 'Start on day' , type: 'checkbox' , value: <%= raw Caboose.json(s.start_on_day )%>, width: 400, align: 'left' },
52
- { name: 'start_day' , nice_name: 'Start day' , type: 'select' , value: <%= raw Caboose.json(s.start_day )%>, width: 400, align: 'left' , options_url: '/admin/subscriptions/start-day-options' },
53
- { name: 'start_month' , nice_name: 'Start month' , type: 'select' , value: <%= raw Caboose.json(s.start_month )%>, width: 400, align: 'left' , options_url: '/admin/subscriptions/start-month-options' }
54
- ]
55
- });
25
+ attributes: [
26
+ { name: 'variant_id' , nice_name: 'Variant' , type: 'select' , value: <%= raw Caboose.json(@subscription.variant_id ) %>, width: 400 , options_url: '/admin/subscriptions/subscription-options' },
27
+ { name: 'date_started' , nice_name: 'Date Started' , type: 'date' , value: <%= raw Caboose.json(@subscription.date_started ) %>, width: 400 , date_format: 'Y-m-d' },
28
+ { name: 'date_started_full' , nice_name: 'Date Started Full' , type: 'date' , value: <%= raw Caboose.json(@subscription.date_started_full ) %>, width: 400 , date_format: 'Y-m-d' },
29
+ { name: 'status' , nice_name: 'Status' , type: 'select' , value: <%= raw Caboose.json(@subscription.status ) %>, width: 400 , options_url: '/admin/subscriptions/status-options' }
30
+ ]
31
+ });
56
32
  });
57
33
 
58
- function delete_subscription(subscription_id, confirm)
34
+ function create_subscription_invoices(subscription_id)
59
35
  {
60
- if (!confirm)
61
- {
62
- var p = $('<p/>')
63
- .addClass('note warning')
64
- .append("Are you sure you want to delete the subscription? ")
65
- .append($('<input/>').attr('type','button').val('Yes').click(function(e) { delete_subscription(subscription_id, true); })).append(' ')
66
- .append($('<input/>').attr('type','button').val('No' ).click(function(e) { $('#message').empty(); }));
67
- $('#message').empty().append(p);
68
- return;
69
- }
70
- $('#message').html("<p class='loading'>Deleting subscription...</p>");
71
36
  $.ajax({
72
- url: '/admin/subscriptions/' + subscription_id,
73
- type: 'delete',
37
+ url: "/admin/users/<%= @edituser.id %>/subscriptions/" + subscription_id + "/invoices",
38
+ type: 'post',
74
39
  success: function(resp) {
75
40
  if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
76
- if (resp.success) window.location = '/admin/subscriptions';
77
- }
78
- });
41
+ if (resp.success) $('#message').html("<p class='note success'>Invoices have been created successfully.</p>");
42
+ }
43
+ });
79
44
  }
80
45
 
81
46
  </script>
@@ -1,8 +1,6 @@
1
- <%
2
- sc = @site.store_config
3
- %>
4
1
 
5
- <h1>Subscriptions</h1>
2
+ <h1>Subcriptions</h1>
3
+
6
4
  <div id='subscriptions'></div>
7
5
 
8
6
  <% content_for :caboose_js do %>
@@ -19,24 +17,25 @@ $(document).ready(function() {
19
17
  allow_bulk_delete: true,
20
18
  allow_duplicate: false,
21
19
  allow_advanced_edit: true,
22
- fields: [
23
- { show: true, bulk_edit: true, name: 'name' , nice_name: 'Name' , sort: 'name' , type: 'text' , value: function(s) { return s.name }, width: 75, align: 'left' },
24
- { show: true, bulk_edit: true, name: 'description' , nice_name: 'Description' , sort: 'description' , type: 'text' , value: function(s) { return s.description }, width: 75, align: 'left' },
25
- { show: true, bulk_edit: true, name: 'variant_id' , nice_name: 'Variant ID' , sort: 'variant_id' , type: 'text' , value: function(s) { return s.variant_id }, width: 75, align: 'left' },
26
- { show: true, bulk_edit: true, name: 'interval' , nice_name: 'Interval' , sort: 'interval' , type: 'select' , value: function(s) { return s.interval }, width: 75, align: 'left' , options_url: '/admin/subscriptions/interval-options' },
27
- { show: true, bulk_edit: true, name: 'prorate' , nice_name: 'Prorate' , sort: 'prorate' , type: 'checkbox' , value: function(s) { return s.prorate }, width: 75, align: 'left' },
28
- { show: true, bulk_edit: true, name: 'prorate_method' , nice_name: 'Prorate method' , sort: 'prorate_method' , type: 'select' , value: function(s) { return s.prorate_method }, width: 75, align: 'left' , options_url: '/admin/subscriptions/prorate-method-options' },
29
- { show: true, bulk_edit: true, name: 'prorate_flat_amount' , nice_name: 'Prorate flat amount' , sort: 'prorate_flat_amount' , type: 'text' , value: function(s) { return s.prorate_flat_amount }, width: 75, align: 'left' },
30
- { show: true, bulk_edit: true, name: 'start_on_day' , nice_name: 'Start on day' , sort: 'start_on_day' , type: 'checkbox' , value: function(s) { return s.start_on_day }, width: 75, align: 'left' },
31
- { show: true, bulk_edit: true, name: 'start_day' , nice_name: 'Start day' , sort: 'start_day' , type: 'select' , value: function(s) { return s.start_day }, width: 75, align: 'left' , options_url: '/admin/subscriptions/start-day-options' },
32
- { show: true, bulk_edit: true, name: 'start_month' , nice_name: 'Start month' , sort: 'start_month' , type: 'select' , value: function(s) { return s.start_month }, width: 75, align: 'left' , options_url: '/admin/subscriptions/start-month-options' }
20
+ search_fields: [
21
+ { name: 'variant_id' , nice_name: 'Variant' , type: 'select', width: 400, options_url: '/admin/subscriptions/variant-options' , empty_option_text: '-- Any Variant --' },
22
+ { name: 'user_id' , nice_name: 'User' , type: 'select', width: 400, options_url: '/admin/subscriptions/user-options' , empty_option_text: '-- Any User --' },
23
+ { name: 'status' , nice_name: 'Status' , type: 'select', width: 400, options_url: '/admin/subscriptions/status-options' , empty_option_text: '-- Any Status --' }
24
+ ],
25
+ fields: [
26
+ { show: true, bulk_edit: true, name: 'variant_id' , nice_name: 'Variant' , sort: 'variant_id' , type: 'select' , value: function(s) { return s.variant_id }, text: function(s) { return s.variant && s.variant.product ? s.variant.product.title : s.variant_id; }, width: 75, align: 'left', options_url: '/admin/subscriptions/variant-options' },
27
+ { show: true, bulk_edit: true, name: 'user_id' , nice_name: 'User' , sort: 'user_id' , type: 'select' , value: function(s) { return s.user_id }, text: function(s) { return s.user ? s.user.first_name + ' ' + s.user.last_name : s.user_id; }, width: 75, align: 'left', options_url: '/admin/subscriptions/user-options' },
28
+ { show: true, bulk_edit: true, name: 'date_started' , nice_name: 'Date Started' , sort: 'date_started' , type: 'date' , value: function(s) { return s.date_started }, width: 100, align: 'left' , date_format: 'Y-m-d' },
29
+ { show: true, bulk_edit: true, name: 'date_started_full' , nice_name: 'Date Started Full' , sort: 'date_started_full' , type: 'date' , value: function(s) { return s.date_started_full }, width: 100, align: 'left' , date_format: 'Y-m-d' },
30
+ { show: true, bulk_edit: true, name: 'status' , nice_name: 'Status' , sort: 'status' , type: 'select' , value: function(s) { return s.status }, width: 75, align: 'left' , options_url: '/admin/subscriptions/status-options' }
33
31
  ],
34
32
  new_model_text: 'New Subscription',
35
- no_models_text: 'There are no subscriptions right now.',
33
+ no_models_text: "There are subscriptions right now.",
36
34
  new_model_fields: [
37
- { name: 'name', nice_name: 'Name', type: 'text', width: 400 }
35
+ { name: 'variant_id' , nice_name: 'Variant' , type: 'select', width: 400, options_url: '/admin/subscriptions/variant-options' },
36
+ { name: 'user_id' , nice_name: 'User' , type: 'select', width: 400, options_url: '/admin/subscriptions/user-options' }
38
37
  ],
39
- bulk_import_fields: ['name'],
38
+ bulk_import_fields: ['variant_id', 'user_id', 'date_started', 'date_started_full', 'status'],
40
39
  bulk_import_url: '/admin/subscriptions/bulk'
41
40
  });
42
41
  });
@@ -0,0 +1,41 @@
1
+
2
+ <h1>Subcriptions</h1>
3
+
4
+ <div id='subscriptions'></div>
5
+
6
+ <% content_for :caboose_js do %>
7
+ <%= javascript_include_tag 'caboose/model/all' %>
8
+ <script type='text/javascript'>
9
+
10
+ $(document).ready(function() {
11
+ var that = this;
12
+ var table = new IndexTable({
13
+ form_authenticity_token: '<%= form_authenticity_token %>',
14
+ container: 'subscriptions',
15
+ base_url: '/admin/users/<%= @edituser.id %>/subscriptions',
16
+ allow_bulk_edit: true,
17
+ allow_bulk_delete: true,
18
+ allow_duplicate: false,
19
+ allow_advanced_edit: true,
20
+ search_fields: [
21
+ { name: 'variant_id' , nice_name: 'Variant' , type: 'select', width: 400, options_url: '/admin/subscriptions/variant-options' , empty_option_text: '-- Any Variant --' },
22
+ { name: 'status' , nice_name: 'Status' , type: 'select', width: 400, options_url: '/admin/subscriptions/status-options' , empty_option_text: '-- Any Status --' }
23
+ ],
24
+ fields: [
25
+ { show: true, bulk_edit: true, name: 'variant_id' , nice_name: 'Variant' , sort: 'variant_id' , type: 'select' , value: function(s) { return s.variant_id }, text: function(s) { return s.variant && s.variant.product ? s.variant.product.title : s.variant_id; }, width: 75, align: 'left', options_url: '/admin/subscriptions/variant-options' },
26
+ { show: true, bulk_edit: true, name: 'date_started' , nice_name: 'Date Started' , sort: 'date_started' , type: 'date' , value: function(s) { return s.date_started }, width: 100, align: 'left' , date_format: 'Y-m-d' },
27
+ { show: true, bulk_edit: true, name: 'date_started_full' , nice_name: 'Date Started Full' , sort: 'date_started_full' , type: 'date' , value: function(s) { return s.date_started_full }, width: 100, align: 'left' , date_format: 'Y-m-d' },
28
+ { show: true, bulk_edit: true, name: 'status' , nice_name: 'Status' , sort: 'status' , type: 'select' , value: function(s) { return s.status }, width: 75, align: 'left' , options_url: '/admin/subscriptions/status-options' }
29
+ ],
30
+ new_model_text: 'New Subscription',
31
+ no_models_text: "There are subscriptions right now for this user.",
32
+ new_model_fields: [
33
+ { name: 'variant_id' , nice_name: 'Variant' , type: 'select', width: 400, options_url: '/admin/subscriptions/variant-options' }
34
+ ],
35
+ bulk_import_fields: ['variant_id', 'date_started', 'date_started_full', 'status'],
36
+ bulk_import_url: '/admin/users/<%= @edituser.id %>/subscriptions/bulk'
37
+ });
38
+ });
39
+
40
+ </script>
41
+ <% end %>
@@ -9,9 +9,11 @@
9
9
  <%
10
10
  tabs = {
11
11
  'General' => "/admin/users/#{@edituser.id}",
12
+ 'Invoices' => "/admin/users/#{@edituser.id}/invoices",
12
13
  'Login Logs' => "/admin/login-logs?user_id=#{@edituser.id}",
13
14
  'Password' => "/admin/users/#{@edituser.id}/password",
14
- 'Roles' => "/admin/users/#{@edituser.id}/roles",
15
+ 'Roles' => "/admin/users/#{@edituser.id}/roles",
16
+ 'Subscriptions' => "/admin/users/#{@edituser.id}/subscriptions",
15
17
  'Delete' => "/admin/users/#{@edituser.id}/delete"
16
18
  }
17
19
  if @site.use_store
@@ -55,6 +55,22 @@ v = @variant
55
55
  <div id='variant_<%= v.id %>_is_bundle'></div>
56
56
  <div id='variant_children'></div>
57
57
 
58
+ <h2>Subscription</h2>
59
+ <div id='variant_<%= v.id %>_is_subscription'></div>
60
+ <div id='variant_<%= v.id %>_subscription_interval' ></div>
61
+ <div id='variant_<%= v.id %>_subscription_prorate' ></div>
62
+ <div id='variant_<%= v.id %>_subscription_prorate_method' ></div>
63
+ <div id='variant_<%= v.id %>_subscription_prorate_flat_amount' ></div>
64
+ <div id='variant_<%= v.id %>_subscription_start_on_day' ></div>
65
+ <div id='variant_<%= v.id %>_subscription_start_day' ></div>
66
+ <div id='variant_<%= v.id %>_subscription_start_month' ></div>
67
+ <p><code>def custom_prorate_function() {</code></p>
68
+ <p><div id='variant_<%= v.id %>_subscription_prorate_function' ></div></p>
69
+ <p><code>
70
+ # Returns the amount that should be prorated for the first invoice for a subscription.<br />
71
+ # Note: self represents the subscription object.<br />
72
+ }</code></p>
73
+
58
74
  <h2>Delete Variant</h2>
59
75
  <div id='message'></div>
60
76
  <p><input type='button' value='Delete Variant' onclick="delete_variant(<%= v.id %>);" /></p>
@@ -124,7 +140,16 @@ $(document).ready(function() {
124
140
  else
125
141
  vcc.hide();
126
142
  }
127
- }
143
+ },
144
+ { name: 'is_subscription' , nice_name: 'Is Subscription' , type: 'checkbox' , align: 'right' , width: 400, value: <%= raw Caboose.json(v.is_subscription ? 1 : 0 ) %> },
145
+ { name: 'subscription_interval' , nice_name: 'Interval' , type: 'select' , align: 'right' , width: 400, value: <%= raw Caboose.json(v.subscription_interval ) %> , options_url: '/admin/variants/subscription-interval-options' },
146
+ { name: 'subscription_prorate' , nice_name: 'Prorate' , type: 'checkbox' , align: 'right' , width: 400, value: <%= raw Caboose.json(v.subscription_prorate ) %> },
147
+ { name: 'subscription_prorate_method' , nice_name: 'Prorate method' , type: 'select' , align: 'right' , width: 400, value: <%= raw Caboose.json(v.subscription_prorate_method ) %> , options_url: '/admin/variants/subscription-prorate-method-options' },
148
+ { name: 'subscription_prorate_flat_amount' , nice_name: 'Prorate flat amount' , type: 'text' , align: 'right' , width: 400, value: <%= raw Caboose.json(v.subscription_prorate_flat_amount ) %> },
149
+ { name: 'subscription_prorate_function' , nice_name: 'Custom Prorate Function' , type: 'textarea' , align: 'right' , width: 400, value: <%= raw Caboose.json(v.subscription_prorate_function ) %> , height: 100 },
150
+ { name: 'subscription_start_on_day' , nice_name: 'Start on day' , type: 'checkbox' , align: 'right' , width: 400, value: <%= raw Caboose.json(v.subscription_start_on_day ) %> },
151
+ { name: 'subscription_start_day' , nice_name: 'Start day' , type: 'select' , align: 'right' , width: 400, value: <%= raw Caboose.json(v.subscription_start_day ) %> , options_url: '/admin/variants/subscription-start-day-options' },
152
+ { name: 'subscription_start_month' , nice_name: 'Start month' , type: 'select' , align: 'right' , width: 400, value: <%= raw Caboose.json(v.subscription_start_month ) %> , options_url: '/admin/variants/subscription-start-month-options' }
128
153
  ]
129
154
  });
130
155
  vcc = new VariantChildrenController({
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.8.78'
2
+ VERSION = '0.8.79'
3
3
  end
@@ -2,6 +2,10 @@ require "caboose/version"
2
2
  require 'aws-sdk'
3
3
 
4
4
  namespace :caboose do
5
+
6
+ task :subscription_migration => :environment do
7
+ Caboose::Subscription.migrate_from_user_subscriptions
8
+ end
5
9
 
6
10
  desc "Save sample asset"
7
11
  task :save_sample_asset => :environment do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.78
4
+ version: 0.8.79
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-13 00:00:00.000000000 Z
11
+ date: 2016-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -811,7 +811,6 @@ files:
811
811
  - app/controllers/caboose/station_controller.rb
812
812
  - app/controllers/caboose/store_controller.rb
813
813
  - app/controllers/caboose/subscriptions_controller.rb
814
- - app/controllers/caboose/user_subscriptions_controller.rb
815
814
  - app/controllers/caboose/users_controller.rb
816
815
  - app/controllers/caboose/variant_children_controller.rb
817
816
  - app/controllers/caboose/variants_controller.rb
@@ -933,7 +932,6 @@ files:
933
932
  - app/models/caboose/tax_calculator.rb
934
933
  - app/models/caboose/tax_line.rb
935
934
  - app/models/caboose/user.rb
936
- - app/models/caboose/user_subscription.rb
937
935
  - app/models/caboose/utilities/schema.rb
938
936
  - app/models/caboose/variant.rb
939
937
  - app/models/caboose/variant_child.rb
@@ -1077,6 +1075,7 @@ files:
1077
1075
  - app/views/caboose/invoices/admin_new.html.erb
1078
1076
  - app/views/caboose/invoices/admin_print.html.erb
1079
1077
  - app/views/caboose/invoices/admin_summary_report.html.erb
1078
+ - app/views/caboose/invoices/admin_user_edit.html.erb
1080
1079
  - app/views/caboose/invoices_mailer/customer_new_invoice.html.erb
1081
1080
  - app/views/caboose/invoices_mailer/customer_payment_authorization.html.erb
1082
1081
  - app/views/caboose/invoices_mailer/customer_receipt.html.erb
@@ -1208,9 +1207,7 @@ files:
1208
1207
  - app/views/caboose/store/admin_edit_tax.html.erb
1209
1208
  - app/views/caboose/subscriptions/admin_edit.html.erb
1210
1209
  - app/views/caboose/subscriptions/admin_index.html.erb
1211
- - app/views/caboose/user_subscriptions/admin_edit.html.erb
1212
- - app/views/caboose/user_subscriptions/admin_index.html.erb
1213
- - app/views/caboose/user_subscriptions/admin_user_index.html.erb
1210
+ - app/views/caboose/subscriptions/admin_user_index.html.erb
1214
1211
  - app/views/caboose/users/_admin_footer.html.erb
1215
1212
  - app/views/caboose/users/_admin_header.html.erb
1216
1213
  - app/views/caboose/users/admin_delete_form.html.erb
@@ -1,146 +0,0 @@
1
-
2
- module Caboose
3
- class UserSubscriptionsController < ApplicationController
4
-
5
- #===========================================================================
6
- # Admin actions
7
- #===========================================================================
8
-
9
- # @route GET /admin/user-subscriptions
10
- def admin_index
11
- return if !user_is_allowed('usersubscriptions', 'view')
12
- render :layout => 'caboose/admin'
13
- end
14
-
15
- # @route GET /admin/users/:user_id/subscriptions
16
- def admin_user_index
17
- return if !user_is_allowed('usersubscriptions', 'view')
18
- @edituser = User.find(params[:user_id])
19
- render :layout => 'caboose/admin'
20
- end
21
-
22
- # @route GET /admin/user-subscriptions/json
23
- # @route GET /admin/users/:user_id/subscriptions/json
24
- def admin_json
25
- return if !user_is_allowed('usersubscriptions', 'view')
26
-
27
- pager = PageBarGenerator.new(params, {
28
- 'subscription_id' => '',
29
- 'user_id' => params[:user_id] ? params[:user_id] : '',
30
- 'date_started_gte' => '',
31
- 'date_started_lte' => '',
32
- 'date_started_full_gte' => '',
33
- 'date_started_full_lte' => '',
34
- 'status' => ''
35
- },{
36
- 'model' => 'Caboose::UserSubscription',
37
- 'sort' => 'date_started',
38
- 'desc' => false,
39
- 'base_url' => params[:user_id] ? "/admin/users/#{params[:user_id]}/subscriptions" : '/admin/user-subscriptions',
40
- 'use_url_params' => false
41
- })
42
- render :json => {
43
- :pager => pager,
44
- :models => pager.items.as_json(:include => [:user, :subscription])
45
- }
46
- end
47
-
48
- # @route GET /admin/users/:user_id/subscriptions/:id
49
- def admin_edit
50
- return if !user_is_allowed('usersubscriptions', 'edit')
51
- @user_subscription = UserSubscription.find(params[:id])
52
- @edituser = User.find(params[:user_id])
53
- render :layout => 'caboose/admin'
54
- end
55
-
56
- # @route GET /admin/users/:user_id/subscriptions/:id/json
57
- def admin_json_single
58
- return if !user_is_allowed('usersubscriptions', 'view')
59
- us = UserSubscription.find(params[:id])
60
- render :json => us
61
- end
62
-
63
- # @route POST /admin/users/:user_id/subscriptions
64
- def admin_add
65
- return unless user_is_allowed('usersubscriptions', 'add')
66
-
67
- resp = Caboose::StdClass.new
68
- s = params[:subscription_id] ? Subscription.where(:id => params[:subscription_id]).first : nil
69
-
70
- if subscription_id.nil? || s.nil? || s.site_id != @site.id
71
- resp.error = "A valid subscription is required."
72
- else
73
- us = UserSubscription.create(
74
- :subscription_id => s.id,
75
- :user_id => params[:user_id],
76
- :date_started => Date.today,
77
- :date_started_full => Date.today,
78
- :status => UserSubcription::STATUS_ACTIVE
79
- )
80
- resp.redirect = "/admin/users/#{params[:user_id]}/subscriptions/#{us.id}"
81
- resp.success = true
82
- end
83
- render :json => resp
84
- end
85
-
86
- # @route PUT /admin/users/:user_id/subscriptions/:id
87
- def admin_update
88
- return unless user_is_allowed('usersubscriptions', 'edit')
89
-
90
- resp = StdClass.new
91
- models = params[:id] == 'bulk' ? params[:model_ids].collect{ |model_id| UserSubscription.find(model_id) } : [UserSubscription.find(params[:id])]
92
-
93
- params.each do |k, v|
94
- case k
95
- when 'subscription_id' then models.each{ |us| us.subscription_id = v }
96
- when 'user_id' then models.each{ |us| us.user_id = v }
97
- when 'date_started' then models.each{ |us| us.date_started = v }
98
- when 'date_started_full' then models.each{ |us| us.date_started_full = v }
99
- when 'status' then models.each{ |us| us.status = v }
100
- end
101
- end
102
- models.each{ |us| us.save }
103
- resp.success = true
104
- render :json => resp
105
- end
106
-
107
- # @route DELETE /admin/users/:user_id/subscriptions/:id
108
- def admin_delete
109
- return unless user_is_allowed('usersubscriptions', 'delete')
110
-
111
- model_ids = params[:id] == 'bulk' ? params[:model_ids] : [params[:id]]
112
- model_ids.each do |model_id|
113
- UserSubscription.where(:id => model_id).destroy_all
114
- end
115
-
116
- render :json => { :sucess => true }
117
- end
118
-
119
- # @route_priority 1
120
- # @route GET /admin/user-subscriptions/:field-options
121
- # @route GET /admin/users/:user_id/subscriptions/:field-options
122
- def admin_options
123
- if !user_is_allowed('subscriptions', 'edit')
124
- render :json => false
125
- return
126
- end
127
-
128
- options = []
129
- case params[:field]
130
- when 'subscription'
131
- arr = Subcription.where(:site_id => @site.id).reorder(:name).all
132
- options = arr.collect{ |s| { 'value' => s.id, 'text' => s.name }}
133
- when 'status'
134
- options = [
135
- { 'value' => UserSubscription::STATUS_ACTIVE , 'text' => 'Active' },
136
- { 'value' => UserSubscription::STATUS_INACTIVE , 'text' => 'Inactive' }
137
- ]
138
- when 'user'
139
- arr = User.where(:site_id => @site.id).reorder('last_name, first_name').all
140
- options = arr.collect{ |u| { 'value' => u.id, 'text' => "#{u.first_name} #{u.last_name}" }}
141
- end
142
- render :json => options
143
- end
144
-
145
- end
146
- end