app_user.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:hashtagtodo-open 作者: slackpad 项目源码 文件源码
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')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号