def test_user_follow_other_user(self): u = UserFactory() # toni u1 = UserFactory() # yasen request = self.factory.put("api/users/follow") force_authenticate(request, user=u) response = self.follow_view(request, pk=u1.id) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertIn(u.id, u1.get_followers_ids())
def setUp(self): self.main_user = UserFactory() self.follower = UserFactory() self.test_user = UserFactory() self.main_user.followers.add(self.follower) self.follower.following.add(self.main_user) for i in range(0, self.POSTS_PER_USER): PostFactory(creator=self.main_user) PostFactory(creator=self.test_user) PostFactory(creator=self.follower)
def admin_api_client(): admin = UserFactory( is_staff=True, ) client = APIClient() client.force_authenticate(user=admin) return client
def admin_django_client(): admin = UserFactory( is_staff=True, ) client = Client() client.force_login(admin) return client
def admin_client(): admin = UserFactory( is_staff=True, person=None, ) client = Client() client.force_login(admin) return client
def user_api_client(): person = PersonFactory() user = UserFactory( is_staff=False, person=person, ) client = APIClient() client.force_authenticate(user=user) return client
def setUp(self): self.factory = APIRequestFactory() self.detail_view = PostViewSet.as_view({'get': 'retrieve'}) self.list_view = PostViewSet.as_view({'get': 'list'}) self.trending_view = PostViewSet.as_view({'get': 'trending'}) self.new_filter_view = PostViewSet.as_view({'get': 'new'}) self.create_view = PostViewSet.as_view({'post': 'create'}) self.top_view = PostViewSet.as_view({'get': 'top'}) self.rate_view = PostViewSet.as_view({'put': 'rate'}) self.user = UserFactory()
def setUp(self): self.user = UserFactory.build() self.jsonUser = UserSerializer(self.user).data self.jsonUser['password'] = '******' self.jsonUser['password_confirmation'] = 'test123' self.factory = APIRequestFactory() self.create_view = UserViewSet.as_view({'post': 'create'}) self.follow_view = UserViewSet.as_view({'put': 'follow'}) self.unfollow_view = UserViewSet.as_view({'put': 'unfollow'}) self.me_view = UserViewSet.as_view({'get': 'me'})
def setUp(self): self.factory = APIRequestFactory() self.active_view = TopicViewSet.as_view({'get': 'active'}) self.inactive_view = TopicViewSet.as_view({'get': 'inactive'}) self.user = UserFactory() self.active_topics_count = 5 self.inactive_topics_count = 5 TopicFactory.create_batch( self.active_topics_count, start=datetime.now(pytz.utc) - timedelta(days=3), end=datetime.now(pytz.utc) + timedelta(days=4)) TopicFactory.create_batch( self.inactive_topics_count, start=datetime.now(pytz.utc) + timedelta(weeks=1), end=datetime.now(pytz.utc) + timedelta(weeks=2))
def bhs_member(): user = UserFactory() client = APIClient() client.force_authenticate(user=user) return client
def api_user_client(): user = UserFactory() client = APIClient() client.force_authenticate(user=user) return client
def user_client(): user = UserFactory() client = Client() client.force_login(user) return client
def setUpTestData(cls): """ Create basic model instances """ set_up_data(cls) # PoliticalRelations cls.EU_germany = PoliticalRelationFactory( parent=cls.european_union, child=cls.germany, start_date=cls.JD_0001, end_date=cls.JD_0002, control_type=PoliticalRelation.INDIRECT, ) # CachedData cls.hastings = CachedDataFactory( wikidata_id=1, location=Point(0, 0), date=cls.JD_0001, event_type=CachedData.BATTLE, ) # SpacetimeVolumes cls.alsace_stv = SpacetimeVolumeFactory( start_date=cls.JD_0001, end_date=cls.JD_0002, entity=cls.france, references=["ref"], visual_center=Point(1.2, 1.8), territory=Polygon(((1, 1), (1, 2), (2, 2), (1, 1))), ) # Narratives cls.norman_conquest = NarrativeFactory( author="Test Author", title="Test Narrative", url="test", description="This is a test narrative for automated testing.", tags=["test", "tags"], ) # Users cls.django_user = UserFactory( email=FIREBASE_USER.email, username="******", password=FIREBASE_USER.password, ) cls.test_user = UserFactory( email="*****@*****.**", username="******", password=get_random_string(length=16), ) # NarrativeVotes cls.norman_conquest_vote = NarrativeVoteFactory( narrative=cls.norman_conquest, user=cls.test_user, vote=True ) # MapSettings cls.norman_conquest_settings = MapSettingsFactory(zoom_min=1, zoom_max=12) # Narrations cls.hastings_narration = NarrationFactory( narrative=cls.norman_conquest, title="Test Narration", description="This is a narration point", date_label="test", map_datetime=cls.JD_0002, settings=cls.norman_conquest_settings, location=Point(0, 0), ) # Cities cls.paris = CityFactory( wikidata_id=1, label="Paris", location=Point(0, 0), inception_date=cls.JD_0001, )
def handle(self, *args, **options): # Create Persons admin_person = PersonFactory( first_name='Admin', last_name='Person', email='*****@*****.**', ) scjc_person = PersonFactory( first_name='SCJC', last_name='Person', email='*****@*****.**', ) drcj_person = PersonFactory( first_name='DRCJ', last_name='Person', email='*****@*****.**', ) ca_person = PersonFactory( first_name='CA', last_name='Person', email='*****@*****.**', ) quartet_lead_person = PersonFactory( first_name='Quartet', last_name='Lead', email='*****@*****.**', ) quartet_tenor_person = PersonFactory( first_name='Quartet', last_name='Tenor', ) quartet_baritone_person = PersonFactory( first_name='Quartet', last_name='Baritone', ) quartet_bass_person = PersonFactory( first_name='Quartet', last_name='Bass', ) chorus_manager_person = PersonFactory( first_name='Chorus', last_name='Admin', email='*****@*****.**', ) music_judge_person = PersonFactory( first_name='Music', last_name='Judge', email='*****@*****.**', ) performance_judge_person = PersonFactory( first_name='Performance', last_name='Judge', email='*****@*****.**', ) singing_judge_person = PersonFactory( first_name='Singing', last_name='Judge', email='*****@*****.**', ) # Create Users admin_user = UserFactory( username='******', password='******', person=admin_person, is_staff=True, ) scjc_user = UserFactory( username='******', password='******', person=scjc_person, ) drcj_user = UserFactory( username='******', password='******', person=drcj_person, ) ca_user = UserFactory( username='******', password='******', person=ca_person, ) quartet_lead_user = UserFactory( username='******', password='******', person=quartet_lead_person, ) chorus_manager_user = UserFactory( username='******', password='******', person=chorus_manager_person, ) music_judge_user = UserFactory( username='******', password='******', person=music_judge_person, ) performance_judge_user = UserFactory( username='******', password='******', person=performance_judge_person, ) singing_judge_user = UserFactory( username='******', password='******', person=singing_judge_person, ) # Create Groups international = GroupFactory( name='International Group', code='INT', kind=Group.KIND.international, ) district_alpha = GroupFactory( name='District Alpha', code='ALF', parent=international, kind=Group.KIND.district, ) chapter_1 = GroupFactory( name='Chapter One', code='A-001', parent=district_alpha, kind=Group.KIND.chapter, ) chorus_1 = GroupFactory( name='Chorus One', kind=Group.KIND.chorus, parent=chapter_1, bhs_id=40, international=international.code, district=district_alpha.code, chapter=chapter_1.name, ) quartet_1 = GroupFactory( name='Quartet 1', kind=Group.KIND.quartet, parent=district_alpha, bhs_id=10, international=international.code, district=district_alpha.code, ) quartet_2 = GroupFactory( name='Quartet 2', kind=Group.KIND.quartet, bhs_id=20, parent=district_alpha, international=international.code, district=district_alpha.code, ) quartet_3 = GroupFactory( name='Quartet 3', kind=Group.KIND.quartet, bhs_id=30, parent=district_alpha, international=international.code, district=district_alpha.code, ) # Sort tree Group.objects.sort_tree() # create Venue venue = VenueFactory() # create Chart chart_1 = ChartFactory( title='Chart 1', ) chart_2 = ChartFactory( title='Chart 2', ) chart_3 = ChartFactory( title='Chart 3', ) chart_4 = ChartFactory( title='Chart 4', ) chart_5 = ChartFactory( title='Chart 5', ) chart_6 = ChartFactory( title='Chart 6', ) # Create Offices scjc_office = OfficeFactory( name='Society Chairman of C&J', kind=Office.KIND.international, code=Office.CODE.scjc_chair, is_convention_manager=True, is_session_manager=True, is_round_manager=True, is_scoring_manager=True, is_group_manager=True, is_person_manager=True, is_award_manager=True, is_officer_manager=True, is_chart_manager=True, is_assignment_manager=True, ) drcj_office = OfficeFactory( name='District Director C&J', kind=Office.KIND.district, code=Office.CODE.drcj, is_convention_manager=True, is_session_manager=True, is_award_manager=True, ) ca_office = OfficeFactory( name='Contest Administrator', kind=Office.KIND.district, code=Office.CODE.judge_ca, is_round_manager=True, is_scoring_manager=True, is_officer_manager=True, ) mus_office = OfficeFactory( name='Music Judge', kind=Office.KIND.district, code=Office.CODE.judge_mus, is_officer_manager=True, ) per_office = OfficeFactory( name='Performance Judge', kind=Office.KIND.district, code=Office.CODE.judge_per, is_officer_manager=True, ) sng_office = OfficeFactory( name='Singing Judge', kind=Office.KIND.district, code=Office.CODE.judge_sng, is_officer_manager=True, ) chorus_manager = OfficeFactory( name='Chorus Manager', kind=Office.KIND.chapter, code=Office.CODE.chap_man, is_group_manager=True, ) quartet_manager = OfficeFactory( name='Quartet Manager', kind=Office.KIND.quartet, code=Office.CODE.quartet_admin, is_group_manager=True, ) # Create Core Officers scjc_officer = OfficerFactory( office=scjc_office, person=admin_person, group=international, status=Officer.STATUS.active, ) drcj_alpha_officer = OfficerFactory( office=drcj_office, person=drcj_person, group=district_alpha, status=Officer.STATUS.active, ) ca_officer = OfficerFactory( office=ca_office, person=ca_person, group=district_alpha, status=Officer.STATUS.active, ) mus_judge = OfficerFactory( office=mus_office, person=music_judge_person, group=international, status=Officer.STATUS.active, ) per_judge = OfficerFactory( office=per_office, person=performance_judge_person, group=international, status=Officer.STATUS.active, ) sng_judge = OfficerFactory( office=sng_office, person=singing_judge_person, group=international, status=Officer.STATUS.active, ) OfficerFactory( office=chorus_manager, person=admin_person, group=chorus_1, status=Officer.STATUS.active, ) chapter_president = OfficerFactory( office=chorus_manager, person=chorus_manager_person, group=chorus_1, status=Officer.STATUS.active, ) quartet_1_manager = OfficerFactory( office=quartet_manager, person=admin_person, group=quartet_1, status=Officer.STATUS.active, ) quartet_2_manager = OfficerFactory( office=quartet_manager, person=quartet_lead_person, group=quartet_2, status=Officer.STATUS.active, ) quartet_3_manager = OfficerFactory( office=quartet_manager, person=quartet_lead_person, group=quartet_3, status=Officer.STATUS.active, ) # Create Awards international_quartet_championship = AwardFactory( name='International Quartet Championship', group=international, rounds=1, level=Award.LEVEL.championship, kind=Award.KIND.quartet, season=Award.SEASON.summer, ) international_chorus_championship = AwardFactory( name='International Chorus Championship', group=international, rounds=1, level=Award.LEVEL.championship, kind=Award.KIND.chorus, season=Award.SEASON.summer, ) district_alpha_quartet_championship = AwardFactory( name='District Alpha Quartet Championship', group=district_alpha, rounds=2, level=Award.LEVEL.championship, season=Award.SEASON.fall, ) district_alpha_international_quartet_championship_qualifier = AwardFactory( name='District Alpha International Quartet Championship Qualifier', group=district_alpha, rounds=2, parent=international_quartet_championship, level=Award.LEVEL.qualifier, season=Award.SEASON.spring, kind=Award.KIND.quartet, advance=76.0, ) district_alpha_international_chorus_championship_qualifier = AwardFactory( name='District Alpha International Chorus Championship Qualifier', group=district_alpha, rounds=1, parent=international_chorus_championship, level=Award.LEVEL.qualifier, season=Award.SEASON.fall, kind=Award.KIND.chorus, advance=73.0, ) international_senior_quartet_championship = AwardFactory( name='International Senior Quartet Championship', group=international, rounds=1, level=Award.LEVEL.championship, kind=Award.KIND.quartet, season=Award.SEASON.midwinter, ) # Create conventions international_midwinter_convention = ConventionFactory( name='International Midwinter Convention', group=international, panel=3, season=Convention.SEASON.midwinter, ) GrantorFactory( group=international, convention=international_midwinter_convention, ) district_alpha_fall_convention = ConventionFactory( name='District Alpha Fall Convention', group=district_alpha, panel=3, season=Convention.SEASON.fall, ) GrantorFactory( group=district_alpha, convention=district_alpha_fall_convention, ) district_alpha_spring_convention = ConventionFactory( name='District Alpha Spring Convention', group=district_alpha, panel=3, season=Convention.SEASON.spring, ) GrantorFactory( group=district_alpha, convention=district_alpha_spring_convention, ) # Create assignments AssignmentFactory( category=Assignment.CATEGORY.drcj, convention=district_alpha_fall_convention, person=admin_person, ) AssignmentFactory( category=Assignment.CATEGORY.drcj, convention=district_alpha_fall_convention, person=drcj_person, ) AssignmentFactory( category=Assignment.CATEGORY.ca, convention=district_alpha_fall_convention, person=ca_person, ) AssignmentFactory( category=Assignment.CATEGORY.music, convention=district_alpha_fall_convention, person=music_judge_person, ) AssignmentFactory( category=Assignment.CATEGORY.performance, convention=district_alpha_fall_convention, person=performance_judge_person, ) AssignmentFactory( category=Assignment.CATEGORY.singing, convention=district_alpha_fall_convention, person=singing_judge_person, ) AssignmentFactory( category=Assignment.CATEGORY.drcj, convention=district_alpha_spring_convention, person=admin_person, ) AssignmentFactory( category=Assignment.CATEGORY.ca, convention=district_alpha_spring_convention, person=admin_person, ) AssignmentFactory( category=Assignment.CATEGORY.music, convention=district_alpha_spring_convention, person=music_judge_person, ) AssignmentFactory( category=Assignment.CATEGORY.performance, convention=district_alpha_spring_convention, person=performance_judge_person, ) AssignmentFactory( category=Assignment.CATEGORY.singing, convention=district_alpha_spring_convention, person=singing_judge_person, ) AssignmentFactory( category=Assignment.CATEGORY.drcj, convention=international_midwinter_convention, person=admin_person, ) AssignmentFactory( category=Assignment.CATEGORY.ca, convention=international_midwinter_convention, person=admin_person, ) AssignmentFactory( category=Assignment.CATEGORY.music, convention=international_midwinter_convention, person=music_judge_person, ) AssignmentFactory( category=Assignment.CATEGORY.performance, convention=international_midwinter_convention, person=performance_judge_person, ) AssignmentFactory( category=Assignment.CATEGORY.singing, convention=international_midwinter_convention, person=singing_judge_person, ) international_midwinter_convention_quartet_session = SessionFactory( convention=international_midwinter_convention, kind=Session.KIND.quartet, num_rounds=1, is_invitational=True, ) district_alpha_fall_convention_quartet_session = SessionFactory( convention=district_alpha_fall_convention, kind=Session.KIND.quartet, num_rounds=2, ) district_alpha_spring_convention_quartet_session = SessionFactory( convention=district_alpha_spring_convention, kind=Session.KIND.quartet, num_rounds=2, ) district_alpha_fall_convention_chorus_session = SessionFactory( convention=district_alpha_fall_convention, kind=Session.KIND.chorus, num_rounds=1, ) # Create members member_quartet_lead = MemberFactory( part=Member.PART.lead, group=quartet_1, person=admin_person, ) member_quartet_tenor = MemberFactory( part=Member.PART.tenor, group=quartet_1, person=quartet_tenor_person, ) member_quartet_baritone = MemberFactory( part=Member.PART.baritone, group=quartet_1, person=quartet_baritone_person, ) member_quartet_bass = MemberFactory( part=Member.PART.bass, group=quartet_1, person=quartet_bass_person, ) member_chorus_manager = MemberFactory( part=Member.PART.lead, group=chorus_1, person=admin_person, ) member_quartet_2_lead = MemberFactory( part=Member.PART.lead, group=quartet_2, person=quartet_lead_person, ) member_quartet_2_tenor = MemberFactory( part=Member.PART.tenor, group=quartet_2, person=quartet_tenor_person, ) member_quartet_2_baritone = MemberFactory( part=Member.PART.baritone, group=quartet_2, person=quartet_baritone_person, ) member_quartet_2_bass = MemberFactory( part=Member.PART.bass, group=quartet_2, person=quartet_bass_person, ) member_quartet_3_lead = MemberFactory( part=Member.PART.lead, group=quartet_3, person=quartet_lead_person, ) member_quartet_3_tenor = MemberFactory( part=Member.PART.tenor, group=quartet_3, person=quartet_tenor_person, ) member_quartet_3_baritone = MemberFactory( part=Member.PART.baritone, group=quartet_3, person=quartet_baritone_person, ) member_quartet_3_bass = MemberFactory( part=Member.PART.bass, group=quartet_3, person=quartet_bass_person, ) # Create repertories RepertoryFactory( group=quartet_1, chart=chart_1, ) RepertoryFactory( group=quartet_1, chart=chart_2, ) RepertoryFactory( group=quartet_1, chart=chart_3, ) RepertoryFactory( group=quartet_1, chart=chart_4, ) RepertoryFactory( group=quartet_1, chart=chart_5, ) RepertoryFactory( group=quartet_1, chart=chart_6, ) RepertoryFactory( group=chorus_1, chart=chart_1, ) RepertoryFactory( group=chorus_1, chart=chart_2, ) RepertoryFactory( group=quartet_2, chart=chart_1, ) RepertoryFactory( group=quartet_2, chart=chart_2, ) RepertoryFactory( group=quartet_2, chart=chart_3, ) RepertoryFactory( group=quartet_2, chart=chart_4, ) RepertoryFactory( group=quartet_2, chart=chart_5, ) RepertoryFactory( group=quartet_2, chart=chart_6, ) RepertoryFactory( group=quartet_3, chart=chart_1, ) RepertoryFactory( group=quartet_3, chart=chart_2, ) RepertoryFactory( group=quartet_3, chart=chart_3, ) RepertoryFactory( group=quartet_3, chart=chart_4, ) RepertoryFactory( group=quartet_3, chart=chart_5, ) RepertoryFactory( group=quartet_3, chart=chart_6, ) # Contests created via signal. international_midwinter_convention.activate() international_midwinter_convention.save() district_alpha_fall_convention.activate() district_alpha_fall_convention.save() district_alpha_spring_convention.activate() district_alpha_spring_convention.save() if options['breakpoint'] == 'session': return # Build sessions international_midwinter_convention_quartet_session.build() international_midwinter_convention_quartet_session.save() district_alpha_fall_convention_quartet_session.build() district_alpha_fall_convention_quartet_session.save() district_alpha_spring_convention_quartet_session.build() district_alpha_spring_convention_quartet_session.save() district_alpha_fall_convention_chorus_session.build() district_alpha_fall_convention_chorus_session.save() # Monkeypatch finals round district_alpha_fall_convention_quartet_session_round_one = district_alpha_fall_convention_quartet_session.rounds.first() district_alpha_fall_convention_quartet_session_round_one.spots = 2 district_alpha_fall_convention_quartet_session_round_one.save() # Open sessions international_midwinter_convention_quartet_session.open() international_midwinter_convention_quartet_session.save() district_alpha_fall_convention_quartet_session.open() district_alpha_fall_convention_quartet_session.save() district_alpha_spring_convention_quartet_session.open() district_alpha_spring_convention_quartet_session.save() district_alpha_fall_convention_chorus_session.open() district_alpha_fall_convention_chorus_session.save() # Add entries senior_entry = EntryFactory( session=international_midwinter_convention_quartet_session, group=quartet_1, description='We would like to sing last', ) senior_2_entry = EntryFactory( session=international_midwinter_convention_quartet_session, group=quartet_2, ) senior_3_entry = EntryFactory( session=international_midwinter_convention_quartet_session, group=quartet_3, ) quartet_entry = EntryFactory( session=district_alpha_fall_convention_quartet_session, group=quartet_1, ) quartet_2_entry = EntryFactory( session=district_alpha_fall_convention_quartet_session, group=quartet_2, ) quartet_3_entry = EntryFactory( session=district_alpha_fall_convention_quartet_session, group=quartet_3, ) spring_quartet_entry = EntryFactory( session=district_alpha_spring_convention_quartet_session, group=quartet_1, ) spring_quartet_2_entry = EntryFactory( session=district_alpha_spring_convention_quartet_session, group=quartet_2, ) spring_quartet_3_entry = EntryFactory( session=district_alpha_spring_convention_quartet_session, group=quartet_3, ) chorus_entry = EntryFactory( session=district_alpha_fall_convention_chorus_session, group=chorus_1, ) # Build entries senior_entry.build() senior_entry.save() senior_2_entry.build() senior_2_entry.save() senior_3_entry.build() senior_3_entry.save() quartet_entry.build() quartet_entry.save() quartet_2_entry.build() quartet_2_entry.save() quartet_3_entry.build() quartet_3_entry.save() spring_quartet_entry.build() spring_quartet_entry.save() spring_quartet_2_entry.build() spring_quartet_2_entry.save() spring_quartet_3_entry.build() spring_quartet_3_entry.save() chorus_entry.build() chorus_entry.save() # Activate Contestants lst = [ quartet_entry, quartet_2_entry, quartet_3_entry, chorus_entry, ] for l in lst: contestants = l.contestants.all() for contestant in contestants: contestant.include() contestant.save() # Approve entries senior_entry.submit() senior_entry.approve() senior_entry.save() senior_2_entry.approve() senior_2_entry.save() senior_3_entry.approve() senior_3_entry.save() quartet_entry.approve() quartet_entry.save() quartet_2_entry.approve() quartet_2_entry.save() quartet_3_entry.approve() quartet_3_entry.save() spring_quartet_entry.approve() spring_quartet_entry.save() spring_quartet_2_entry.approve() spring_quartet_2_entry.save() spring_quartet_3_entry.approve() spring_quartet_3_entry.save() chorus_entry.approve() chorus_entry.save() # Close sessions international_midwinter_convention_quartet_session.close() international_midwinter_convention_quartet_session.save() district_alpha_fall_convention_quartet_session.close() district_alpha_fall_convention_quartet_session.save() district_alpha_spring_convention_quartet_session.close() district_alpha_spring_convention_quartet_session.save() district_alpha_fall_convention_chorus_session.close() district_alpha_fall_convention_chorus_session.save() # Verify sessions international_midwinter_convention_quartet_session.verify() international_midwinter_convention_quartet_session.save() district_alpha_fall_convention_quartet_session.verify() district_alpha_fall_convention_quartet_session.save() district_alpha_spring_convention_quartet_session.verify() district_alpha_spring_convention_quartet_session.save() district_alpha_fall_convention_chorus_session.verify() district_alpha_fall_convention_chorus_session.save() # Start sessions international_midwinter_convention_quartet_session.start() international_midwinter_convention_quartet_session.save() district_alpha_spring_convention_quartet_session.start() district_alpha_spring_convention_quartet_session.save() district_alpha_fall_convention_quartet_session.start() district_alpha_fall_convention_quartet_session.save() district_alpha_fall_convention_chorus_session.start() district_alpha_fall_convention_chorus_session.save() # CA BREAKPOINT if options['breakpoint'] == 'round': return # Start First Round international_midwinter_convention_quartet_session_round_one = international_midwinter_convention_quartet_session.rounds.earliest() district_alpha_fall_convention_quartet_session_round_one = district_alpha_fall_convention_quartet_session.rounds.earliest() district_alpha_spring_convention_quartet_session_round_one = district_alpha_spring_convention_quartet_session.rounds.earliest() district_alpha_fall_convention_chorus_session_round_one = district_alpha_fall_convention_chorus_session.rounds.earliest() international_midwinter_convention_quartet_session_round_one.start() international_midwinter_convention_quartet_session_round_one.save() district_alpha_fall_convention_quartet_session_round_one.start() district_alpha_fall_convention_quartet_session_round_one.save() district_alpha_spring_convention_quartet_session_round_one.start() district_alpha_spring_convention_quartet_session_round_one.save() district_alpha_fall_convention_chorus_session_round_one.start() district_alpha_fall_convention_chorus_session_round_one.save() s = 70 for appearance in international_midwinter_convention_quartet_session_round_one.appearances.order_by('num'): appearance.start() appearance.save() song_one = appearance.songs.earliest() song_two = appearance.songs.latest() song_one.chart = Chart.objects.get(title='Chart 1') song_two.chart = Chart.objects.get(title='Chart 2') song_one.save() song_two.save() appearance.finish() appearance.save() s += 5 for song in appearance.songs.all(): for score in song.scores.all(): score.points = s score.save() appearance.confirm() appearance.save() s = 70 for appearance in district_alpha_fall_convention_quartet_session_round_one.appearances.order_by('num'): appearance.start() appearance.save() song_one = appearance.songs.earliest() song_two = appearance.songs.latest() song_one.chart = Chart.objects.get(title='Chart 1') song_two.chart = Chart.objects.get(title='Chart 2') song_one.save() song_two.save() appearance.finish() appearance.save() s += 5 for song in appearance.songs.all(): for score in song.scores.all(): score.points = s score.save() appearance.confirm() appearance.save() s = 70 for appearance in district_alpha_spring_convention_quartet_session_round_one.appearances.order_by('num'): appearance.start() appearance.save() song_one = appearance.songs.earliest() song_two = appearance.songs.latest() song_one.chart = Chart.objects.get(title='Chart 1') song_two.chart = Chart.objects.get(title='Chart 2') song_one.save() song_two.save() appearance.finish() appearance.save() s += 5 for song in appearance.songs.all(): for score in song.scores.all(): score.points = s score.save() appearance.confirm() appearance.save() if options['breakpoint'] == 'confirmed': return district_alpha_fall_convention_quartet_session_round_one.verify() district_alpha_fall_convention_quartet_session_round_one.save() district_alpha_fall_convention_quartet_session_round_one.finish() district_alpha_fall_convention_quartet_session_round_one.save() # Start Second Round district_alpha_fall_convention_quartet_session_round_two = district_alpha_fall_convention_quartet_session.rounds.get(num=2) district_alpha_fall_convention_quartet_session_round_two.start() district_alpha_fall_convention_quartet_session_round_two.save() s = 75 for appearance in district_alpha_fall_convention_quartet_session_round_two.appearances.order_by('num'): appearance.start() appearance.save() song_one = appearance.songs.earliest() song_two = appearance.songs.latest() song_one.chart = Chart.objects.get(title='Chart 1') song_two.chart = Chart.objects.get(title='Chart 2') song_one.save() song_two.save() appearance.finish() appearance.save() s += 3 for song in appearance.songs.all(): for score in song.scores.all(): score.points = s score.save() appearance.confirm() appearance.save() district_alpha_fall_convention_quartet_session_round_two.verify() district_alpha_fall_convention_quartet_session_round_two.save() district_alpha_fall_convention_quartet_session_round_two.finish() district_alpha_fall_convention_quartet_session_round_two.save() return
def setUp(self): self.user = UserFactory()
def user(): return UserFactory()
def handle(self, *args, **options): # Create Admin admin_person = PersonFactory( name='Admin Person', email='*****@*****.**', ) admin = UserFactory( email='*****@*****.**', password='******', is_staff=True, person=admin_person, ) # Create Core Persons scjc_person = PersonFactory( name='SCJC Person', email='*****@*****.**', ) drcj_person = PersonFactory( name='DRCJ Person', email='*****@*****.**', ) ca_person = PersonFactory( name='CA Person', email='*****@*****.**', ) quartet_person = PersonFactory( name='Quartet Person', email='*****@*****.**', ) chorus_person = PersonFactory( name='Chorus Person', email='*****@*****.**', ) # Create Core Users scjc_user = UserFactory( email=scjc_person.email, person=scjc_person, ) drcj_user = UserFactory( email=drcj_person.email, person=drcj_person, ) ca_user = UserFactory( email=ca_person.email, person=ca_person, ) quartet_user = UserFactory( email=quartet_person.email, person=quartet_person, ) chorus_user = UserFactory( email=chorus_person.email, person=chorus_person, ) # Create International and Districts international = OrganizationFactory( name='International Organization', short_name='INT', kind=Organization.KIND.international, ) district_alpha = OrganizationFactory( name='District Alpha', short_name='ALF', parent=international, kind=Organization.KIND.district, ) district_beta = OrganizationFactory( name='District Beta', short_name='BTA', parent=international, kind=Organization.KIND.district, ) district_beta_division_north = OrganizationFactory( name='Division Beta North', short_name='BTA ND', parent=district_beta, kind=Organization.KIND.division, ) district_beta_division_south = OrganizationFactory( name='Division Beta South', short_name='BTA SD', parent=district_beta, kind=Organization.KIND.division, ) district_beta_division_east = OrganizationFactory( name='Division Beta East', short_name='BTA ED', parent=district_beta, kind=Organization.KIND.division, ) district_beta_division_west = OrganizationFactory( name='Division Beta West', short_name='BTA WD', parent=district_beta, kind=Organization.KIND.division, ) affiliate = OrganizationFactory( name='Affiliate Organization', short_name='AFF', parent=international, kind=Organization.KIND.affiliate, ) # Create Core Offices scjc_office = OfficeFactory( name='Society Chairman of C&J', short_name='SCJC', is_convention_manager=True, is_session_manager=True, is_scoring_manager=True, is_organization_manager=True, is_group_manager=True, is_person_manager=True, is_award_manager=True, is_judge_manager=True, is_chart_manager=True, ) drcj_office = OfficeFactory( name='District Director C&J', short_name='DRCJ', is_convention_manager=True, is_session_manager=True, is_organization_manager=True, is_award_manager=True, ) ca_office = OfficeFactory( name='Contest Administrator', short_name='CA', is_scoring_manager=True, is_judge_manager=True, ) mus_office = OfficeFactory( name='Music Judge', short_name='MUS', is_judge_manager=True, ) per_office = OfficeFactory( name='Performance Judge', short_name='PER', is_judge_manager=True, ) sng_office = OfficeFactory( name='Singing Judge', short_name='SNG', is_judge_manager=True, ) # Create Core Officers scjc_officer = OfficerFactory( office=scjc_office, person=scjc_person, organization=international, status=Officer.STATUS.active, ) drcj_alpha_officer = OfficerFactory( office=drcj_office, person=drcj_person, organization=district_alpha, status=Officer.STATUS.active, ) drcj_beta_officer = OfficerFactory( office=drcj_office, person=drcj_person, organization=district_beta, status=Officer.STATUS.active, ) drcj_beta_north_officer = OfficerFactory( office=drcj_office, person=drcj_person, organization=district_beta_division_north, status=Officer.STATUS.active, ) drcj_beta_south_officer = OfficerFactory( office=drcj_office, person=drcj_person, organization=district_beta_division_south, status=Officer.STATUS.active, ) drcj_beta_east_officer = OfficerFactory( office=drcj_office, person=drcj_person, organization=district_beta_division_east, status=Officer.STATUS.active, ) drcj_beta_west_officer = OfficerFactory( office=drcj_office, person=drcj_person, organization=district_beta_division_west, status=Officer.STATUS.active, ) ca_officer = OfficerFactory( office=ca_office, person=ca_person, organization=international, status=Officer.STATUS.active, ) # Create Charts charts = ChartFactory.create_batch( size=500, status=Chart.STATUS.active, ) # Create Quartets quartets = GroupFactory.build_batch( size=140, kind=Group.KIND.quartet, ) n = 1 for quartet in quartets: if n <= 60: quartet.organization = district_alpha elif n <= 80: quartet.organization = district_beta_division_north elif n <= 100: quartet.organization = district_beta_division_south elif n <= 120: quartet.organization = district_beta_division_east elif n <= 140: quartet.organization = district_beta_division_west n += 1 quartet.save() i = 1 while i <= 4: try: MemberFactory( group=quartet, part=i, status=Member.STATUS.active, ) except IntegrityError: continue i += 1 i = 1 while i <= 6: try: chart = Chart.objects.order_by('?').first() RepertoryFactory( group=quartet, chart=chart, ) except IntegrityError: continue i += 1 member = Group.objects.filter( organization__name='District Alpha').first().members.get(part=1) member.person = quartet_person member.is_admin = True member.save() member = Group.objects.filter( organization__name='Division Beta North').first().members.get( part=1) member.person = quartet_person member.is_admin = True member.save() member = Group.objects.filter( organization__name='Division Beta South').first().members.get( part=1) member.person = quartet_person member.is_admin = True member.save() member = Group.objects.filter( organization__name='Division Beta East').first().members.get( part=1) member.person = quartet_person member.is_admin = True member.save() member = Group.objects.filter( organization__name='Division Beta West').first().members.get( part=1) member.person = quartet_person member.is_admin = True member.save() # Create Judges mus_judges = OfficerFactory.create_batch( size=30, office=mus_office, organization=international, status=Officer.STATUS.active, ) per_judges = OfficerFactory.create_batch( size=30, office=per_office, organization=international, status=Officer.STATUS.active, ) sng_judges = OfficerFactory.create_batch( size=30, office=sng_office, organization=international, status=Officer.STATUS.active, ) # Create Awards international_quartet_championship = AwardFactory( name='International Quartet Championship', organization=international, rounds=3, level=Award.LEVEL.championship, ) district_alpha_international_quartet_championship_qualifier = AwardFactory( name='District Alpha International Quartet Championship Qualifier', organization=district_alpha, rounds=2, parent=international_quartet_championship, level=Award.LEVEL.qualifier, season=Award.SEASON.spring, ) district_beta_international_quartet_championship_qualifier = AwardFactory( name='District Beta International Quartet Championship Qualifier', organization=district_beta, rounds=2, parent=international_quartet_championship, level=Award.LEVEL.qualifier, season=Award.SEASON.spring, ) international_chorus_championship = AwardFactory( name='International Chorus Championship', organization=international, rounds=1, level=Award.LEVEL.championship, kind=Award.KIND.chorus, ) district_alpha_international_chorus_championship_qualifier = AwardFactory( name='District Alpha International Chorus Championship Qualifier', organization=district_alpha, rounds=1, parent=international_chorus_championship, level=Award.LEVEL.qualifier, season=Award.SEASON.fall, kind=Award.KIND.chorus, ) district_beta_international_chorus_championship_qualifier = AwardFactory( name='District Beta International Chorus Championship Qualifier', organization=district_beta, rounds=1, parent=international_chorus_championship, level=Award.LEVEL.qualifier, season=Award.SEASON.fall, kind=Award.KIND.chorus, ) # international_youth_quartet_championship=AwardFactory( # name='International Youth Quartet Championship', # organization=international, # rounds=1, # level=Award.LEVEL.championship, # ) # international_dc_award=AwardFactory( # name='International Dealers Choice Award', # organization=international, # rounds=3, # level=Award.LEVEL.award, # ) district_alpha_quartet_championship = AwardFactory( name='District Alpha Quartet Championship', organization=district_alpha, rounds=2, level=Award.LEVEL.championship, season=Award.SEASON.fall, ) district_alpha_chorus_championship = AwardFactory( name='District Alpha Chorus Championship', organization=district_alpha, rounds=1, level=Award.LEVEL.championship, season=Award.SEASON.spring, kind=Award.KIND.chorus, ) district_beta_quartet_championship = AwardFactory( name='District Beta Quartet Championship', organization=district_beta, rounds=2, level=Award.LEVEL.championship, season=Award.SEASON.fall, ) district_beta_division_north_district_beta_quartet_championship_qualifier = AwardFactory( name= 'BTA Division North District Beta Quartet Championship Qualifier', organization=district_beta_division_north, rounds=1, parent=district_beta_quartet_championship, level=Award.LEVEL.qualifier, season=Award.SEASON.spring, ) district_beta_division_south_district_beta_quartet_championship_qualifier = AwardFactory( name= 'BTA Division South District Beta Quartet Championship Qualifier', organization=district_beta_division_south, rounds=1, parent=district_beta_quartet_championship, level=Award.LEVEL.qualifier, season=Award.SEASON.spring, ) district_beta_division_east_district_beta_quartet_championship_qualifier = AwardFactory( name= 'BTA Division East District Beta Quartet Championship Qualifier', organization=district_beta_division_east, rounds=1, parent=district_beta_quartet_championship, level=Award.LEVEL.qualifier, season=Award.SEASON.spring, ) district_beta_division_west_district_beta_quartet_championship_qualifier = AwardFactory( name= 'BTA Division West District Beta Quartet Championship Qualifier', organization=district_beta_division_west, rounds=1, parent=district_beta_quartet_championship, level=Award.LEVEL.qualifier, season=Award.SEASON.spring, ) district_beta_chorus_championship = AwardFactory( name='District Beta Chorus Championship', organization=district_beta, rounds=1, level=Award.LEVEL.championship, season=Award.SEASON.fall, kind=Award.KIND.chorus, ) district_beta_division_east_district_beta_chorus_championship_qualifier = AwardFactory( name= 'BTA Division East District Beta Chorus Championship Qualifier', organization=district_beta_division_east, rounds=1, parent=district_beta_chorus_championship, level=Award.LEVEL.qualifier, season=Award.SEASON.spring, kind=Award.KIND.chorus, ) district_beta_division_west_district_beta_chorus_championship_qualifier = AwardFactory( name= 'BTA Division West District Beta Chorus Championship Qualifier', organization=district_beta_division_west, rounds=1, parent=district_beta_chorus_championship, level=Award.LEVEL.qualifier, season=Award.SEASON.spring, kind=Award.KIND.chorus, ) district_beta_division_north_quartet_championship = AwardFactory( name='BTA Division North Quartet Championship', organization=district_beta_division_north, rounds=1, level=Award.LEVEL.championship, season=Award.SEASON.spring, ) district_beta_division_south_quartet_championship = AwardFactory( name='BTA Division South Quartet Championship', organization=district_beta_division_south, rounds=1, level=Award.LEVEL.championship, season=Award.SEASON.spring, ) district_beta_division_east_quartet_championship = AwardFactory( name='BTA Division East Quartet Championship', organization=district_beta_division_east, rounds=1, level=Award.LEVEL.championship, season=Award.SEASON.spring, ) district_beta_division_west_quartet_championship = AwardFactory( name='BTA Division West Quartet Championship', organization=district_beta_division_west, rounds=1, level=Award.LEVEL.championship, season=Award.SEASON.spring, ) district_beta_division_north_chorus_championship = AwardFactory( name='BTA Division North Chorus Championship', organization=district_beta_division_north, rounds=1, level=Award.LEVEL.championship, season=Award.SEASON.spring, kind=Award.KIND.chorus, ) district_beta_division_south_chorus_championship = AwardFactory( name='BTA Division South Chorus Championship', organization=district_beta_division_south, rounds=1, level=Award.LEVEL.championship, season=Award.SEASON.spring, kind=Award.KIND.chorus, ) district_beta_division_east_chorus_championship = AwardFactory( name='BTA Division East Chorus Championship', organization=district_beta_division_east, rounds=1, level=Award.LEVEL.championship, season=Award.SEASON.spring, kind=Award.KIND.chorus, ) district_beta_division_west_chorus_championship = AwardFactory( name='BTA Division West Chorus Championship', organization=district_beta_division_west, rounds=1, level=Award.LEVEL.championship, season=Award.SEASON.spring, kind=Award.KIND.chorus, ) # Create Conventions and Sessions # international_convention=ConventionFactory( # name='International Convention', # start_date='2017-07-01', # end_date='2017-07-08', # organization=international, # ) # international_convention_quartet_session = international_convention.sessions.create(kind=Session.KIND.quartet) # international_convention_chorus_session = international_convention.sessions.create(kind=Session.KIND.chorus) # # international_youth_convention=ConventionFactory( # name='International Youth Convention', # organization=international, # start_date='2017-07-02', # end_date='2017-07-02', # panel=3, # ) # international_youth_convention_quartet_session = international_youth_convention.sessions.create(kind=Session.KIND.quartet) # international_youth_convention_chorus_session = international_youth_convention.sessions.create(kind=Session.KIND.chorus) district_alpha_fall_convention = ConventionFactory( name='District Alpha Fall Convention', start_date='2017-10-01', end_date='2017-10-02', organization=district_alpha, panel=3, season=Convention.SEASON.fall, ) district_alpha_spring_convention = ConventionFactory( name='District Alpha Spring Convention', start_date='2018-05-01', end_date='2018-05-02', organization=district_alpha, panel=3, season=Convention.SEASON.spring, ) district_beta_fall_convention = ConventionFactory( name='District Beta Fall Convention', start_date='2017-09-01', end_date='2017-09-02', organization=district_beta, panel=3, season=Convention.SEASON.fall, ) district_beta_division_north_spring_convention = ConventionFactory( name='BTA Division North Spring Convention', start_date='2018-03-01', end_date='2018-03-01', organization=district_beta, year=2018, panel=2, season=Convention.SEASON.spring, ) district_beta_division_south_spring_convention = ConventionFactory( name='BTA Division South Spring Convention', start_date='2018-04-01', end_date='2018-04-01', organization=district_beta, year=2018, panel=2, season=Convention.SEASON.spring, ) district_beta_division_east_west_spring_convention = ConventionFactory( name='BTA Division East & West Spring Convention', start_date='2018-04-01', end_date='2018-04-01', organization=district_beta, year=2018, panel=2, season=Convention.SEASON.spring, ) # Add Sessions district_alpha_fall_convention_quartet_session = SessionFactory( convention=district_alpha_fall_convention, kind=Session.KIND.quartet, ) district_alpha_fall_convention_chorus_session = SessionFactory( convention=district_alpha_fall_convention, kind=Session.KIND.chorus, ) district_alpha_spring_convention_quartet_session = SessionFactory( convention=district_alpha_spring_convention, kind=Session.KIND.quartet, ) district_alpha_spring_convention_chorus_session = SessionFactory( convention=district_alpha_spring_convention, kind=Session.KIND.chorus, ) district_beta_fall_convention_quartet_session = SessionFactory( convention=district_beta_fall_convention, kind=Session.KIND.quartet, ) district_beta_fall_convention_chorus_session = SessionFactory( convention=district_beta_fall_convention, kind=Session.KIND.chorus, ) district_beta_division_north_spring_convention_quartet_session = SessionFactory( convention=district_beta_division_north_spring_convention, kind=Session.KIND.quartet, ) district_beta_division_north_spring_convention_chorus_session = SessionFactory( convention=district_beta_division_north_spring_convention, kind=Session.KIND.chorus, ) district_beta_division_south_spring_convention_quartet_session = SessionFactory( convention=district_beta_division_south_spring_convention, kind=Session.KIND.quartet, ) district_beta_division_south_spring_convention_chorus_session = SessionFactory( convention=district_beta_division_south_spring_convention, kind=Session.KIND.chorus, ) district_beta_division_east_west_spring_convention_quartet_session = SessionFactory( convention=district_beta_division_east_west_spring_convention, kind=Session.KIND.quartet, ) district_beta_division_east_west_spring_convention_chorus_session = SessionFactory( convention=district_beta_division_east_west_spring_convention, kind=Session.KIND.chorus, ) # Add Assignments conventions = Convention.objects.all() for convention in conventions: convention.assignments.create( status=Assignment.STATUS.active, category=Assignment.CATEGORY.drcj, kind=Assignment.KIND.official, person=drcj_person, ) js = Officer.objects.filter( office__short_name='CA').order_by('?')[:2] for j in js: convention.assignments.create( status=Assignment.STATUS.active, category=Assignment.CATEGORY.admin, kind=Assignment.KIND.official, person=j.person, ) js = Officer.objects.filter( office__short_name='MUS').order_by('?')[:convention.panel] for j in js: convention.assignments.create( status=Assignment.STATUS.active, category=Assignment.CATEGORY.music, kind=Assignment.KIND.official, person=j.person, ) js = Officer.objects.filter( office__short_name='PER').order_by('?')[:convention.panel] for j in js: convention.assignments.create( status=Assignment.STATUS.active, category=Assignment.CATEGORY.performance, kind=Assignment.KIND.official, person=j.person, ) js = Officer.objects.filter( office__short_name='SNG').order_by('?')[:convention.panel] for j in js: convention.assignments.create( status=Assignment.STATUS.active, category=Assignment.CATEGORY.singing, kind=Assignment.KIND.official, person=j.person, ) # Convention New if options['breakpoint'] == 'conventions_created': return # Add Grantors GrantorFactory( organization=district_alpha, session=district_alpha_fall_convention_quartet_session, ) GrantorFactory( organization=district_alpha, session=district_alpha_fall_convention_chorus_session, ) GrantorFactory( organization=district_alpha, session=district_alpha_spring_convention_quartet_session, ) GrantorFactory( organization=district_alpha, session=district_alpha_spring_convention_chorus_session, ) GrantorFactory( organization=district_beta, session=district_beta_fall_convention_quartet_session, ) GrantorFactory( organization=district_beta, session=district_beta_fall_convention_chorus_session, ) GrantorFactory( organization=district_beta_division_north, session= district_beta_division_north_spring_convention_quartet_session, ) GrantorFactory( organization=district_beta_division_north, session= district_beta_division_north_spring_convention_chorus_session, ) GrantorFactory( organization=district_beta_division_south, session= district_beta_division_south_spring_convention_quartet_session, ) GrantorFactory( organization=district_beta_division_south, session= district_beta_division_south_spring_convention_chorus_session, ) GrantorFactory( organization=district_beta_division_east, session= district_beta_division_east_west_spring_convention_quartet_session, ) GrantorFactory( organization=district_beta_division_east, session= district_beta_division_east_west_spring_convention_chorus_session, ) GrantorFactory( organization=district_beta_division_west, session= district_beta_division_east_west_spring_convention_quartet_session, ) GrantorFactory( organization=district_beta_division_west, session= district_beta_division_east_west_spring_convention_chorus_session, ) # Add Contests for convention in conventions: for session in convention.sessions.all(): for grantor in session.grantors.all(): for award in grantor.organization.awards.all(): session.contests.create(award=award, ) # Publish Conventions district_alpha_fall_convention.publish() district_alpha_fall_convention.save() district_alpha_spring_convention.publish() district_alpha_spring_convention.save() district_beta_fall_convention.publish() district_beta_fall_convention.save() district_beta_division_north_spring_convention.publish() district_beta_division_north_spring_convention.save() district_beta_division_south_spring_convention.publish() district_beta_division_south_spring_convention.save() district_beta_division_east_west_spring_convention.publish() district_beta_division_east_west_spring_convention.save() if options['breakpoint'] == 'conventions_published': return # Open the Session for Entries quartet_session.open() quartet_session.save() # Enter 50 Quartets at Random quartets = Group.objects.filter( kind=Group.KIND.quartet, ).order_by('?')[:50] youth_quartets = Group.objects.filter( kind=Group.KIND.quartet, ).order_by('?')[:20] # Create Quartet Entries for quartet in quartets: EntryFactory( session=quartet_session, group=quartet, is_evaluation=False, status=Entry.STATUS.approved, ) for quartet in youth_quartets: EntryFactory( session=youth_session, group=quartet, is_evaluation=False, status=Entry.STATUS.approved, ) # Add Participants to Entries for entry in quartet_session.entries.all(): for member in entry.group.members.all(): ParticipantFactory( entry=entry, member=member, ) for entry in youth_session.entries.all(): for member in entry.group.members.all(): ParticipantFactory( entry=entry, member=member, ) # Add Contests to Entries for entry in quartet_session.entries.all(): ContestantFactory( entry=entry, contest=quartet_contest, ) for entry in youth_session.entries.all(): ContestantFactory( entry=entry, contest=youth_contest, ) for entry in quartet_session.entries.all().order_by('?')[:10]: ContestantFactory( entry=entry, contest=dc_contest, ) for entry in youth_session.entries.all().order_by('?')[:10]: ContestantFactory( entry=entry, contest=oy_contest, ) # Close Session quartet_session.close() quartet_session.save() youth_session.close() youth_session.save() if options['breakpoint'] == 'session_closed': return # Verify Session quartet_session.verify() quartet_session.save() youth_session.verify() youth_session.save() # youth youth_session.start() youth_session.save() if options['breakpoint'] == 'youth_started': return # Get the first round youth_finals = youth_session.rounds.get(num=1) # Start the round youth_finals.start() youth_finals.save() # Score the round for appearance in youth_finals.appearances.filter( status=Appearance.STATUS.published, ): appearance.start() for song in appearance.songs.all(): song.chart = appearance.entry.group.repertories.order_by( '?').first().chart song.save() appearance.finish() for song in appearance.songs.all(): center = random.randint(60, 70) for score in song.scores.all(): offset = random.randint(-5, 5) score.points = center + offset score.save() appearance.confirm() appearance.save() if options['breakpoint'] == 'youth_scored': return youth_finals.finish() youth_finals.announce() youth_finals.save() # Start Session quartet_session.start() quartet_session.save() if options['breakpoint'] == 'session_started': return # Get the first round quartet_quarters = quartet_session.rounds.get(num=1) # Start the round quartet_quarters.start() quartet_quarters.save() # Score the round for appearance in quartet_quarters.appearances.filter( status=Appearance.STATUS.published, ): appearance.start() for song in appearance.songs.all(): song.chart = appearance.entry.group.repertories.order_by( '?').first().chart song.save() appearance.finish() for song in appearance.songs.all(): center = random.randint(70, 80) for score in song.scores.all(): offset = random.randint(-5, 5) score.points = center + offset score.save() appearance.confirm() appearance.save() if options['breakpoint'] == 'quarters_scored': return quartet_quarters.finish() quartet_quarters.announce() quartet_quarters.save() quartet_semis = quartet_session.rounds.get(num=2) quartet_semis.start() quartet_semis.save() # Score the round for appearance in quartet_semis.appearances.filter( status=Appearance.STATUS.published, ): appearance.start() for song in appearance.songs.all(): song.chart = appearance.entry.group.repertories.order_by( '?').first().chart song.save() appearance.finish() for song in appearance.songs.all(): center = random.randint(75, 85) for score in song.scores.all(): offset = random.randint(-5, 5) score.points = center + offset score.save() appearance.confirm() appearance.save() if options['breakpoint'] == 'semis_scored': return quartet_semis.finish() quartet_semis.announce() quartet_semis.save() quartet_finals = quartet_session.rounds.get(num=3) quartet_finals.start() quartet_finals.save() # Score the round for appearance in quartet_finals.appearances.filter( status=Appearance.STATUS.published, ): appearance.start() for song in appearance.songs.all(): song.chart = appearance.entry.group.repertories.order_by( '?').first().chart song.save() appearance.finish() for song in appearance.songs.all(): center = random.randint(80, 90) for score in song.scores.all(): offset = random.randint(-3, 3) score.points = center + offset score.save() appearance.confirm() appearance.save() if options['breakpoint'] == 'finals_scored': return
def setUp(self): self.factory = APIRequestFactory() self.rate_view = CommentViewSet.as_view({'put': 'rate'}) self.user = UserFactory()