This commit is contained in:
jysperm
2014-11-16 22:40:41 +08:00
parent 91a5b0ea2c
commit 2819597746
8 changed files with 46 additions and 21 deletions

View File

@@ -216,7 +216,7 @@ Account.methods.updatePassword = (password, callback) ->
# @param callback(err) # @param callback(err)
Account.methods.incBalance = (amount, type, payload, callback) -> Account.methods.incBalance = (amount, type, payload, callback) ->
unless _.isNumber amount unless _.isNumber amount
return callback new Error 'amount must be a number' return callback 'invalid_amount'
financials = new models.Financials financials = new models.Financials
account_id: @_id account_id: @_id

View File

@@ -11,7 +11,7 @@ Notification = mongoose.Schema
type: type:
required: true required: true
type: String type: String
enum: ['payment_success'] enum: ['payment_success', 'ticket_create', 'ticket_reply']
level: level:
required: true required: true

View File

@@ -13,6 +13,10 @@ exports.get '/', (req, res) ->
accounts: accounts accounts: accounts
coupon_code_types: _.keys config.coupons_meta coupon_code_types: _.keys config.coupons_meta
exports.get '/account_details', (req, res) ->
Account.findById req.query.account_id, (err, account) ->
res.json _.omit account.toObject(), 'password', 'password_salt', 'tokens', '__v'
exports.get '/ticket', (req, res) -> exports.get '/ticket', (req, res) ->
LIMIT = 10 LIMIT = 10
@@ -66,7 +70,8 @@ exports.post '/confirm_payment', (req, res) ->
account.incBalance req.body.amount, 'deposit', account.incBalance req.body.amount, 'deposit',
type: req.body.type type: req.body.type
order_id: req.body.order_id order_id: req.body.order_id
, -> , (err) ->
return res.error err if err
res.json {} res.json {}
exports.post '/delete_account', (req, res) -> exports.post '/delete_account', (req, res) ->

View File

@@ -5,16 +5,23 @@ $ ->
$('.action-delete-account').click (e) -> $('.action-delete-account').click (e) ->
e.preventDefault() e.preventDefault()
$.post '/admin/delete_account', JSON.stringify if window.confirm 'Are you sure?'
account_id: $(@).parents('tr').data 'id' request '/admin/delete_account',
.success -> account_id: $(@).parents('tr').data 'id'
location.reload() , ->
location.reload()
$('.action-details').click ->
request "/admin/account_details?account_id=#{$(@).parents('tr').data 'id'}", {}, {method: 'get'}, (account) ->
$('.account-details-modal .label-account-id').text account._id
$('.account-details-modal .label-details').html JSON.stringify account, null, ' '
$('.account-details-modal').modal 'show'
$('.confirm-payment-modal .action-confirm-payment').click -> $('.confirm-payment-modal .action-confirm-payment').click ->
request '/admin/confirm_payment', request '/admin/confirm_payment',
account_id: $('.input-account-id').text() account_id: $('.input-account-id').text()
type: 'taobao' type: 'taobao'
amount: $('.input-amount').val() amount: parseFloat $('.input-amount').val()
order_id: $('.input-order-id').val() order_id: $('.input-order-id').val()
, -> , ->
location.reload() location.reload()

View File

@@ -6,4 +6,8 @@
.output-coupon-code { .output-coupon-code {
margin-top: 50px; margin-top: 50px;
} }
} }
pre {
font-family: Menlo, Monaco, Consolas, 'Courier New', monospace;
}

View File

@@ -2,16 +2,16 @@
padding: 6px 12px; padding: 6px 12px;
} }
.img-avatar {
width: 58px;
height: 58px;
}
.list-group-item { .list-group-item {
a { a {
margin-right: 10px; margin-right: 10px;
} }
img.pull-left {
width: 58px;
height: 58px;
}
.list-content { .list-content {
margin-left: 68px; margin-left: 68px;

View File

@@ -32,7 +32,7 @@ block main
td= account.billing.plans.join(', ') td= account.billing.plans.join(', ')
td= account.billing.balance.toFixed(2) td= account.billing.balance.toFixed(2)
td td
button.btn.btn-info.btn-sm(type='button')= t('common.details') button.btn.btn-info.btn-sm.action-details(type='button')= t('common.details')
.btn-group .btn-group
button(type='button', data-toggle='dropdown').btn.btn-primary.btn-sm.dropdown-toggle button(type='button', data-toggle='dropdown').btn.btn-primary.btn-sm.dropdown-toggle
| #{t('common.actions')}   | #{t('common.actions')}  
@@ -73,8 +73,18 @@ block main
.col-sm-5 .col-sm-5
button.action-generate-code.btn.btn-lg.btn-primary(type='button')= t('common.generate') button.action-generate-code.btn.btn-lg.btn-primary(type='button')= t('common.generate')
.output-coupon-code pre.output-coupon-code
.account-details-modal.modal.fade
.modal-dialog
.modal-content
.modal-header
button.close(type='button', data-dismiss='modal', aria-hidden='true') ×
h4.label-account-id
.modal-body
pre.label-details
.modal-footer
button.btn.btn-danger(type='button', data-dismiss='modal')= t('common.close')
.confirm-payment-modal.modal.fade .confirm-payment-modal.modal.fade
.modal-dialog .modal-dialog
@@ -98,7 +108,6 @@ block main
input.input-order-id.form-control(type='order_id') input.input-order-id.form-control(type='order_id')
.modal-footer .modal-footer
button.btn.btn-danger(type='button', data-dismiss='modal')= t('common.close')
button.btn.btn-success.action-confirm-payment(type='button')= t('common.create') button.btn.btn-success.action-confirm-payment(type='button')= t('common.create')
prepend sidebar prepend sidebar

View File

@@ -31,12 +31,12 @@ block main
for reply in ticket.replies for reply in ticket.replies
li.list-group-item.clearfix li.list-group-item.clearfix
a.pull-left a.pull-left
img(src= reply.account.preferences.avatar_url) img.img-avatar(src= reply.account.preferences.avatar_url)
.list-content .list-content
p!= reply.content_html p!= reply.content_html
p p
span.label.label-info= reply.account.username span.label.label-info= reply.account.username
span.label.label-default(title= reply.created_at)= moment(reply.created_at).fromNow() span.label.label-default(title=reply.created_at)= moment(reply.created_at).fromNow()
.row .row
if ticket.status != 'closed' if ticket.status != 'closed'
@@ -66,7 +66,7 @@ prepend sidebar
header= t('ticket.creator') header= t('ticket.creator')
li.list-group-item.clearfix li.list-group-item.clearfix
a.pull-left a.pull-left
img(src= ticket.account.preferences.avatar_url) img.img-avatar(src= ticket.account.preferences.avatar_url)
p p
span.label.label-info= ticket.account.username span.label.label-info= ticket.account.username
br br
@@ -76,7 +76,7 @@ prepend sidebar
header= t('ticket.members') header= t('ticket.members')
for member in ticket.members for member in ticket.members
a.pull-left a.pull-left
img(src= member.preferences.avatar_url, alt= member.username) img.img-avatar(src=member.preferences.avatar_url, alt=member.username)
append footer append footer
script(src='/script/ticket/view.js') script(src='/script/ticket/view.js')