예제 #1
0
    def send_ride_mails(self):
        if self.rides_mails_sent is True:
            log_event(event="Not sending ride mails for round %d because "
                      "rides_mails_sent is True" % self.pk)
            return

        log_event(event="Sending ride mails for round %d" % self.pk)

        mail_template = get_template_by_id(config.RIDE_MAIL)

        self.rides_mails_sent = True
        self.save()

        rides = self.rides.all()
        for ride in rides:
            involved = {
                ride.driver, ride.codriver, self.distribution_coordinator
            }
            for user in involved:
                if user is None:
                    continue
                rendered_template_vars = render_mail_template(
                    mail_template,
                    user=user,
                    ride=ride,
                    base_url=settings.BASE_URL)
                mail_user(user, *rendered_template_vars)
예제 #2
0
 def mail_confirmation(self):
     """
     Send confirmation mail to user about successful order placement
     """
     mail_template = get_template_by_id(ORDER_CONFIRM_MAIL_ID)
     rendered_template_vars = render_mail_template(mail_template, user=self.user, order=self)
     mail_user(self.user, *rendered_template_vars)
예제 #3
0
파일: models.py 프로젝트: rikva/voko
    def send_prepare_ride_mails(self):
        if self.prepare_ride_mails_sent is True:
            log_event(event="Not sending prepare ride mails for round %d "
                            "because prepare_ride_mails_sent is True" %
                            self.pk)
            return

        log_event(event="Sending prepare ride mails for round %d" % self.pk)

        mail_template = get_template_by_id(config.PREPARE_RIDE_MAIL)

        self.prepare_ride_mails_sent = True
        self.save()

        rides = self.rides.all()
        for ride in rides:
            drivers = [ride.driver, ride.codriver]
            for user in drivers:
                rendered_template_vars = render_mail_template(
                    mail_template,
                    user=user,
                    ride=ride,
                    base_url=settings.BASE_URL
                )
                mail_user(user, *rendered_template_vars)
예제 #4
0
 def mail_failure_notification(self):
     """
     Use when order was paid after round has closed (corner case)
     """
     mail_template = get_template_by_id(ORDER_FAILED_ID)
     rendered_template_vars = render_mail_template(mail_template, user=self.user, order=self)
     mail_user(self.user, *rendered_template_vars)
예제 #5
0
파일: models.py 프로젝트: rikva/voko
    def send_ride_mails(self):
        if self.rides_mails_sent is True:
            log_event(event="Not sending ride mails for round %d because "
                            "rides_mails_sent is True" % self.pk)
            return

        log_event(event="Sending ride mails for round %d" % self.pk)

        mail_template = get_template_by_id(config.RIDE_MAIL)

        self.rides_mails_sent = True
        self.save()

        rides = self.rides.all()
        for ride in rides:
            involved = {
                ride.driver,
                ride.codriver,
                self.distribution_coordinator
            }
            for user in involved:
                if user is None:
                    continue
                rendered_template_vars = render_mail_template(
                    mail_template,
                    user=user,
                    ride=ride,
                    base_url=settings.BASE_URL
                )
                mail_user(user, *rendered_template_vars)
예제 #6
0
 def send_email(self):
     mail_template = get_template_by_id(config.PASSWORD_RESET_MAIL)
     rendered_template_vars = render_mail_template(
         mail_template,
         user=self.user,
         url=settings.BASE_URL + reverse('reset_pass', args=(self.pk, )))
     mail_user(self.user, *rendered_template_vars)
예제 #7
0
파일: models.py 프로젝트: rikva/voko
 def send_email(self):
     mail_template = get_template_by_id(config.PASSWORD_RESET_MAIL)
     rendered_template_vars = render_mail_template(
         mail_template,
         user=self.user,
         url=settings.BASE_URL + reverse('reset_pass', args=(self.pk,))
     )
     mail_user(self.user, *rendered_template_vars)
예제 #8
0
 def mail_failure_notification(self):
     """
     Use when order was paid after round has been closed (corner case)
     """
     mail_template = get_template_by_id(config.ORDER_FAILED_MAIL)
     rendered_template_vars = render_mail_template(mail_template,
                                                   user=self.user,
                                                   order=self)
     mail_user(self.user, *rendered_template_vars)
예제 #9
0
 def mail_confirmation(self):
     """
     Send confirmation mail to user about successful order placement
     """
     mail_template = get_template_by_id(config.ORDER_CONFIRM_MAIL)
     rendered_template_vars = render_mail_template(mail_template,
                                                   user=self.user,
                                                   order=self)
     mail_user(self.user, *rendered_template_vars)
예제 #10
0
파일: views.py 프로젝트: thomaspaulb/voko
    def _send_mails(self):
        for user in self.users:
            (subject, html_message, plain_message,
             from_email) = render_mail_template(
                 self.template,
                 user=user,
                 order_round=self.current_order_round)

            mail_user(user, subject, html_message, plain_message, from_email)

            log_event(operator=self.request.user,
                      user=user,
                      event="Mail verstuurd met onderwerp '%s'" % subject,
                      extra=html_message)
예제 #11
0
def enable_user(modeladmin, request, queryset):
    for user in queryset:
        if not user.email_confirmation.is_confirmed or user.is_active:
            return

    queryset.update(can_activate=True)

    for user in queryset:
        # send mail
        mail_template = get_template_by_id(config.ACTIVATE_ACCOUNT_MAIL)
        (subject, html_message, plain_message,
         from_email) = render_mail_template(mail_template, user=user)
        mail_user(user, subject, html_message, plain_message, from_email)
        log.log_event(
            user=user,
            event="User set to 'can_activate=True' and activation mail sent",
            extra=html_message)
예제 #12
0
파일: models.py 프로젝트: rikva/voko
    def send_reminder_mails(self):
        if self.reminder_sent is True:
            log_event(event="Not sending order reminder for round %d because "
                            "reminder_sent is True" % self.pk)

            return

        log_event(event="Sending order reminder for round %d" % self.pk)

        mail_template = get_template_by_id(config.ORDER_REMINDER_MAIL)

        self.reminder_sent = True
        self.save()

        for user in self.get_users_without_orders():
            rendered_template_vars = render_mail_template(
                mail_template, user=user, order_round=self)
            mail_user(user, *rendered_template_vars)
예제 #13
0
파일: views.py 프로젝트: rikva/voko
    def _send_mails(self):
        for user in self.users:
            (
                subject,
                html_message,
                plain_message,
                from_email
            ) = render_mail_template(
                self.template,
                user=user,
                order_round=self.current_order_round
            )

            mail_user(user, subject, html_message, plain_message, from_email)

            log_event(operator=self.request.user,
                      user=user,
                      event="Mail verstuurd met onderwerp '%s'" % subject,
                      extra=html_message)
예제 #14
0
    def send_reminder_mails(self):
        if self.reminder_sent is True:
            log_event(event="Not sending order reminder for round %d because "
                      "reminder_sent is True" % self.pk)

            return

        log_event(event="Sending order reminder for round %d" % self.pk)

        mail_template = get_template_by_id(config.ORDER_REMINDER_MAIL)

        self.reminder_sent = True
        self.save()

        for user in self.get_users_without_orders():
            rendered_template_vars = render_mail_template(mail_template,
                                                          user=user,
                                                          order_round=self)
            mail_user(user, *rendered_template_vars)
예제 #15
0
    def send_distribution_mails(self):
        if self.distribution_mails_sent is True:
            log_event(event="Not sending distribution mails for round %d "
                      "because distribution_mails_sent is True" % self.pk)
            return

        log_event(event="Sending distribution mails for round %d" % self.pk)

        mail_template = get_template_by_id(config.DISTRIBUTION_MAIL)

        self.distribution_mails_sent = True
        self.save()

        shifts = self.distribution_shifts.all()
        for shift in shifts:
            for user in shift.members.all():
                rendered_template_vars = render_mail_template(
                    mail_template,
                    user=user,
                    shift=shift,
                    base_url=settings.BASE_URL)
                mail_user(user, *rendered_template_vars)
예제 #16
0
    def send_prepare_ride_mails(self):
        if self.prepare_ride_mails_sent is True:
            log_event(event="Not sending prepare ride mails for round %d "
                      "because prepare_ride_mails_sent is True" % self.pk)
            return

        log_event(event="Sending prepare ride mails for round %d" % self.pk)

        mail_template = get_template_by_id(config.PREPARE_RIDE_MAIL)

        self.prepare_ride_mails_sent = True
        self.save()

        rides = self.rides.all()
        for ride in rides:
            drivers = [ride.driver, ride.codriver]
            for user in drivers:
                rendered_template_vars = render_mail_template(
                    mail_template,
                    user=user,
                    ride=ride,
                    base_url=settings.BASE_URL)
                mail_user(user, *rendered_template_vars)
예제 #17
0
파일: admin.py 프로젝트: rikva/voko
def enable_user(modeladmin, request, queryset):
    for user in queryset:
        if not user.email_confirmation.is_confirmed or user.is_active:
            return

    queryset.update(can_activate=True)

    for user in queryset:
        # send mail
        mail_template = get_template_by_id(config.ACTIVATE_ACCOUNT_MAIL)
        (
            subject,
            html_message,
            plain_message,
            from_email
        ) = render_mail_template(
            mail_template, user=user
        )
        mail_user(user, subject, html_message, plain_message, from_email)
        log.log_event(
            user=user,
            event="User set to 'can_activate=True' and activation mail sent",
            extra=html_message
        )
예제 #18
0
 def send_confirmation_mail(self):
     mail_template = get_template_by_id(config.CONFIRM_MAIL)
     rendered_template_vars = render_mail_template(mail_template,
                                                   user=self.user)
     mail_user(self.user, *rendered_template_vars)
예제 #19
0
파일: models.py 프로젝트: rikva/voko
 def send_confirmation_mail(self):
     mail_template = get_template_by_id(config.CONFIRM_MAIL)
     rendered_template_vars = render_mail_template(mail_template,
                                                   user=self.user)
     mail_user(self.user, *rendered_template_vars)