def notify_team_join_request_processed(sender, **kwargs): jr = kwargs["join_request"] if jr.status == "PENDING": return emails = get_team_emails(jr.team) subject = "team/email/notify_team_join_request_processed_subject.txt" message = "team/email/notify_team_join_request_processed_message.txt" send_mail(emails, subject, message, kwargs)
def notify_concerned_remove_request_created(sender, **kwargs): rr = kwargs["remove_request"] if rr.status != "PENDING": return email = account_control.get_email_or_404(rr.concerned) subject = "team/email/notify_concerned_remove_request_created_subject.txt" message = "team/email/notify_concerned_remove_request_created_message.txt" send_mail([email], subject, message, kwargs)
def notify_team_remove_request_created(sender, **kwargs): rr = kwargs["remove_request"] if rr.status != "PENDING": return emails = get_team_emails(rr.team, excludes=[rr.concerned]) subject = "team/email/notify_team_remove_request_created_subject.txt" message = "team/email/notify_team_remove_request_created_message.txt" send_mail(emails, subject, message, kwargs)
def notify_team_remove_request_processed(sender, **kwargs): rr = kwargs["remove_request"] if rr.status == "PENDING": return emails = get_team_emails(rr.team) if rr.status == "ACCEPTED": emails.append(account_control.get_email_or_404(rr.concerned)) subject = "team/email/notify_team_remove_request_processed_subject.txt" message = "team/email/notify_team_remove_request_processed_message.txt" send_mail(emails, subject, message, kwargs)
def log_created_lender_callback(sender, **kwargs): log = kwargs["log"] if log.action in ["FINISHED", "BORROWER_RATE"]: return # no one cares, dont spam sys_edit = log.initiator == None if sys_edit or team_control.is_member(log.initiator, log.borrow.team): return # not need to notify team of its own actions emails = _lender_emails(log.borrow) subject, message = _get_email_templates("lender", log.action) send_mail(emails, subject, message, kwargs)
def log_created_borrower_callback(sender, **kwargs): log = kwargs["log"] if log.borrow.borrower == log.initiator: return # no need to notify user of there own actions today = datetime.datetime.now().date() if log.borrow.finish < today or log.action in ["FINISHED", "LENDER_RATE"]: return # no one cares, dont spam emails = _borrower_emails(log.borrow) subject, message = _get_email_templates("borrower", log.action) send_mail(emails, subject, message, kwargs)
def send_reminders_lender_takein(): today = datetime.datetime.now().date() tomorrow = today + datetime.timedelta(days=1) borrows = Borrow.objects.filter( state="ACCEPTED", finish=tomorrow, reminded_lender_takein=False ) for borrow in borrows: email = account_control.get_email_or_404(borrow.dest.responsible) subject, message = _get_email_templates("lender", "remind_takein") send_mail([email], subject, message, { "borrow" : borrow }) borrow.reminded_lender_takein = True borrow.save()
def send_reminders_borrower_dropoff(): today = datetime.datetime.now().date() tomorrow = today + datetime.timedelta(days=1) borrows = Borrow.objects.filter( state="ACCEPTED", finish=tomorrow, reminded_borrower_dropoff=False ) for borrow in borrows: emails = _borrower_emails(borrow) subject, message = _get_email_templates("borrower", "remind_dropoff") send_mail(emails, subject, message, { "borrow" : borrow }) borrow.reminded_borrower_dropoff = True borrow.save()
def send_reminders_borrower_rate(): today = datetime.datetime.now().date() borrows = Borrow.objects.filter( state="ACCEPTED", finish__lt=today, reminded_borrower_rate=False ) for borrow in borrows: if len(Rating.objects.filter(borrow=borrow, originator='BORROWER')): continue # already rated emails = _borrower_emails(borrow) subject, message = _get_email_templates("borrower", "remind_rate") send_mail(emails, subject, message, { "borrow" : borrow }) borrow.reminded_borrower_rate = True borrow.save()
def notify_staff_team_created(sender, **kwargs): emails = account_control.get_superuser_emails() subject = "team/email/notify_staff_team_created_subject.txt" message = "team/email/notify_staff_team_created_message.txt" send_mail(emails, subject, message, kwargs)