Commit cee26c47 authored by Patrick Colmant's avatar Patrick Colmant Committed by GitHub

Merge pull request #8 from tobald/sqlite

add sqlite db backend
parents 308a5ccd f4bc1466
**/__pycache__
*.pyc
*.sqlite
venv
cache
.ropeproject
......@@ -46,53 +46,66 @@ MEDIA_URL = "%s%s%s" % (os.sep, "media", os.sep)
STATIC_ROOT = os.path.join(PROJECT_DIR, "collect-static")
DJANGO_SETTINGS_SITE_NAME = os.path.split(PROJECT_DIR)[-1]
DJANGO_SETTINGS_DATABASE_ENGINE = 'django.db.backends.postgresql_psycopg2'
config = configparser.RawConfigParser(allow_no_value=True)
conf_file_name = '%s%s%s.ini' % (
PROJECT_DIR,
os.sep,
DJANGO_SETTINGS_SITE_NAME
)
try:
# Open the file with the correct encoding
with codecs.open(conf_file_name, 'r', encoding='utf-8') as f:
config.readfp(f)
DJANGO_SETTINGS_ADMIN_EMAIL = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_ADMIN_EMAIL')
DJANGO_SETTINGS_ADMIN_NAME = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_ADMIN_NAME')
DJANGO_SETTINGS_DATABASE_HOST = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_DATABASE_HOST')
DJANGO_SETTINGS_DATABASE_NAME = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_DATABASE_NAME')
DJANGO_SETTINGS_DATABASE_PASSWORD = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_DATABASE_PASSWORD')
DJANGO_SETTINGS_DATABASE_PORT = config.getint('DJANGO_SETTINGS', 'DJANGO_SETTINGS_DATABASE_PORT')
DJANGO_SETTINGS_DATABASE_USER = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_DATABASE_USER')
DJANGO_SETTINGS_DEBUG = config.getboolean('DJANGO_SETTINGS', 'DJANGO_SETTINGS_DEBUG')
DJANGO_SETTINGS_DEMO = config.getboolean('DJANGO_SETTINGS', 'DJANGO_SETTINGS_DEMO')
DJANGO_SETTINGS_EMAIL_HOST = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_EMAIL_HOST')
DJANGO_SETTINGS_EMAIL_HOST_PASSWORD = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_EMAIL_HOST_PASSWORD')
DJANGO_SETTINGS_EMAIL_HOST_USER = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_EMAIL_HOST_USER')
DJANGO_SETTINGS_EMAIL_PORT = config.getint('DJANGO_SETTINGS', 'DJANGO_SETTINGS_EMAIL_PORT')
DJANGO_SETTINGS_EMAIL_USE_SSL = config.getboolean('DJANGO_SETTINGS', 'DJANGO_SETTINGS_EMAIL_USE_TLS')
DJANGO_SETTINGS_EMAIL_USE_TLS = config.getboolean('DJANGO_SETTINGS', 'DJANGO_SETTINGS_EMAIL_USE_TLS')
DJANGO_SETTINGS_ENV = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_ENV')
DJANGO_SETTINGS_LANGUAGE = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_LANGUAGE')
DJANGO_SETTINGS_LOGGING = config.getboolean('DJANGO_SETTINGS', 'DJANGO_SETTINGS_LOGGING')
DJANGO_SETTINGS_CACHE = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_CACHE')
DJANGO_SETTINGS_SESSION = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_SESSION')
DJANGO_SETTINGS_COUNTRY = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_COUNTRY')
DJANGO_SETTINGS_IS_MINIMALIST = config.getboolean('DJANGO_SETTINGS', 'DJANGO_SETTINGS_IS_MINIMALIST')
DJANGO_STATIC = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_STATIC')
DJANGO_SETTINGS_ALLOWED_HOSTS = []
for name in config.options('ALLOWED_HOSTS'):
allowed_host = config.get('ALLOWED_HOSTS', name)
if allowed_host.startswith("demo"):
DJANGO_SETTINGS_DEMO = True
DJANGO_SETTINGS_ALLOWED_HOSTS.append(allowed_host)
logging.info("Settings loaded from %s" % (conf_file_name,))
print ("Settings loaded from %s" % (conf_file_name,))
print(DJANGO_SETTINGS_ALLOWED_HOSTS)
DJANGO_SETTINGS_ALLOWED_MAIL_EXTENSION = get_allowed_mail_extension()
except IOError:
logging.exception("Unable to open %s settings" % (conf_file_name,))
print ("Unable to open %s settings" % (conf_file_name,))
raise SystemExit(-1)
OPTIONS = ('DJANGO_SETTINGS_ADMIN_EMAIL',
'DJANGO_SETTINGS_ADMIN_NAME',
'DJANGO_SETTINGS_DATABASE_ENGINE',
'DJANGO_SETTINGS_DATABASE_HOST',
'DJANGO_SETTINGS_DATABASE_NAME',
'DJANGO_SETTINGS_DATABASE_PASSWORD',
'DJANGO_SETTINGS_DATABASE_PORT',
'DJANGO_SETTINGS_DATABASE_USER',
'DJANGO_SETTINGS_DEBUG',
'DJANGO_SETTINGS_DEMO',
'DJANGO_SETTINGS_EMAIL_HOST',
'DJANGO_SETTINGS_EMAIL_HOST_PASSWORD',
'DJANGO_SETTINGS_EMAIL_HOST_USER',
'DJANGO_SETTINGS_EMAIL_PORT',
'DJANGO_SETTINGS_EMAIL_USE_SSL',
'DJANGO_SETTINGS_EMAIL_USE_TLS',
'DJANGO_SETTINGS_ENV',
'DJANGO_SETTINGS_LANGUAGE',
'DJANGO_SETTINGS_LOGGING',
'DJANGO_SETTINGS_CACHE',
'DJANGO_SETTINGS_SESSION',
'DJANGO_SETTINGS_COUNTRY',
'DJANGO_SETTINGS_IS_MINIMALIST')
for OPTION in OPTIONS:
try:
globals()[OPTION] = config.get('DJANGO_SETTINGS', OPTION)
except configparser.NoOptionError:
pass
DJANGO_STATIC = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_STATIC')
DJANGO_SETTINGS_ALLOWED_HOSTS = []
for name in config.options('ALLOWED_HOSTS'):
allowed_host = config.get('ALLOWED_HOSTS', name)
if allowed_host.startswith("demo"):
DJANGO_SETTINGS_DEMO = True
DJANGO_SETTINGS_ALLOWED_HOSTS.append(allowed_host)
logging.info("Settings loaded from %s" % (conf_file_name,))
print ("Settings loaded from %s" % (conf_file_name,))
print(DJANGO_SETTINGS_ALLOWED_HOSTS)
DJANGO_SETTINGS_ALLOWED_MAIL_EXTENSION = get_allowed_mail_extension()
DJANGO_SETTINGS_DATE = "%d-%m-%Y"
DJANGO_SETTINGS_DATETIME = "%d-%m-%Y %H:%M"
......@@ -105,6 +118,10 @@ else:
# Be carefull from CMS 4.3.2 you must patch ManifestStaticFilesStorage
# STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
STATICFILES_STORAGE = 'repanier.big_blind_static.BigBlindManifestStaticFilesStorage'
if DJANGO_SETTINGS_SITE_NAME == 'mysite':
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
# STATICFILES_DIRS = (
# os.path.join(PROJECT_PATH, "repanier", "static"),
# )
......@@ -126,7 +143,7 @@ SERVER_EMAIL = "%s%s" % (DJANGO_SETTINGS_ADMIN_NAME, DJANGO_SETTINGS_ALLOWED_MAI
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'ENGINE': DJANGO_SETTINGS_DATABASE_ENGINE,
'NAME': DJANGO_SETTINGS_DATABASE_NAME, # Or path to database file if using sqlite3.
'USER': DJANGO_SETTINGS_DATABASE_USER,
'PASSWORD': DJANGO_SETTINGS_DATABASE_PASSWORD,
......
......@@ -2,8 +2,9 @@
; test settings for repanier
DJANGO_SETTINGS_ADMIN_EMAIL=admin@locahost
DJANGO_SETTINGS_ADMIN_NAME=admin
DJANGO_SETTINGS_DATABASE_ENGINE=django.db.backends.sqlite3
DJANGO_SETTINGS_DATABASE_HOST=default
DJANGO_SETTINGS_DATABASE_NAME=db.sqlite3
DJANGO_SETTINGS_DATABASE_NAME=db.sqlite
DJANGO_SETTINGS_DATABASE_PASSWORD=
DJANGO_SETTINGS_DATABASE_PORT=0
DJANGO_SETTINGS_DATABASE_USER=
......@@ -18,10 +19,12 @@ DJANGO_SETTINGS_EMAIL_USE_TLS=False
DJANGO_SETTINGS_ENV=dev
DJANGO_SETTINGS_LANGUAGE=Fr
DJANGO_SETTINGS_LOGGING=True
DJANGO_SETTINGS_CACHE=True
DJANGO_SETTINGS_CACHE=cache
DJANGO_SETTINGS_SESSION=
DJANGO_SETTINGS_COUNTRY=Be
DJANGO_SETTINGS_STATIC=/tmp
DJANGO_SETTINGS_IS_MINIMALIST=False
[ALLOWED_HOSTS]
localhost=localhost
localhost1=127.0.0.1
"""
WSGI config for flyers project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
......@@ -8,8 +8,8 @@ from django.db.models import F, Q
from django.utils import translation
from django.utils.translation import ugettext_lazy as _
from const import DECIMAL_ZERO, DECIMAL_ONE, DECIMAL_THREE
from models import Customer, Staff, Configuration
from repanier.const import DECIMAL_ZERO, DECIMAL_ONE, DECIMAL_THREE
from repanier.models import Customer, Staff, Configuration
class RepanierCustomBackend(ModelBackend):
......
......@@ -9,7 +9,7 @@ from openpyxl.style import NumberFormat
from openpyxl.styles import Border
from openpyxl.workbook import Workbook
from const import *
from .const import *
from repanier.const import EMPTY_STRING
from repanier.models.staff import Staff
from repanier.tools import cap
......
......@@ -7,7 +7,7 @@ from django.utils.translation import ugettext_lazy as _
from openpyxl import load_workbook
import repanier.apps
from export_tools import *
from repanier.xlsx.export_tools import *
from repanier.const import *
from repanier.models import Configuration
from repanier.models import CustomerInvoice
......
......@@ -5,7 +5,7 @@ from django.http import HttpResponse
from django.utils.translation import ugettext_lazy as _
import repanier.apps
from export_tools import *
from repanier.xlsx.export_tools import *
from repanier.models.producer import Producer
from repanier.models.offeritem import OfferItem
from repanier.models.product import Product
......
......@@ -7,7 +7,7 @@ from openpyxl.style import Fill
from openpyxl.styles import Color
import repanier.apps
from export_tools import *
from repanier.xlsx.export_tools import *
from repanier.const import *
from repanier.models.configuration import Configuration
from repanier.models.customer import Customer
......@@ -20,7 +20,7 @@ from repanier.models.producer import Producer
from repanier.models.purchase import Purchase
from repanier.models.staff import Staff
from repanier.tools import get_base_unit, next_row
from xlsx_stock import export_permanence_stock
from .xlsx_stock import export_permanence_stock
def next_purchase(purchases):
......
......@@ -6,7 +6,7 @@ from django.utils import timezone
from django.utils import translation
from django.utils.translation import ugettext_lazy as _
from export_tools import *
from repanier.xlsx.export_tools import *
from repanier.const import *
from repanier.models.product import Product
from repanier.tools import next_row
......
......@@ -8,8 +8,8 @@ from openpyxl import load_workbook
from openpyxl.style import Fill
from openpyxl.styles import Color
from export_tools import *
from import_tools import *
from repanier.xlsx.export_tools import *
from repanier.xlsx.import_tools import *
from repanier.apps import REPANIER_SETTINGS_CURRENCY_XLSX
from repanier.const import *
from repanier.models.offeritem import OfferItem
......
......@@ -10,7 +10,7 @@ from openpyxl.style import Fill
from openpyxl.styles import Color
import repanier.apps
from export_tools import *
from repanier.xlsx.export_tools import *
from repanier.const import *
from repanier.models.offeritem import OfferItem
from repanier.models.product import Product
......
......@@ -33,3 +33,4 @@ easy-thumbnails==2.4.1
openpyxl==1.8.6
psycopg2==2.7.1
uwsgi
tablib==0.10
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment