mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
VAT validation: Move cache to data directory
This commit is contained in:
@@ -20,11 +20,13 @@
|
|||||||
# <https://www.gnu.org/licenses/>.
|
# <https://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
from urllib.error import HTTPError
|
from urllib.error import HTTPError
|
||||||
|
|
||||||
import vat_moss.errors
|
import vat_moss.errors
|
||||||
import vat_moss.id
|
import vat_moss.id
|
||||||
|
from django.conf import settings
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from zeep import Client, Transport
|
from zeep import Client, Transport
|
||||||
from zeep.cache import SqliteCache
|
from zeep.cache import SqliteCache
|
||||||
@@ -83,7 +85,7 @@ def _validate_vat_id_CH(vat_id, country_code):
|
|||||||
|
|
||||||
vat_id = re.sub('[^A-Z0-9]', '', vat_id.replace('HR', '').replace('MWST', ''))
|
vat_id = re.sub('[^A-Z0-9]', '', vat_id.replace('HR', '').replace('MWST', ''))
|
||||||
try:
|
try:
|
||||||
transport = Transport(cache=SqliteCache())
|
transport = Transport(cache=SqliteCache(os.path.join(settings.CACHE_DIR, "validate_vat_id_ch_zeep_cache.db")))
|
||||||
client = Client(
|
client = Client(
|
||||||
'https://www.uid-wse-a.admin.ch/V5.0/PublicServices.svc?wsdl',
|
'https://www.uid-wse-a.admin.ch/V5.0/PublicServices.svc?wsdl',
|
||||||
transport=transport
|
transport=transport
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ DATA_DIR = config.get('pretix', 'datadir', fallback=os.environ.get('DATA_DIR', '
|
|||||||
LOG_DIR = os.path.join(DATA_DIR, 'logs')
|
LOG_DIR = os.path.join(DATA_DIR, 'logs')
|
||||||
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
||||||
PROFILE_DIR = os.path.join(DATA_DIR, 'profiles')
|
PROFILE_DIR = os.path.join(DATA_DIR, 'profiles')
|
||||||
|
CACHE_DIR = os.path.join(DATA_DIR, 'cache')
|
||||||
|
|
||||||
if not os.path.exists(DATA_DIR):
|
if not os.path.exists(DATA_DIR):
|
||||||
os.mkdir(DATA_DIR)
|
os.mkdir(DATA_DIR)
|
||||||
@@ -74,6 +75,8 @@ if not os.path.exists(LOG_DIR):
|
|||||||
os.mkdir(LOG_DIR)
|
os.mkdir(LOG_DIR)
|
||||||
if not os.path.exists(MEDIA_ROOT):
|
if not os.path.exists(MEDIA_ROOT):
|
||||||
os.mkdir(MEDIA_ROOT)
|
os.mkdir(MEDIA_ROOT)
|
||||||
|
if not os.path.exists(CACHE_DIR):
|
||||||
|
os.mkdir(CACHE_DIR)
|
||||||
|
|
||||||
if config.has_option('django', 'secret'):
|
if config.has_option('django', 'secret'):
|
||||||
SECRET_KEY = config.get('django', 'secret')
|
SECRET_KEY = config.get('django', 'secret')
|
||||||
|
|||||||
Reference in New Issue
Block a user