comable_backend 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/comable/admin/application.coffee +4 -0
- data/app/assets/stylesheets/comable/admin/_common.scss +23 -0
- data/app/assets/stylesheets/comable/admin/_flow.scss +149 -0
- data/app/assets/stylesheets/comable/admin/application.scss +1 -0
- data/app/assets/stylesheets/comable/admin/overrides/bootstrap.scss +1 -0
- data/app/controllers/comable/admin/application_controller.rb +24 -4
- data/app/controllers/comable/admin/dashboard_controller.rb +4 -4
- data/app/controllers/comable/admin/orders_controller.rb +82 -1
- data/app/controllers/comable/admin/payment_methods_controller.rb +1 -0
- data/app/controllers/comable/admin/products_controller.rb +16 -0
- data/app/controllers/comable/admin/stocks_controller.rb +16 -0
- data/app/controllers/comable/admin/trackers_controller.rb +58 -0
- data/app/controllers/comable/admin/{customers_controller.rb → users_controller.rb} +8 -8
- data/app/helpers/comable/admin/orders_helper.rb +30 -0
- data/app/views/comable/admin/categories/index.slim +2 -2
- data/app/views/comable/admin/dashboard/show.slim +9 -10
- data/app/views/comable/admin/orders/_payment_state.slim +40 -0
- data/app/views/comable/admin/orders/_shipment_state.slim +44 -0
- data/app/views/comable/admin/orders/edit.slim +112 -0
- data/app/views/comable/admin/orders/index.slim +22 -6
- data/app/views/comable/admin/orders/show.slim +141 -110
- data/app/views/comable/admin/payment_methods/_form.slim +6 -2
- data/app/views/comable/admin/products/_form.slim +9 -9
- data/app/views/comable/admin/products/index.slim +16 -0
- data/app/views/comable/admin/shared/_header.slim +3 -3
- data/app/views/comable/admin/shared/_sidebar.slim +5 -3
- data/app/views/comable/admin/shared/export.xlsx.axlsx +17 -0
- data/app/views/comable/admin/shipment_methods/_form.slim +2 -2
- data/app/views/comable/admin/stocks/_form.slim +2 -2
- data/app/views/comable/admin/stocks/index.slim +16 -0
- data/app/views/comable/admin/store/_form.slim +2 -2
- data/app/views/comable/admin/trackers/_form.slim +109 -0
- data/app/views/comable/admin/trackers/edit.slim +27 -0
- data/app/views/comable/admin/trackers/index.slim +37 -0
- data/app/views/comable/admin/trackers/new.slim +16 -0
- data/app/views/comable/admin/{customers → users}/edit.slim +10 -10
- data/app/views/comable/admin/{customers → users}/index.slim +20 -20
- data/app/views/comable/admin/users/show.slim +88 -0
- data/app/views/layouts/comable/admin/application.slim +1 -1
- data/config/routes.rb +31 -4
- metadata +19 -8
- data/app/views/comable/admin/customers/show.slim +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa2786c8556acb44601370d90dedc34405b75fc4
|
4
|
+
data.tar.gz: 302afe2c02974bdba2d04c700165ca215a813cfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b09ac7adc713fc6433722946eb45c60a6d9f6bd9eeca82cf7d93442c4f1200fa95bc519694157ca5ca37f2ef65e41df387499d6387339f5feced120b2679d79
|
7
|
+
data.tar.gz: f820fa64c10074668e0bd4c2b68fd34257bd373dc24b5052bfae1b6597d29c7b0552d3e2d324130fed9617eeb336e8c914eac1e3ada30c864a8ae5630612123b
|
@@ -92,6 +92,10 @@ $( ->
|
|
92
92
|
$(window).on('resize', resize_comable_affix)
|
93
93
|
|
94
94
|
$('[data-toggle="tooltip"]').tooltip()
|
95
|
+
|
96
|
+
$(document).on('change', '.btn-file :file', ->
|
97
|
+
$(this).closest('form').submit()
|
98
|
+
)
|
95
99
|
)
|
96
100
|
# Place all the behaviors and hooks related to the matching controller here.
|
97
101
|
# All this logic will automatically be available in application.js.
|
@@ -290,3 +290,26 @@ footer {
|
|
290
290
|
color: #000;
|
291
291
|
}
|
292
292
|
}
|
293
|
+
|
294
|
+
// for File Inputs
|
295
|
+
// refs: http://www.abeautifulsite.net/whipping-file-inputs-into-shape-with-bootstrap-3/
|
296
|
+
.btn-file {
|
297
|
+
position: relative;
|
298
|
+
overflow: hidden;
|
299
|
+
cursor: pointer;
|
300
|
+
}
|
301
|
+
|
302
|
+
.btn-file input[type=file] {
|
303
|
+
@include opacity(0);
|
304
|
+
position: absolute;
|
305
|
+
top: 0;
|
306
|
+
right: 0;
|
307
|
+
min-width: 100%;
|
308
|
+
min-height: 100%;
|
309
|
+
font-size: 100px;
|
310
|
+
text-align: right;
|
311
|
+
outline: none;
|
312
|
+
background: white;
|
313
|
+
cursor: inherit;
|
314
|
+
display: block;
|
315
|
+
}
|
@@ -0,0 +1,149 @@
|
|
1
|
+
// Variables
|
2
|
+
$comable-flow-border: #eee;
|
3
|
+
$comable-badge-size: 50px;
|
4
|
+
$comable-badge-default-color: $gray;
|
5
|
+
$comable-badge-default-bg: #fff;
|
6
|
+
$comable-badge-default-border: $btn-default-border;
|
7
|
+
$comable-badge-disable-color: #fff;
|
8
|
+
$comable-badge-disable-bg: #ddd;
|
9
|
+
$comable-badge-disable-border: $btn-default-border;
|
10
|
+
$comable-badge-primary-color: $btn-primary-color;
|
11
|
+
$comable-badge-primary-bg: $btn-primary-bg;
|
12
|
+
$comable-badge-primary-border: $btn-primary-border;
|
13
|
+
$comable-badge-success-color: $btn-success-color;
|
14
|
+
$comable-badge-success-bg: $btn-success-bg;
|
15
|
+
$comable-badge-success-border: $btn-success-border;
|
16
|
+
$comable-badge-warning-color: $btn-warning-color;
|
17
|
+
$comable-badge-warning-bg: $btn-warning-bg;
|
18
|
+
$comable-badge-warning-border: $btn-warning-border;
|
19
|
+
$comable-badge-danger-color: $btn-danger-color;
|
20
|
+
$comable-badge-danger-bg: $btn-danger-bg;
|
21
|
+
$comable-badge-danger-border: $btn-danger-border;
|
22
|
+
|
23
|
+
// Mixins
|
24
|
+
@mixin comable-badge($color, $background-color, $border-color) {
|
25
|
+
color: $color;
|
26
|
+
background-color: $background-color;
|
27
|
+
border-color: $border-color;
|
28
|
+
|
29
|
+
&:hover, &:focus {
|
30
|
+
color: $color;
|
31
|
+
}
|
32
|
+
|
33
|
+
@at-root a#{&}:hover, a#{&}:focus {
|
34
|
+
background-color: darken($background-color, 10%);
|
35
|
+
border-color: darken($border-color, 10%);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
// Rules
|
40
|
+
.comable-flow {
|
41
|
+
list-style: none;
|
42
|
+
margin-bottom: 20px;
|
43
|
+
padding: 20px 0;
|
44
|
+
position: relative;
|
45
|
+
|
46
|
+
&:before {
|
47
|
+
content: ' ';
|
48
|
+
margin-top: -1.5px;
|
49
|
+
height: 3px;
|
50
|
+
background-color: $comable-flow-border;
|
51
|
+
position: absolute;
|
52
|
+
top: 50%;
|
53
|
+
left: 0;
|
54
|
+
right: 0;
|
55
|
+
}
|
56
|
+
|
57
|
+
li {
|
58
|
+
@include inline-block;
|
59
|
+
margin-right: $comable-badge-size + 50px;
|
60
|
+
position: relative;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
.comable-badge {
|
65
|
+
@include border-radius(50%);
|
66
|
+
margin-top: -($comable-badge-size / 2);
|
67
|
+
height: $comable-badge-size;
|
68
|
+
width: $comable-badge-size;
|
69
|
+
line-height: $comable-badge-size;
|
70
|
+
font-size: 1.4em;
|
71
|
+
text-align: center;
|
72
|
+
position: absolute;
|
73
|
+
left: 16px;
|
74
|
+
top: 50%;
|
75
|
+
z-index: 100;
|
76
|
+
border: 1px solid transparent;
|
77
|
+
|
78
|
+
&[disabled] {
|
79
|
+
@include opacity(0.65);
|
80
|
+
@include box-shadow(none);
|
81
|
+
cursor: not-allowed;
|
82
|
+
pointer-events: none;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
.comable-badge-default {
|
87
|
+
@include comable-badge(
|
88
|
+
$color: $comable-badge-default-color,
|
89
|
+
$background-color: $comable-badge-default-bg,
|
90
|
+
$border-color: $comable-badge-default-border
|
91
|
+
);
|
92
|
+
}
|
93
|
+
|
94
|
+
.comable-badge-disable {
|
95
|
+
@include comable-badge(
|
96
|
+
$color: $comable-badge-disable-color,
|
97
|
+
$background-color: $comable-badge-disable-bg,
|
98
|
+
$border-color: $comable-badge-default-border
|
99
|
+
);
|
100
|
+
}
|
101
|
+
|
102
|
+
.comable-badge-primary {
|
103
|
+
@include comable-badge(
|
104
|
+
$color: $comable-badge-primary-color,
|
105
|
+
$background-color: $comable-badge-primary-bg,
|
106
|
+
$border-color: $comable-badge-primary-border
|
107
|
+
);
|
108
|
+
}
|
109
|
+
|
110
|
+
.comable-badge-success {
|
111
|
+
@include comable-badge(
|
112
|
+
$color: $comable-badge-success-color,
|
113
|
+
$background-color: $comable-badge-success-bg,
|
114
|
+
$border-color: $comable-badge-success-border
|
115
|
+
);
|
116
|
+
}
|
117
|
+
|
118
|
+
.comable-badge-danger {
|
119
|
+
@include comable-badge(
|
120
|
+
$color: $comable-badge-danger-color,
|
121
|
+
$background-color: $comable-badge-danger-bg,
|
122
|
+
$border-color: $comable-badge-danger-border
|
123
|
+
);
|
124
|
+
}
|
125
|
+
|
126
|
+
.comable-badge-warning {
|
127
|
+
@include comable-badge(
|
128
|
+
$color: $comable-badge-warning-color,
|
129
|
+
$background-color: $comable-badge-warning-bg,
|
130
|
+
$border-color: $comable-badge-warning-border
|
131
|
+
);
|
132
|
+
}
|
133
|
+
|
134
|
+
.comable-flow-label {
|
135
|
+
display: table;
|
136
|
+
height: $comable-badge-size + 5px;
|
137
|
+
margin: 0 0 0 auto;
|
138
|
+
text-align: right;
|
139
|
+
}
|
140
|
+
|
141
|
+
.comable-flow-label-container {
|
142
|
+
display: table-cell;
|
143
|
+
vertical-align: middle;
|
144
|
+
|
145
|
+
*:last-child {
|
146
|
+
margin-bottom: 0;
|
147
|
+
padding-bottom: 0;
|
148
|
+
}
|
149
|
+
}
|
@@ -9,7 +9,19 @@ module Comable
|
|
9
9
|
layout 'comable/admin/application'
|
10
10
|
|
11
11
|
def current_ability
|
12
|
-
Comable::Ability.new(
|
12
|
+
Comable::Ability.new(current_comable_user)
|
13
|
+
end
|
14
|
+
|
15
|
+
def respond_to_export_with(records)
|
16
|
+
respond_to do |format|
|
17
|
+
format.csv do
|
18
|
+
render csv: records, filename: filename
|
19
|
+
end
|
20
|
+
|
21
|
+
format.xlsx do
|
22
|
+
render xlsx: 'export', filename: filename, locals: { records: records }, template: 'comable/admin/shared/export', layout: false
|
23
|
+
end
|
24
|
+
end
|
13
25
|
end
|
14
26
|
|
15
27
|
private
|
@@ -17,22 +29,30 @@ module Comable
|
|
17
29
|
rescue_from CanCan::AccessDenied, with: :unauthorized
|
18
30
|
|
19
31
|
def unauthorized
|
20
|
-
if
|
32
|
+
if current_comable_user.signed_in?
|
21
33
|
flash[:alert] = Comable.t('admin.access_denied')
|
22
34
|
redirect_to after_access_denied_path
|
23
35
|
else
|
24
36
|
store_location
|
25
|
-
redirect_to comable.
|
37
|
+
redirect_to comable.new_admin_user_session_path
|
26
38
|
end
|
27
39
|
end
|
28
40
|
|
29
41
|
def after_access_denied_path
|
30
|
-
if
|
42
|
+
if current_comable_user.user?
|
31
43
|
comable.root_path
|
32
44
|
else
|
33
45
|
comable.admin_root_path
|
34
46
|
end
|
35
47
|
end
|
48
|
+
|
49
|
+
def filename
|
50
|
+
"#{timestamp}_#{controller_name}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def timestamp
|
54
|
+
Time.now.strftime('%Y%m%d%H%M%S')
|
55
|
+
end
|
36
56
|
end
|
37
57
|
end
|
38
58
|
end
|
@@ -10,10 +10,10 @@ module Comable
|
|
10
10
|
authorize! :read, @this_month_orders
|
11
11
|
|
12
12
|
# TODO: Comment out after adding timestamp columns
|
13
|
-
# @
|
14
|
-
# @
|
15
|
-
# @
|
16
|
-
# authorize! :read, @
|
13
|
+
# @this_month_users = Comable::User.with_role(:user).this_month
|
14
|
+
# @this_week_users = Comable::User.with_role(:user).this_week
|
15
|
+
# @last_week_users = Comable::User.with_role(:user).last_week
|
16
|
+
# authorize! :read, @this_week_users
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -3,15 +3,96 @@ require_dependency 'comable/admin/application_controller'
|
|
3
3
|
module Comable
|
4
4
|
module Admin
|
5
5
|
class OrdersController < Comable::Admin::ApplicationController
|
6
|
+
include Comable::PermittedAttributes
|
7
|
+
|
6
8
|
load_and_authorize_resource class: Comable::Order.name, except: :index
|
7
9
|
|
8
10
|
def index
|
9
11
|
@q = Comable::Order.complete.ransack(params[:q])
|
10
|
-
@orders = @q.result.page(params[:page]).per(15).
|
12
|
+
@orders = @q.result.page(params[:page]).per(15).recent.accessible_by(current_ability)
|
11
13
|
end
|
12
14
|
|
13
15
|
def show
|
14
16
|
end
|
17
|
+
|
18
|
+
def edit
|
19
|
+
end
|
20
|
+
|
21
|
+
def update
|
22
|
+
if @order.update_attributes(order_params)
|
23
|
+
redirect_to comable.admin_order_path(@order), notice: Comable.t('successful')
|
24
|
+
else
|
25
|
+
flash.now[:alert] = Comable.t('failure')
|
26
|
+
render :edit
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def export
|
31
|
+
q = Comable::Order.complete.ransack(params[:q])
|
32
|
+
orders = q.result.recent.accessible_by(current_ability)
|
33
|
+
order_items = Comable::OrderItem.joins(:order).merge(orders)
|
34
|
+
|
35
|
+
respond_to_export_with order_items
|
36
|
+
end
|
37
|
+
|
38
|
+
def cancel
|
39
|
+
@order.cancel!
|
40
|
+
redirect_to :back, notice: Comable.t('successful')
|
41
|
+
rescue ActiveRecord::RecordInvalid => e
|
42
|
+
redirect_to :back, alert: e.message
|
43
|
+
end
|
44
|
+
|
45
|
+
def resume
|
46
|
+
@order.resume!
|
47
|
+
redirect_to :back, notice: Comable.t('successful')
|
48
|
+
rescue ActiveRecord::RecordInvalid => e
|
49
|
+
redirect_to :back, alert: e.message
|
50
|
+
end
|
51
|
+
|
52
|
+
def cancel_payment
|
53
|
+
@order.payment.cancel!
|
54
|
+
redirect_to :back, notice: Comable.t('successful')
|
55
|
+
rescue ActiveRecord::RecordInvalid => e
|
56
|
+
redirect_to :back, alert: e.message
|
57
|
+
end
|
58
|
+
|
59
|
+
def resume_payment
|
60
|
+
@order.payment.resume!
|
61
|
+
redirect_to :back, notice: Comable.t('successful')
|
62
|
+
rescue ActiveRecord::RecordInvalid => e
|
63
|
+
redirect_to :back, alert: e.message
|
64
|
+
end
|
65
|
+
|
66
|
+
def ship
|
67
|
+
@order.shipment.ship!
|
68
|
+
redirect_to :back, notice: Comable.t('successful')
|
69
|
+
rescue ActiveRecord::RecordInvalid => e
|
70
|
+
redirect_to :back, alert: e.message
|
71
|
+
end
|
72
|
+
|
73
|
+
def cancel_shipment
|
74
|
+
@order.shipment.cancel!
|
75
|
+
redirect_to :back, notice: Comable.t('successful')
|
76
|
+
rescue ActiveRecord::RecordInvalid => e
|
77
|
+
redirect_to :back, alert: e.message
|
78
|
+
end
|
79
|
+
|
80
|
+
def resume_shipment
|
81
|
+
@order.shipment.resume!
|
82
|
+
redirect_to :back, notice: Comable.t('successful')
|
83
|
+
rescue ActiveRecord::RecordInvalid => e
|
84
|
+
redirect_to :back, alert: e.message
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def order_params
|
90
|
+
params.require(:order).permit(
|
91
|
+
:email,
|
92
|
+
bill_address_attributes: permitted_address_attributes,
|
93
|
+
ship_address_attributes: permitted_address_attributes
|
94
|
+
)
|
95
|
+
end
|
15
96
|
end
|
16
97
|
end
|
17
98
|
end
|
@@ -47,6 +47,22 @@ module Comable
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
def export
|
51
|
+
q = Comable::Product.ransack(params[:q])
|
52
|
+
products = q.result.accessible_by(current_ability)
|
53
|
+
|
54
|
+
respond_to_export_with products
|
55
|
+
end
|
56
|
+
|
57
|
+
def import
|
58
|
+
ActiveRecord::Base.transaction do
|
59
|
+
Comable::Product.import_from(params[:file])
|
60
|
+
end
|
61
|
+
redirect_to comable.admin_products_path, notice: Comable.t('successful')
|
62
|
+
rescue Comable::Importable::Exception => e
|
63
|
+
redirect_to comable.admin_products_path, alert: e.message
|
64
|
+
end
|
65
|
+
|
50
66
|
private
|
51
67
|
|
52
68
|
def product_params
|
@@ -50,6 +50,22 @@ module Comable
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
def export
|
54
|
+
q = @stocks.ransack(params[:q])
|
55
|
+
stocks = q.result.includes(:product).accessible_by(current_ability)
|
56
|
+
|
57
|
+
respond_to_export_with stocks
|
58
|
+
end
|
59
|
+
|
60
|
+
def import
|
61
|
+
ActiveRecord::Base.transaction do
|
62
|
+
Comable::Stock.import_from(params[:file])
|
63
|
+
end
|
64
|
+
redirect_to comable.admin_stocks_path, notice: Comable.t('successful')
|
65
|
+
rescue Comable::Importable::Exception => e
|
66
|
+
redirect_to comable.admin_stocks_path, alert: e.message
|
67
|
+
end
|
68
|
+
|
53
69
|
private
|
54
70
|
|
55
71
|
def stock_params
|