Esempio n. 1
0
    def handle(self, *args, **options):
        num_applications = options['num'][0]
        fake = Faker()

        available_partners = Partner.objects.all()
        # Don't fire any applications from the superuser.
        all_users = User.objects.exclude(is_superuser=True)

        import_date = datetime.datetime(2017, 7, 17, 0, 0, 0)

        for _ in range(num_applications):
            random_user = random.choice(all_users)
            random_partner = random.choice(available_partners)

            app = ApplicationFactory(
                editor = random_user.editor,
                partner = random_partner,
                hidden = self.chance(True, False, 10)
                )

            # Make sure partner-specific information is filled.
            if random_partner.specific_stream:
                app.specific_stream = random.choice(
                    Stream.objects.filter(partner=random_partner))

            if random_partner.specific_title:
                app.specific_title = fake.sentence(nb_words= 3)

            if random_partner.agreement_with_terms_of_use:
                app.agreement_with_terms_of_use = True

            if random_partner.account_email:
                app.account_email = fake.email()

            # Imported applications have very specific information, and were
            # all imported on the same date.
            imported = self.chance(True, False, 50)

            if imported:
                app.status = Application.SENT
                app.date_created = import_date
                app.date_closed = import_date
                app.rationale = "Imported on 2017-07-17"
                app.comments = "Imported on 2017-07-17"
                app.imported = True
            else:
                app.status = random.choice(Application.STATUS_CHOICES)[0]
                app.date_created = fake.date_time_between(
                    start_date = random_user.editor.wp_registered,
                    end_date = "now",
                    tzinfo=None)
                app.rationale = fake.paragraph(nb_sentences=3)
                app.comments = fake.paragraph(nb_sentences=2)

            # For closed applications, assign date_closed and date_open
            if app.status in Application.FINAL_STATUS_LIST:
                if not imported:
                    potential_end_date = app.date_created + relativedelta(years=1)
                    if potential_end_date > datetime.datetime.now():
                        end_date = "now"
                    else:
                        end_date = potential_end_date
                    app.date_closed = fake.date_time_between(
                        start_date = app.date_created,
                        end_date = end_date,
                        tzinfo=None)
                    app.days_open = (app.date_closed - app.date_created).days

            if app.status == Application.SENT:
                # Assign sent_by if this is a non-imported sent applications
                if not imported:
                    app.sent_by = random_partner.coordinator

                # If this partner has access codes, assign a code to
                # this sent application.
                if random_partner.authorization_method == Partner.CODES:
                    this_partner_access_codes = AccessCode.objects.filter(
                        partner=random_partner,
                        authorization__isnull=True)
                    app_code = random.choice(this_partner_access_codes)
                    #app_code.application = app
                    app_code.save()
            app.save()

        # Renew a selection of sent apps.
        all_apps = Application.objects.filter(status=Application.SENT)
        num_to_renew = int(all_apps.count()*0.5)
        for app_to_renew in random.sample(all_apps, num_to_renew):
            app_to_renew.renew()
Esempio n. 2
0
 def test_approval_calls_email_function(self, mock_email):
     app = ApplicationFactory(status=Application.PENDING)
     app.status = Application.APPROVED
     app.save()
     self.assertTrue(mock_email.called)
Esempio n. 3
0
    def setUp(self):
        super(AuthorizationBaseTestCase, self).setUp()

        self.partner1 = PartnerFactory(authorization_method=Partner.EMAIL,
                                       status=Partner.AVAILABLE)
        self.partner2 = PartnerFactory(authorization_method=Partner.PROXY,
                                       status=Partner.AVAILABLE)
        self.partner3 = PartnerFactory(authorization_method=Partner.CODES,
                                       status=Partner.AVAILABLE)
        self.partner4 = PartnerFactory(authorization_method=Partner.EMAIL,
                                       status=Partner.AVAILABLE)

        self.editor1 = EditorFactory()
        self.editor1.user.email = fake.email()
        self.editor1.user.save()
        self.editor2 = EditorFactory()
        self.editor3 = EditorFactory()
        # Editor 4 is a coordinator with a session.
        self.editor4 = EditorCraftRoom(self, Terms=True, Coordinator=True)
        # Editor 4 is the designated coordinator for all partners.
        self.partner1.coordinator = self.editor4.user
        self.partner1.account_length = timedelta(days=180)
        self.partner1.target_url = 'http://test.localdomain'
        self.partner1.save()
        self.partner2.coordinator = self.editor4.user
        self.partner2.save()
        self.partner3.coordinator = self.editor4.user
        self.partner3.save()
        self.partner4.coordinator = self.editor4.user
        self.partner4.save()

        # Editor 5 is a coordinator without a session and with no designated partners.
        self.editor5 = EditorFactory()
        coordinators.user_set.add(self.editor5.user)

        # Create applications.
        self.app1 = ApplicationFactory(editor=self.editor1,
                                       partner=self.partner1,
                                       status=Application.PENDING)
        self.app2 = ApplicationFactory(editor=self.editor2,
                                       partner=self.partner1,
                                       status=Application.PENDING)
        self.app3 = ApplicationFactory(editor=self.editor3,
                                       partner=self.partner1,
                                       status=Application.PENDING)
        self.app4 = ApplicationFactory(editor=self.editor1,
                                       partner=self.partner2,
                                       status=Application.PENDING)
        self.app5 = ApplicationFactory(editor=self.editor2,
                                       partner=self.partner2,
                                       status=Application.PENDING)
        self.app6 = ApplicationFactory(editor=self.editor3,
                                       partner=self.partner2,
                                       status=Application.PENDING)
        self.app7 = ApplicationFactory(editor=self.editor1,
                                       partner=self.partner3,
                                       status=Application.PENDING)
        self.app8 = ApplicationFactory(editor=self.editor1,
                                       partner=self.partner4,
                                       status=Application.PENDING)
        self.app9 = ApplicationFactory(editor=self.editor2,
                                       partner=self.partner3,
                                       status=Application.PENDING)

        # Editor 4 will update status on applications to partners 1 and 2.
        # Send the application
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app1.pk}),
            data={"status": Application.SENT},
            follow=True,
        )
        self.app1.refresh_from_db()
        self.auth_app1 = Authorization.objects.get(
            authorizer=self.editor4.user,
            authorized_user=self.editor1.user,
            partner=self.partner1,
        )

        # Approve the application
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app2.pk}),
            data={"status": Application.APPROVED},
            follow=True,
        )
        self.app2.refresh_from_db()
        self.auth_app2 = Authorization(
            authorizer=self.editor4.user,
            authorized_user=self.editor2.user,
            partner=self.partner1,
        )

        # Send the application
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app3.pk}),
            data={"status": Application.SENT},
            follow=True,
        )
        self.app3.refresh_from_db()
        self.auth_app3 = Authorization.objects.get(
            authorizer=self.editor4.user,
            authorized_user=self.editor3.user,
            partner=self.partner1,
        )

        # Send the application
        # PROXY authorization methods don't set .SENT on the evaluate page;
        # .APPROVED will automatically update them to .SENT
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app4.pk}),
            data={"status": Application.APPROVED},
            follow=True,
        )
        self.app4.refresh_from_db()
        self.auth_app4 = Authorization.objects.get(
            # https://phabricator.wikimedia.org/T233508
            # authorizer=self.editor4.user,
            authorized_user=self.editor1.user,
            partner=self.partner2,
        )

        # Send the application
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app5.pk}),
            data={"status": Application.APPROVED},
            follow=True,
        )
        self.app5.refresh_from_db()
        self.auth_app5 = Authorization.objects.get(
            # https://phabricator.wikimedia.org/T233508
            # authorizer=self.editor4.user,
            authorized_user=self.editor2.user,
            partner=self.partner2,
        )

        # Set up an access code to distribute
        self.access_code = AccessCode(code="ABCD-EFGH-IJKL",
                                      partner=self.partner3)
        self.access_code.save()

        self.message_patcher = patch(
            "TWLight.applications.views.messages.add_message")
        self.message_patcher.start()
Esempio n. 4
0
 def test_rerejection_does_not_call_email_function(self, mock_email):
     app = ApplicationFactory(status=Application.PENDING)
     app.status = Application.NOT_APPROVED
     app.save()
     app.save()
     self.assertEqual(mock_email.call_count, 1)
    def handle(self, *args, **options):
        num_applications = options["num"][0]

        available_partners = Partner.objects.all()
        # Don't fire any applications from the superuser.
        all_editors = Editor.objects.exclude(user__is_superuser=True)

        import_date = datetime.datetime(2017, 7, 17, 0, 0, 0)

        # We want to flag applications as SENT via a client later, so let's only
        # automatically give applications non-Sent statuses.
        valid_choices = [
            Application.PENDING,
            Application.QUESTION,
            Application.APPROVED,
            Application.NOT_APPROVED,
            Application.INVALID,
        ]

        for _ in range(num_applications):
            random_editor = random.choice(all_editors)
            # Limit to partners this user hasn't already applied to.
            not_applied_partners = available_partners.exclude(
                applications__editor=random_editor)

            if not_applied_partners:
                random_partner = random.choice(not_applied_partners)
                app = ApplicationFactory(
                    editor=random_editor,
                    partner=random_partner,
                    hidden=self.chance(True, False, 10),
                )

                # Make sure partner-specific information is filled.
                if random_partner.specific_stream:
                    app.specific_stream = random.choice(
                        Stream.objects.filter(partner=random_partner))

                if random_partner.specific_title:
                    app.specific_title = Faker(
                        random.choice(
                            settings.FAKER_LOCALES)).sentence(nb_words=3)

                if random_partner.agreement_with_terms_of_use:
                    app.agreement_with_terms_of_use = True

                if random_partner.account_email:
                    app.account_email = Faker(
                        random.choice(settings.FAKER_LOCALES)).email()

                # Imported applications have very specific information, and were
                # all imported on the same date.
                imported = self.chance(True, False, 50)

                if imported:
                    app.status = Application.SENT
                    app.date_created = import_date
                    app.date_closed = import_date
                    app.rationale = "Imported on 2017-07-17"
                    app.comments = "Imported on 2017-07-17"
                    app.imported = True
                else:
                    app.status = random.choice(valid_choices)

                    # Figure out earliest valid date for this app
                    if random_editor.wp_registered < import_date.date():
                        start_date = import_date
                    else:
                        start_date = random_editor.wp_registered

                    app.date_created = Faker(
                        random.choice(
                            settings.FAKER_LOCALES)).date_time_between(
                                start_date=start_date,
                                end_date="now",
                                tzinfo=None)
                    app.rationale = Faker(random.choice(
                        settings.FAKER_LOCALES)).paragraph(nb_sentences=3)
                    app.comments = Faker(random.choice(
                        settings.FAKER_LOCALES)).paragraph(nb_sentences=2)

                # For closed applications, assign date_closed and date_open
                if app.status in Application.FINAL_STATUS_LIST:
                    if not imported:
                        potential_end_date = app.date_created + relativedelta(
                            years=1)
                        if potential_end_date > datetime.datetime.now():
                            end_date = "now"
                        else:
                            end_date = potential_end_date
                        app.date_closed = Faker(
                            random.choice(
                                settings.FAKER_LOCALES)).date_time_between(
                                    start_date=app.date_created,
                                    end_date=end_date,
                                    tzinfo=None)
                        app.days_open = (app.date_closed -
                                         app.date_created).days
                # Make sure we always set sent_by
                if app.status == Application.SENT and not app.sent_by:
                    app.sent_by = twl_team

                app.save()

        # Let's mark all Approved applications that were approved more
        # than 3 weeks ago as Sent.
        old_approved_apps = Application.objects.filter(
            status=Application.APPROVED,
            date_created__lte=datetime.datetime.now() - relativedelta(weeks=3),
        )

        # We need to be able to handle messages
        message_patcher = patch(
            "TWLight.applications.views.messages.add_message")
        message_patcher.start()
        for approved_app in old_approved_apps:
            client = Client(SERVER_NAME="twlight.vagrant.localdomain")
            coordinator = logged_in_example_coordinator(
                client, approved_app.partner.coordinator)
            url = reverse("applications:send_partner",
                          kwargs={"pk": approved_app.partner.pk})

            this_partner_access_codes = AccessCode.objects.filter(
                partner=approved_app.partner, authorization__isnull=True)

            if approved_app.partner.authorization_method == Partner.EMAIL:
                request = RequestFactory().post(
                    url, data={"applications": [approved_app.pk]})

            # If this partner has access codes, assign a code to
            # this sent application.
            elif (this_partner_access_codes and
                  approved_app.partner.authorization_method == Partner.CODES):
                access_code = random.choice(this_partner_access_codes)
                request = RequestFactory().post(
                    url,
                    data={
                        "accesscode": [
                            "{app_pk}_{code}".format(app_pk=approved_app.pk,
                                                     code=access_code.code)
                        ]
                    },
                )

            request.user = coordinator

            response = SendReadyApplicationsView.as_view()(
                request, pk=approved_app.partner.pk)

        # Renew a selection of sent apps.
        all_apps = Application.objects.filter(status=Application.SENT)
        num_to_renew = int(all_apps.count() * 0.5)
        for app_to_renew in random.sample(list(all_apps), num_to_renew):
            app_to_renew.renew()

        for application in Application.objects.filter(
                status=Application.PENDING, parent__isnull=False):
            parent_application = Application.objects.get(
                pk=application.parent.pk)
            app_date = parent_application.date_closed

            renewal_date = Faker(random.choice(
                settings.FAKER_LOCALES)).date_time_between(start_date=app_date,
                                                           end_date="now",
                                                           tzinfo=None)
            application.date_created = renewal_date
            application.save()
Esempio n. 6
0
    def setUp(self):
        super(AuthorizationBaseTestCase, self).setUp()

        self.partner1 = PartnerFactory(authorization_method=Partner.EMAIL,
                                       status=Partner.AVAILABLE)
        self.partner2 = PartnerFactory(
            authorization_method=Partner.PROXY,
            status=Partner.AVAILABLE,
            requested_access_duration=True,
        )
        self.partner3 = PartnerFactory(authorization_method=Partner.CODES,
                                       status=Partner.AVAILABLE)
        self.partner4 = PartnerFactory(authorization_method=Partner.EMAIL,
                                       status=Partner.AVAILABLE)
        self.partner5 = PartnerFactory(
            authorization_method=Partner.EMAIL,
            status=Partner.AVAILABLE,
            specific_stream=True,
        )
        self.partner5_stream1 = StreamFactory(
            partner=self.partner5, authorization_method=Partner.EMAIL)
        self.partner5_stream2 = StreamFactory(
            partner=self.partner5, authorization_method=Partner.EMAIL)

        self.editor1 = EditorFactory()
        self.editor1.user.email = Faker(random.choice(
            settings.FAKER_LOCALES)).email()
        self.editor1.user.save()
        self.editor2 = EditorFactory()
        self.editor3 = EditorFactory()
        # Editor 4 is a coordinator with a session.
        self.editor4 = EditorCraftRoom(self, Terms=True, Coordinator=True)
        # Editor 4 is the designated coordinator for all partners.
        self.partner1.coordinator = self.editor4.user
        self.partner1.account_length = timedelta(days=180)
        self.partner1.target_url = "http://test.localdomain"
        self.partner1.save()
        self.partner2.coordinator = self.editor4.user
        self.partner2.save()
        self.partner3.coordinator = self.editor4.user
        self.partner3.save()
        self.partner4.coordinator = self.editor4.user
        self.partner4.save()
        self.partner5.coordinator = self.editor4.user
        self.partner5.save()

        # Editor 5 is a coordinator without a session and with no designated partners.
        self.editor5 = EditorFactory()
        coordinators.user_set.add(self.editor5.user)

        # Create applications.
        self.app1 = ApplicationFactory(editor=self.editor1,
                                       partner=self.partner1,
                                       status=Application.PENDING)
        self.app2 = ApplicationFactory(editor=self.editor2,
                                       partner=self.partner1,
                                       status=Application.PENDING)
        self.app3 = ApplicationFactory(editor=self.editor3,
                                       partner=self.partner1,
                                       status=Application.PENDING)
        self.app4 = ApplicationFactory(editor=self.editor1,
                                       partner=self.partner2,
                                       status=Application.PENDING)
        self.app5 = ApplicationFactory(editor=self.editor2,
                                       partner=self.partner2,
                                       status=Application.PENDING)
        self.app6 = ApplicationFactory(editor=self.editor3,
                                       partner=self.partner2,
                                       status=Application.PENDING)
        self.app7 = ApplicationFactory(editor=self.editor1,
                                       partner=self.partner3,
                                       status=Application.PENDING)
        self.app8 = ApplicationFactory(editor=self.editor1,
                                       partner=self.partner4,
                                       status=Application.PENDING)
        self.app9 = ApplicationFactory(editor=self.editor2,
                                       partner=self.partner3,
                                       status=Application.PENDING)
        self.app10 = ApplicationFactory(
            editor=self.editor1,
            partner=self.partner5,
            specific_stream=self.partner5_stream1,
            status=Application.PENDING,
        )
        self.app11 = ApplicationFactory(
            editor=self.editor1,
            partner=self.partner5,
            specific_stream=self.partner5_stream2,
            status=Application.PENDING,
        )

        # Editor 4 will update status on applications to partners 1, 2, and 5.
        # Send the application
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app1.pk}),
            data={"status": Application.SENT},
            follow=True,
        )
        self.app1.refresh_from_db()
        self.auth_app1 = Authorization.objects.get(
            authorizer=self.editor4.user,
            user=self.editor1.user,
            partners=self.partner1)
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app10.pk}),
            data={"status": Application.SENT},
            follow=True,
        )
        self.app10.refresh_from_db()
        self.auth_app10 = Authorization.objects.get(
            authorizer=self.editor4.user,
            user=self.editor1.user,
            partners=self.partner5,
            stream=self.partner5_stream1,
        )
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app11.pk}),
            data={"status": Application.SENT},
            follow=True,
        )
        self.app11.refresh_from_db()
        self.auth_app11 = Authorization.objects.get(
            authorizer=self.editor4.user,
            user=self.editor1.user,
            partners=self.partner5,
            stream=self.partner5_stream2,
        )

        # Send the application
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app2.pk}),
            data={"status": Application.SENT},
            follow=True,
        )
        self.app2.refresh_from_db()
        self.auth_app2 = Authorization.objects.get(
            authorizer=self.editor4.user,
            user=self.editor2.user,
            partners=self.partner1)

        # Send the application
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app3.pk}),
            data={"status": Application.SENT},
            follow=True,
        )
        self.app3.refresh_from_db()
        self.auth_app3 = Authorization.objects.get(
            authorizer=self.editor4.user,
            user=self.editor3.user,
            partners=self.partner1)

        # PROXY authorization methods don't set .SENT on the evaluate page;
        # .APPROVED will automatically update them to .SENT

        # This app was created with a factory, which doesn't create a revision.
        # Let's update the status so that we have one.
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app4.pk}),
            data={"status": Application.QUESTION},
            follow=True,
        )
        # Approve the application
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app4.pk}),
            data={"status": Application.APPROVED},
            follow=True,
        )

        self.app4.refresh_from_db()
        self.auth_app4 = Authorization.objects.get(
            authorizer=self.editor4.user,
            user=self.editor1.user,
            partners=self.partner2)

        # This app was created with a factory, which doesn't create a revision.
        # Let's update the status so that we have one.
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app5.pk}),
            data={"status": Application.QUESTION},
            follow=True,
        )
        # Approve the application
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app5.pk}),
            data={"status": Application.APPROVED},
            follow=True,
        )
        self.app5.refresh_from_db()
        self.auth_app5 = Authorization.objects.get(
            authorizer=self.editor4.user,
            user=self.editor2.user,
            partners=self.partner2)

        # Set up an access code to distribute
        self.access_code = AccessCode(code="ABCD-EFGH-IJKL",
                                      partner=self.partner3)
        self.access_code.save()

        self.message_patcher = patch(
            "TWLight.applications.views.messages.add_message")
        self.message_patcher.start()
Esempio n. 7
0
    def _set_up_email_test_objects(self):
        app = ApplicationFactory(editor=self.editor.editor)

        factory = RequestFactory()
        request = factory.post(get_form_target())
        return app, request
    def handle(self, *args, **options):
        num_applications = options['num'][0]
        fake = Faker()

        available_partners = Partner.objects.all()
        # Don't fire any applications from the superuser.
        all_users = User.objects.exclude(is_superuser=True)

        for _ in range(num_applications):
            random_user = random.choice(all_users)
            random_partner = random.choice(available_partners)

            app = ApplicationFactory(
                editor = random_user.editor,
                partner = random_partner,
                hidden = self.chance(True, False, 10)
                )

            # Make sure partner-specific information is filled.
            if random_partner.specific_stream:
                app.specific_stream = random.choice(
                    Stream.objects.filter(partner=random_partner))

            if random_partner.specific_title:
                app.specific_title = fake.sentence(nb_words= 3)

            if random_partner.agreement_with_terms_of_use:
                app.agreement_with_terms_of_use = True

            if random_partner.account_email:
                app.account_email = fake.email()

            # Imported applications have very specific information, and were
            # all imported on the same date.
            imported = self.chance(True, False, 50)
            import_date = datetime.datetime(2017, 7, 17, 0, 0, 0)

            if imported:
                app.status = Application.SENT
                app.date_created = import_date
                app.date_closed = import_date
                app.rationale = "Imported on 2017-07-17"
                app.comments = "Imported on 2017-07-17"
            else:
                app.status = random.choice(Application.STATUS_CHOICES)[0]
                app.date_created = fake.date_time_between(
                    start_date = random_user.editor.wp_registered,
                    end_date = "now",
                    tzinfo=None)
                app.rationale = fake.paragraph(nb_sentences=3)
                app.comments = fake.paragraph(nb_sentences=2)

            # Assign sent_by if this is a non-imported sent applications
            if app.status == Application.SENT:
                if not imported:
                    app.sent_by = random_partner.coordinator
                    app.date_closed = fake.date_time_between(
                        start_date = app.date_created,
                        end_date = "now",
                        tzinfo=None)
                else:
                    app.date_closed = import_date

            app.save()

        # Renew a selection of apps.
        all_apps = Application.objects.all()
        num_to_renew = int(num_applications*0.3)
        for app_to_renew in random.sample(all_apps, num_to_renew):
            app_to_renew.renew()
Esempio n. 9
0
class AuthorizationBaseTestCase(TestCase):
    """
    Setup class for Authorization Object tests.
    Could possibly achieve the same effect via a new factory class.
    """
    def setUp(self):
        super(AuthorizationBaseTestCase, self).setUp()

        self.partner1 = PartnerFactory(authorization_method=Partner.EMAIL,
                                       status=Partner.AVAILABLE)
        self.partner2 = PartnerFactory(authorization_method=Partner.PROXY,
                                       status=Partner.AVAILABLE,
                                       requested_access_duration=True)
        self.partner3 = PartnerFactory(authorization_method=Partner.CODES,
                                       status=Partner.AVAILABLE)
        self.partner4 = PartnerFactory(authorization_method=Partner.EMAIL,
                                       status=Partner.AVAILABLE)

        self.editor1 = EditorFactory()
        self.editor1.user.email = fake.email()
        self.editor1.user.save()
        self.editor2 = EditorFactory()
        self.editor3 = EditorFactory()
        # Editor 4 is a coordinator with a session.
        self.editor4 = EditorCraftRoom(self, Terms=True, Coordinator=True)
        # Editor 4 is the designated coordinator for all partners.
        self.partner1.coordinator = self.editor4.user
        self.partner1.account_length = timedelta(days=180)
        self.partner1.target_url = 'http://test.localdomain'
        self.partner1.save()
        self.partner2.coordinator = self.editor4.user
        self.partner2.save()
        self.partner3.coordinator = self.editor4.user
        self.partner3.save()
        self.partner4.coordinator = self.editor4.user
        self.partner4.save()

        # Editor 5 is a coordinator without a session and with no designated partners.
        self.editor5 = EditorFactory()
        coordinators.user_set.add(self.editor5.user)

        # Create applications.
        self.app1 = ApplicationFactory(editor=self.editor1,
                                       partner=self.partner1,
                                       status=Application.PENDING)
        self.app2 = ApplicationFactory(editor=self.editor2,
                                       partner=self.partner1,
                                       status=Application.PENDING)
        self.app3 = ApplicationFactory(editor=self.editor3,
                                       partner=self.partner1,
                                       status=Application.PENDING)
        self.app4 = ApplicationFactory(editor=self.editor1,
                                       partner=self.partner2,
                                       status=Application.PENDING)
        self.app5 = ApplicationFactory(editor=self.editor2,
                                       partner=self.partner2,
                                       status=Application.PENDING)
        self.app6 = ApplicationFactory(editor=self.editor3,
                                       partner=self.partner2,
                                       status=Application.PENDING)
        self.app7 = ApplicationFactory(editor=self.editor1,
                                       partner=self.partner3,
                                       status=Application.PENDING)
        self.app8 = ApplicationFactory(editor=self.editor1,
                                       partner=self.partner4,
                                       status=Application.PENDING)
        self.app9 = ApplicationFactory(editor=self.editor2,
                                       partner=self.partner3,
                                       status=Application.PENDING)

        # Editor 4 will update status on applications to partners 1 and 2.
        # Send the application
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app1.pk}),
            data={"status": Application.SENT},
            follow=True,
        )
        self.app1.refresh_from_db()
        self.auth_app1 = Authorization.objects.get(
            authorizer=self.editor4.user,
            user=self.editor1.user,
            partner=self.partner1,
        )

        # Approve the application
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app2.pk}),
            data={"status": Application.APPROVED},
            follow=True,
        )
        self.app2.refresh_from_db()
        self.auth_app2 = Authorization(
            authorizer=self.editor4.user,
            user=self.editor2.user,
            partner=self.partner1,
        )

        # Send the application
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app3.pk}),
            data={"status": Application.SENT},
            follow=True,
        )
        self.app3.refresh_from_db()
        self.auth_app3 = Authorization.objects.get(
            authorizer=self.editor4.user,
            user=self.editor3.user,
            partner=self.partner1,
        )

        # PROXY authorization methods don't set .SENT on the evaluate page;
        # .APPROVED will automatically update them to .SENT

        # This app was created with a factory, which doesn't create a revision.
        # Let's update the status so that we have one.
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app4.pk}),
            data={"status": Application.QUESTION},
            follow=True,
        )
        # Approve the application
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app4.pk}),
            data={"status": Application.APPROVED},
            follow=True,
        )

        self.app4.refresh_from_db()
        self.auth_app4 = Authorization.objects.get(
            authorizer=self.editor4.user,
            user=self.editor1.user,
            partner=self.partner2,
        )

        # This app was created with a factory, which doesn't create a revision.
        # Let's update the status so that we have one.
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app5.pk}),
            data={"status": Application.QUESTION},
            follow=True,
        )
        # Approve the application
        self.client.post(
            reverse("applications:evaluate", kwargs={"pk": self.app5.pk}),
            data={"status": Application.APPROVED},
            follow=True,
        )
        self.app5.refresh_from_db()
        self.auth_app5 = Authorization.objects.get(
            authorizer=self.editor4.user,
            user=self.editor2.user,
            partner=self.partner2,
        )

        # Set up an access code to distribute
        self.access_code = AccessCode(code="ABCD-EFGH-IJKL",
                                      partner=self.partner3)
        self.access_code.save()

        self.message_patcher = patch(
            "TWLight.applications.views.messages.add_message")
        self.message_patcher.start()

    def tearDown(self):
        super(AuthorizationBaseTestCase, self).tearDown()
        self.partner1.delete()
        self.partner2.delete()
        self.partner3.delete()
        self.partner4.delete()
        self.access_code.delete()
        self.editor1.delete()
        self.editor2.delete()
        self.editor3.delete()
        self.editor4.delete()
        self.app1.delete()
        self.app2.delete()
        self.app3.delete()
        self.app4.delete()
        self.app5.delete()
        self.app6.delete()
        self.app7.delete()
        self.app8.delete()
        self.app9.delete()