diff --git a/PyRIGS/settings.py b/PyRIGS/settings.py index f7e4ff2d..a4e9a3aa 100644 --- a/PyRIGS/settings.py +++ b/PyRIGS/settings.py @@ -51,9 +51,11 @@ INSTALLED_APPS = ( 'reversion', 'captcha', 'widget_tweaks', + 'raven.contrib.django.raven_compat', ) MIDDLEWARE_CLASSES = ( + 'raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware', 'reversion.middleware.RevisionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', @@ -138,6 +140,15 @@ LOGGING = { } } +import raven + +RAVEN_CONFIG = { + 'dsn': os.environ.get('RAVEN_DSN'), + # If you are using git, you can also automatically configure the + # release based on the git info. + # 'release': raven.fetch_git_sha(os.path.dirname(os.path.dirname(__file__))), +} + # User system AUTH_USER_MODEL = 'RIGS.Profile' @@ -148,21 +159,21 @@ LOGOUT_URL = '/user/logout' ACCOUNT_ACTIVATION_DAYS = 7 # reCAPTCHA settings -RECAPTCHA_PUBLIC_KEY = '6Le16gUTAAAAAO5f-6te_x0NjWmF65_h7saBI6Cg' -RECAPTCHA_PRIVATE_KEY = '6Le16gUTAAAAAByo-ZxRRX3RKyoBngf7ms3dnoEW' +RECAPTCHA_PUBLIC_KEY = os.environ.get('RECAPTCHA_PUBLIC_KEY', None) +RECAPTCHA_PRIVATE_KEY = os.environ.get('RECAPTCHA_PRIVATE_KEY', None) NOCAPTCHA = True # Email EMAILER_TEST = False if not DEBUG or EMAILER_TEST: EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' - EMAIL_HOST = 'mail.nottinghamtec.co.uk' - EMAIL_PORT = 465 - 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' + EMAIL_HOST = os.environ.get('EMAIL_HOST') + EMAIL_PORT = int(os.environ.get('EMAIL_PORT')) + EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER') + EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD') + EMAIL_USE_TLS = bool(int(os.environ.get('EMAIL_USE_TLS', 0))) + EMAIL_USE_SSL = bool(int(os.environ.get('EMAIL_USE_SSL', 0))) + DEFAULT_FROM_EMAIL = os.environ.get('EMAIL_FROM') else: EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' diff --git a/RIGS/admin.py b/RIGS/admin.py index 37f35a8b..18dc554e 100644 --- a/RIGS/admin.py +++ b/RIGS/admin.py @@ -1,9 +1,10 @@ from django.contrib import admin -from RIGS import models +from RIGS import models, forms +from django.contrib.auth.admin import UserAdmin +from django.utils.translation import ugettext_lazy as _ import reversion # Register your models here. -admin.site.register(models.Profile) admin.site.register(models.Person, reversion.VersionAdmin) admin.site.register(models.Organisation, reversion.VersionAdmin) admin.site.register(models.VatRate, reversion.VersionAdmin) @@ -11,4 +12,25 @@ admin.site.register(models.Venue, reversion.VersionAdmin) admin.site.register(models.Event, reversion.VersionAdmin) admin.site.register(models.EventItem, reversion.VersionAdmin) admin.site.register(models.Invoice) -admin.site.register(models.Payment) \ No newline at end of file +admin.site.register(models.Payment) + +class ProfileAdmin(UserAdmin): + fieldsets = ( + (None, {'fields': ('username', 'password')}), + (_('Personal info'), { + 'fields': ('first_name', 'last_name', 'email', 'initials', 'phone')}), + (_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser', + 'groups', 'user_permissions')}), + (_('Important dates'), { + 'fields': ('last_login', 'date_joined')}), + ) + add_fieldsets = ( + (None, { + 'classes': ('wide',), + 'fields': ('username', 'password1', 'password2'), + }), + ) + form = forms.ProfileChangeForm + add_form = forms.ProfileCreationForm + +admin.site.register(models.Profile, ProfileAdmin) diff --git a/RIGS/forms.py b/RIGS/forms.py index 922558c3..24773475 100644 --- a/RIGS/forms.py +++ b/RIGS/forms.py @@ -3,7 +3,7 @@ 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 django.contrib.auth.forms import UserCreationForm, UserChangeForm, AuthenticationForm, PasswordResetForm from registration.forms import RegistrationFormUniqueEmail from captcha.fields import ReCaptchaField import simplejson @@ -33,6 +33,17 @@ class LoginForm(AuthenticationForm): class PasswordReset(PasswordResetForm): captcha = ReCaptchaField(label='Captcha') +class ProfileCreationForm(UserCreationForm): + + class Meta(UserCreationForm.Meta): + model = models.Profile + + +class ProfileChangeForm(UserChangeForm): + + class Meta(UserChangeForm.Meta): + model = models.Profile + # Events Shit class EventForm(forms.ModelForm): datetime_input_formats = formats.get_format_lazy("DATETIME_INPUT_FORMATS") + settings.DATETIME_INPUT_FORMATS diff --git a/RIGS/templates/RIGS/event_form.html b/RIGS/templates/RIGS/event_form.html index b0b94e14..0e7aa6ad 100644 --- a/RIGS/templates/RIGS/event_form.html +++ b/RIGS/templates/RIGS/event_form.html @@ -57,14 +57,14 @@ $('#is_rig-selector button').on('click', function () { $('.form-non_rig').slideDown(); if ($(this).data('is_rig') == 1) { - $('#{{form.is_rig.auto_id}}').attr('checked', true); + $('#{{form.is_rig.auto_id}}').prop('checked', true); if ($('.form-non_rig').is(':hidden')) { $('.form-is_rig').show(); } else { $('.form-is_rig').slideDown(); } } else { - $('#{{form.is_rig.auto_id}}').attr('checked', false); + $('#{{form.is_rig.auto_id}}').prop('checked', false); $('.form-is_rig').slideUp(); } }) diff --git a/RIGS/test_functional.py b/RIGS/test_functional.py index 378f859b..cc145d7e 100644 --- a/RIGS/test_functional.py +++ b/RIGS/test_functional.py @@ -613,7 +613,38 @@ class EventTest(LiveServerTestCase): event = models.Event.objects.get(name='Test Event Name') self.assertIn("N0000%d | Test Event Name"%event.pk, self.browser.find_element_by_xpath('//h1').text) + def testRigNonRig(self): + self.browser.get(self.live_server_url + '/event/create/') + # Gets redirected to login and back + self.authenticate('/event/create/') + wait = WebDriverWait(self.browser, 10) #setup WebDriverWait to use later (to wait for animations) + self.browser.implicitly_wait(3) #Set session-long wait (only works for non-existant DOM objects) + + wait.until(animation_is_finished()) + + # Click Non-Rig button + self.browser.find_element_by_xpath('//button[.="Non-Rig"]').click() + + # Click Rig button + self.browser.find_element_by_xpath('//button[.="Rig"]').click() + + form = self.browser.find_element_by_tag_name('form') + save = self.browser.find_element_by_xpath('(//button[@type="submit"])[3]') + + # Set title + e = self.browser.find_element_by_id('id_name') + e.send_keys('Test Event Name') + + # Set an arbitrary date + form.find_element_by_id('id_start_date').clear() + form.find_element_by_id('id_start_date').send_keys('3015-04-24') + + # Save the rig + save.click() + detail_panel = self.browser.find_element_by_xpath("//div[@id='content']/div/div[6]/div/div") + self.assertTrue(detail_panel.is_displayed()) + self.assertIn("Event Detail", detail_panel.text) def testEventDetail(self): with transaction.atomic(), reversion.create_revision(): diff --git a/db.sqlite3 b/db.sqlite3 index ab240dff..d0e8fed8 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/requirements.txt b/requirements.txt index 03448bdb..1f32e3dc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,6 +17,7 @@ Pygments==2.0.2 PyPDF2==1.24 python-dateutil==2.4.2 pytz==2015.4 +raven==5.8.1 reportlab==3.1.44 selenium==2.46.0 simplejson==3.7.2 diff --git a/templates/500.html b/templates/500.html index c135cd4c..2fc2db83 100644 --- a/templates/500.html +++ b/templates/500.html @@ -6,5 +6,6 @@

500: Server error

+

If you need assistance, you may reference this error as {{ request.sentry.id }}.

{% endblock %} diff --git a/templates/base.html b/templates/base.html index dbf56576..8bf8b62c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,4 +1,5 @@ {% load static from staticfiles %} +{% load raven %} @@ -21,6 +22,8 @@ {% endblock %} + + {% block preload_js %} {% endblock %}