예제 #1
0
 def save(self, *args, **kwargs):
     s = super(Profile, self).save(*args, **kwargs)
     if self.approved and not self.__original_approved:
         email_msg = EmailMessage.objects.get(email="bikeanjo-aprovado")
         email_subject = Template(email_msg.subject).render(
             Context({"bike_anjo_full_name": self.user.get_full_name()})
         )
         email_txt = Template(email_msg.text).render(Context({"bike_anjo_full_name": self.user.get_full_name()}))
         send_mail(email_subject, email_txt, "*****@*****.**", [self.user.email])
     self.__original_approved = self.approved
     return s
예제 #2
0
파일: models.py 프로젝트: bgola/bikeanjo
 def save(self, *args, **kwargs):
     s = super(Profile, self).save(*args, **kwargs)
     if self.approved and not self.__original_approved:
         email_msg = EmailMessage.objects.get(email="bikeanjo-aprovado")
         email_subject = Template(email_msg.subject).render(
             Context({'bike_anjo_full_name': self.user.get_full_name()}))
         email_txt = Template(email_msg.text).render(
             Context({'bike_anjo_full_name': self.user.get_full_name()}))
         send_mail(email_subject, email_txt,
                   '*****@*****.**', [self.user.email])
     self.__original_approved = self.approved
     return s
예제 #3
0
    def send_mail(self, subject=None, email_msg=None):
        if self.bikeanjo:
            baemail = self.bikeanjo.user.email
            baname = self.bikeanjo.user.get_full_name()
        else:
            baemail = None
            baname = None

        if email_msg is None:
            try:
                email_msg = EmailMessage.objects.get(email=self.status.lower())
            except EmailMessage.DoesNotExist:
                email = render_to_string("emails/requests/%s.txt" % self.status.lower(), {"request": self})

        if email_msg is not None:
            subject = Template(email_msg.subject).render(
                Context({"full_name": self.user.user.get_full_name(), "bike_anjo_full_name": baname})
            )

            email = Template(email_msg.text).render(
                Context(
                    {
                        "request": self,
                        "full_name": self.user.user.get_full_name(),
                        "service": self.get_service_display(),
                        "bike_anjo_full_name": baname,
                    }
                )
            )

        uemail = self.user.user.email
        recipients = {"ONGOING": [baemail], "WAITING": [baemail, uemail], "IMPOSSIBLE": [uemail]}
        return send_mail(subject, email, "*****@*****.**", recipients[self.status])
예제 #4
0
파일: models.py 프로젝트: bgola/bikeanjo
    def send_mail_staff(self, email_msg=None, subject=None, email=None):
        if email_msg:
            subject = Template(email_msg.subject).render(
                Context({'full_name': self.user.user.get_full_name()}))

            email = Template(email_msg.text).render(
                Context({
                    'request': self,
                    'full_name': self.user.user.get_full_name(),
                    'service': self.get_service_display()
                }))

        return send_mail(subject, email, '*****@*****.**',
                         ['*****@*****.**', '*****@*****.**'])
예제 #5
0
    def send_mail_staff(self, email_msg=None, subject=None, email=None):
        if email_msg:
            subject = Template(email_msg.subject).render(Context({"full_name": self.user.user.get_full_name()}))

            email = Template(email_msg.text).render(
                Context(
                    {
                        "request": self,
                        "full_name": self.user.user.get_full_name(),
                        "service": self.get_service_display(),
                    }
                )
            )

        return send_mail(subject, email, "*****@*****.**", ["*****@*****.**", "*****@*****.**"])
예제 #6
0
파일: models.py 프로젝트: bgola/bikeanjo
    def send_mail(self, subject=None, email_msg=None):
        if self.bikeanjo:
            baemail = self.bikeanjo.user.email
            baname = self.bikeanjo.user.get_full_name()
        else:
            baemail = None
            baname = None

        if email_msg is None:
            try:
                email_msg = EmailMessage.objects.get(email=self.status.lower())
            except EmailMessage.DoesNotExist:
                email = render_to_string(
                    'emails/requests/%s.txt' % self.status.lower(),
                    {'request': self})

        if email_msg is not None:
            subject = Template(email_msg.subject).render(
                Context({
                    'full_name': self.user.user.get_full_name(),
                    'bike_anjo_full_name': baname
                }))

            email = Template(email_msg.text).render(
                Context({
                    'request': self,
                    'full_name': self.user.user.get_full_name(),
                    'service': self.get_service_display(),
                    'bike_anjo_full_name': baname
                }))

        uemail = self.user.user.email
        recipients = {
            'ONGOING': [baemail],
            'WAITING': [baemail, uemail],
            'IMPOSSIBLE': [uemail]
        }
        return send_mail(subject, email, '*****@*****.**',
                         recipients[self.status])