expire_applications.py 文件源码

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

项目:registration 作者: HackAssistant 项目源码 文件源码
def handle(self, *args, **options):
        fourdaysago = datetime.today() - timedelta(days=4)
        self.stdout.write('Checking reminders...')
        reminders = models.Application.objects.filter(
            status_update_date__lte=fourdaysago, status=models.APP_INVITED)
        self.stdout.write('Checking reminders...%s found' % reminders.count())
        self.stdout.write('Sending reminders...')
        msgs = []
        for app in reminders:
            app.last_reminder()
            msgs.append(emails.create_lastreminder_email(app))

        connection = mail.get_connection()
        connection.send_messages(msgs)
        self.stdout.write(self.style.SUCCESS(
            'Sending reminders... Successfully sent %s reminders' % len(msgs)))

        onedayago = datetime.today() - timedelta(days=1)
        self.stdout.write('Checking expired...')
        expired = models.Application.objects.filter(
            status_update_date__lte=onedayago, status=models.APP_LAST_REMIDER)
        self.stdout.write('Checking expired...%s found' % expired.count())
        self.stdout.write('Setting expired...')
        count = len([app.expire() for app in expired])
        self.stdout.write(self.style.SUCCESS(
            'Setting expired... Successfully expired %s applications' % count))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号