forked from PolyLAN/polybanking
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of ssh://dit.polylan.ch:1025/agepoly/polybanking
- Loading branch information
Showing
6 changed files
with
60 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,67 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from django.shortcuts import get_object_or_404, render_to_response, redirect | ||
from django.template import RequestContext | ||
from django.core.context_processors import csrf | ||
from django.shortcuts import get_object_or_404 | ||
from django.views.decorators.csrf import csrf_exempt | ||
from django.http import Http404, HttpResponse, HttpResponseForbidden, HttpResponseNotFound | ||
from django.utils.encoding import smart_str | ||
from django.conf import settings | ||
from django.contrib.admin.views.decorators import staff_member_required | ||
from django.contrib.auth.decorators import login_required, user_passes_test | ||
from django.http import HttpResponseRedirect | ||
from django.db import connections | ||
from django.core.paginator import InvalidPage, EmptyPage, Paginator | ||
from django.core.cache import cache | ||
from django.core.urlresolvers import reverse | ||
from django.contrib import messages | ||
from django.http import HttpResponse | ||
from django.views.decorators import require_GET | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
|
||
import json | ||
|
||
|
||
from configs.models import Config | ||
from paiements.models import Transaction, TransactionLog | ||
from paiements.models import Transaction | ||
|
||
|
||
@csrf_exempt | ||
@require_GET | ||
def transactions_list(request): | ||
"""Return the list of transaction""" | ||
config_pk = request.GET.get('config_id', -1) | ||
secret = request.GET.get('secret', '#') | ||
|
||
config = get_object_or_404(Config, pk=request.POST.get('config_id', -1), key_api=request.POST.get('secret', '#')) | ||
|
||
max_transaction = int(request.POST.get('max_transaction', '100')) | ||
config = get_object_or_404(Config, pk=config_pk, key_api=secret) | ||
try: | ||
max_transaction = int(request.GET['max_transaction']) | ||
except (ValueError, KeyError): | ||
max_transaction = 100 | ||
|
||
retour = [] | ||
|
||
for transaction in config.transaction_set.order_by('-creation_date').all()[:max_transaction]: | ||
for transaction in config.transaction_set.order_by('-creation_date')[:max_transaction]: | ||
retour.append({'reference': transaction.reference}) | ||
|
||
return HttpResponse(json.dumps({'result': 'ok', 'data': retour})) | ||
|
||
|
||
@csrf_exempt | ||
@require_GET | ||
def transactions_show(request, reference): | ||
"""Return details of a transaction""" | ||
config_pk = request.GET.get('config_id', -1) | ||
secret = request.GET.get('secret', '#') | ||
|
||
config = get_object_or_404(Config, pk=request.POST.get('config_id', -1), key_api=request.POST.get('secret', '#')) | ||
config = get_object_or_404(Config, pk=config_pk, key_api=secret) | ||
|
||
transaction = get_object_or_404(Transaction, config=config, reference=reference) | ||
|
||
return HttpResponse(json.dumps({'result': 'ok', 'data': transaction.dump_api()})) | ||
|
||
|
||
@csrf_exempt | ||
@require_GET | ||
def transactions_show_logs(request, reference): | ||
"""Return logs of a transaction""" | ||
config_pk = request.GET.get('config_id', -1) | ||
secret = request.GET.get('secret', '#') | ||
|
||
config = get_object_or_404(Config, pk=request.POST.get('config_id', -1), key_api=request.POST.get('secret', '#')) | ||
config = get_object_or_404(Config, pk=config_pk, key_api=secret) | ||
|
||
transaction = get_object_or_404(Transaction, config=config, reference=reference) | ||
|
||
retour = [] | ||
|
||
for log in transaction.transactionlog_set.order_by('-when').all(): | ||
for log in transaction.transactionlog_set.order_by('-when'): | ||
retour.append(log.dump_api()) | ||
|
||
return HttpResponse(json.dumps({'result': 'ok', 'data': retour})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters