Пример #1
0
def home(request):
    new_claims = Service.getAllClaim()
    featured_claim = new_claims[0]
    hot_claims = Service.getAllClaim()
    help_titles = Service.getHelpTitleAsDict('home')
    help_descriptions = Service.getHelpDescriptionAsDict('home')
    return render(request, 'market/home.html', locals())
Пример #2
0
def claim_create(request):
    if request.method == 'POST':
        form = ClaimForm(request.POST)
        if form.is_valid():
            claim = form.save(commit=False)
            Service.createClaim(claim)
            return redirect('home')
    else:
        form = ClaimForm()
    return render(request, 'market/claim_create.html', locals())
Пример #3
0
def order_create(request, claim_id):
    claim = Service.getClaimById(claim_id)
    if request.method == 'POST':
        form = OrderForm(request.POST)
        if form.is_valid():
            order = form.save(commit=False)
            Service.createOrder(order, claim, request.user.trader)
            return redirect('home')
    else:
        form = OrderForm()
    return render(request, 'market/order_create.html', locals())
Пример #4
0
def signup(request):
    if request.method == 'POST':
        traderform = TraderForm(request.POST)
        userform = UserForm(request.POST)
        if traderform.is_valid() and userform.is_valid():
            trader = traderform.save(commit=False)
            user = userform.save(commit=False)
            Service.createTrader(trader, user)
            return render(request, 'market/home.html')
    else:
        traderform = TraderForm()
        userform = UserForm()
    return render(request, 'market/signup.html', locals())
Пример #5
0
 def put(self, request, pk, format=None):
     Order = Service.getOrderById(pk)
     serializer = OrderSerializer(Order, data=request.DATA)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Пример #6
0
def claims(request):
    claims = Service.getAllClaim()
    return render(request, 'market/claims.html', locals())
Пример #7
0
def claim_info(request, id):
    claim = Service.getClaimById(id)
    return render(request, 'market/claim_info.html', locals())
Пример #8
0
def portfolio(request):
    holdings = Service.getAllHolding(request.user.trader)
    help_titles = Service.getHelpTitleAsDict('home')
    help_descriptions = Service.getHelpDescriptionAsDict('home')
    waiting_orders = Service.getAllOrder(request.user.trader)
    return render(request, 'market/portfolio.html', locals())
Пример #9
0
def leaderboard(request):
    trader_leaderboard = Service.getLeaderboard()
    return render(request, 'market/leaderboard.html', locals())
Пример #10
0
def dashboard_user(request):
    performance_data = Service.getDataChartPerformance(request.user.trader)
    return render(request, 'market/dashboard_user.html', locals())
Пример #11
0
 def delete(self, request, pk, format=None):
     Order = Service.getOrderById(pk)
     Service.deleteOrder(Order)
     return Response(status=status.HTTP_204_NO_CONTENT)
Пример #12
0
 def get(self, request, pk, format=None):
     Order = Service.getOrderById(pk)
     serializer = OrderSerializer(Order)
     return Response(serializer.data)
Пример #13
0
 def get(self, request, format=None):
     Orders = Service.getAllOrder()
     serializer = OrderSerializer(Orders, many=True)
     return Response(serializer.data)
Пример #14
0
 def delete(self, request, pk, format=None):
     claim = Service.getClaimById(pk)
     Service.deleteClaim(claim)
     return Response(status=status.HTTP_204_NO_CONTENT)
Пример #15
0
 def get(self, request, pk, format=None):
     Claim = Service.getClaimById(pk)
     serializer = ClaimSerializer(Claim)
     return Response(serializer.data)
Пример #16
0
 def get(self, request, format=None):
     claims = Service.getAllClaim()
     serializer = ClaimSerializer(claims, many=True)
     return Response(serializer.data)