def test_date_changed(self):
        assignment = AssignmentFactory(
            title='Test Title',
            status='open',
            date=now() + timedelta(days=4),
        )
        ApplicantFactory.create_batch(3, activity=assignment, status='new')
        ApplicantFactory.create_batch(3,
                                      activity=assignment,
                                      status='accepted')
        withdrawn = ApplicantFactory.create(activity=assignment, status='new')
        withdrawn.states.withdraw(save=True)

        mail.outbox = []

        assignment.date = assignment.date + timedelta(days=1)
        assignment.save()

        messages = dict(
            (message.to[0], message.body) for message in mail.outbox)

        for participant in assignment.contributions.instance_of(
                Applicant).all():
            if participant.status in ('new', 'accepted'):
                self.assertTrue(participant.user.email in messages)
                self.assertTrue(
                    formats.date_format(assignment.date) in messages[
                        participant.user.email])
            else:
                self.assertFalse(participant.user.email in messages)
示例#2
0
    def test_sort_activity_date(self):
        first = InitiativeFactory.create(status='approved')
        FundingFactory.create(initiative=first,
                              status='open',
                              deadline=now() + datetime.timedelta(days=8))
        FundingFactory.create(initiative=first,
                              status='submitted',
                              deadline=now() + datetime.timedelta(days=7))

        second = InitiativeFactory.create(status='approved')
        EventFactory.create(initiative=second,
                            status='open',
                            start=now() + datetime.timedelta(days=7))
        third = InitiativeFactory.create(status='approved')
        EventFactory.create(initiative=third,
                            status='open',
                            start=now() + datetime.timedelta(days=7))
        AssignmentFactory.create(initiative=third,
                                 status='open',
                                 date=now() + datetime.timedelta(days=9))

        response = self.client.get(self.url + '?sort=activity_date',
                                   HTTP_AUTHORIZATION="JWT {0}".format(
                                       self.owner.get_jwt_token()))

        data = json.loads(response.content)

        self.assertEqual(data['meta']['pagination']['count'], 3)
        self.assertEqual(data['data'][0]['id'], str(third.pk))
        self.assertEqual(data['data'][1]['id'], str(first.pk))
        self.assertEqual(data['data'][2]['id'], str(second.pk))
示例#3
0
    def test_export(self):
        from_date = now() - timedelta(weeks=2)
        to_date = now() + timedelta(weeks=1)
        data = {'from_date': from_date, 'to_date': to_date, '_save': 'Confirm'}
        tenant = connection.tenant
        initiatives = InitiativeFactory.create_batch(4)
        for initiative in initiatives:
            EventFactory.create_batch(3, initiative=initiative)
            AssignmentFactory.create_batch(2, initiative=initiative)
            FundingFactory.create_batch(1, initiative=initiative)

        result = plain_export(Exporter, tenant=tenant, **data)
        book = xlrd.open_workbook(result)
        self.assertEqual(book.sheet_by_name('Users').ncols, 11)
        self.assertEqual(book.sheet_by_name('Users').nrows, 41)
        self.assertEqual(book.sheet_by_name('Initiatives').nrows, 5)
        self.assertEqual(book.sheet_by_name('Funding activities').nrows, 5)
        self.assertEqual(book.sheet_by_name('Events').nrows, 13)
        self.assertEqual(
            book.sheet_by_name('Events').cell(0, 13).value, 'Start')
        self.assertEqual(
            book.sheet_by_name('Events').cell(0, 14).value, 'Time needed')

        self.assertEqual(book.sheet_by_name('Tasks').nrows, 9)
        self.assertEqual(
            book.sheet_by_name('Tasks').cell(0, 16).value, 'Preparation time')
        self.assertEqual(
            book.sheet_by_name('Tasks').cell(0, 17).value, 'Start time')
        self.assertEqual(
            book.sheet_by_name('Tasks').cell(0, 19).value, 'End date')
示例#4
0
    def test_sort_matching_skill(self):
        skill = SkillFactory.create()
        self.owner.skills.add(skill)
        self.owner.save()

        first = AssignmentFactory.create(status='full')
        ApplicantFactory.create_batch(3, activity=first, status='accepted')

        second = AssignmentFactory.create(status='full', expertise=skill)
        ApplicantFactory.create_batch(3, activity=second, status='accepted')

        third = AssignmentFactory.create(status='open')
        fourth = AssignmentFactory.create(status='open', expertise=skill)

        response = self.client.get(self.url + '?sort=popularity',
                                   user=self.owner)

        data = json.loads(response.content)

        self.assertEqual(data['meta']['pagination']['count'], 4)

        self.assertEqual(data['data'][0]['id'], str(fourth.pk))
        self.assertEqual(data['data'][1]['id'], str(third.pk))
        self.assertEqual(data['data'][2]['id'], str(second.pk))
        self.assertEqual(data['data'][3]['id'], str(first.pk))
示例#5
0
    def test_sort_matching_office_location(self):
        self.owner.location = LocationFactory.create(position='10.0, 20.0')
        self.owner.save()

        first = AssignmentFactory.create(status='full')
        ApplicantFactory.create_batch(3, activity=first, status='accepted')

        second = AssignmentFactory.create(
            status='full',
            is_online=False,
            location=GeolocationFactory.create(position=Point(20.0, 10.0)))
        ApplicantFactory.create_batch(3, activity=second, status='accepted')

        third = AssignmentFactory.create(status='open')
        fourth = AssignmentFactory.create(
            status='open',
            is_online=False,
            location=GeolocationFactory.create(position=Point(21.0, 9.0)))
        fifth = AssignmentFactory.create(
            status='open',
            is_online=False,
            location=GeolocationFactory.create(position=Point(20.0, 10.0)))

        response = self.client.get(self.url + '?sort=popularity',
                                   user=self.owner)

        data = json.loads(response.content)

        self.assertEqual(data['meta']['pagination']['count'], 5)

        self.assertEqual(data['data'][0]['id'], str(fifth.pk))
        self.assertEqual(data['data'][1]['id'], str(fourth.pk))
        self.assertEqual(data['data'][2]['id'], str(third.pk))
        self.assertEqual(data['data'][3]['id'], str(second.pk))
        self.assertEqual(data['data'][4]['id'], str(first.pk))
示例#6
0
    def test_filter_country(self):
        country1 = CountryFactory.create()
        country2 = CountryFactory.create()

        initiative1 = InitiativeFactory.create(place=GeolocationFactory.create(
            country=country1))
        initiative2 = InitiativeFactory.create(place=GeolocationFactory.create(
            country=country2))
        initiative3 = InitiativeFactory.create(place=GeolocationFactory.create(
            country=country1))
        initiative4 = InitiativeFactory.create(place=GeolocationFactory.create(
            country=country2))

        first = AssignmentFactory.create(status='full', initiative=initiative1)
        ApplicantFactory.create_batch(3, activity=first, status='accepted')

        second = AssignmentFactory.create(status='open',
                                          initiative=initiative3)

        third = AssignmentFactory.create(status='full', initiative=initiative2)
        ApplicantFactory.create_batch(3, activity=third, status='accepted')

        AssignmentFactory.create(status='open', initiative=initiative4)

        response = self.client.get(
            self.url +
            '?sort=popularity&filter[country]={}'.format(country1.id),
            user=self.owner)

        data = json.loads(response.content)

        self.assertEqual(data['meta']['pagination']['count'], 2)

        self.assertEqual(data['data'][0]['id'], str(second.pk))
        self.assertEqual(data['data'][1]['id'], str(first.pk))
示例#7
0
    def test_images(self):
        EventFactory.create(owner=self.owner,
                            review_status='approved',
                            image=ImageFactory.create())
        AssignmentFactory.create(review_status='approved',
                                 image=ImageFactory.create())
        FundingFactory.create(review_status='approved',
                              image=ImageFactory.create())

        response = self.client.get(self.url, user=self.owner)

        for activity in response.json()['data']:
            self.assertEqual(
                activity['relationships']['image']['data']['type'], 'images')
    def test_end_date_type_changed(self):
        assignment = AssignmentFactory(
            title='Test Title',
            status='open',
            end_date_type='on_date',
            preparation=5,
            date=now() + timedelta(days=4),
        )

        assignment.end_date_type = 'deadline'
        assignment.save()

        self.assertEqual(assignment.end_date_type, 'deadline')
        self.assertIsNone(assignment.preparation)
示例#9
0
    def test_export_impact(self):
        from_date = now() - timedelta(weeks=2)
        to_date = now() + timedelta(weeks=1)
        users = BlueBottleUserFactory.create_batch(5)

        co2 = ImpactType.objects.get(slug='co2')
        co2.active = True
        co2.save()
        water = ImpactType.objects.get(slug='water')
        water.active = True
        water.save()

        initiative = InitiativeFactory.create(owner=users[0])

        assignment = AssignmentFactory.create(owner=users[1],
                                              initiative=initiative)
        assignment.goals.create(type=co2, realized=300)
        assignment.goals.create(type=water, realized=750)

        data = {'from_date': from_date, 'to_date': to_date, '_save': 'Confirm'}
        tenant = connection.tenant
        result = plain_export(Exporter, tenant=tenant, **data)
        book = xlrd.open_workbook(result)

        self.assertEqual(
            book.sheet_by_name('Tasks').cell(0, 23).value,
            u'Reduce CO\u2082 emissions')
        self.assertEqual(book.sheet_by_name('Tasks').cell(1, 23).value, 300)
        self.assertEqual(
            book.sheet_by_name('Tasks').cell(0, 24).value, u'Save water')
        self.assertEqual(book.sheet_by_name('Tasks').cell(1, 24).value, 750)
示例#10
0
    def test_get_stats(self):
        event = EventFactory.create(initiative=self.initiative,
                                    status='succeeded')
        ParticipantFactory.create_batch(3,
                                        activity=event,
                                        status='succeeded',
                                        time_spent=3)

        assignment = AssignmentFactory.create(initiative=self.initiative,
                                              status='succeeded',
                                              duration=3)
        ApplicantFactory.create_batch(3,
                                      activity=assignment,
                                      status='succeeded',
                                      time_spent=3)

        funding = FundingFactory.create(initiative=self.initiative,
                                        status='succeeded')
        DonationFactory.create_batch(3,
                                     activity=funding,
                                     status='succeeded',
                                     amount=Money(10, 'EUR'))
        DonationFactory.create_batch(3,
                                     activity=funding,
                                     status='succeeded',
                                     amount=Money(10, 'USD'))

        response = self.client.get(self.url, user=self.owner)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        stats = response.json()['data']['meta']['stats']
        self.assertEqual(stats['hours'], 18)
        self.assertEqual(stats['activities'], 3)
        self.assertEqual(stats['contributions'], 12)
        self.assertEqual(stats['amount'], 75.0)
示例#11
0
 def test_task_textwallpost_admin(self):
     task = AssignmentFactory.create()
     self.wallpost = MediaWallpostFactory.create(content_object=task)
     url = reverse('admin:wallposts_mediawallpost_change', args=(self.wallpost.id, ))
     response = self.client.get(url)
     self.assertEqual(response.status_code, 200, response.content)
     self.assertContains(response, task.title)
示例#12
0
 def setUp(self):
     super(TestAssignmentAdmin, self).setUp()
     self.site = AdminSite()
     self.assignment_admin = AssignmentAdmin(Assignment, self.site)
     self.assignment = AssignmentFactory.create(status='created', end_date_type='on_date', preparation=5,)
     self.assignment_url = reverse('admin:assignments_assignment_change', args=(self.assignment.id,))
     self.assignment.save()
示例#13
0
    def test_date_not_changed(self):
        assignment = AssignmentFactory(
            title='Test Title',
            status='open',
            date=now() + timedelta(days=4),
        )
        ApplicantFactory.create_batch(3, activity=assignment, status='new')
        withdrawn = ApplicantFactory.create(activity=assignment, status='new')
        withdrawn.states.withdraw(save=True)

        mail.outbox = []

        assignment.title = 'New title'
        assignment.save()

        self.assertEqual(len(mail.outbox), 0)
示例#14
0
    def test_assignment_reminder_task_on_date(self):
        user = BlueBottleUserFactory.create(first_name='Nono')
        end = now() + timedelta(days=4)
        assignment = AssignmentFactory.create(
            owner=user,
            status='open',
            end_date_type='on_date',
            initiative=self.initiative,
            date=end
        )

        ApplicantFactory.create_batch(2, activity=assignment, status='new')
        ApplicantFactory.create(activity=assignment, status='accepted')
        withdrawn = ApplicantFactory.create(activity=assignment, status='new')
        withdrawn.states.withdraw(save=True)

        mail.outbox = []
        tenant = connection.tenant
        assignment_tasks()

        with LocalTenant(tenant, clear_tenant=True):
            assignment.refresh_from_db()

        recipients = [message.to[0] for message in mail.outbox]

        for applicant in assignment.contributions.instance_of(Applicant).all():
            if applicant.status in ['new', 'accepted']:
                self.assertTrue(applicant.user.email in recipients)
            else:
                self.assertFalse(applicant.user.email in recipients)
        self.assertEqual(
            mail.outbox[0].subject,
            '"{}" will take place in 5 days!'.format(assignment.title)
        )
示例#15
0
    def test_assignment_check_end_date_future(self):
        user = BlueBottleUserFactory.create(first_name='Nono')

        deadline = now() - timedelta(days=4)
        date = now() + timedelta(days=2)

        assignment = AssignmentFactory.create(
            owner=user,
            status='open',
            capacity=3,
            registration_deadline=deadline.date(),
            initiative=self.initiative,
            date=date,
        )

        applicants = ApplicantFactory.create_batch(3, activity=assignment)
        for applicant in applicants:
            applicant.states.accept(save=True)

        ApplicantFactory.create_batch(3, activity=assignment)

        tenant = connection.tenant

        future = timezone.now() + timedelta(days=3)
        with mock.patch.object(timezone, 'now', return_value=future):
            assignment_tasks()

        with LocalTenant(tenant, clear_tenant=True):
            assignment.refresh_from_db()

        self.assertEqual(assignment.status, 'succeeded')
        for applicant in assignment.applicants:
            self.assertEqual(applicant.status, 'succeeded')
示例#16
0
    def test_assignment_check_start_date(self):
        user = BlueBottleUserFactory.create(first_name='Nono')

        registration_deadline = now() - timedelta(days=1)
        date = now() + timedelta(hours=6)

        assignment = AssignmentFactory.create(
            owner=user,
            status='open',
            capacity=3,
            registration_deadline=registration_deadline.date(),
            initiative=self.initiative,
            end_date_type='on_date',
            duration=10,
            date=date
        )
        applicants = ApplicantFactory.create_batch(3, activity=assignment, status='new')
        for applicant in applicants:
            applicant.states.accept(save=True)

        tenant = connection.tenant
        with mock.patch.object(timezone, 'now', return_value=(timezone.now() + timedelta(hours=7))):
            assignment_tasks()

        with LocalTenant(tenant, clear_tenant=True):
            assignment.refresh_from_db()

        self.assertEqual(assignment.status, 'running')
示例#17
0
    def test_assignment_check_registration_deadline(self):
        user = BlueBottleUserFactory.create(first_name='Nono')

        deadline = now() - timedelta(days=1)
        end = now() + timedelta(days=4)

        assignment = AssignmentFactory.create(
            owner=user,
            status='open',
            capacity=3,
            end_date_type='on_date',
            registration_deadline=deadline.date(),
            initiative=self.initiative,
            duration=4,
            date=end,
        )
        applicants = ApplicantFactory.create_batch(3, activity=assignment, status='new')
        for applicant in applicants:
            applicant.states.accept(save=True)

        tenant = connection.tenant
        assignment_tasks()

        with LocalTenant(tenant, clear_tenant=True):
            assignment.refresh_from_db()

        self.assertEqual(assignment.status, 'full')
示例#18
0
 def setUp(self):
     super(AssignmentStatisticsTest, self).setUp()
     self.assignment = AssignmentFactory.create(
         owner=self.some_user,
         initiative=self.initiative,
         registration_deadline=(timezone.now() +
                                datetime.timedelta(hours=24)).date(),
         date=(timezone.now() + datetime.timedelta(hours=48)),
         duration=0.1)
     self.assignment.states.submit(save=True)
示例#19
0
    def setUp(self):
        super(UsedCountryListTestCase, self).setUp()

        belgium = Country.objects.get(translations__name="Belgium")
        location_be = GeolocationFactory.create(country=belgium)

        bulgaria = Country.objects.get(translations__name="Bulgaria")
        location_bg = GeolocationFactory.create(country=bulgaria)

        germany = Country.objects.get(translations__name="Germany")
        location_de = GeolocationFactory.create(country=germany)

        turkey = Country.objects.get(translations__name="Turkey")
        location_tr = LocationFactory.create(country=turkey)
        LocationFactory.create(country=Country.objects.get(translations__name='France'))

        EventFactory.create(
            status='open',
            location=location_be
        )
        EventFactory.create(
            status='full',
            location=location_bg
        )

        AssignmentFactory.create(
            status='draft',
            location=location_de
        )

        EventFactory.create(
            status='submitted',
            location=location_de
        )
        initiative = InitiativeFactory.create(
            status='approved',
            location=location_tr
        )
        FundingFactory.create(
            initiative=initiative,
            status='open'
        )
示例#20
0
    def setUp(self):
        super(AssignmentStateMachineTestCase, self).setUp()
        self.settings = InitiativePlatformSettingsFactory.create(
            activity_types=['assignment'])
        self.initiative = InitiativeFactory()
        self.initiative.states.submit()
        self.initiative.states.approve(save=True)

        self.assignment = AssignmentFactory.create(owner=self.initiative.owner,
                                                   initiative=self.initiative)
        mail.outbox = []
示例#21
0
    def test_incomplete(self):
        self.assignment = AssignmentFactory.create(owner=self.initiative.owner,
                                                   title='',
                                                   initiative=self.initiative)

        self.assertEqual(self.assignment.status,
                         AssignmentStateMachine.draft.value)

        organizer = self.assignment.contributions.get()
        self.assertTrue(isinstance(organizer, Organizer))
        self.assertEqual(organizer.status, OrganizerStateMachine.new.value)
        self.assertRaises(TransitionNotPossible, self.assignment.states.submit)
示例#22
0
    def test_activity_date_filter(self):
        next_month = now() + dateutil.relativedelta.relativedelta(months=1)
        after = now() + dateutil.relativedelta.relativedelta(months=2)

        event = EventFactory.create(status='open', start=next_month)
        EventFactory.create(status='open', start=after)

        on_date_assignment = AssignmentFactory.create(status='open',
                                                      date=next_month,
                                                      end_date_type='on_date')
        AssignmentFactory.create(status='open',
                                 date=after,
                                 end_date_type='on_date')
        deadline_assignment = AssignmentFactory.create(
            status='open', date=next_month, end_date_type='deadline')

        # Feature is not dealing with time. Disabling timezone check for test
        funding = FundingFactory.create(status='open', deadline=next_month)
        FundingFactory.create(status='open', deadline=after)

        response = self.client.get(self.url + '?filter[date]={}-{}-{}'.format(
            after.year, after.month, after.day),
                                   user=self.owner)

        data = json.loads(response.content)
        self.assertEqual(data['meta']['pagination']['count'], 3)

        response = self.client.get(self.url + '?filter[date]={}-{}-{}'.format(
            next_month.year, next_month.month, next_month.day),
                                   user=self.owner)

        data = json.loads(response.content)
        self.assertEqual(data['meta']['pagination']['count'], 4)

        found = [item['id'] for item in data['data']]

        self.assertTrue(str(event.pk) in found)
        self.assertTrue(str(on_date_assignment.pk) in found)
        self.assertTrue(str(deadline_assignment.pk) in found)
        self.assertTrue(str(funding.pk) in found)
示例#23
0
    def test_submit_initiative_not_submitted(self):
        self.assignment = AssignmentFactory.create(
            owner=self.initiative.owner, initiative=InitiativeFactory.create())

        self.assertEqual(self.assignment.status,
                         AssignmentStateMachine.draft.value)

        self.assertRaises(TransitionNotPossible, self.assignment.states.submit)
        self.assignment.initiative.states.submit(save=True)
        self.assignment.refresh_from_db()

        self.assertEqual(self.assignment.status,
                         AssignmentStateMachine.submitted.value)
示例#24
0
    def test_approve(self):
        self.assignment = AssignmentFactory.create(end_date_type='on_date',
                                                   owner=self.initiative.owner,
                                                   initiative=self.initiative,
                                                   capacity=3)
        self.assignment.states.submit(save=True)

        self.assertEqual(self.assignment.status,
                         AssignmentStateMachine.open.value)

        organizer = self.assignment.contributions.get()
        self.assertTrue(isinstance(organizer, Organizer))
        self.assertEqual(organizer.status,
                         OrganizerStateMachine.succeeded.value)
示例#25
0
    def test_sort_matching_combined(self):
        theme = ProjectThemeFactory.create()
        self.owner.favourite_themes.add(theme)

        skill = SkillFactory.create()
        self.owner.skills.add(skill)

        self.owner.location = LocationFactory.create(position='10.0, 20.0')
        self.owner.save()

        initiative = InitiativeFactory.create(theme=theme)

        first = EventFactory.create(status='open',
                                    initiative=initiative,
                                    is_online=False)
        second = AssignmentFactory.create(
            status='open',
            location=GeolocationFactory.create(position=Point(21.0, 9.0)),
            initiative=initiative,
            is_online=False)
        third = AssignmentFactory.create(
            status='open',
            location=GeolocationFactory.create(position=Point(21.0, 9.0)),
            initiative=initiative,
            expertise=skill,
            is_online=False)

        response = self.client.get(self.url + '?sort=popularity',
                                   user=self.owner)

        data = json.loads(response.content)

        self.assertEqual(data['meta']['pagination']['count'], 3)

        self.assertEqual(data['data'][0]['id'], str(third.pk))
        self.assertEqual(data['data'][1]['id'], str(second.pk))
        self.assertEqual(data['data'][2]['id'], str(first.pk))
示例#26
0
    def test_check_status_applicant_removed(self):
        assignment = AssignmentFactory(
            title='Test Title',
            status='open',
            date=now() + timedelta(days=4),
            capacity=3,
        )
        applicants = ApplicantFactory.create_batch(3, activity=assignment)
        for applicant in applicants:
            applicant.states.accept(save=True)

        self.assertEqual(assignment.status, 'full')

        applicants[0].delete()

        self.assertEqual(assignment.status, 'open')
示例#27
0
    def setUp(self):
        super(WallpostPermissionsTest, self).setUp()

        self.owner = BlueBottleUserFactory.create(password='******', first_name='someName', last_name='someLast')
        self.owner_token = "JWT {0}".format(self.owner.get_jwt_token())

        self.initiative = InitiativeFactory.create(owner=self.owner)
        self.event = EventFactory.create(owner=self.owner)
        self.assignment = AssignmentFactory.create(owner=self.owner)

        self.other_user = BlueBottleUserFactory.create()
        self.other_token = "JWT {0}".format(
            self.other_user.get_jwt_token())

        self.media_wallpost_url = reverse('media_wallpost_list')
        self.text_wallpost_url = reverse('text_wallpost_list')
        self.wallpost_url = reverse('wallpost_list')
示例#28
0
 def test_change_deadline(self):
     tomorrow = now() + timedelta(days=1)
     next_week = now() + timedelta(days=7)
     assignment = AssignmentFactory.create(capacity=5,
                                           end_date_type='deadline',
                                           date=tomorrow)
     self.assignment.save()
     applicants = ApplicantFactory.create_batch(3, activity=assignment)
     for applicant in applicants:
         applicant.states.accept(save=True)
     mail.outbox = []
     assignment.date = next_week
     assignment.save()
     self.assertEqual(len(mail.outbox), 3)
     self.assertEqual(
         mail.outbox[0].subject,
         'The deadline for your task "{}" has been changed.'.format(
             assignment.title))
示例#29
0
    def test_check_status_capacity_changed(self):
        assignment = AssignmentFactory(
            title='Test Title',
            status='open',
            date=now() + timedelta(days=4),
            capacity=3,
        )
        for applicant in ApplicantFactory.create_batch(3, activity=assignment):
            applicant.states.accept(save=True)

        assignment.refresh_from_db()
        self.assertEqual(assignment.status, 'full')

        assignment.capacity = 10
        assignment.save()

        self.assertEqual(assignment.status, 'open')
示例#30
0
    def setUp(self):
        super(ApplicantTransitionAPITestCase, self).setUp()
        self.settings = InitiativePlatformSettingsFactory.create(
            activity_types=['assignment'])

        self.client = JSONAPITestClient()
        self.transition_url = reverse('applicant-transition-list')
        self.user = BlueBottleUserFactory()
        self.someone_else = BlueBottleUserFactory()
        self.manager = BlueBottleUserFactory(first_name="Boss")
        self.owner = BlueBottleUserFactory(first_name="Owner")
        self.initiative = InitiativeFactory.create(
            activity_manager=self.manager)

        self.initiative.states.submit()
        self.initiative.states.approve(save=True)
        self.assignment = AssignmentFactory.create(owner=self.owner,
                                                   initiative=self.initiative)
        self.assignment.states.submit(save=True)

        document = PrivateDocumentFactory.create()
        self.applicant = ApplicantFactory.create(activity=self.assignment,
                                                 document=document,
                                                 user=self.user)
        self.participant_url = reverse('applicant-detail',
                                       args=(self.applicant.id, ))
        self.transition_data = {
            'data': {
                'type': 'contributions/applicant-transitions',
                'attributes': {
                    'transition': 'accept',
                },
                'relationships': {
                    'resource': {
                        'data': {
                            'type': 'contributions/applicants',
                            'id': self.applicant.pk
                        }
                    }
                }
            }
        }
        mail.outbox = []