diff --git a/Procfile b/Procfile new file mode 100644 index 00000000..e6088524 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn PyRIGS.wsgi --log-file - diff --git a/PyRIGS/settings.py b/PyRIGS/settings.py index d1aa118a..1f0c8cad 100644 --- a/PyRIGS/settings.py +++ b/PyRIGS/settings.py @@ -12,6 +12,8 @@ https://docs.djangoproject.com/en/1.7/ref/settings/ import os BASE_DIR = os.path.dirname(os.path.dirname(__file__)) +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') + # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ @@ -19,13 +21,13 @@ BASE_DIR = os.path.dirname(os.path.dirname(__file__)) SECRET_KEY = 'gxhy(a#5mhp289_=6xx$7jh=eh$ymxg^ymc+di*0c*geiu3p_e' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False TEMPLATE_DEBUG = True ALLOWED_HOSTS = ['*'] -INTERNAL_IPS = ['127.0.0.1', '10.20.30.20'] +INTERNAL_IPS = ['127.0.0.1'] # Application definition @@ -82,6 +84,44 @@ DATABASES = { } } +if not DEBUG: + import dj_database_url + DATABASES['default'] = dj_database_url.config() + +# Logging +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { + 'verbose': { + 'format': ('%(asctime)s [%(process)d] [%(levelname)s] ' + + 'pathname=%(pathname)s lineno=%(lineno)s ' + + 'funcname=%(funcName)s %(message)s'), + 'datefmt': '%Y-%m-%d %H:%M:%S' + }, + 'simple': { + 'format': '%(levelname)s %(message)s' + } + }, + 'handlers': { + 'null': { + 'level': 'DEBUG', + 'class': 'logging.NullHandler', + }, + 'console': { + 'level': 'DEBUG', + 'class': 'logging.StreamHandler', + 'formatter': 'verbose' + } + }, + 'loggers': { + 'RIGS': { + 'handlers': ['console'], + 'level': 'INFO', + } + } +} + # User system AUTH_USER_MODEL = 'RIGS.Profile' @@ -95,11 +135,13 @@ ACCOUNT_ACTIVATION_DAYS = 7 EMAILER_TEST = False if not DEBUG or EMAILER_TEST: EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' - EMAIL_HOST = 'server.techost.co.uk' + EMAIL_HOST = 'mail.nottinghamtec.co.uk' EMAIL_PORT = 465 - EMAIL_HOST_USER = 'tec' - EMAIL_HOST_PASSWORD = '***REMOVED***' - DEFAULT_FROM_EMAIL = 'rigs@nottinghamtec.co.uk' + EMAIL_HOST_USER = 'pyrigs@nottinghamtec.co.uk' + EMAIL_HOST_PASSWORD = 'N_dF9T&dD(Th' + EMAIL_USE_TLS = False + EMAIL_USE_SSL = True + DEFAULT_FROM_EMAIL = 'pyrigs@nottinghamtec.co.uk' else: EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' diff --git a/PyRIGS/wsgi.py b/PyRIGS/wsgi.py index ae436d87..07f922a1 100644 --- a/PyRIGS/wsgi.py +++ b/PyRIGS/wsgi.py @@ -6,9 +6,10 @@ 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.7/howto/deployment/wsgi/ """ - import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "PyRIGS.settings") from django.core.wsgi import get_wsgi_application -application = get_wsgi_application() +from dj_static import Cling + +application = Cling(get_wsgi_application()) diff --git a/RIGS/migrations/0022_auto_20150424_2104.py b/RIGS/migrations/0022_auto_20150424_2104.py new file mode 100644 index 00000000..cdc3abe0 --- /dev/null +++ b/RIGS/migrations/0022_auto_20150424_2104.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('RIGS', '0021_auto_20150420_1155'), + ] + + operations = [ + migrations.AlterField( + model_name='event', + name='collector', + field=models.CharField(max_length=255, null=True, verbose_name=b'Collected by', blank=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='event', + name='purchase_order', + field=models.CharField(max_length=255, null=True, verbose_name=b'PO', blank=True), + preserve_default=True, + ), + ] diff --git a/RIGS/urls.py b/RIGS/urls.py index 9862ee72..dfe725c2 100644 --- a/RIGS/urls.py +++ b/RIGS/urls.py @@ -57,7 +57,7 @@ urlpatterns = patterns('', name='venue_update'), # Rigboard - url(r'^rigboard/$', rigboard.RigboardIndex.as_view(), name='rigboard'), + url(r'^rigboard/$', login_required(rigboard.RigboardIndex.as_view()), name='rigboard'), url(r'^rigboard/calendar/$', login_required()(rigboard.WebCalendar.as_view()), name='web_calendar'), url(r'^rigboard/archive/$', RedirectView.as_view(pattern_name='event_archive')), diff --git a/importer.py b/importer.py index 4362e203..c7f3c9e0 100644 --- a/importer.py +++ b/importer.py @@ -345,6 +345,7 @@ def main(): # [x.start() for x in processs] # # Wait for all processs to finish # [x.join() for x in processs] + import_users() import_people(True) import_organisations(True) @@ -354,8 +355,18 @@ def main(): import_rigs(True) import_eventitem(True) import_invoices(True) + + # Do this before doing non rigs else it gets ugly + sql = "SELECT setval(\'\"RIGS_%s_id_seq\"\', (SELECT MAX(id) FROM \"RIGS_%s\"));" % ('event', 'event') + cursor = connections['default'].cursor() + cursor.execute(sql) import_nonrigs(False) + sequences = ['profile', 'person', 'organisation', 'vatrate', 'venue', 'event', 'eventitem', 'invoice', 'payment'] + for seq in sequences: + sql = "SELECT setval(\'\"RIGS_%s_id_seq\"\', (SELECT MAX(id) FROM \"RIGS_%s\"));" % (seq, seq) + cursor = connections['default'].cursor() + cursor.execute(sql) if __name__ == "__main__": main()