mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-28 23:03:31 +03:00
Make book show all (any/any)
This commit is contained in:
parent
8e5233267f
commit
6400921f48
@ -84,6 +84,13 @@ class LNNode():
|
||||
'''Sends sats to buyer, or cancelinvoices'''
|
||||
return True
|
||||
|
||||
def check_if_hold_invoice_is_locked(payment_hash):
|
||||
'''Every hodl invoice that is in state INVGEN
|
||||
Has to be checked for payment received until
|
||||
the window expires'''
|
||||
|
||||
return True
|
||||
|
||||
def settle_hold_htlcs(payment_hash):
|
||||
'''Charges a LN hold invoice'''
|
||||
return True
|
||||
|
22
api/views.py
22
api/views.py
@ -179,7 +179,7 @@ class OrderView(viewsets.ViewSet):
|
||||
if order.maker_bond.status == order.taker_bond.status == order.trade_escrow.status == LNPayment.Status.LOCKED:
|
||||
# add whether a collaborative cancel is pending
|
||||
data['pending_cancel'] = order.is_pending_cancel
|
||||
|
||||
|
||||
|
||||
return Response(data, status.HTTP_200_OK)
|
||||
|
||||
@ -343,25 +343,27 @@ class UserView(APIView):
|
||||
|
||||
class BookView(ListAPIView):
|
||||
serializer_class = ListOrderSerializer
|
||||
queryset = Order.objects.filter(status=Order.Status.PUB)
|
||||
|
||||
def get(self,request, format=None):
|
||||
currency = request.GET.get('currency')
|
||||
print("currency:", currency)
|
||||
type = request.GET.get('type')
|
||||
queryset = Order.objects.filter(currency=currency, type=type, status=int(Order.Status.PUB))
|
||||
type = request.GET.get('type')
|
||||
|
||||
queryset = Order.objects.filter(status=Order.Status.PUB)
|
||||
# Currency 0 and type 2 are special cases treated as "ANY". They are not possible choices.
|
||||
if not (int(currency) == 0 and int(type) == 2):
|
||||
queryset = Order.objects.filter(currency=currency, type=type, status=Order.Status.PUB)
|
||||
|
||||
if len(queryset)== 0:
|
||||
return Response({'not_found':'No orders found, be the first to make one'}, status=status.HTTP_404_NOT_FOUND)
|
||||
|
||||
queryset = queryset.order_by('created_at')
|
||||
# queryset = queryset.order_by('created_at')
|
||||
book_data = []
|
||||
for order in queryset:
|
||||
data = ListOrderSerializer(order).data
|
||||
user = User.objects.filter(id=data['maker'])
|
||||
if len(user) == 1:
|
||||
data['maker_nick'] = user[0].username
|
||||
data['maker_nick'] = str(order.maker)
|
||||
|
||||
# Non participants should not see the status or who is the taker
|
||||
for key in ('status','taker'):
|
||||
for key in ('status','taker'): # Non participants should not see the status or who is the taker
|
||||
del data[key]
|
||||
|
||||
book_data.append(data)
|
||||
|
@ -7,9 +7,9 @@ export default class BookPage extends Component {
|
||||
super(props);
|
||||
this.state = {
|
||||
orders: new Array(),
|
||||
currency: 1,
|
||||
type: 1,
|
||||
currencies_dict: {"1":"USD"}
|
||||
currency: 0,
|
||||
type: 2,
|
||||
currencies_dict: {"0":"ANY"}
|
||||
};
|
||||
this.getCurrencyDict()
|
||||
this.getOrderDetails(this.state.type,this.state.currency)
|
||||
@ -142,7 +142,7 @@ export default class BookPage extends Component {
|
||||
style: {textAlign:"center"}
|
||||
}}
|
||||
onChange={this.handleTypeChange}
|
||||
>
|
||||
> <MenuItem value={2}>ANY</MenuItem>
|
||||
<MenuItem value={1}>BUY</MenuItem>
|
||||
<MenuItem value={0}>SELL</MenuItem>
|
||||
</Select>
|
||||
@ -162,7 +162,7 @@ export default class BookPage extends Component {
|
||||
style: {textAlign:"center"}
|
||||
}}
|
||||
onChange={this.handleCurrencyChange}
|
||||
>
|
||||
> <MenuItem value={0}>ANY</MenuItem>
|
||||
{
|
||||
Object.entries(this.state.currencies_dict)
|
||||
.map( ([key, value]) => <MenuItem value={parseInt(key)}>{value}</MenuItem> )
|
||||
|
Loading…
Reference in New Issue
Block a user