Private
Public Access
1
0

checks email for uniqueness upon change

This commit is contained in:
Sander Roosendaal
2017-11-08 13:19:25 +01:00
parent a5c34c85d1
commit 1489e9c47a
3 changed files with 48 additions and 5 deletions

View File

@@ -29,7 +29,7 @@ from rowingdata import (
TCXParser, RowProParser, ErgDataParser, TCXParser, RowProParser, ErgDataParser,
CoxMateParser, CoxMateParser,
BoatCoachParser, RowPerfectParser, BoatCoachAdvancedParser, BoatCoachParser, RowPerfectParser, BoatCoachAdvancedParser,
MysteryParser, BoatCoachOTWParser, MysteryParser, BoatCoachOTWParser,QuiskeParser,
painsledDesktopParser, speedcoachParser, ErgStickParser, painsledDesktopParser, speedcoachParser, ErgStickParser,
SpeedCoach2Parser, FITParser, fitsummarydata, SpeedCoach2Parser, FITParser, fitsummarydata,
make_cumvalues,cumcpdata, make_cumvalues,cumcpdata,
@@ -866,6 +866,11 @@ def handle_nonpainsled(f2, fileformat, summary=''):
row = MysteryParser(f2) row = MysteryParser(f2)
hasrecognized = True hasrecognized = True
# handle Quiske
if (fileformat == 'quiske'):
row = QuiskeParser(f2)
hasrecognized = True
# handle RowPerfect # handle RowPerfect
if (fileformat == 'rowperfect3'): if (fileformat == 'rowperfect3'):
row = RowPerfectParser(f2) row = RowPerfectParser(f2)

View File

@@ -2,6 +2,8 @@ from __future__ import unicode_literals
from django.db import models from django.db import models
from django.contrib.auth.models import User 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 import forms
from django.forms import ModelForm from django.forms import ModelForm
from django.dispatch import receiver from django.dispatch import receiver
@@ -941,15 +943,50 @@ class AccountRowerForm(ModelForm):
'defaulttimezone','showfavoritechartnotes', 'defaulttimezone','showfavoritechartnotes',
'defaultlandingpage'] '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 UserForm(ModelForm):
class Meta: class Meta:
model = User model = User
fields = ['first_name','last_name','email'] fields = ['first_name','last_name','email']
def clean_email(self):
email = self.cleaned_data.get('email')
def clean(self): try:
cleaned_data = super(UserForm, self).clean() 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')
# Form to set rower's Heart Rate zones, including test routines # Form to set rower's Heart Rate zones, including test routines
# to enable consistency # to enable consistency
class RowerForm(ModelForm): class RowerForm(ModelForm):

View File

@@ -17,6 +17,7 @@ from django import template
from django.db import IntegrityError, transaction from django.db import IntegrityError, transaction
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import render from django.shortcuts import render
from django.http import ( from django.http import (
HttpResponse, HttpResponseRedirect, HttpResponse, HttpResponseRedirect,
@@ -9703,7 +9704,7 @@ def rower_edit_view(request,message=""):
}) })
elif request.method == 'POST' and "weightcategory" in request.POST: elif request.method == 'POST' and "weightcategory" in request.POST:
accountform = AccountRowerForm(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(): if accountform.is_valid() and userform.is_valid():
# process # process
cd = accountform.cleaned_data cd = accountform.cleaned_data
@@ -9720,7 +9721,7 @@ def rower_edit_view(request,message=""):
if len(first_name): if len(first_name):
u.first_name = first_name u.first_name = first_name
u.last_name = last_name u.last_name = last_name
if len(email): if len(email): ## and check_email_freeforuse(u,email):
u.email = email u.email = email