Private
Public Access
1
0

better filter for lowercase email addresses

This commit is contained in:
Sander Roosendaal
2017-02-14 08:36:15 +01:00
parent 3ae5382a62
commit 9e737458b6
2 changed files with 35 additions and 35 deletions

View File

@@ -55,47 +55,44 @@ class Command(BaseCommand):
name = m.subject
cntr += 1
# get a list of users
theusers = User.objects.filter(email=from_address)
for u in theusers:
try:
rr = Rower.objects.get(user=u.id)
if extension == 'zip':
z = zipfile.ZipFile(a.document)
for f in z.namelist():
f2 = z.extract(f,path='media/')
try:
wid = [
make_new_workout_from_email(rr,f2[6:],name)
]
res += wid
link = 'http://rowsandall.com/rowers/workout/'+str(wid)+'/edit'
dd = send_confirm(u,name,link)
except:
pass
else:
# move attachment and make workout
try:
wid = [
make_new_workout_from_email(rr,
a.document,
name)
# theusers = User.objects.filter(email=from_address)
ther = [
r for r in Rower.objects.all() if r.user.email.lower() == from_address
]
for rr in ther:
if extension == 'zip':
z = zipfile.ZipFile(a.document)
for f in z.namelist():
f2 = z.extract(f,path='media/')
try:
wid = [
make_new_workout_from_email(rr,f2[6:],name)
]
res += wid
link = 'http://rowsandall.com/rowers/workout/'+str(wid[0])+'/edit'
except:
# replace with code to process error
res += ['fail: '+name]
donotdelete = 1
try:
link = 'http://rowsandall.com/rowers/workout/'+str(wid)+'/edit'
dd = send_confirm(u,name,link)
except:
pass
else:
# move attachment and make workout
try:
wid = [
make_new_workout_from_email(rr,
a.document,
name)
]
res += wid
link = 'http://rowsandall.com/rowers/workout/'+str(wid[0])+'/edit'
except:
# replace with code to process error
res += ['fail: '+name]
donotdelete = 1
try:
dd = send_confirm(u,name,link)
except:
pass
except Rower.DoesNotExist:
pass
# remove attachment
if donotdelete == 0:
a.delete()

View File

@@ -211,6 +211,9 @@ class Rower(models.Model):
def __str__(self):
return self.user.username
def clean_email(self):
return self.user.email.lower()
# Saving a chart as a favorite chart
class FavoriteChart(models.Model):
y1params = (