コード例 #1
0
    def setUp(self):
        wmc_area_type = AreaTypeFactory.create()
        self.election = ElectionFactory.create(
            slug='2015',
            name='2015 General Election',
            area_types=(wmc_area_type,)
        )
        commons = ParliamentaryChamberFactory.create()
        self.post_extra = PostExtraFactory.create(
            elections=(self.election,),
            base__organization=commons,
            slug='65808',
            base__label='Member of Parliament for Dulwich and West Norwood'
        )
        PartyExtraFactory.reset_sequence()
        PartyFactory.reset_sequence()
        self.parties = {}
        for i in xrange(0, 4):
            party_extra = PartyExtraFactory.create()
            self.parties[party_extra.slug] = party_extra

        person_extra = PersonExtraFactory.create(
            base__id='2009',
            base__name='Tessa Jowell'
        )

        CandidacyExtraFactory.create(
            election=self.election,
            base__person=person_extra.base,
            base__post=self.post_extra.base,
            base__on_behalf_of=self.parties['party:63'].base
        )

        person_extra = PersonExtraFactory.create(
            base__id='2010',
            base__name='Andrew Smith',
            base__email='*****@*****.**',
        )

        CandidacyExtraFactory.create(
            election=self.election,
            base__person=person_extra.base,
            base__post=self.post_extra.base,
            base__on_behalf_of=self.parties['party:63'].base
        )
コード例 #2
0
    def setUp(self):
        wmc_area_type = AreaTypeFactory.create()
        self.election = ElectionFactory.create(slug='2015',
                                               name='2015 General Election',
                                               area_types=(wmc_area_type, ))
        commons = ParliamentaryChamberFactory.create()
        self.post_extra = PostExtraFactory.create(
            elections=(self.election, ),
            base__organization=commons,
            slug='65808',
            base__label='Member of Parliament for Dulwich and West Norwood')
        PartyExtraFactory.reset_sequence()
        PartyFactory.reset_sequence()
        self.parties = {}
        for i in range(0, 4):
            party_extra = PartyExtraFactory.create()
            self.parties[party_extra.slug] = party_extra

        person_extra = PersonExtraFactory.create(base__id='2009',
                                                 base__name='Tessa Jowell')

        CandidacyExtraFactory.create(
            election=self.election,
            base__person=person_extra.base,
            base__post=self.post_extra.base,
            base__on_behalf_of=self.parties['party:63'].base)

        person_extra = PersonExtraFactory.create(
            base__id='2010',
            base__name='Andrew Smith',
            base__email='*****@*****.**',
        )

        CandidacyExtraFactory.create(
            election=self.election,
            base__person=person_extra.base,
            base__post=self.post_extra.base,
            base__on_behalf_of=self.parties['party:63'].base)
コード例 #3
0
    def setUp(self):
        wmc_area_type = AreaTypeFactory.create()
        gb_parties = PartySetFactory.create(slug='gb', name='Great Britain')
        commons = ParliamentaryChamberFactory.create()
        area = AreaFactory.create(name="Dulwich and West Norwood", )

        election = ElectionFactory.create(slug='2015',
                                          name='2015 General Election',
                                          area_types=(wmc_area_type, ),
                                          organization=commons)
        post_extra = PostExtraFactory.create(
            elections=(election, ),
            base__organization=commons,
            base__id='65808',
            base__label='Member of Parliament for Dulwich and West Norwood',
            party_set=gb_parties,
            base__area=area,
        )
        person_2009 = PersonExtraFactory.create(base__id='2009',
                                                base__name='Tessa Jowell')
        person_2007 = PersonExtraFactory.create(base__id='2007',
                                                base__name='Tessa Jowell')
        PartyFactory.reset_sequence()
        party_extra = PartyExtraFactory.create()
        CandidacyExtraFactory.create(election=election,
                                     base__person=person_2009.base,
                                     base__post=post_extra.base,
                                     base__on_behalf_of=party_extra.base)
        CandidacyExtraFactory.create(election=election,
                                     base__person=person_2007.base,
                                     base__post=post_extra.base,
                                     base__on_behalf_of=party_extra.base)

        self.site = Site.objects.create(domain='example.com', name='YNR')
        self.test_upload_user = User.objects.create_user(
            'john',
            '*****@*****.**',
            'notagoodpassword',
        )
        self.test_upload_user.terms_agreement.assigned_to_dc = True
        self.test_upload_user.terms_agreement.save()
        self.test_reviewer = User.objects.create_superuser(
            'jane',
            '*****@*****.**',
            'alsonotagoodpassword',
        )
        self.test_reviewer.terms_agreement.assigned_to_dc = True
        self.test_reviewer.terms_agreement.save()
        self.test_reviewer.groups.add(
            Group.objects.get(name=PHOTO_REVIEWERS_GROUP_NAME))
        self.q1 = QueuedImage.objects.create(
            why_allowed='public-domain',
            justification_for_use="It's their Twitter avatar",
            decision='undecided',
            image=self.storage_filename,
            person=person_2009.base,
            user=self.test_upload_user)
        self.q2 = QueuedImage.objects.create(
            why_allowed='copyright-assigned',
            justification_for_use="I took this last week",
            decision='approved',
            image=self.storage_filename,
            person=person_2007.base,
            user=self.test_upload_user)
        self.q3 = QueuedImage.objects.create(
            why_allowed='other',
            justification_for_use="I found it somewhere",
            decision='rejected',
            image=self.storage_filename,
            person=person_2007.base,
            user=self.test_reviewer)
コード例 #4
0
    def setUp(self):
        wmc_area_type = AreaTypeFactory.create()
        gb_parties = PartySetFactory.create(slug='gb', name='Great Britain')
        commons = ParliamentaryChamberFactory.create()
        area = AreaFactory.create(
            name="Dulwich and West Norwood",
        )

        election = ElectionFactory.create(
            slug='2015',
            name='2015 General Election',
            area_types=(wmc_area_type,),
            organization=commons
        )
        post_extra = PostExtraFactory.create(
            elections=(election,),
            base__organization=commons,
            base__id='65808',
            base__label='Member of Parliament for Dulwich and West Norwood',
            party_set=gb_parties,
            base__area=area,
        )
        person_2009 = PersonExtraFactory.create(
            base__id='2009',
            base__name='Tessa Jowell'
        )
        person_2007 = PersonExtraFactory.create(
            base__id='2007',
            base__name='Tessa Jowell'
        )
        PartyFactory.reset_sequence()
        party_extra = PartyExtraFactory.create()
        CandidacyExtraFactory.create(
            election=election,
            base__person=person_2009.base,
            base__post=post_extra.base,
            base__on_behalf_of=party_extra.base
            )
        CandidacyExtraFactory.create(
            election=election,
            base__person=person_2007.base,
            base__post=post_extra.base,
            base__on_behalf_of=party_extra.base
            )

        self.site = Site.objects.create(domain='example.com', name='YNR')
        self.test_upload_user = User.objects.create_user(
            'john',
            '*****@*****.**',
            'notagoodpassword',
        )
        self.test_upload_user.terms_agreement.assigned_to_dc = True
        self.test_upload_user.terms_agreement.save()
        self.test_reviewer = User.objects.create_superuser(
            'jane',
            '*****@*****.**',
            'alsonotagoodpassword',
        )
        self.test_reviewer.terms_agreement.assigned_to_dc = True
        self.test_reviewer.terms_agreement.save()
        self.test_reviewer.groups.add(
            Group.objects.get(name=PHOTO_REVIEWERS_GROUP_NAME)
        )
        self.q1 = QueuedImage.objects.create(
            why_allowed='public-domain',
            justification_for_use="It's their Twitter avatar",
            decision='undecided',
            image='pilot.jpg',
            person=person_2009.base,
            user=self.test_upload_user
        )
        self.q2 = QueuedImage.objects.create(
            why_allowed='copyright-assigned',
            justification_for_use="I took this last week",
            decision='approved',
            image='pilot.jpg',
            person=person_2007.base,
            user=self.test_upload_user
        )
        self.q3 = QueuedImage.objects.create(
            why_allowed='other',
            justification_for_use="I found it somewhere",
            decision='rejected',
            image='pilot.jpg',
            person=person_2007.base,
            user=self.test_reviewer
        )
コード例 #5
0
ファイル: tests.py プロジェクト: lamby/yournextrepresentative
    def setUp(self):
        wmc_area_type = AreaTypeFactory.create()
        gb_parties = PartySetFactory.create(slug='gb', name='Great Britain')
        election = ElectionFactory.create(slug='2015',
                                          name='2015 General Election',
                                          area_types=(wmc_area_type, ))
        area_extra = AreaExtraFactory.create(
            base__name="Dulwich and West Norwood",
            type=wmc_area_type,
        )
        commons = ParliamentaryChamberFactory.create()
        post_extra = PostExtraFactory.create(
            elections=(election, ),
            base__area=area_extra.base,
            base__organization=commons,
            slug='65808',
            party_set=gb_parties,
            base__label='Member of Parliament for Dulwich and West Norwood')
        camberwell_area_extra = AreaExtraFactory.create(
            base__identifier='65913',
            type=wmc_area_type,
        )
        camberwell_post = PostExtraFactory.create(
            elections=(election, ),
            base__area=camberwell_area_extra.base,
            base__organization=commons,
            slug='65913',
            candidates_locked=True,
            base__label='Member of Parliament for Camberwell and Peckham',
            party_set=gb_parties,
        )
        person_extra = PersonExtraFactory.create(base__id='2009',
                                                 base__name='Tessa Jowell')
        self.person = person_extra.base

        PartyExtraFactory.reset_sequence()
        PartyFactory.reset_sequence()
        self.parties = {}
        for i in range(0, 4):
            party_extra = PartyExtraFactory.create()
            gb_parties.parties.add(party_extra.base)
            self.parties[party_extra.slug] = party_extra

        CandidacyExtraFactory.create(
            election=election,
            base__person=person_extra.base,
            base__post=post_extra.base,
            base__on_behalf_of=self.parties['party:63'].base)

        person_extra = PersonExtraFactory.create(base__id='2010',
                                                 base__name='Angela Smith')
        self.person2 = person_extra.base

        CandidacyExtraFactory.create(
            election=election,
            base__person=person_extra.base,
            base__post=post_extra.base,
            base__on_behalf_of=self.parties['party:63'].base)

        content_type = ContentType.objects.get_for_model(person_extra.base)

        last_sent = datetime.now(pytz.utc) - timedelta(days=2)
        self.alert = Alert.objects.create(user=self.user,
                                          target_content_type=content_type,
                                          target_object_id=self.person.id,
                                          last_sent=last_sent,
                                          frequency='hourly')

        self.alert2 = Alert.objects.create(user=self.user_who_can_lock,
                                           target_content_type=content_type,
                                           target_object_id=self.person2.id,
                                           last_sent=last_sent,
                                           frequency='daily')

        person_extra = PersonExtraFactory.create(base__id='2011',
                                                 base__name='Martin Jones')
        self.person2 = person_extra.base

        CandidacyExtraFactory.create(
            election=election,
            base__person=person_extra.base,
            base__post=camberwell_post.base,
            base__on_behalf_of=self.parties['party:63'].base)

        content_type = ContentType.objects.get_for_model(
            camberwell_area_extra.base)
        self.alert3 = Alert.objects.create(
            user=self.user_who_can_merge,
            target_content_type=content_type,
            target_object_id=camberwell_area_extra.base.id,
            last_sent=last_sent,
            frequency='daily')

        aldershot_area_extra = AreaExtraFactory.create(
            base__identifier='65730',
            type=wmc_area_type,
        )

        aldershot_post = PostExtraFactory.create(
            elections=(election, ),
            base__area=aldershot_area_extra.base,
            base__organization=commons,
            slug='65730',
            base__label='Member of Parliament for Aldershot',
            party_set=gb_parties,
        )

        person_extra = PersonExtraFactory.create(base__id='2012',
                                                 base__name='Gillian Collins')
        self.person3 = person_extra.base

        CandidacyExtraFactory.create(
            election=election,
            base__person=person_extra.base,
            base__post=aldershot_post.base,
            base__on_behalf_of=self.parties['party:63'].base)

        content_type = ContentType.objects.get_for_model(
            self.parties['party:90'].base)

        self.alert4 = Alert.objects.create(
            user=self.user_who_can_rename,
            target_content_type=content_type,
            target_object_id=self.parties['party:90'].base.id,
            last_sent=last_sent,
            frequency='daily')

        content_type = ContentType.objects.get_for_model(
            camberwell_area_extra.base)

        self.alert5 = Alert.objects.create(user=self.user,
                                           target_content_type=content_type,
                                           target_object_id=66101,
                                           last_sent=last_sent,
                                           frequency='hourly')
コード例 #6
0
    def setUp(self):
        wmc_area_type = AreaTypeFactory.create()
        gb_parties = PartySetFactory.create(slug='gb', name='Great Britain')
        election = ElectionFactory.create(
            slug='2015',
            name='2015 General Election',
            area_types=(wmc_area_type,)
        )
        area_extra = AreaExtraFactory.create(
            base__name="Dulwich and West Norwood",
            type=wmc_area_type,
        )
        commons = ParliamentaryChamberFactory.create()
        post_extra = PostExtraFactory.create(
            elections=(election,),
            base__area=area_extra.base,
            base__organization=commons,
            slug='65808',
            party_set=gb_parties,
            base__label='Member of Parliament for Dulwich and West Norwood'
        )
        camberwell_area_extra = AreaExtraFactory.create(
            base__identifier='65913',
            type=wmc_area_type,
        )
        camberwell_post = PostExtraFactory.create(
            elections=(election,),
            base__area=camberwell_area_extra.base,
            base__organization=commons,
            slug='65913',
            candidates_locked=True,
            base__label='Member of Parliament for Camberwell and Peckham',
            party_set=gb_parties,
        )
        person_extra = PersonExtraFactory.create(
            base__id='2009',
            base__name='Tessa Jowell'
        )
        self.person = person_extra.base

        PartyExtraFactory.reset_sequence()
        PartyFactory.reset_sequence()
        self.parties = {}
        for i in range(0, 4):
            party_extra = PartyExtraFactory.create()
            gb_parties.parties.add(party_extra.base)
            self.parties[party_extra.slug] = party_extra

        CandidacyExtraFactory.create(
            election=election,
            base__person=person_extra.base,
            base__post=post_extra.base,
            base__on_behalf_of=self.parties['party:63'].base
        )

        person_extra = PersonExtraFactory.create(
            base__id='2010',
            base__name='Angela Smith'
        )
        self.person2 = person_extra.base

        CandidacyExtraFactory.create(
            election=election,
            base__person=person_extra.base,
            base__post=post_extra.base,
            base__on_behalf_of=self.parties['party:63'].base
        )

        content_type = ContentType.objects.get_for_model(person_extra.base)

        last_sent = datetime.now(pytz.utc) - timedelta(days=2)
        self.alert = Alert.objects.create(
            user=self.user,
            target_content_type=content_type,
            target_object_id=self.person.id,
            last_sent=last_sent,
            frequency='hourly'
        )

        self.alert2 = Alert.objects.create(
            user=self.user_who_can_lock,
            target_content_type=content_type,
            target_object_id=self.person2.id,
            last_sent=last_sent,
            frequency='daily'
        )

        person_extra = PersonExtraFactory.create(
            base__id='2011',
            base__name='Martin Jones'
        )
        self.person2 = person_extra.base

        CandidacyExtraFactory.create(
            election=election,
            base__person=person_extra.base,
            base__post=camberwell_post.base,
            base__on_behalf_of=self.parties['party:63'].base
        )

        content_type = ContentType.objects.get_for_model(
            camberwell_area_extra.base
        )
        self.alert3 = Alert.objects.create(
            user=self.user_who_can_merge,
            target_content_type=content_type,
            target_object_id=camberwell_area_extra.base.id,
            last_sent=last_sent,
            frequency='daily'
        )

        aldershot_area_extra = AreaExtraFactory.create(
            base__identifier='65730',
            type=wmc_area_type,
        )

        aldershot_post = PostExtraFactory.create(
            elections=(election,),
            base__area=aldershot_area_extra.base,
            base__organization=commons,
            slug='65730',
            base__label='Member of Parliament for Aldershot',
            party_set=gb_parties,
        )

        person_extra = PersonExtraFactory.create(
            base__id='2012',
            base__name='Gillian Collins'
        )
        self.person3 = person_extra.base

        CandidacyExtraFactory.create(
            election=election,
            base__person=person_extra.base,
            base__post=aldershot_post.base,
            base__on_behalf_of=self.parties['party:63'].base
        )

        content_type = ContentType.objects.get_for_model(
            self.parties['party:90'].base
        )

        self.alert4 = Alert.objects.create(
            user=self.user_who_can_rename,
            target_content_type=content_type,
            target_object_id=self.parties['party:90'].base.id,
            last_sent=last_sent,
            frequency='daily'
        )

        content_type = ContentType.objects.get_for_model(
            camberwell_area_extra.base
        )

        self.alert5 = Alert.objects.create(
            user=self.user,
            target_content_type=content_type,
            target_object_id=66101,
            last_sent=last_sent,
            frequency='hourly'
        )