def alertOwnersToChange(item, userThatMadeTheChange=None, toinform=[]): context = { 'user': userThatMadeTheChange, 'base': settings.BASE, } if userThatMadeTheChange: toinform.add(userThatMadeTheChange.email) return emailUfoInfo(items, 'ufo/email_notification', toinform=[], context={})
def alertOwnersToChange(items, userThatMadeTheChange=None, toinform=[]): context = { 'user': userThatMadeTheChange, 'base': settings.BASE, } if userThatMadeTheChange: toinform.append(userThatMadeTheChange.email) if settings.ALSO_INFORM_EMAIL_ADDRESSES: toinform.extend(settings.ALSO_INFORM_EMAIL_ADDRESSES) return emailUfoInfo(items, 'email_notification', toinform=[], context={})
def handle(self, *args, **options): rc = 0 DAYS = 12 deadline = datetime.date.today() + datetime.timedelta(days=DAYS) if options['save']: settings.EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend' settings.EMAIL_FILE_PATH = options['save'] dests = [settings.MAILINGLIST] if options['to']: dests = [options['to']] # Items that are still identified and will go 'can be disposed' in days, or # that are going out completely. # postDeadline = Ufo.objects.filter(Q(state='UNK')).filter( (Q(deadline__lt=deadline))).filter( Q(dispose_by_date__gte=deadline)) postDisposeline = Ufo.objects.filter(( Q(state='UNK') & Q(dispose_by_date__lt=deadline)) | Q(state='DEL')) items = {} for item in postDeadline: items[item.id] = item for item in postDisposeline: items[item.id] = item context = { 'postDeadline': postDeadline, 'postDisposeline': postDisposeline, } if items: emailUfoInfo(list(items.values()), 'email_notification_reminder', dests, context) sys.exit(rc)
def handle(self, *args, **options): rc = 0 DAYS=7 deadline = datetime.date.today() + datetime.timedelta(days=DAYS) # Items that are still identified and will go 'can be disposed' in days, or # that are going out completely. # postDeadline = Ufo.objects.filter(Q(state = 'UNK')).filter((Q(deadline__lt=deadline))).filter(Q(dispose_by_date__gte=deadline)) postDisposeline = Ufo.objects.filter(Q(state = 'UNK') | Q(state = 'DEL')).filter(Q(dispose_by_date__lt=deadline)) items = {} for item in postDeadline: items[ item.id ] = item for item in postDisposeline: items[ item.id ] = item context = { 'postDeadline': postDeadline, 'postDisposeline': postDisposeline, } emailUfoInfo(items.values(), 'email_notification_reminder', [ settings.MAILINGLIST ], context ) sys.exit(rc)