def send_wfmail(self, profile, workitems, user, subject, template): try : send_mail(workitems=workitems, user=user, subject=subject, template=template) profile.notif_sent() log.info('notification sent to %s' % user.username) except Exception, v: log.error('sendmail error: %s' % v)
def sendmail(workitem, subject='goflow.apptools sendmail message', template='goflow/app_sendmail.txt'): '''send a mail notification to the workitem user. parameters: subject default='goflow.apptools sendmail message' template default='goflow/app_sendmail.txt' ''' send_mail(workitems=(workitem,), user=workitem.user, subject=subject, template=template)
def notify_if_needed(self, user=None, roles=None): ''' notify user if conditions are fullfilled ''' if user: workitems = self.list_safe(user=user, notstatus='complete', noauto=True) profile, created = UserProfile.objects.get_or_create(user=user) if len(workitems) >= profile.nb_wi_notif: try: if profile.check_notif_to_send(): send_mail(workitems=workitems, user=user, subject='message', template='mail.txt') profile.notif_sent() log.info('notification sent to %s' % user.username) except Exception, v: log.error('sendmail error: %s' % v)
def notify_if_needed(self, user=None, roles=None): """ notify user if conditions are fullfilled """ if user: workitems = self.list_safe(user=user, notstatus="complete", noauto=True) UserProfile.objects.get_or_create(user=user) profile = user.get_profile() if len(workitems) >= profile.nb_wi_notif: try: if profile.check_notif_to_send(): send_mail(workitems=workitems, user=user, subject="message", template="mail.txt") profile.notif_sent() log.info("notification sent to %s" % user.username) except Exception, v: log.error("sendmail error: %s" % v)
def notify_if_needed(self, user=None, roles=None): ''' notify user if conditions are fullfilled ''' if user: workitems = self.list_safe(user=user, notstatus='complete', noauto=True) profile, created = UserProfile.objects.get_or_create(user=user) if len(workitems) >= profile.nb_wi_notif: try: if profile.check_notif_to_send(): send_mail(workitems=workitems, user=user, subject='message', template='mail.txt') profile.notif_sent() log.info('notification sent to %s' % user.username) except Exception as v: log.error('sendmail error: %s' % v) return
#!/usr/local/bin/python