def setUp(self):
        wmc_area_type = AreaTypeFactory.create()
        lac_area_type = AreaTypeFactory.create(name='LAC')
        gb_parties = PartySetFactory.create(slug='gb', name='Great Britain')
        commons = ParliamentaryChamberExtraFactory.create()
        lac = ParliamentaryChamberExtraFactory.create(slug='lac')

        election = ElectionFactory.create(
            slug='2015',
            name='2015 General Election',
            area_types=(wmc_area_type,),
            organization=commons.base
        )
        election2 = ElectionFactory.create(
            slug='2015-secondary',
            name='2015 Secondary Election',
            area_types=(lac_area_type,),
            organization=lac.base
        )
        area_extra = AreaExtraFactory.create(
            base__name="Westminster",
            type=wmc_area_type,
        )

        PostExtraFactory.create(
            elections=(election,),
            base__organization=commons.base,
            slug='65759',
            base__label='Member of Parliament for Westminster',
            party_set=gb_parties,
            base__area=area_extra.base,
        )

        area_extra = AreaExtraFactory.create(
            base__name="Dulwich and West Norwood",
            type=wmc_area_type,
        )

        PostExtraFactory.create(
            elections=(election,),
            base__organization=commons.base,
            slug='65808',
            base__label='Member of Parliament for Dulwich and West Norwood',
            party_set=gb_parties,
            base__area=area_extra.base,
        )

        area_extra = AreaExtraFactory.create(
            base__name="Lambeth and Southwark",
            type=lac_area_type,
        )

        PostExtraFactory.create(
            elections=(election2,),
            base__organization=commons.base,
            slug='11822',
            base__label='London Assembly Member for Lambeth and Southwark',
            party_set=gb_parties,
            base__area=area_extra.base,
        )
Ejemplo n.º 2
0
 def setUp(self):
     super(TestConstituencyPostcodeFinderView, self).setUp()
     wmc_area_type = AreaTypeFactory.create()
     gb_parties = PartySetFactory.create(slug='gb', name='Great Britain')
     commons = ParliamentaryChamberFactory.create()
     election = ElectionFactory.create(
         slug='2015',
         name='2015 General Election',
         area_types=(wmc_area_type, ),
         organization=commons,
     )
     area_extra = AreaExtraFactory.create(
         base__name="Dulwich and West Norwood",
         base__identifier='gss:E14000673',
         type=wmc_area_type,
     )
     self.area = area_extra.base
     PostExtraFactory.create(
         elections=(election, ),
         base__organization=commons,
         slug='65808',
         base__label='Member of Parliament for Dulwich and West Norwood',
         party_set=gb_parties,
         base__area=area_extra.base,
     )
 def setUp(self):
     super(TestConstituencyPostcodeFinderView, self).setUp()
     wmc_area_type = AreaTypeFactory.create()
     gb_parties = PartySetFactory.create(slug='gb', name='Great Britain')
     commons = ParliamentaryChamberFactory.create()
     election = ElectionFactory.create(
         slug='2015',
         name='2015 General Election',
         area_types=(wmc_area_type,),
         organization=commons,
     )
     area_extra = AreaExtraFactory.create(
         base__name="Dulwich and West Norwood",
         base__identifier='gss:E14000673',
         type=wmc_area_type,
     )
     self.area = area_extra.base
     PostExtraFactory.create(
         elections=(election,),
         base__organization=commons,
         slug='65808',
         base__label='Member of Parliament for Dulwich and West Norwood',
         party_set=gb_parties,
         base__area=area_extra.base,
     )
Ejemplo n.º 4
0
 def setUp(self):
     gb_parties = PartySetFactory.create(slug="gb", name="Great Britain")
     self.election = ElectionFactory.create(
         slug="parl.2015-05-07", name="2015 General Election", current=True
     )
     commons = ParliamentaryChamberFactory.create()
     self.post = PostFactory.create(
         elections=(self.election,),
         organization=commons,
         slug="dulwich-and-west-norwood",
         label="Member of Parliament for Dulwich and West Norwood",
         party_set=gb_parties,
     )
     self.ballot = self.post.ballot_set.get(election=self.election)
Ejemplo n.º 5
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, ))
     commons = ParliamentaryChamberFactory.create()
     self.post_extra = PostExtraFactory.create(
         elections=(election, ),
         base__organization=commons,
         slug='65808',
         base__label='Member of Parliament for Dulwich and West Norwood',
         party_set=gb_parties,
     )
Ejemplo n.º 6
0
 def setUp(self):
     gb_parties = PartySetFactory.create(slug='gb', name='Great Britain')
     commons = ParliamentaryChamberFactory.create()
     election = ElectionFactory.create(
         slug='parl.2017-03-23',
         name='2015 General Election',
         organization=commons,
         election_date="2017-03-23",
     )
     PostExtraFactory.create(
         elections=(election, ),
         base__organization=commons,
         slug='dulwich-and-west-norwood',
         base__label='Member of Parliament for Dulwich and West Norwood',
         party_set=gb_parties,
     )
 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,)
     )
     commons = ParliamentaryChamberFactory.create()
     self.post_extra = PostExtraFactory.create(
         elections=(election,),
         base__organization=commons,
         slug='65808',
         base__label='Member of Parliament for Dulwich and West Norwood',
         party_set=gb_parties,
     )
Ejemplo n.º 8
0
 def setUp(self):
     gb_parties = PartySetFactory.create(slug="gb", name="Great Britain")
     commons = ParliamentaryChamberFactory.create()
     election = ElectionFactory.create(
         slug="parl.2017-03-23",
         name="2015 General Election",
         organization=commons,
         election_date="2017-03-23",
     )
     PostFactory.create(
         elections=(election, ),
         organization=commons,
         slug="dulwich-and-west-norwood",
         label="Member of Parliament for Dulwich and West Norwood",
         party_set=gb_parties,
     )
 def setUp(self):
     election = Election.objects.get(slug='2015')
     wmc_area_type = election.area_types.get(name='WMC')
     gb_parties = PartySetFactory.create(slug='gb', name='Great Britain')
     commons = ParliamentaryChamberFactory.create()
     area_extra = AreaExtraFactory.create(
         base__name="Dulwich and West Norwood",
         type=wmc_area_type,
     )
     self.area = area_extra.base
     PostExtraFactory.create(
         elections=(election, ),
         base__organization=commons,
         slug='65808',
         base__label='Member of Parliament for Dulwich and West Norwood',
         party_set=gb_parties,
         base__area=area_extra.base,
     )
Ejemplo n.º 10
0
 def setUp(self):
     election = Election.objects.get(slug='2015')
     wmc_area_type = election.area_types.get(name='WMC')
     gb_parties = PartySetFactory.create(slug='gb', name='Great Britain')
     commons = ParliamentaryChamberFactory.create()
     area_extra = AreaExtraFactory.create(
         base__name="Dulwich and West Norwood",
         type=wmc_area_type,
     )
     self.area = area_extra.base
     PostExtraFactory.create(
         elections=(election,),
         base__organization=commons,
         slug='65808',
         base__label='Member of Parliament for Dulwich and West Norwood',
         party_set=gb_parties,
         base__area=area_extra.base,
     )
Ejemplo n.º 11
0
 def setUp(self):
     wmc_area_type = AreaTypeFactory.create()
     gb_parties = PartySetFactory.create(slug="gb", name="Great Britain")
     commons = ParliamentaryChamberFactory.create()
     election = ElectionFactory.create(
         slug="2015", name="2015 General Election", area_types=(wmc_area_type,), organization=commons
     )
     area_extra = AreaExtraFactory.create(
         base__name="Dulwich and West Norwood", base__identifier="gss:E14000673", type=wmc_area_type
     )
     self.area = area_extra.base
     PostExtraFactory.create(
         elections=(election,),
         base__organization=commons,
         slug="65808",
         base__label="Member of Parliament for Dulwich and West Norwood",
         party_set=gb_parties,
         base__area=area_extra.base,
     )
Ejemplo n.º 12
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)
Ejemplo n.º 13
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
        )
Ejemplo n.º 14
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')
Ejemplo n.º 15
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'
        )