Merge branch 'login' into training

This commit is contained in:
Tom Price
2016-01-04 23:58:01 +00:00
4 changed files with 11 additions and 23 deletions

View File

@@ -10,13 +10,14 @@ import simplejson
from RIGS import models from RIGS import models
#Registration
# Registration
class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail): class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail):
captcha = ReCaptchaField() captcha = ReCaptchaField()
class Meta: class Meta:
model = models.Profile model = models.Profile
fields = ('username','email','first_name','last_name','initials','phone') fields = ('username', 'email', 'first_name', 'last_name', 'initials', 'phone')
def clean_initials(self): def clean_initials(self):
""" """
@@ -26,24 +27,22 @@ 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')
# Login form
class PasswordReset(PasswordResetForm): class PasswordReset(PasswordResetForm):
captcha = ReCaptchaField(label='Captcha') captcha = ReCaptchaField(label='Captcha')
class ProfileCreationForm(UserCreationForm):
class ProfileCreationForm(UserCreationForm):
class Meta(UserCreationForm.Meta): class Meta(UserCreationForm.Meta):
model = models.Profile model = models.Profile
class ProfileChangeForm(UserChangeForm): class ProfileChangeForm(UserChangeForm):
class Meta(UserChangeForm.Meta): class Meta(UserChangeForm.Meta):
model = models.Profile model = models.Profile
# 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
@@ -96,7 +95,7 @@ class EventForm(forms.ModelForm):
def _get_or_initialise_item(self, pk, data, event): def _get_or_initialise_item(self, pk, data, event):
try: try:
item = models.EventItem.objects.get(pk=pk,event=event) item = models.EventItem.objects.get(pk=pk, event=event)
except models.EventItem.DoesNotExist: except models.EventItem.DoesNotExist:
# This occurs for one of two reasons # This occurs for one of two reasons
# 1) The event has been duplicated, so the item PKs belong to another event # 1) The event has been duplicated, so the item PKs belong to another event
@@ -134,7 +133,6 @@ class EventForm(forms.ModelForm):
for key in items: for key in items:
items[key].save() items[key].save()
return m return m
class Meta: class Meta:
@@ -142,4 +140,4 @@ class EventForm(forms.ModelForm):
fields = ['is_rig', 'name', 'venue', 'start_time', 'end_date', 'start_date', fields = ['is_rig', 'name', 'venue', 'start_time', 'end_date', 'start_date',
'end_time', 'meet_at', 'access_at', 'description', 'notes', 'mic', 'end_time', 'meet_at', 'access_at', 'description', 'notes', 'mic',
'person', 'organisation', 'dry_hire', 'checked_in_by', 'status', 'person', 'organisation', 'dry_hire', 'checked_in_by', 'status',
'collector','purchase_order'] 'collector', 'purchase_order']

View File

@@ -177,8 +177,6 @@ class EventTest(LiveServerTestCase):
username.send_keys("EventTest") username.send_keys("EventTest")
password.send_keys("EventTestPassword") password.send_keys("EventTestPassword")
self.browser.execute_script(
"return jQuery('#g-recaptcha-response').val('PASSED')")
submit.click() submit.click()
self.assertEqual(self.live_server_url + n, self.browser.current_url) self.assertEqual(self.live_server_url + n, self.browser.current_url)
@@ -752,8 +750,6 @@ class IcalTest(LiveServerTestCase):
username.send_keys("EventTest") username.send_keys("EventTest")
password.send_keys("EventTestPassword") password.send_keys("EventTestPassword")
self.browser.execute_script(
"return jQuery('#g-recaptcha-response').val('PASSED')")
submit.click() submit.click()
self.assertEqual(self.live_server_url + n, self.browser.current_url) self.assertEqual(self.live_server_url + n, self.browser.current_url)

View File

@@ -33,7 +33,7 @@ def login(request, **kwargs):
else: else:
from django.contrib.auth.views import login from django.contrib.auth.views import login
return login(request, authentication_form=forms.LoginForm) return login(request)
""" """
Called from a modal window (e.g. when an item is submitted to an event/invoice). Called from a modal window (e.g. when an item is submitted to an event/invoice).

View File

@@ -12,12 +12,6 @@
<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"/>