gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-bank] branch master updated (51fe2d3 -> 6e82367)


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] branch master updated (51fe2d3 -> 6e82367)
Date: Thu, 07 Dec 2017 17:35:40 +0100

This is an automated email from the git hooks/post-receive script.

marcello pushed a change to branch master
in repository bank.

    from 51fe2d3  make 'both' 'direction' exist
     new 45f614c  associate a 'cancelled' flag with transactions
     new 6e82367  make 'cancel+/-' /history args exist

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ...0_1642.py => 0010_banktransaction_cancelled.py} | 10 +++++-----
 talerbank/app/models.py                            |  4 ++--
 talerbank/app/tests.py                             |  2 ++
 talerbank/app/views.py                             | 23 ++++++++++++----------
 4 files changed, 22 insertions(+), 17 deletions(-)
 copy talerbank/app/migrations/{0009_auto_20171120_1642.py => 
0010_banktransaction_cancelled.py} (53%)

diff --git a/talerbank/app/migrations/0009_auto_20171120_1642.py 
b/talerbank/app/migrations/0010_banktransaction_cancelled.py
similarity index 53%
copy from talerbank/app/migrations/0009_auto_20171120_1642.py
copy to talerbank/app/migrations/0010_banktransaction_cancelled.py
index 590fb93..ee46222 100644
--- a/talerbank/app/migrations/0009_auto_20171120_1642.py
+++ b/talerbank/app/migrations/0010_banktransaction_cancelled.py
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Generated by Django 1.10.3 on 2017-11-20 16:42
+# Generated by Django 1.10.3 on 2017-12-07 16:11
 from __future__ import unicode_literals
 
 from django.db import migrations, models
@@ -8,13 +8,13 @@ from django.db import migrations, models
 class Migration(migrations.Migration):
 
     dependencies = [
-        ('app', '0008_auto_20171031_0938'),
+        ('app', '0009_auto_20171120_1642'),
     ]
 
     operations = [
-        migrations.AlterField(
+        migrations.AddField(
             model_name='banktransaction',
-            name='date',
-            field=models.DateTimeField(auto_now=True, db_index=True),
+            name='cancelled',
+            field=models.BooleanField(default=False),
         ),
     ]
diff --git a/talerbank/app/models.py b/talerbank/app/models.py
index b0d0ca4..f8c5c47 100644
--- a/talerbank/app/models.py
+++ b/talerbank/app/models.py
@@ -78,5 +78,5 @@ class BankTransaction(models.Model):
                                        db_index=True,
                                        related_name="credit_account")
     subject = models.CharField(default="(no subject given)", max_length=200)
-    date = models.DateTimeField(auto_now=True,
-                                db_index=True)
+    date = models.DateTimeField(auto_now=True, db_index=True)
+    cancelled = models.BooleanField(default=False)
diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index b69fa4e..b19ceb0 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -315,6 +315,8 @@ class HistoryTestCase(TestCase):
                     HistoryContext(expected_resp={"status": 204},
                                    delta="1", start="11", direction="both"),
                     HistoryContext(expected_resp={"status": 204},
+                                   delta="+1", direction="cancel+"),
+                    HistoryContext(expected_resp={"status": 204},
                                    delta="+1", direction="credit"),
                     HistoryContext(expected_resp={"status": 200},
                                    delta="+1", direction="debit")):
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index bb8ed18..846458a 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -383,18 +383,21 @@ def serve_history(request, user_account):
         if sign == "-":
             sign_filter = Q(id__lt=start)
 
-    # assume 'both' is given
-    direction = request.GET.get("direction")
-
-    query_string = Q(debit_account=user_account.bankaccount) \
-                   | Q(credit_account=user_account.bankaccount)
+    direction_switch = {
+        "both": Q(debit_account=user_account.bankaccount) \
+                | Q(credit_account=user_account.bankaccount),
+        "credit": Q(credit_account=user_account.bankaccount),
+        "debit": Q(debit_account=user_account.bankaccount),
+        "cancel+": Q(credit_account=user_account.bankaccount) \
+                      & Q(cancelled=True),
+        "cancel-": Q(debit_account=user_account.bankaccount) \
+                      & Q(cancelled=True)
+    }
+    # Sanity checks are done at the beginning, so 'direction' key
+    # (and its value as switch's key) does exist here.
+    query_string = direction_switch[request.GET["direction"]]
     history = []
 
-    if direction == "credit":
-        query_string = Q(credit_account=user_account.bankaccount)
-    if direction == "debit":
-        query_string = Q(debit_account=user_account.bankaccount)
-
     qs = BankTransaction.objects.filter(
         query_string, sign_filter).order_by(
             "-id" if sign == "-" else "id")[:int(parsed_delta.group(2))]

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]