From 426202d80a86fb75d0ddca18c3b20e30a023a1ac Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Tue, 25 Nov 2014 11:09:29 -0800 Subject: [PATCH] Added a simple payments page. --- app/Router.coffee | 2 +- app/locale/en.coffee | 6 +++++ app/models/Payment.coffee | 5 ++++ app/templates/account/payments-view.jade | 30 ++++++++++++++++++++++++ app/views/account/PaymentsView.coffee | 18 ++++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 app/models/Payment.coffee create mode 100644 app/templates/account/payments-view.jade create mode 100644 app/views/account/PaymentsView.coffee diff --git a/app/Router.coffee b/app/Router.coffee index d66c61717..a075424f2 100644 --- a/app/Router.coffee +++ b/app/Router.coffee @@ -24,7 +24,7 @@ module.exports = class CocoRouter extends Backbone.Router 'account/settings': go('account/AccountSettingsView') 'account/unsubscribe': go('account/UnsubscribeView') 'account/profile': go('user/JobProfileView') # legacy URL, sent in emails - #'account/payment' + 'account/payments': go('account/PaymentsView') 'admin': go('admin/MainAdminView') 'admin/candidates': go('admin/CandidatesView') diff --git a/app/locale/en.coffee b/app/locale/en.coffee index 3873fcdb2..94a0ad3ef 100644 --- a/app/locale/en.coffee +++ b/app/locale/en.coffee @@ -792,6 +792,12 @@ recently_played: "Recently Played" no_recent_games: "No games played during the past two weeks." payments: "Payments" + service_apple: "Apple" + service_web: "Web" + paid_on: "Paid On" + service: "Service" + price: "Price" + gems: "Gems" loading_error: could_not_load: "Error loading from server" diff --git a/app/models/Payment.coffee b/app/models/Payment.coffee new file mode 100644 index 000000000..1e4b31ff3 --- /dev/null +++ b/app/models/Payment.coffee @@ -0,0 +1,5 @@ +CocoModel = require('./CocoModel') + +module.exports = class Payment extends CocoModel + @className: "Payment" + urlRoot: "/db/payment" \ No newline at end of file diff --git a/app/templates/account/payments-view.jade b/app/templates/account/payments-view.jade new file mode 100644 index 000000000..ae7a9cfd7 --- /dev/null +++ b/app/templates/account/payments-view.jade @@ -0,0 +1,30 @@ +extends /templates/base + +block content + + ol.breadcrumb + li + a(href="/") + span.glyphicon.glyphicon-home + li + a(href="/account")(data-i18n="nav.account") + li.active(data-i18n="account.payments") + + if payments.models.length + table.table.table-striped + tr + th(data-i18n="account.paid_on") + th(data-i18n="account.service") + th(data-i18n="account.price") + th(data-i18n="account.gems") + for payment in payments.models + - var service = payment.get('service') + tr + td= moment(payment.getCreationDate()).format('lll') + if service === 'ios' + td(data-i18n="account.service_apple") + td= payment.get('ios').localPrice + else + td(data-i18n="account.service_web") + td $#{(payment.get('amount')/100).toFixed(2)} + td= payment.get('gems') diff --git a/app/views/account/PaymentsView.coffee b/app/views/account/PaymentsView.coffee new file mode 100644 index 000000000..dc7ac2219 --- /dev/null +++ b/app/views/account/PaymentsView.coffee @@ -0,0 +1,18 @@ +RootView = require 'views/kinds/RootView' +template = require 'templates/account/payments-view' +CocoCollection = require 'collections/CocoCollection' +Payment = require 'models/Payment' + +module.exports = class PaymentsView extends RootView + id: "payments-view" + template: template + + constructor: (options) -> + super(options) + @payments = new CocoCollection([], { url: '/db/payment', model: Payment }) + @supermodel.loadCollection(@payments, 'payments') + + getRenderData: -> + c = super() + c.payments = @payments + c \ No newline at end of file