def delete():
if request.method == 'POST':
dos = arrow.get(g.user.created).humanize()
calendars = len([c for c in Calendar.query(ancestor=g.user.key)])
todos = len([e for e in Event.query(ancestor=g.user.key)])
subject = '%s %s closed their account' % (g.user.first_name, g.user.last_name)
body = '''
%s (joined %s, made %d todos and had %d calendars)
%s
''' % (g.user.email, dos, todos, calendars, request.form.get('feedback'))
mail.send_mail(sender=EMAILS['alerts'], to=EMAILS['support'], subject=subject, body=body)
calendars = Calendar.get_all(g.user.key)
for calendar in calendars:
for event in Event.get_all(calendar.key):
event.key.delete()
calendar.key.delete()
User.unindex(g.user.key.urlsafe())
g.user.key.delete()
session.pop('user', None)
return redirect('/index.html')
return render_template('delete.html')
评论列表
文章目录