Exemplo n.º 1
0
Arquivo: models.py Projeto: 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)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 6
0
Arquivo: models.py Projeto: 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)
Exemplo n.º 7
0
Arquivo: models.py Projeto: 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 10
0
    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)
Exemplo n.º 11
0
    def get_context_data(self, **kwargs):
        context = super(PreviewMailView, self).get_context_data(**kwargs)

        users = [VokoUser.objects.get(pk=uid) for uid in self.request.session.get('mailing_user_ids')]
        context['mailing_users'] = users

        template = MailTemplate.objects.get(pk=self.kwargs.get('pk'))
        context['template'] = template

        context['example'] = render_mail_template(template,
                                                  user=self.request.user,
                                                  order_round=self.request.current_order_round)

        return context
Exemplo n.º 12
0
    def _send_mails(self):
        for user in self.users:
            subject, html_message, plain_message = render_mail_template(self.template,
                                                                        user=user,
                                                                        order_round=self.current_order_round)

            send_mail(subject=subject,
                      message=plain_message,
                      from_email="VOKO Utrecht <*****@*****.**>",
                      recipient_list=["%s <%s>" % (user.get_full_name(), user.email)],
                      html_message=html_message)

            log_event(operator=self.request.user,
                      user=user,
                      event="Mail verstuurd met onderwerp '%s'" % subject,
                      extra=html_message)
Exemplo n.º 13
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)
Exemplo n.º 14
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(ACTIVATE_ACCOUNT_MAILTEMPLATE_ID)
        subject, html_message, plain_message = render_mail_template(mail_template, user=user)
        send_mail(subject=subject,
                  message=plain_message,
                  from_email="VOKO Utrecht <*****@*****.**>",
                  recipient_list=["%s <%s>" % (user.get_full_name(), user.email)],
                  html_message=html_message)
        log.log_event(user=user, event="User set to 'can_activate=True' and activation mail sent", extra=html_message)
Exemplo n.º 15
0
Arquivo: models.py Projeto: 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)
Exemplo n.º 16
0
    def get_context_data(self, **kwargs):
        context = super(PreviewMailView, self).get_context_data(**kwargs)

        users = [
            VokoUser.objects.get(pk=uid)
            for uid in self.request.session.get('mailing_user_ids')
        ]
        context['mailing_users'] = users

        template = MailTemplate.objects.get(pk=self.kwargs.get('pk'))
        context['template'] = template

        context['example'] = render_mail_template(
            template,
            user=self.request.user,
            order_round=self.request.current_order_round)

        return context
Exemplo n.º 17
0
Arquivo: views.py Projeto: 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)
Exemplo n.º 18
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)
Exemplo n.º 19
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)
Exemplo n.º 20
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)
Exemplo n.º 21
0
Arquivo: admin.py Projeto: 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
        )
Exemplo n.º 22
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)
Exemplo n.º 23
0
Arquivo: models.py Projeto: 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)