Ejemplo n.º 1
0
 def send_mail(
     self,
     subject_template_name,
     email_template_name,
     context,
     from_email,
     to_email,
     html_email_template_name=None,
     notify_service: NotifyService = Provide[Container.notify_service],
 ):
     user = context.get("user")
     url = context.get("base_url") + reverse(
         "password_reset_confirm",
         kwargs={
             "uidb64": urlsafe_base64_encode(force_bytes(user.pk)),
             "token": context.get("token"),
         },
     )
     notify_service.send_email(
         address=user.email,
         template_id=settings.PASSWORD_RESET_EMAIL_TEMPLATE_ID.get(
             context.get("language") or "en"),
         details={
             "name": user.name,
             "url": url,
         },
     )
Ejemplo n.º 2
0
 def send_sms(
     self,
     language,
     otk,
     notify_service: NotifyService = Provide[Container.notify_service],
 ):
     notify_service.send_sms(
         phone_number=str(self.cleaned_data.get("phone_number")),
         template_id=settings.OTK_SMS_TEMPLATE_ID.get(language or "en"),
         details={"code": otk["code"]},
     )
Ejemplo n.º 3
0
 def send_mail(
     self,
     language,
     to_email,
     link,
     notify_service: NotifyService = Provide[Container.notify_service],
 ):
     notify_service.send_email(
         address=to_email,
         template_id=settings.REGISTER_EMAIL_CONFIRMATION_ID.get(language
                                                                 or "en"),
         details={"verification_link": link},
     )
Ejemplo n.º 4
0
 def send_mail(
     self,
     language,
     notify_service: NotifyService = Provide[Container.notify_service],
 ):
     notify_service.send_email(
         address=self.admin.email,
         template_id=settings.BACKUP_CODE_ADMIN_EMAIL_TEMPLATE_ID.get(
             language or "en"),
         details={
             "name": self.admin.name,
             "user_email": self.user.email,
             "user_name": self.user.name,
         },
     )
Ejemplo n.º 5
0
 def send_mail(
     self,
     language,
     admin_email,
     notify_service: NotifyService = Provide[Container.notify_service],
 ):
     """
     Send a confirmation email to the newly signed-up user
     """
     notify_service.send_email(
         address=self.cleaned_data.get("email"),
         template_id=settings.CONFIRMATION_EMAIL_TEMPLATE_ID.get(language
                                                                 or "en"),
         details={
             "admin_email": admin_email,
         },
     )
Ejemplo n.º 6
0
 def send_mail(
     self,
     template_prefix,
     email,
     context,
     notify_service: NotifyService = Provide[Container.notify_service],
 ):
     notify_service.send_email(
         address=context.get("email"),
         template_id=settings.INVITATION_EMAIL_TEMPLATE_ID.get(
             context.get("language") or "en"
         ),
         details={
             "url": context.get("invite_url"),
             "admin_email": context.get("inviter").email,
         },
     )
Ejemplo n.º 7
0
    def setUp(self):
        super().setUp()
        container.notify_service.override(
            NotifyService())  # Prevent sending emails/SMS

        # Ensure that manitoba has sms enabled (test user is located in manitoba)
        manitoba = HealthcareProvince.objects.get(name="Manitoba")
        manitoba.sms_enabled = True
        manitoba.save()
Ejemplo n.º 8
0
    def setUp(self):
        super().setUp()
        container.notify_service.override(
            NotifyService())  # Prevent sending emails
        self.invite = Invitation.create(self.invited_email,
                                        inviter=self.user,
                                        sent=timezone.now())

        password = uuid4()
        self.new_user_data = {
            "email": self.invited_email,
            "province": "CDS",
            "name": "Chuck Norris",
            "phone_number": "+12125552368",
            "phone_number_confirmation": "+12125552368",
            "password1": password,
            "password2": password,
        }
Ejemplo n.º 9
0
 def setUp(self):
     container.notify_service.override(
         NotifyService())  # Prevent sending emails