[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-bank] branch master updated (8e7202e -> 58127cb)
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-bank] branch master updated (8e7202e -> 58127cb) |
Date: |
Wed, 10 May 2017 16:22:03 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a change to branch master
in repository bank.
from 8e7202e dedicated class for currency mismatch errors
new c23a650 towards removing the 'admin' interface
new 5e18da7 still on removing admin interface
new 33360c4 remove dedicated testcase for admin interface
new 669fff8 fix +n for 'delta'
new 58127cb fix /history test, as moving admin test into the other tests
file altered the way row_ids are defined during the test run.
The 5 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:
Makefile.am | 4 +-
bank-admin.wsgi.in | 21 -----
bank.wsgi.in | 1 -
configure.ac | 1 -
taler-bank-manage.in | 23 ++----
talerbank/app/tests.py | 45 +++++++++-
talerbank/app/tests_admin.py | 64 ---------------
talerbank/app/urls.py | 1 +
talerbank/app/urlsadmin.py | 23 ------
talerbank/app/views.py | 5 +-
talerbank/settings.py | 191 ++++++++++++++++++++++++++++++++++++++++++-
talerbank/settings_admin.py | 2 -
talerbank/settings_base.py | 191 -------------------------------------------
13 files changed, 243 insertions(+), 329 deletions(-)
delete mode 100644 bank-admin.wsgi.in
delete mode 100644 talerbank/app/tests_admin.py
delete mode 100644 talerbank/app/urlsadmin.py
delete mode 100644 talerbank/settings_admin.py
delete mode 100644 talerbank/settings_base.py
diff --git a/Makefile.am b/Makefile.am
index 1d91bac..b1b0d7e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,8 +14,7 @@ pkgcfg_DATA = \
bank.conf
pkgdata_DATA = \
- bank.wsgi \
- bank-admin.wsgi
+ bank.wsgi
# link package under prefix to source tree
install-dev:
@@ -23,7 +22,6 @@ install-dev:
check:
@export DJANGO_SETTINGS_MODULE="talerbank.settings"
TALER_PREFIX="@prefix@" && python3 -m django test talerbank.app.tests
- @export DJANGO_SETTINGS_MODULE="talerbank.settings_admin"
TALER_PREFIX="@prefix@" && python3 -m django test talerbank.app.tests_admin
# install into prefix
install-exec-hook:
diff --git a/bank-admin.wsgi.in b/bank-admin.wsgi.in
deleted file mode 100644
index 94dc5ed..0000000
--- a/bank-admin.wsgi.in
+++ /dev/null
@@ -1,21 +0,0 @@
-import os
-import sys
-import site
-
-if sys.version_info.major < 3:
- print("The taler bank needs to run with Python>=3.4")
- sys.exit(1)
-
-os.environ.setdefault("DJANGO_SETTINGS_MODULE", "talerbank.settings_admin")
-os.environ.setdefault("TALER_PREFIX", "@prefix@")
-site.addsitedir("%s/lib/python%d.%d/site-packages" % (
- "@prefix@",
- sys.version_info.major,
- sys.version_info.minor))
-
-import django
-django.setup()
-
-from django.core.wsgi import get_wsgi_application
-
-application = get_wsgi_application()
diff --git a/bank.wsgi.in b/bank.wsgi.in
index f276b99..c15e645 100644
--- a/bank.wsgi.in
+++ b/bank.wsgi.in
@@ -6,7 +6,6 @@ if sys.version_info.major < 3:
print("The taler bank needs to run with Python>=3.4")
sys.exit(1)
-os.environ.setdefault("DJANGO_SETTINGS_MODULE", "talerbank.settings")
os.environ.setdefault("TALER_PREFIX", "@prefix@")
site.addsitedir("%s/lib/python%d.%d/site-packages" % (
"@prefix@",
diff --git a/configure.ac b/configure.ac
index 92a401b..3082b5c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,7 +76,6 @@ fi
AC_CONFIG_FILES([Makefile
bank.wsgi
- bank-admin.wsgi
taler-bank-manage
talerbank/Makefile
talerbank/app/Makefile
diff --git a/taler-bank-manage.in b/taler-bank-manage.in
index 911782f..01655c8 100644
--- a/taler-bank-manage.in
+++ b/taler-bank-manage.in
@@ -41,7 +41,7 @@ def handle_serve_http(args):
tc = TalerConfig.from_file(os.environ.get("TALER_CONFIG_FILE"))
port = args.port
if port is None:
- port = tc[token]["http_port"].value_int(required=True)
+ port = tc["bank"]["http_port"].value_int(required=True)
httpspec = ":%d" % (port,)
params = ["uwsgi", "uwsgi",
@@ -49,7 +49,7 @@ def handle_serve_http(args):
"--die-on-term",
"--http", httpspec,
"--log-format", uwsgi_logfmt,
- "--wsgi-file", "@prefix@/share/taler-bank/%s.wsgi" % token]
+ "--wsgi-file", "@prefix@/share/taler-bank/bank.wsgi"]
os.execlp(*params)
@@ -66,14 +66,14 @@ def handle_serve_uwsgi(args):
"--master",
"--die-on-term",
"--log-format", uwsgi_logfmt,
- "--wsgi-file", "@prefix@/share/taler-bank/%s.wsgi" % token]
+ "--wsgi-file", "@prefix@/share/taler-bank/%s.wsgi"]
if "tcp" == serve_uwsgi:
- port = tc[token]["uwsgi_port"].value_int(required=True)
+ port = tc["bank"]["uwsgi_port"].value_int(required=True)
spec = ":%d" % (port,)
params.extend(["--socket", spec])
else:
- spec = tc[token]["uwsgi_unixpath"].value_filename(required=True)
- mode = tc[token]["uwsgi_unixpath_mode"].value_filename(required=True)
+ spec = tc["bank"]["uwsgi_unixpath"].value_filename(required=True)
+ mode = tc["bank"]["uwsgi_unixpath_mode"].value_filename(required=True)
params.extend(["--socket", spec])
params.extend(["--chmod-socket="+mode])
os.makedirs(os.path.dirname(spec), exist_ok=True)
@@ -96,7 +96,6 @@ parser = argparse.ArgumentParser()
parser.set_defaults(func=None)
parser.add_argument('--config', '-c', help="configuration file to use",
metavar="CONFIG", type=str, dest="config", default=None)
parser.add_argument('--with-db', help="use ALTERNATE_DB", type=str,
metavar="ALTERNATE_DB", dest="altdb")
-parser.add_argument("--admin", "-a", dest="admin", action="store_true",
help="Only run the \"admin\" interface")
sub = parser.add_subparsers()
p = sub.add_parser('django', help="Run django-admin command")
@@ -119,15 +118,7 @@ p.set_defaults(func=handle_config)
args = parser.parse_args()
-token = "bank%s" % ("-admin" if args.admin else "")
-
-settings_module = "talerbank.settings"
-if token == "bank-admin":
- settings_module = "talerbank.settings_admin"
-
-os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module)
-
-logger.info("Setting token to %s" % token)
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "talerbank.settings")
if args.altdb:
os.environ.setdefault("ALTDB", args.altdb)
diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index 130aba2..2461124 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -18,8 +18,8 @@ from django.test import TestCase, Client
from django.core.urlresolvers import reverse
from django.conf import settings
from django.contrib.auth.models import User
-from .models import BankAccount
-from . import urlsadmin, urls
+from .models import BankAccount, BankTransaction
+from . import urls
from . import amounts
from .views import wire_transfer
import json
@@ -31,6 +31,7 @@ logger = logging.getLogger(__name__)
def clearDb():
User.objects.all().delete()
BankAccount.objects.all().delete()
+ BankTransaction.objects.all().delete()
class RegisterTestCase(TestCase):
@@ -88,6 +89,40 @@ class AmountTestCase(TestCase):
self.assertEqual(1, amounts.amount_cmp(a2, a1))
self.assertEqual(0, amounts.amount_cmp(a1, _a1))
+class AddIncomingTestCase(TestCase):
+ """Test money transfer's API"""
+
+ def setUp(self):
+ bank = User.objects.create_user(username="bank_user",
+ password="bank_password")
+ bank_account = BankAccount(user=bank,
+ currency=settings.TALER_CURRENCY)
+ user = User.objects.create_user(username="user_user",
+ password="user_password")
+ user_account = BankAccount(user=user,
+ currency=settings.TALER_CURRENCY)
+ bank_account.save()
+ user_account.save()
+
+ def tearDown(self):
+ clearDb()
+
+ def test_add_incoming(self):
+ c = Client()
+ data = '{"auth": {"type": "basic"}, \
+ "credit_account": 1, \
+ "wtid": "TESTWTID", \
+ "exchange_url": "https://exchange.test", \
+ "amount": \
+ {"value": 1, \
+ "fraction": 0, \
+ "currency": "%s"}}' \
+ % settings.TALER_CURRENCY
+ response = c.post(reverse("add-incoming", urlconf=urls),
+ data=data,
+ content_type="application/json",
+ follow=True, **{"HTTP_X_TALER_BANK_USERNAME":
"user_user", "HTTP_X_TALER_BANK_PASSWORD": "user_password"})
+ self.assertEqual(200, response.status_code)
class HistoryTestCase(TestCase):
@@ -132,9 +167,11 @@ class HistoryTestCase(TestCase):
data = response.content.decode("utf-8")
data = json.loads(data)
self.assertEqual(data["data"][0]["subject"], "h")
- # Get non-existent record: the latest plus one in the future
- response = c.get(reverse("history", urlconf=urls), {"auth": "basic",
"delta": "+1", "start": "10"},
+ # Get non-existent record: the latest plus one in the future:
transaction "h" takes row_id 11
+ response = c.get(reverse("history", urlconf=urls), {"auth": "basic",
"delta": "1", "start": "11"},
**{"HTTP_X_TALER_BANK_USERNAME": "User",
"HTTP_X_TALER_BANK_PASSWORD": "Password"})
+ response_txt = response.content.decode("utf-8")
+ logger.info(response_txt)
self.assertEqual(204, response.status_code)
# Get credit records
response = c.get(reverse("history", urlconf=urls), {"auth": "basic",
"delta": "+1", "direction": "credit"},
diff --git a/talerbank/app/tests_admin.py b/talerbank/app/tests_admin.py
deleted file mode 100644
index 950fdc2..0000000
--- a/talerbank/app/tests_admin.py
+++ /dev/null
@@ -1,64 +0,0 @@
-# This file is part of TALER
-# (C) 2014, 2015, 2016 INRIA
-#
-# TALER is free software; you can redistribute it and/or modify it under the
-# terms of the GNU Affero General Public License as published by the Free
Software
-# Foundation; either version 3, or (at your option) any later version.
-#
-# TALER is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-#
-# @author Marcello Stanisci
-
-from django.test import TestCase, Client
-from django.core.urlresolvers import reverse
-from django.conf import settings
-from django.contrib.auth.models import User
-from .models import BankAccount
-from . import urlsadmin, urls
-
-import logging
-
-logger = logging.getLogger(__name__)
-
-
-class AddIncomingTestCase(TestCase):
- """Test money transfer's API"""
-
- def setUp(self):
- bank = User.objects.create_user(username="bank_user",
- password="bank_password")
- bank_account = BankAccount(user=bank,
- currency=settings.TALER_CURRENCY)
- user = User.objects.create_user(username="user_user",
- password="user_password")
- user_account = BankAccount(user=user,
- currency=settings.TALER_CURRENCY)
- bank_account.save()
- user_account.save()
-
- def tearDown(self):
- User.objects.all().delete()
- BankAccount.objects.all().delete()
-
- def test_add_incoming(self):
- c = Client()
- data = '{"auth": {"type": "basic"}, \
- "credit_account": 1, \
- "wtid": "TESTWTID", \
- "exchange_url": "https://exchange.test", \
- "amount": \
- {"value": 1, \
- "fraction": 0, \
- "currency": "%s"}}' \
- % settings.TALER_CURRENCY
- response = c.post(reverse("add-incoming", urlconf=urlsadmin),
- data=data,
- content_type="application/json",
- follow=True, **{"HTTP_X_TALER_BANK_USERNAME":
"user_user", "HTTP_X_TALER_BANK_PASSWORD": "user_password"})
- logger.info(response.content.decode("utf-8"))
- self.assertEqual(200, response.status_code)
diff --git a/talerbank/app/urls.py b/talerbank/app/urls.py
index 85aec1c..667366c 100644
--- a/talerbank/app/urls.py
+++ b/talerbank/app/urls.py
@@ -22,6 +22,7 @@ urlpatterns = [
url(r'^', include('talerbank.urls')),
url(r'^$', RedirectView.as_view(pattern_name="profile"), name="index"),
url(r'^favicon\.ico$', views.ignore),
+ url(r'^admin/add/incoming$', views.add_incoming, name="add-incoming"),
url(r'^javascript(?:.html)?/$', views.javascript_licensing,
name="javascript"),
url(r'^login/$', views.login_view, name="login"),
url(r'^logout/$', views.logout_view, name="logout"),
diff --git a/talerbank/app/urlsadmin.py b/talerbank/app/urlsadmin.py
deleted file mode 100644
index e2e51f8..0000000
--- a/talerbank/app/urlsadmin.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# This file is part of TALER
-# (C) 2014, 2015, 2016 INRIA
-#
-# TALER is free software; you can redistribute it and/or modify it under the
-# terms of the GNU Affero General Public License as published by the Free
Software
-# Foundation; either version 3, or (at your option) any later version.
-#
-# TALER is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-#
-# @author Marcello Stanisci
-
-from django.conf.urls import include, url
-from . import views
-
-urlpatterns = [
- url(r'^', include('talerbank.urls')),
- url(r'^admin/add/incoming$', views.add_incoming, name="add-incoming"),
- ]
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index a0be3b4..b6b4095 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -352,13 +352,14 @@ def history(request):
start = int(start)
sign = parsed_delta.group(1)
+
if not start:
sign = "-"
# Assuming Q() means 'true'
sign_filter = Q()
if "-" == sign and start:
sign_filter = Q(id__lt=start)
- elif ("+" == sign or "" == sign) and start:
+ elif ("+" == sign or not sign) and start:
sign_filter = Q(id__gt=start)
sign = ""
# direction (debit/credit)
@@ -421,7 +422,7 @@ def auth_and_login(request):
username = request.META.get("HTTP_X_TALER_BANK_USERNAME")
password = request.META.get("HTTP_X_TALER_BANK_PASSWORD")
- logger.info("Trying to log '%s/%s' in" % (username, password))
+ # logger.info("Trying to log '%s/%s' in" % (username, password))
if not username or not password:
return False
return django.contrib.auth.authenticate(username=username,
diff --git a/talerbank/settings.py b/talerbank/settings.py
index 6542acf..d5e7b63 100644
--- a/talerbank/settings.py
+++ b/talerbank/settings.py
@@ -1,2 +1,191 @@
-from talerbank.settings_base import *
+"""
+Django settings for talerbank.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/1.9/topics/settings/
+
+For the full list of settings and their values, see
+https://docs.djangoproject.com/en/1.9/ref/settings/
+"""
+
+import os
+import logging
+import base64
+from .talerconfig import TalerConfig
+import sys
+import urllib.parse
+
+logger = logging.getLogger(__name__)
+
+logger.info("DJANGO_SETTINGS_MODULE: %s" %
os.environ.get("DJANGO_SETTINGS_MODULE"))
+
+tc = TalerConfig.from_file(os.environ.get("TALER_CONFIG_FILE"))
+
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+# Quick-start development settings - unsuitable for production
+# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
+
+
+SECRET_KEY = os.environ.get("TALER_BANK_SECRET_KEY", None)
+
+if not SECRET_KEY:
+ logging.info("secret key not configured in TALER_BANK_SECRET_KEY env
variable, generating random secret")
+ SECRET_KEY = base64.b64encode(os.urandom(32)).decode('utf-8')
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+ALLOWED_HOSTS = ["*"]
+
+LOGIN_URL = "login"
+
+LOGIN_REDIRECT_URL = "index"
+
+
+# Application definition
+
+INSTALLED_APPS = [
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+ 'talerbank.app'
+]
+
+MIDDLEWARE_CLASSES = [
+ 'django.middleware.security.SecurityMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.common.CommonMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+]
+
+TEMPLATES = [
+ {
+ 'BACKEND': 'django.template.backends.jinja2.Jinja2',
+ 'DIRS': [os.path.join(BASE_DIR, "talerbank/app/static/web-common/"),
+ os.path.join(BASE_DIR, "talerbank/app/templates")],
+ 'OPTIONS': {
+ 'environment': 'talerbank.jinja2.environment',
+ },
+ },
+]
+
+# Disable those, since they don't work with
+# jinja2 anyways.
+TEMPLATE_CONTEXT_PROCESSORS = []
+
+WSGI_APPLICATION = 'talerbank.wsgi.application'
+
+
+# Database
+# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
+
+DATABASES = {}
+
+# parse a database URL, django can't natively do this!
+dbname = tc.value_string("bank", "database", required=True)
+
+if not dbname:
+ raise Exception("'database' option value is missing from config")
+
+logger.info("dbname: %s" % dbname)
+dbconfig = {}
+db_url = urllib.parse.urlparse(dbname)
+
+if db_url.scheme not in ("postgres"):
+ raise Exception("DB '%s' is not supported" % db_url.scheme)
+
+if db_url.scheme == "postgres":
+ dbconfig["ENGINE"] = 'django.db.backends.postgresql_psycopg2'
+ dbconfig["NAME"] = db_url.path.lstrip("/")
+
+if not db_url.netloc:
+ p = urllib.parse.parse_qs(db_url.query)
+ if ("host" not in p) or len(p["host"]) == 0:
+ host = None
+ else:
+ host = p["host"][0]
+else:
+ host = db_url.netloc
+
+if host:
+ dbconfig["HOST"] = host
+
+logger.info("db string '%s'", dbname)
+logger.info("db info '%s'", dbconfig)
+
+DATABASES["default"] = dbconfig
+
+# Password validation
+# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
+
+AUTH_PASSWORD_VALIDATORS = [
+ {
+ 'NAME':
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
+ },
+ {
+ 'NAME':
'django.contrib.auth.password_validation.MinimumLengthValidator',
+ },
+ {
+ 'NAME':
'django.contrib.auth.password_validation.CommonPasswordValidator',
+ },
+ {
+ 'NAME':
'django.contrib.auth.password_validation.NumericPasswordValidator',
+ },
+]
+
+
+# Internationalization
+# https://docs.djangoproject.com/en/1.9/topics/i18n/
+
+LANGUAGE_CODE = 'en-us'
+
+TIME_ZONE = 'UTC'
+
+USE_I18N = True
+
+USE_L10N = True
+
+USE_TZ = True
+
+
+# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/1.9/howto/static-files/
+
+STATIC_URL = '/static/'
+
+STATICFILES_DIRS = [
+ os.path.join(BASE_DIR, "talerbank/app/static"),
+]
+
+# Currently we don't use "collectstatic", so this value isn't used.
+# Instead, we serve static files directly from the installed python package
+# via the "django.contrib.staticfiles" app.
+# We must set it to something valid though, # or django will give us warnings.
+STATIC_ROOT = '/tmp/talerbankstatic/'
+
ROOT_URLCONF = "talerbank.app.urls"
+
+TALER_CURRENCY = tc.value_string("taler", "currency", required=True)
+
+TALER_MAX_DEBT = tc.value_string("bank", "MAX_DEBT",
+ default="50 {}".format(TALER_CURRENCY),
+ required=True)
+
+TALER_MAX_DEBT_BANK = tc.value_string("bank", "MAX_DEBT_BANK",
+ default="0 {}".format(TALER_CURRENCY),
+ required=True)
+TALER_DIGITS = 2
+TALER_PREDEFINED_ACCOUNTS = ['Tor', 'GNUnet', 'Taler', 'FSF', 'Tutorial']
+TALER_EXPECTS_DONATIONS = ['Tor', 'GNUnet', 'Taler', 'FSF']
+TALER_SUGGESTED_EXCHANGE = tc.value_string("bank", "suggested_exchange")
+
+logging.info("currency: '%s'", TALER_CURRENCY)
diff --git a/talerbank/settings_admin.py b/talerbank/settings_admin.py
deleted file mode 100644
index b2ce6a3..0000000
--- a/talerbank/settings_admin.py
+++ /dev/null
@@ -1,2 +0,0 @@
-from talerbank.settings_base import *
-ROOT_URLCONF = "talerbank.app.urlsadmin"
diff --git a/talerbank/settings_base.py b/talerbank/settings_base.py
deleted file mode 100644
index 4371861..0000000
--- a/talerbank/settings_base.py
+++ /dev/null
@@ -1,191 +0,0 @@
-"""
-Django settings for talerbank.
-
-For more information on this file, see
-https://docs.djangoproject.com/en/1.9/topics/settings/
-
-For the full list of settings and their values, see
-https://docs.djangoproject.com/en/1.9/ref/settings/
-"""
-
-import os
-import logging
-import base64
-from .talerconfig import TalerConfig
-import sys
-import urllib.parse
-
-logger = logging.getLogger(__name__)
-
-logger.info("DJANGO_SETTINGS_MODULE: %s" %
os.environ.get("DJANGO_SETTINGS_MODULE"))
-
-tc = TalerConfig.from_file(os.environ.get("TALER_CONFIG_FILE"))
-
-# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
-BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-
-# Quick-start development settings - unsuitable for production
-# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
-
-
-SECRET_KEY = os.environ.get("TALER_BANK_SECRET_KEY", None)
-
-if not SECRET_KEY:
- logging.info("secret key not configured in TALER_BANK_SECRET_KEY env
variable, generating random secret")
- SECRET_KEY = base64.b64encode(os.urandom(32)).decode('utf-8')
-
-# SECURITY WARNING: don't run with debug turned on in production!
-DEBUG = True
-
-ALLOWED_HOSTS = ["*"]
-
-LOGIN_URL = "login"
-
-LOGIN_REDIRECT_URL = "index"
-
-
-# Application definition
-
-INSTALLED_APPS = [
- 'django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- 'talerbank.app'
-]
-
-MIDDLEWARE_CLASSES = [
- 'django.middleware.security.SecurityMiddleware',
- 'django.contrib.sessions.middleware.SessionMiddleware',
- 'django.middleware.common.CommonMiddleware',
- 'django.middleware.csrf.CsrfViewMiddleware',
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
- 'django.contrib.messages.middleware.MessageMiddleware',
- 'django.middleware.clickjacking.XFrameOptionsMiddleware',
-]
-
-TEMPLATES = [
- {
- 'BACKEND': 'django.template.backends.jinja2.Jinja2',
- 'DIRS': [os.path.join(BASE_DIR, "talerbank/app/static/web-common/"),
- os.path.join(BASE_DIR, "talerbank/app/templates")],
- 'OPTIONS': {
- 'environment': 'talerbank.jinja2.environment',
- },
- },
-]
-
-# Disable those, since they don't work with
-# jinja2 anyways.
-TEMPLATE_CONTEXT_PROCESSORS = []
-
-WSGI_APPLICATION = 'talerbank.wsgi.application'
-
-
-# Database
-# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
-
-DATABASES = {}
-
-# parse a database URL, django can't natively do this!
-dbname = tc.value_string("bank", "database", required=True)
-
-if not dbname:
- raise Exception("'database' option value is missing from config")
-
-logger.info("dbname: %s" % dbname)
-dbconfig = {}
-db_url = urllib.parse.urlparse(dbname)
-
-if db_url.scheme not in ("postgres"):
- raise Exception("DB '%s' is not supported" % db_url.scheme)
-
-if db_url.scheme == "postgres":
- dbconfig["ENGINE"] = 'django.db.backends.postgresql_psycopg2'
- dbconfig["NAME"] = db_url.path.lstrip("/")
-
-if not db_url.netloc:
- p = urllib.parse.parse_qs(db_url.query)
- if ("host" not in p) or len(p["host"]) == 0:
- host = None
- else:
- host = p["host"][0]
-else:
- host = db_url.netloc
-
-if host:
- dbconfig["HOST"] = host
-
-logger.info("db string '%s'", dbname)
-logger.info("db info '%s'", dbconfig)
-
-DATABASES["default"] = dbconfig
-
-# Password validation
-# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
-
-AUTH_PASSWORD_VALIDATORS = [
- {
- 'NAME':
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
- },
- {
- 'NAME':
'django.contrib.auth.password_validation.MinimumLengthValidator',
- },
- {
- 'NAME':
'django.contrib.auth.password_validation.CommonPasswordValidator',
- },
- {
- 'NAME':
'django.contrib.auth.password_validation.NumericPasswordValidator',
- },
-]
-
-
-# Internationalization
-# https://docs.djangoproject.com/en/1.9/topics/i18n/
-
-LANGUAGE_CODE = 'en-us'
-
-TIME_ZONE = 'UTC'
-
-USE_I18N = True
-
-USE_L10N = True
-
-USE_TZ = True
-
-
-# Static files (CSS, JavaScript, Images)
-# https://docs.djangoproject.com/en/1.9/howto/static-files/
-
-STATIC_URL = '/static/'
-
-STATICFILES_DIRS = [
- os.path.join(BASE_DIR, "talerbank/app/static"),
-]
-
-# Currently we don't use "collectstatic", so this value isn't used.
-# Instead, we serve static files directly from the installed python package
-# via the "django.contrib.staticfiles" app.
-# We must set it to something valid though, # or django will give us warnings.
-STATIC_ROOT = '/tmp/talerbankstatic/'
-
-
-
-TALER_CURRENCY = tc.value_string("taler", "currency", required=True)
-
-TALER_MAX_DEBT = tc.value_string("bank", "MAX_DEBT",
- default="50 {}".format(TALER_CURRENCY),
- required=True)
-
-TALER_MAX_DEBT_BANK = tc.value_string("bank", "MAX_DEBT_BANK",
- default="0 {}".format(TALER_CURRENCY),
- required=True)
-TALER_DIGITS = 2
-TALER_PREDEFINED_ACCOUNTS = ['Tor', 'GNUnet', 'Taler', 'FSF', 'Tutorial']
-TALER_EXPECTS_DONATIONS = ['Tor', 'GNUnet', 'Taler', 'FSF']
-TALER_SUGGESTED_EXCHANGE = tc.value_string("bank", "suggested_exchange")
-
-logging.info("currency: '%s'", TALER_CURRENCY)
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [taler-bank] branch master updated (8e7202e -> 58127cb),
gnunet <=
- [GNUnet-SVN] [taler-bank] 04/05: fix +n for 'delta', gnunet, 2017/05/10
- [GNUnet-SVN] [taler-bank] 05/05: fix /history test, as moving admin test into the other tests file altered the way row_ids are defined during the test run., gnunet, 2017/05/10
- [GNUnet-SVN] [taler-bank] 03/05: remove dedicated testcase for admin interface, gnunet, 2017/05/10
- [GNUnet-SVN] [taler-bank] 02/05: still on removing admin interface, gnunet, 2017/05/10
- [GNUnet-SVN] [taler-bank] 01/05: towards removing the 'admin' interface, gnunet, 2017/05/10