예제 #1
0
    def _send_email(self, recipients, template_name, context=None, **kwargs):
        context = context or {}

        base_context = {
            'visit': self.get_mail_context(),
            'environment': get_environment(),
        }
        base_context.update(context)
        context = base_context

        if isinstance(recipients, six.string_types):
            recipients = [
                recipients,
            ]
        else:
            recipients = list(recipients)

        # assert recipients
        if recipients:
            notification = Notification.objects.create(
                sender=self,
                recipients=recipients,
                template_name=template_name,
                template_data=context)
            notification.send_notification()
예제 #2
0
def send_invite_email(staff):
    context = {
        'environment': get_environment(),
        'login_link': get_token_auth_link(staff.user)
    }

    notification = Notification.objects.create(
        sender=staff,
        recipients=[staff.user.email],
        template_name='organisations/staff_member/invite',
        template_data=context)
    notification.send_notification()
예제 #3
0
    def send_user_appointed_email(self, engagement):
        context = {
            'environment': get_environment(),
            'engagement': engagement.get_mail_context(),
            'staff_member': self.user.get_full_name(),
        }

        notification = Notification.objects.create(
            sender=self,
            recipients=[self.user.email], template_name='audit/engagement/submit_to_auditor',
            template_data=context
        )
        notification.send_notification()
예제 #4
0
    def notify_person_responsible(self, template_name):
        context = {
            'environment': get_environment(),
            'engagement': Engagement.objects.get_subclass(action_points__id=self.id).get_mail_context(),
            'action_point': self.get_mail_context(),
        }

        notification = Notification.objects.create(
            sender=self,
            recipients=[self.person_responsible.email], template_name=template_name,
            template_data=context
        )
        notification.send_notification()
예제 #5
0
    def notify_person_responsible(self, template_name):
        context = {
            'environment': get_environment(),
            'visit': self.tpm_visit.get_mail_context(),
            'action_point': self.get_mail_context(),
        }

        notification = Notification.objects.create(
            sender=self,
            recipients=[self.person_responsible.email],
            template_name=template_name,
            template_data=context)
        notification.send_notification()
예제 #6
0
def send_invite_email(staff, engagement):
    context = {
        'environment': get_environment(),
        'staff_member': staff.user.get_full_name(),
        'engagement': engagement.get_mail_context(),
        'login_link': get_token_auth_link(staff.user),
    }

    notification = Notification.objects.create(
        sender=staff,
        recipients=[staff.user.email],
        template_name='audit/staff_member/invite',
        template_data=context)
    notification.send_notification()
예제 #7
0
    def _send_email(self, recipients, template_name, context=None, **kwargs):
        context = context or {}

        base_context = {
            'engagement': self.get_mail_context(),
            'environment': get_environment(),
        }
        base_context.update(context)
        context = base_context

        recipients = list(recipients)
        # assert recipients

        if recipients:
            notification = Notification.objects.create(
                sender=self,
                recipients=recipients, template_name=template_name,
                template_data=context
            )
            notification.send_notification()