Skip to content

Commit

Permalink
Order updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Hoffman committed May 13, 2014
1 parent ec03491 commit b6b3668
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
8 changes: 7 additions & 1 deletion html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ <h3 class="modal-title">Order #{{orderId}}</h3>
<td width=200><strong>Order Date:</strong></td>
<td><span id="modalCreated"></span></td>
</tr>
<tr>
<td width=200><strong>Status:</strong></td>
<td style="vertical-align:middle;"><span id="modalStatus" class="label label-info"></span></td>
</tr>
<tr>
<td><strong>Buyer:</strong></td>
<td style="word-break:break-all"><span id="modalBuyer"></span></td>
Expand All @@ -288,7 +292,7 @@ <h3 class="modal-title">Order #{{orderId}}</h3>
</tr>
<tr>
<td><strong>Escrows:</strong></td>
<td><ul id="modalEscrows"></ul></td>
<td style="word-break:break-all"><span id="modalEscrows"></span></td>
</tr>
<tr>
<td><strong>Payment Address:</strong></td>
Expand All @@ -300,8 +304,10 @@ <h3 class="modal-title">Order #{{orderId}}</h3>
</tr>
</table>

<div id="payment_buttons">
<button ng-click="markOrderPaid(orderId)" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-ok"></span> Mark as Paid</button>
<button ng-click="" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-remove"></span> Cancel Order</button>
</div>

</div>
<div class="modal-footer">
Expand Down
21 changes: 16 additions & 5 deletions html/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,20 @@ angular.module('app').controller('Market', ['$scope', function($scope) {

$('#modalOrderDescription').html(msg.order.text);
$('#modalBuyer').html(msg.order.buyer);
$('#modalStatus').html(msg.order.state);
$('#modalSeller').html(msg.order.seller);
$('#modalPaymentAddress').html('<a href="https://blockchain.info/address/'+msg.order.address+'" target="_blank">'+msg.order.address+'</a>');
$('#modalCreated').html(new Date(msg.order.created*1000));

msg.order.escrows.forEach(function(escrow) {
escrows = '<li style="word-break:break-all">' + escrow + "</li>";
});

$('#modalEscrows').html(escrows);

$('#modalEscrows').html(msg.order.escrows);

if(msg.order.state == 'accepted') {
$('#payment_buttons').show();
} else {
$('#payment_buttons').hide();
}


if (!$scope.$$phase) {
Expand Down Expand Up @@ -606,7 +611,13 @@ $scope.WelcomeModalCtrl = function ($scope, $modal, $log) {
$scope.orderId = orderId;

$scope.markOrderPaid = function(orderId) {
socket.send("pay_order", { orderId: orderId} )
socket.send("pay_order", { orderId: orderId} )
$('#payment_buttons').hide();

if (!$scope.$$phase) {
$scope.$apply();
}

}

$scope.ok = function () {
Expand Down
4 changes: 3 additions & 1 deletion node/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,17 @@ def on_order(self, msg):
self._log.info('Order cancelled')
else:
self._log.info("Order not for us")

elif state == 'accepted':
if myself == seller:
self._log.info("Bad subjects [%s]" % state)
elif myself == buyer:
# wait for confirmation
self._db.orders.update({"id":msg['id']}, {"$set":msg}, True)
pass
else:
self._log.info("Order not for us")
elif state == 'payed':
elif state == 'paid':
if myself == seller:
# wait for confirmation
pass
Expand Down
5 changes: 2 additions & 3 deletions node/ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ def client_query_page(self, socket_handler, msg):

def client_query_orders(self, socket_handler, msg):

self._log.info("Querying for Orders: ", msg)
self._log.info("Querying for Orders")

# Query mongo for orders
orders = self.node.orders.get_orders()
print orders

self.send_to_client(None, { "type": "myorders", "orders": orders } )

Expand Down Expand Up @@ -99,7 +98,7 @@ def client_pay_order(self, socket_handler, msg):

# Update order in mongo
order = self.node.orders.get_order(msg['orderId'])
print order
print order

# Send to exchange partner
self.node.orders.pay_order(order)
Expand Down

0 comments on commit b6b3668

Please sign in to comment.