checks email for uniqueness upon change
This commit is contained in:
@@ -29,7 +29,7 @@ from rowingdata import (
|
||||
TCXParser, RowProParser, ErgDataParser,
|
||||
CoxMateParser,
|
||||
BoatCoachParser, RowPerfectParser, BoatCoachAdvancedParser,
|
||||
MysteryParser, BoatCoachOTWParser,
|
||||
MysteryParser, BoatCoachOTWParser,QuiskeParser,
|
||||
painsledDesktopParser, speedcoachParser, ErgStickParser,
|
||||
SpeedCoach2Parser, FITParser, fitsummarydata,
|
||||
make_cumvalues,cumcpdata,
|
||||
@@ -866,6 +866,11 @@ def handle_nonpainsled(f2, fileformat, summary=''):
|
||||
row = MysteryParser(f2)
|
||||
hasrecognized = True
|
||||
|
||||
# handle Quiske
|
||||
if (fileformat == 'quiske'):
|
||||
row = QuiskeParser(f2)
|
||||
hasrecognized = True
|
||||
|
||||
# handle RowPerfect
|
||||
if (fileformat == 'rowperfect3'):
|
||||
row = RowPerfectParser(f2)
|
||||
|
||||
@@ -2,6 +2,8 @@ from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.validators import validate_email
|
||||
from django.core.exceptions import ValidationError
|
||||
from django import forms
|
||||
from django.forms import ModelForm
|
||||
from django.dispatch import receiver
|
||||
@@ -941,14 +943,49 @@ class AccountRowerForm(ModelForm):
|
||||
'defaulttimezone','showfavoritechartnotes',
|
||||
'defaultlandingpage']
|
||||
|
||||
def clean_email(self):
|
||||
email = self.cleaned_data.get('email')
|
||||
|
||||
try:
|
||||
validate_email(email)
|
||||
except ValidationError:
|
||||
raise forms.ValidationError(
|
||||
'Please enter a valid email address')
|
||||
|
||||
try:
|
||||
match = User.objects.get(email__iexact=email)
|
||||
if self.instance.user == match:
|
||||
return email
|
||||
except User.DoesNotExist:
|
||||
return email
|
||||
|
||||
raise forms.ValidationError('This email address is not allowed')
|
||||
|
||||
|
||||
|
||||
class UserForm(ModelForm):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ['first_name','last_name','email']
|
||||
|
||||
def clean_email(self):
|
||||
email = self.cleaned_data.get('email')
|
||||
|
||||
try:
|
||||
validate_email(email)
|
||||
except ValidationError:
|
||||
raise forms.ValidationError(
|
||||
'Please enter a valid email address')
|
||||
|
||||
try:
|
||||
match = User.objects.get(email__iexact=email)
|
||||
if self.instance == match:
|
||||
return email
|
||||
except User.DoesNotExist:
|
||||
return email
|
||||
|
||||
raise forms.ValidationError('This email address is not allowed')
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(UserForm, self).clean()
|
||||
|
||||
# Form to set rower's Heart Rate zones, including test routines
|
||||
# to enable consistency
|
||||
|
||||
@@ -17,6 +17,7 @@ from django import template
|
||||
from django.db import IntegrityError, transaction
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.http import (
|
||||
HttpResponse, HttpResponseRedirect,
|
||||
@@ -9703,7 +9704,7 @@ def rower_edit_view(request,message=""):
|
||||
})
|
||||
elif request.method == 'POST' and "weightcategory" in request.POST:
|
||||
accountform = AccountRowerForm(request.POST)
|
||||
userform = UserForm(request.POST)
|
||||
userform = UserForm(request.POST,instance=request.user)
|
||||
if accountform.is_valid() and userform.is_valid():
|
||||
# process
|
||||
cd = accountform.cleaned_data
|
||||
@@ -9720,7 +9721,7 @@ def rower_edit_view(request,message=""):
|
||||
if len(first_name):
|
||||
u.first_name = first_name
|
||||
u.last_name = last_name
|
||||
if len(email):
|
||||
if len(email): ## and check_email_freeforuse(u,email):
|
||||
u.email = email
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user