diff --git a/PyRIGS/.slugignore b/PyRIGS/.slugignore new file mode 100644 index 00000000..1ef75e23 --- /dev/null +++ b/PyRIGS/.slugignore @@ -0,0 +1,4 @@ +*.sqlite3 +*.scss +*.md +*.rb \ No newline at end of file diff --git a/PyRIGS/settings.py b/PyRIGS/settings.py index 1f0c8cad..8345160c 100644 --- a/PyRIGS/settings.py +++ b/PyRIGS/settings.py @@ -18,17 +18,21 @@ SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'gxhy(a#5mhp289_=6xx$7jh=eh$ymxg^ymc+di*0c*geiu3p_e' +SECRET_KEY = os.environ.get('SECRET_KEY') if os.environ.get('SECRET_KEY') else 'gxhy(a#5mhp289_=6xx$7jh=eh$ymxg^ymc+di*0c*geiu3p_e' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False +DEBUG = bool(int(os.environ.get('DEBUG'))) if os.environ.get('DEBUG') else True TEMPLATE_DEBUG = True -ALLOWED_HOSTS = ['*'] +ALLOWED_HOSTS = ['pyrigs.nottinghamtec.co.uk', 'rigs.nottinghamtec.co.uk', 'pyrigs.herokuapp.com'] INTERNAL_IPS = ['127.0.0.1'] +ADMINS = ( + ('Tom Price', 'tomtom5152@gmail.com') +) + # Application definition @@ -44,6 +48,7 @@ INSTALLED_APPS = ( 'debug_toolbar', 'registration', 'reversion', + 'captcha', 'widget_tweaks', ) @@ -112,13 +117,27 @@ LOGGING = { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'verbose' - } + }, + 'mail_admins': { + 'class': 'django.utils.log.AdminEmailHandler', + 'level': 'ERROR', + # But the emails are plain text by default - HTML is nicer + 'include_html': True, + }, }, 'loggers': { - 'RIGS': { + # Again, default Django configuration to email unhandled exceptions + 'django.request': { + 'handlers': ['mail_admins'], + 'level': 'ERROR', + 'propagate': True, + }, + # Might as well log any errors anywhere else in Django + 'django': { 'handlers': ['console'], - 'level': 'INFO', - } + 'level': 'ERROR', + 'propagate': False, + }, } } @@ -131,6 +150,11 @@ LOGOUT_URL = '/user/logout' ACCOUNT_ACTIVATION_DAYS = 7 +# reCAPTCHA settings +RECAPTCHA_PUBLIC_KEY = '6Le16gUTAAAAAO5f-6te_x0NjWmF65_h7saBI6Cg' +RECAPTCHA_PRIVATE_KEY = '6Le16gUTAAAAAByo-ZxRRX3RKyoBngf7ms3dnoEW' +NOCAPTCHA = True + # Email EMAILER_TEST = False if not DEBUG or EMAILER_TEST: @@ -187,4 +211,4 @@ TEMPLATE_DIRS = ( USE_GRAVATAR=True -TERMS_OF_HIRE_URL = "http://dev.nottinghamtec.co.uk/wp-content/uploads/2014/11/terms.pdf" +TERMS_OF_HIRE_URL = "http://www.nottinghamtec.co.uk/terms.pdf" diff --git a/RIGS/forms.py b/RIGS/forms.py index 3f38f9d5..8a019409 100644 --- a/RIGS/forms.py +++ b/RIGS/forms.py @@ -3,7 +3,9 @@ from django import forms from django.utils import formats from django.conf import settings from django.core import serializers +from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm from registration.forms import RegistrationFormUniqueEmail +from captcha.fields import ReCaptchaField import simplejson from RIGS import models @@ -14,6 +16,7 @@ class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail): last_name = forms.CharField(required=False, max_length=50) initials = forms.CharField(required=True, max_length=5) phone = forms.CharField(required=False, max_length=13) + captcha = ReCaptchaField() def clean_initials(self): """ @@ -23,6 +26,13 @@ class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail): raise forms.ValidationError("These initials are already in use. Please supply different initials.") return self.cleaned_data['initials'] +# Login form +class LoginForm(AuthenticationForm): + captcha = ReCaptchaField(label='Captcha') + +class PasswordReset(PasswordResetForm): + captcha = ReCaptchaField(label='Captcha') + # Events Shit class EventForm(forms.ModelForm): datetime_input_formats = formats.get_format_lazy("DATETIME_INPUT_FORMATS") + settings.DATETIME_INPUT_FORMATS diff --git a/RIGS/static/js/autocompleter.js b/RIGS/static/js/autocompleter.js index 5e6c5653..3f0a8ef1 100644 --- a/RIGS/static/js/autocompleter.js +++ b/RIGS/static/js/autocompleter.js @@ -25,7 +25,7 @@ function refreshUpdateHref(obj) { // console.log('Trying to disable'); targetObject.attr('disabled', true); } else { - // targetObject.attr('href', update_url); + targetObject.attr('href', update_url); targetObject.attr('disabled', false); } } diff --git a/RIGS/templates/RIGS/event_form.html b/RIGS/templates/RIGS/event_form.html index 5e0b33f7..df975867 100644 --- a/RIGS/templates/RIGS/event_form.html +++ b/RIGS/templates/RIGS/event_form.html @@ -10,14 +10,16 @@ {% endblock %} +{% block preload_js %} + + +{% endblock %} + {% block js %} - - - {% block preload_js %} {% endblock %} @@ -136,7 +137,6 @@
-