Example #1
0
def status_changed(sender, instance, **kwargs):
    try:
        obj = UserVolunteerActivity.objects.get(pk=instance.pk)
    except UserVolunteerActivity.DoesNotExist:
        pass # Object is new, so field hasn't technically changed, but you may want to do something else here.
    else:
        if not obj.status == instance.status and instance.status == 2: # Status is completed
            send_templated_mail(
                from_email=settings.EMAIL_DEFAULT_FROM,
                to_emails=instance.get_emails(),
                subject='Thank you for volunteering with {org} on {date}'.format(
                    org=instance.activity.organization.name,
                    date=instance.activity.date
                ),
                template_name='volunteer_completed',
                context={
                    'org': instance.activity.organization,
                    'org_url': instance.activity.organization.get_absolute_url(),
                    'user': instance.user,
                    'activity': instance.activity,
                    'school': instance.activity.school,
                    'site_url': Site.objects.get_current().domain,
                    'school_url': instance.activity.school.get_absolute_url(),
                    'volunteer_url': reverse('volunteer_map')
                }
            )
Example #2
0
def status_changed(sender, instance, **kwargs):
    try:
        obj = UserVolunteerActivity.objects.get(pk=instance.pk)
    except UserVolunteerActivity.DoesNotExist:
        pass  # Object is new, so field hasn't technically changed, but you may want to do something else here.
    else:
        if not obj.status == instance.status and instance.status == 2:  # Status is completed
            send_templated_mail(
                from_email=settings.EMAIL_DEFAULT_FROM,
                to_emails=instance.get_emails(),
                subject='Thank you for volunteering with {org} on {date}'.
                format(org=instance.activity.organization.name,
                       date=instance.activity.date),
                template_name='volunteer_completed',
                context={
                    'org': instance.activity.organization,
                    'org_url':
                    instance.activity.organization.get_absolute_url(),
                    'user': instance.user,
                    'activity': instance.activity,
                    'school': instance.activity.school,
                    'site_url': Site.objects.get_current().domain,
                    'school_url': instance.activity.school.get_absolute_url(),
                    'volunteer_url': reverse('volunteer_map')
                })
Example #3
0
 def send_volunteer_activity_created_mail(self):
     send_templated_mail(
         from_email=settings.EMAIL_DEFAULT_FROM,
         to_emails=self.get_emails(),
         subject='Volunteering with {org} on {date}'.format(
             org=self.activity.organization.name,
             date=self.activity.date
         ),
         template_name='volunteer',
         context={
             'org': self.activity.organization,
             'user': self.user,
             'activity': self.activity,
             'school': self.activity.school,
             'site_url': Site.objects.get_current().domain,
             'school_url': self.activity.school.get_absolute_url()
         }
     )
Example #4
0
def story_updated(sender, instance=None, created=False, **kwargs):
    if not created:
        return

    #if the story is not created from the web, don't send an email.
    if not instance.group.source.name == 'web':
        return

    send_templated_mail(
        from_email=settings.EMAIL_DEFAULT_FROM,
        to_emails=[instance.email, '*****@*****.**'],
        subject='Thank you for Sharing Your Story at {}'.format(
            instance.school.name),
        template_name='post_sys',
        context={
            'school': instance.school,
            'site_url': Site.objects.get_current().domain,
            'school_url': instance.school.get_absolute_url(),
        })
Example #5
0
def story_updated(sender, instance=None, created=False, **kwargs):
    if not created:
        return

    # if the story is not created from the web, don't send an email.
    if not instance.group.source.name == "web":
        return

    send_templated_mail(
        from_email=settings.EMAIL_DEFAULT_FROM,
        to_emails=[instance.email, "*****@*****.**"],
        subject="Thank you for Sharing Your Story at {}".format(instance.school.name),
        template_name="post_sys",
        context={
            "school": instance.school,
            "site_url": Site.objects.get_current().domain,
            "school_url": instance.school.get_absolute_url(),
        },
    )
Example #6
0
    def send_user_created_verify_email_mail(self):
        email_verification_code = ''.join(
            [random.choice(string.hexdigits) for x in range(32)])
        self.email_verification_code = email_verification_code
        url = reverse(
            'user_email_verify') + '?token={token}&email={email}'.format(
                token=email_verification_code, email=self.email)

        send_templated_mail(from_email=settings.EMAIL_DEFAULT_FROM,
                            to_emails=[self.email],
                            subject='Please verify your email address',
                            template_name='register',
                            context={
                                'user': self,
                                'site_url': Site.objects.get_current().domain,
                                'url': url
                            })

        self.save()
Example #7
0
    def send_verification_email(self):
        self.generate_email_token()
        url = reverse(
            'user_email_verify') + '?token={token}&email={email}'.format(
                token=self.email_verification_code, email=self.email)

        context = {
            'user': self,
            'site_url': Site.objects.get_current().domain,
            'url': url
        }

        send_templated_mail(from_email=settings.EMAIL_DEFAULT_FROM,
                            to_emails=[self.email],
                            subject='Please verify your email address',
                            template_name='register',
                            context=context)

        self.save()
Example #8
0
 def send_volunteer_activity_created_mail(self):
     send_templated_mail(from_email=settings.EMAIL_DEFAULT_FROM,
                         to_emails=self.get_emails(),
                         subject='Volunteering with {org} on {date}'.format(
                             org=self.activity.organization.name,
                             date=self.activity.date),
                         template_name='volunteer',
                         context={
                             'org':
                             self.activity.organization,
                             'user':
                             self.user,
                             'activity':
                             self.activity,
                             'school':
                             self.activity.school,
                             'site_url':
                             Site.objects.get_current().domain,
                             'school_url':
                             self.activity.school.get_absolute_url()
                         })
Example #9
0
    def send_user_created_verify_email_mail(self):
        email_verification_code = ''.join([random.choice(string.hexdigits) for x in range(32)])
        self.email_verification_code = email_verification_code
        url = reverse('user_email_verify') + '?token={token}&email={email}'.format(
            token=email_verification_code,
            email=self.email
        )

        send_templated_mail(
            from_email=settings.EMAIL_DEFAULT_FROM,
            to_emails=[self.email],
            subject='Please verify your email address',
            template_name='register',
            context={
                'user': self,
                'site_url': Site.objects.get_current().domain,
                'url': url
            }
        )

        self.save()