Merge branch 'master' into revision-view

This commit is contained in:
Tom Price
2015-05-18 14:36:23 +01:00
14 changed files with 82 additions and 26 deletions

4
PyRIGS/.slugignore Normal file
View File

@@ -0,0 +1,4 @@
*.sqlite3
*.scss
*.md
*.rb

View File

@@ -18,17 +18,21 @@ SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # 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! # 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 TEMPLATE_DEBUG = True
ALLOWED_HOSTS = ['*'] ALLOWED_HOSTS = ['pyrigs.nottinghamtec.co.uk', 'rigs.nottinghamtec.co.uk', 'pyrigs.herokuapp.com']
INTERNAL_IPS = ['127.0.0.1'] INTERNAL_IPS = ['127.0.0.1']
ADMINS = (
('Tom Price', 'tomtom5152@gmail.com')
)
# Application definition # Application definition
@@ -44,6 +48,7 @@ INSTALLED_APPS = (
'debug_toolbar', 'debug_toolbar',
'registration', 'registration',
'reversion', 'reversion',
'captcha',
'widget_tweaks', 'widget_tweaks',
) )
@@ -112,13 +117,27 @@ LOGGING = {
'level': 'DEBUG', 'level': 'DEBUG',
'class': 'logging.StreamHandler', 'class': 'logging.StreamHandler',
'formatter': 'verbose' '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': { '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'], 'handlers': ['console'],
'level': 'INFO', 'level': 'ERROR',
} 'propagate': False,
},
} }
} }
@@ -131,6 +150,11 @@ LOGOUT_URL = '/user/logout'
ACCOUNT_ACTIVATION_DAYS = 7 ACCOUNT_ACTIVATION_DAYS = 7
# reCAPTCHA settings
RECAPTCHA_PUBLIC_KEY = '6Le16gUTAAAAAO5f-6te_x0NjWmF65_h7saBI6Cg'
RECAPTCHA_PRIVATE_KEY = '***REMOVED***'
NOCAPTCHA = True
# Email # Email
EMAILER_TEST = False EMAILER_TEST = False
if not DEBUG or EMAILER_TEST: if not DEBUG or EMAILER_TEST:
@@ -187,4 +211,4 @@ TEMPLATE_DIRS = (
USE_GRAVATAR=True 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"

View File

@@ -3,7 +3,9 @@ from django import forms
from django.utils import formats from django.utils import formats
from django.conf import settings from django.conf import settings
from django.core import serializers from django.core import serializers
from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm
from registration.forms import RegistrationFormUniqueEmail from registration.forms import RegistrationFormUniqueEmail
from captcha.fields import ReCaptchaField
import simplejson import simplejson
from RIGS import models from RIGS import models
@@ -14,6 +16,7 @@ class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail):
last_name = forms.CharField(required=False, max_length=50) last_name = forms.CharField(required=False, max_length=50)
initials = forms.CharField(required=True, max_length=5) initials = forms.CharField(required=True, max_length=5)
phone = forms.CharField(required=False, max_length=13) phone = forms.CharField(required=False, max_length=13)
captcha = ReCaptchaField()
def clean_initials(self): def clean_initials(self):
""" """
@@ -23,6 +26,13 @@ class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail):
raise forms.ValidationError("These initials are already in use. Please supply different initials.") raise forms.ValidationError("These initials are already in use. Please supply different initials.")
return self.cleaned_data['initials'] return self.cleaned_data['initials']
# Login form
class LoginForm(AuthenticationForm):
captcha = ReCaptchaField(label='Captcha')
class PasswordReset(PasswordResetForm):
captcha = ReCaptchaField(label='Captcha')
# Events Shit # Events Shit
class EventForm(forms.ModelForm): class EventForm(forms.ModelForm):
datetime_input_formats = formats.get_format_lazy("DATETIME_INPUT_FORMATS") + settings.DATETIME_INPUT_FORMATS datetime_input_formats = formats.get_format_lazy("DATETIME_INPUT_FORMATS") + settings.DATETIME_INPUT_FORMATS

View File

@@ -25,7 +25,7 @@ function refreshUpdateHref(obj) {
// console.log('Trying to disable'); // console.log('Trying to disable');
targetObject.attr('disabled', true); targetObject.attr('disabled', true);
} else { } else {
// targetObject.attr('href', update_url); targetObject.attr('href', update_url);
targetObject.attr('disabled', false); targetObject.attr('disabled', false);
} }
} }

View File

@@ -10,14 +10,16 @@
<link rel="stylesheet" href="{% static "css/ajax-bootstrap-select.css" %}"/> <link rel="stylesheet" href="{% static "css/ajax-bootstrap-select.css" %}"/>
{% endblock %} {% endblock %}
{% block preload_js %}
<script src="{% static "js/bootstrap-select.js" %}"></script>
<script src="{% static "js/ajax-bootstrap-select.js" %}"></script>
{% endblock %}
{% block js %} {% block js %}
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script src="{% static "js/interaction.js" %}"></script> <script src="{% static "js/interaction.js" %}"></script>
<script src="{% static "js/modal.js" %}"></script> <script src="{% static "js/modal.js" %}"></script>
<script src="{% static "js/bootstrap-select.js" %}"></script>
<script src="{% static "js/ajax-bootstrap-select.js" %}"></script>
<script src="{% static "js/autocompleter.js" %}"></script> <script src="{% static "js/autocompleter.js" %}"></script>
<script> <script>
@@ -422,6 +424,13 @@
{% include "RIGS/item_table.html" %} {% include "RIGS/item_table.html" %}
</div> </div>
</div> </div>
<div class="col-sm-12 text-right">
<div class="btn-group btn-page">
<button type="submit" class="btn btn-default" title="Save"><span
class="glyphicon glyphicon-floppy-disk"></span>
</button>
</div>
</div>
</div> </div>
</form> </form>

View File

@@ -84,9 +84,9 @@
<setFont name="OpenSans" size="9"/> <setFont name="OpenSans" size="9"/>
<drawString x="137" y="760">Portland Building, University Park, Nottingham, NG7 2RD</drawString> <drawString x="137" y="760">Portland Building, University Park, Nottingham, NG7 2RD</drawString>
<drawString x="137" y="746">Phone: (0115) 846 8720</drawString> <drawString x="137" y="746">www.nottinghamtec.co.uk</drawString>
<drawString x="137" y="732">www.nottinghamtec.co.uk</drawString> <drawString x="265" y="746">info@nottinghamtec.co.uk</drawString>
<drawString x="265" y="732">info@nottinghamtec.co.uk</drawString> <drawString x="137" y="732">Phone: (0115) 846 8720</drawString>

View File

@@ -128,7 +128,7 @@
<keepTogether> <keepTogether>
<blockTable style="totalTable" colWidths="300,115,80"> <blockTable style="totalTable" colWidths="300,115,80">
<tr> <tr>
<td>VAT may be charged at the current rate date of event ({{ object.vat_rate.as_percent|floatformat:2 }}%)</td> <td></td>
<td>Total (ex. VAT)</td> <td>Total (ex. VAT)</td>
<td>£ {{ object.sum_total|floatformat:2 }}</td> <td>£ {{ object.sum_total|floatformat:2 }}</td>
</tr> </tr>

View File

@@ -1,4 +1,4 @@
<div class="panel"> <div class="panel table-responsive">
<table class="table table-hover" id="item-table" {% if edit %}data-orderurl="{#% url 'item_order' %#}"{% endif %}> <table class="table table-hover" id="item-table" {% if edit %}data-orderurl="{#% url 'item_order' %#}"{% endif %}>
<thead> <thead>
<tr> <tr>

View File

@@ -1,6 +1,6 @@
from django.conf.urls import patterns, include, url from django.conf.urls import patterns, include, url
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from RIGS import views, rigboard, finance, ical from RIGS import views, rigboard, finance, ical, forms
from django.views.generic import RedirectView from django.views.generic import RedirectView
from PyRIGS.decorators import permission_required_with_403 from PyRIGS.decorators import permission_required_with_403
@@ -14,6 +14,7 @@ urlpatterns = patterns('',
url(r'^closemodal/$', views.CloseModal.as_view(), name='closemodal'), url(r'^closemodal/$', views.CloseModal.as_view(), name='closemodal'),
url('^user/login/$', 'RIGS.views.login', name='login'), url('^user/login/$', 'RIGS.views.login', name='login'),
url(r'^user/password_reset/$', 'django.contrib.auth.views.password_reset', {'password_reset_form':forms.PasswordReset}),
# People # People
url(r'^people/$', permission_required_with_403('RIGS.view_person')(views.PersonList.as_view()), url(r'^people/$', permission_required_with_403('RIGS.view_person')(views.PersonList.as_view()),

View File

@@ -30,7 +30,7 @@ def login(request, **kwargs):
else: else:
from django.contrib.auth.views import login from django.contrib.auth.views import login
return login(request) return login(request, authentication_form=forms.LoginForm)
""" """

View File

@@ -7,6 +7,7 @@ dj-database-url==0.3.0
dj-static==0.0.6 dj-static==0.0.6
django-debug-toolbar==1.2.2 django-debug-toolbar==1.2.2
django-ical==1.3 django-ical==1.3
django-recaptcha==1.0.4
django-registration-redux==1.1 django-registration-redux==1.1
django-reversion==1.8.5 django-reversion==1.8.5
django-toolbelt==0.0.1 django-toolbelt==0.0.1

View File

@@ -15,6 +15,7 @@
{% block css %} {% block css %}
{% endblock %} {% endblock %}
<script src="//code.jquery.com/jquery-latest.min.js"></script>
{% block preload_js %} {% block preload_js %}
{% endblock %} {% endblock %}
@@ -136,7 +137,6 @@
<div class="modal fade" id="modal"></div> <div class="modal fade" id="modal"></div>
<script src="//code.jquery.com/jquery-latest.min.js"></script>
<script> <script>
Date.prototype.getISOString = function () { Date.prototype.getISOString = function () {
var yyyy = this.getFullYear().toString(); var yyyy = this.getFullYear().toString();

View File

@@ -1,7 +1,7 @@
{% load url from future %} {% load url from future %}
{% load widget_tweaks %} {% load widget_tweaks %}
{% include 'form_errors.html' %} {% include 'form_errors.html' %}
<div class="col-md-4 col-md-offset-4"> <div class="col-sm-6 col-sm-offset-3 col-lg-4 col-lg-offset-4">
<form action="{% url 'login' %}" method="post" role="form">{% csrf_token %} <form action="{% url 'login' %}" method="post" role="form">{% csrf_token %}
<div class="form-group"> <div class="form-group">
@@ -12,6 +12,12 @@
<label for="{{ form.password.id_for_label }}">{{ form.password.label }}</label> <label for="{{ form.password.id_for_label }}">{{ form.password.label }}</label>
{% render_field form.password class+="form-control" placeholder=form.password.label %} {% render_field form.password class+="form-control" placeholder=form.password.label %}
</div> </div>
<div class="form-group">
<label for="{{ form.captcha.id_for_label }}">{{ form.captcha.label }}</label>
<div class="text-center">
{{ form.captcha }}
</div>
</div>
<a href="{% url 'registration_register' %}" class="btn">Register</a> <a href="{% url 'registration_register' %}" class="btn">Register</a>
<a href="{% url 'password_reset' %}" class="btn">Forgotten Password</a> <a href="{% url 'password_reset' %}" class="btn">Forgotten Password</a>
<input type="submit" value="Login" class="btn btn-primary"/> <input type="submit" value="Login" class="btn btn-primary"/>

View File

@@ -21,11 +21,12 @@
{% render_field form.email type="email" class+="form-control" %} {% render_field form.email type="email" class+="form-control" %}
</div> </div>
</div> </div>
<div class="col-sm-12"> <div class="form-group">
<div class="pull-right"> <div class="col-sm-10 col-md-8 col-md-offset-2">
<div class="form-group"> {{ form.captcha }}
<input type="submit" value="Submit" class="btn btn-primary" /> </div>
</div> <div class="col-sm-2 text-right">
<input type="submit" value="Submit" class="btn btn-primary" />
</div> </div>
</div> </div>
</form> </form>