def handle(self, *args, **options):
        """Prepares a list of reps to be notified and the required
        template variables.

        """
        date = go_back_n_months(datetime.today(), 1)
        rep_group = Group.objects.get(name='Rep')
        reps = (rep_group.user_set
                .exclude(userprofile__registration_complete=False)
                .exclude(reports__month__year=date.year,
                         reports__month__month=date.month))
        reps_without_report = reps.values_list('id', flat=True)

        month = number2month(date.month)
        subject = self.SUBJECT % month
        data = {'year': date.year, 'month': month}

        if options['dry_run']:
            email_reps = reps.values_list('email', flat=True)
            for recipient in email_reps:
                msg = 'Second notification sent to %s' % recipient
                print(msg)
        else:
            send_remo_mail(reps_without_report, subject,
                           self.EMAIL_TEMPLATE, data)
    def handle(self, *args, **options):
        """Prepares a list of reps to be notified and the required
        template variables.

        """
        rep_group = Group.objects.get(name='Rep')
        reps = rep_group.user_set.exclude(
            userprofile__registration_complete=False)
        date = go_back_n_months(datetime.today(), 2)

        reps_without_report = reps.exclude(reports__month__year=date.year,
                                           reports__month__month=date.month)

        mentors = [rep.userprofile.mentor.id for rep in reps_without_report]

        month = number2month(date.month)
        subject = self.SUBJECT % month
        data = {'year': date.year, 'month': month,
                'reps_without_report': reps_without_report}

        if options['dry_run']:
            for mentor in mentors:
                msg = 'Email sent to mentor: %d' % mentor
                print(msg)
        else:
            send_remo_mail(mentors, subject, self.EMAIL_TEMPLATE, data)
Exemplo n.º 3
0
    def handle(self, *args, **options):
        """Prepares a list of reps to be notified and the required
        template variables.

        """
        date = go_back_n_months(datetime.today(), 2)
        rep_group = Group.objects.get(name='Rep')
        reps = (rep_group.user_set
                .exclude(userprofile__registration_complete=False)
                .exclude(reports__month__year=date.year,
                         reports__month__month=date.month))
        reps_without_report = reps.values_list('id', flat=True)

        month = number2month(date.month)
        subject = self.SUBJECT % month
        data = {'year': date.year, 'month': month}

        if options['dry_run']:
            email_reps = reps.values_list('email', flat=True)
            for recipient in email_reps:
                msg = 'Third notification sent to %s' % recipient
                print(msg)
        else:
            send_remo_mail(reps_without_report, subject,
                           self.EMAIL_TEMPLATE, data)
    def handle(self, *args, **options):
        """Prepares a list of reps to be notified and the required
        template variables.

        """
        rep_group = Group.objects.get(name="Rep")
        reps = rep_group.user_set.exclude(userprofile__registration_complete=False)
        date = go_back_n_months(datetime.datetime.today(), 1)
        data = {"year": date.year, "month": number2month(date.month)}

        send_remo_mail(reps, self.SUBJECT, self.EMAIL_TEMPLATE, data)
Exemplo n.º 5
0
    def handle(self, *args, **options):
        """Prepares a list of reps to be notified and the required
        template variables.

        """
        rep_group = Group.objects.get(name='Rep')
        reps = rep_group.user_set.exclude(
            userprofile__registration_complete=False)
        date = go_back_n_months(datetime.datetime.today(), 1)
        month = number2month(date.month)
        subject = self.SUBJECT % month
        data = {'year': date.year, 'month': month}

        send_remo_mail(reps, subject, self.EMAIL_TEMPLATE, data)
    def handle(self, *args, **options):
        """Prepares a list of reps to be notified and the required
        template variables.

        """
        rep_group = Group.objects.get(name='Rep')
        reps = (rep_group.user_set
                .exclude(userprofile__registration_complete=False)
                .values_list('id', flat=True))
        date = go_back_n_months(datetime.datetime.today(), 1)
        month = number2month(date.month)
        subject = self.SUBJECT % month
        data = {'year': date.year, 'month': month}

        send_remo_mail(reps, subject, self.EMAIL_TEMPLATE, data)
    def handle(self, *args, **options):
        """Prepares a list of reps to be notified and the required
        template variables.

        """
        rep_group = Group.objects.get(name='Rep')
        reps = rep_group.user_set.exclude(
            userprofile__registration_complete=False)
        date = go_back_n_months(datetime.datetime.today(), 1)
        reps_without_report = reps.exclude(reports__month__year=date.year,
                                           reports__month__month=date.month)

        data = {'year': date.year, 'month': number2month(date.month)}

        send_remo_mail(reps_without_report, self.SUBJECT,
                       self.EMAIL_TEMPLATE, data)
    def handle(self, *args, **options):
        """Prepares a list of reps to be notified and the required
        template variables.

        """
        rep_group = Group.objects.get(name="Rep")
        reps = rep_group.user_set.exclude(userprofile__registration_complete=False)
        date = go_back_n_months(datetime.datetime.today(), 2)

        reps_without_report = reps.exclude(reports__month__year=date.year, reports__month__month=date.month)

        mentors = [rep.userprofile.mentor.id for rep in reps_without_report]

        month = number2month(date.month)
        subject = self.SUBJECT % month
        data = {"year": date.year, "month": month, "reps_without_report": reps_without_report}

        send_remo_mail(mentors, subject, self.EMAIL_TEMPLATE, data)
    def handle(self, *args, **options):
        """Prepares a list of reps to be notified and the required
        template variables.

        """
        rep_group = Group.objects.get(name="Rep")
        reps = rep_group.user_set.exclude(userprofile__registration_complete=False)
        id_reps = reps.values_list("id", flat=True)

        date = go_back_n_months(datetime.datetime.today(), 1)
        month = number2month(date.month)

        subject = self.SUBJECT % month
        data = {"year": date.year, "month": month}

        if options["dry_run"]:
            email_reps = reps.values_list("email", flat=True)
            for recipient in email_reps:
                msg = "First notification sent to %s" % recipient
                print(msg)
        else:
            send_remo_mail(id_reps, subject, self.EMAIL_TEMPLATE, data)