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

View File

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