Exemple #1
0
    def test_post_make_current_member(self):
        membership = Membership.objects.get(member=self.gasman, group=self.hooy_program)
        membership.is_current = False
        membership.save()

        response = self.client.post('/groups/%d/edit_membership/%d/' % (self.hooy_program.id, membership.id), {
            'scener_nick_search': 'gasman',
            'scener_nick_match_id': self.gasman.primary_nick.id,
            'scener_nick_match_name': 'gasman',
            'is_current': 'is_current',
        })
        self.assertRedirects(response, '/groups/%d/?editing=members' % self.hooy_program.id)
        self.assertTrue(Membership.objects.get(member=self.gasman, group=self.hooy_program).is_current)
        edit = Edit.for_model(self.gasman, True).first()
        self.assertIn("set as current member", edit.description)

        # no change => no edit log entry added
        edit_count = Edit.for_model(self.gasman, True).count()

        response = self.client.post('/groups/%d/edit_membership/%d/' % (self.hooy_program.id, membership.id), {
            'scener_nick_search': 'gasman',
            'scener_nick_match_id': self.gasman.primary_nick.id,
            'scener_nick_match_name': 'gasman',
            'is_current': 'is_current',
        })
        self.assertRedirects(response, '/groups/%d/?editing=members' % self.hooy_program.id)
        self.assertEqual(edit_count, Edit.for_model(self.gasman, True).count())
    def test_post(self):
        response = self.client.post('/parties/%d/edit/' % self.party.id, {
            'name': 'Forever 2000',
            'start_date': '17 march 2000',
            'end_date': '19 march 2000',
            'party_series_name': 'Forever',
            'website': 'http://forever.zeroteam.sk/',
        })
        self.assertRedirects(response, '/parties/%d/' % self.party.id)
        self.assertEqual(Party.objects.get(id=self.party.id).name, "Forever 2000")
        self.assertEqual(PartySeries.objects.get(name='Forever').website, 'http://forever.zeroteam.sk/')

        edit = Edit.for_model(self.party, True).first()
        self.assertIn("Set name to 'Forever 2000'", edit.description)

        # no change => no edit log entry added
        edit_count = Edit.for_model(self.party, True).count()

        response = self.client.post('/parties/%d/edit/' % self.party.id, {
            'name': 'Forever 2000',
            'start_date': '17 march 2000',
            'end_date': '19 march 2000',
            'party_series_name': 'Forever',
            'website': 'http://forever.zeroteam.sk/',
        })
        self.assertRedirects(response, '/parties/%d/' % self.party.id)
        self.assertEqual(edit_count, Edit.for_model(self.party, True).count())
Exemple #3
0
    def test_post(self):
        response = self.client.post(
            '/bbs/%d/edit_bbstros/' % self.bbs.id, {
                'form-TOTAL_FORMS': 1,
                'form-INITIAL_FORMS': 0,
                'form-MIN_NUM_FORMS': 0,
                'form-MAX_NUM_FORMS': 1000,
                'form-0-production_id': self.pondlife.id,
                'form-0-production_title': 'Pondlife',
                'form-0-production_byline_search': '',
            })
        self.assertRedirects(response, '/bbs/%d/' % self.bbs.id)
        self.assertEqual(self.bbs.bbstros.count(), 1)

        edit = Edit.for_model(self.bbs, True).first()
        self.assertEqual("Set BBStros to Pondlife", edit.description)

        # no change => no edit log entry added
        edit_count = Edit.for_model(self.bbs, True).count()
        response = self.client.post(
            '/bbs/%d/edit_bbstros/' % self.bbs.id, {
                'form-TOTAL_FORMS': 1,
                'form-INITIAL_FORMS': 1,
                'form-MIN_NUM_FORMS': 0,
                'form-MAX_NUM_FORMS': 1000,
                'form-0-production_id': self.pondlife.id,
                'form-0-production_title': 'Pondlife',
                'form-0-production_byline_search': '',
            })
        self.assertRedirects(response, '/bbs/%d/' % self.bbs.id)
        self.assertEqual(edit_count, Edit.for_model(self.bbs, True).count())
    def test_post(self):
        pondlife = Production.objects.get(title='Pondlife')
        response = self.client.post('/parties/%d/edit_invitations/' % self.party.id, {
            'form-TOTAL_FORMS': 1,
            'form-INITIAL_FORMS': 0,
            'form-MIN_NUM_FORMS': 0,
            'form-MAX_NUM_FORMS': 1000,
            'form-0-production_id': pondlife.id,
            'form-0-production_title': 'Pondlife',
            'form-0-production_byline_search': '',
        })
        self.assertRedirects(response, '/parties/%d/' % self.party.id)
        self.assertEqual(self.party.invitations.count(), 1)

        edit = Edit.for_model(self.party, True).first()
        self.assertEqual("Set invitations to Pondlife", edit.description)

        # no change => no edit log entry added
        edit_count = Edit.for_model(self.party, True).count()
        response = self.client.post('/parties/%d/edit_invitations/' % self.party.id, {
            'form-TOTAL_FORMS': 1,
            'form-INITIAL_FORMS': 1,
            'form-MIN_NUM_FORMS': 0,
            'form-MAX_NUM_FORMS': 1000,
            'form-0-production_id': pondlife.id,
            'form-0-production_title': 'Pondlife',
            'form-0-production_byline_search': '',
        })
        self.assertRedirects(response, '/parties/%d/' % self.party.id)
        self.assertEqual(edit_count, Edit.for_model(self.party, True).count())
Exemple #5
0
def history(request, competition_id):
    competition = get_object_or_404(Competition, id=competition_id)
    return render(
        request, 'competitions/history.html', {
            'competition': competition,
            'edits': Edit.for_model(competition, request.user.is_staff),
        })
Exemple #6
0
 def test_post(self):
     response = self.client.post(
         '/bbs/%d/edit/' % self.bbs.id, {
             'name': 'StarWhisky',
             'location': 'Oxford',
             'names-TOTAL_FORMS': '1',
             'names-INITIAL_FORMS': '1',
             'names-MIN_NUM_FORMS': '0',
             'names-MAX_NUM_FORMS': '1000',
             'names-0-name': 'Star Whisky episode IV: A New Hope',
             'names-0-id': self.alt_name.id,
             'names-0-bbs': self.bbs.id
         })
     self.assertRedirects(response, '/bbs/%d/' % self.bbs.id)
     self.bbs.refresh_from_db()
     self.assertEqual(self.bbs.name, 'StarWhisky')
     self.assertEqual(self.bbs.names.count(), 2)
     self.assertTrue(self.bbs.names.filter(name='StarWhisky').exists())
     self.assertTrue(
         self.bbs.names.filter(
             name='Star Whisky episode IV: A New Hope').exists())
     edit = Edit.for_model(self.bbs, True).first()
     self.assertEqual(
         "Set name to 'StarWhisky', location to Oxford, alternative names to "
         "Star Whisky episode IV: A New Hope", edit.description)
Exemple #7
0
def series_history(request, party_series_id):
    party_series = get_object_or_404(PartySeries, id=party_series_id)
    return render(
        request, 'parties/series_history.html', {
            'party_series': party_series,
            'edits': Edit.for_model(party_series, request.user.is_staff),
        })
Exemple #8
0
def last_edited_by(context, item):
    edit = Edit.for_model(item,
                          is_admin=context['request'].user.is_staff).order_by(
                              '-timestamp').first()
    return {
        'edit': edit,
        'item': item,
    }
Exemple #9
0
def history(request, production_id):
    production = get_object_or_404(Production, id=production_id)
    if production.supertype != 'production':
        return HttpResponseRedirect(production.get_history_url())
    return render(request, 'productions/history.html', {
        'production': production,
        'edits': Edit.for_model(production, request.user.is_staff),
    })
Exemple #10
0
def history(request, production_id):
	production = get_object_or_404(Production, id=production_id)
	if production.supertype != 'production':
		return HttpResponseRedirect(production.get_history_url())
	return render(request, 'productions/history.html', {
		'production': production,
		'edits': Edit.for_model(production, request.user.is_staff),
	})
Exemple #11
0
def history(request, production_id):
    production = get_object_or_404(Production, id=production_id)
    if production.supertype != "production":
        return HttpResponseRedirect(production.get_history_url())
    return render(
        request,
        "productions/history.html",
        {"production": production, "edits": Edit.for_model(production, request.user.is_staff)},
    )
def last_edited_by(context, item):
	try:
		edit = Edit.for_model(item, is_admin=context['request'].user.is_staff).order_by('-timestamp')[0]
	except IndexError:
		edit = None
	return {
		'edit': edit,
		'item': item,
	}
Exemple #13
0
 def test_post_change_member(self):
     membership = Membership.objects.get(member=self.gasman, group=self.hooy_program)
     response = self.client.post('/groups/%d/edit_membership/%d/' % (self.hooy_program.id, membership.id), {
         'scener_nick_search': 'laesq',
         'scener_nick_match_id': self.laesq.primary_nick.id,
         'scener_nick_match_name': 'laesq',
     })
     self.assertRedirects(response, '/groups/%d/?editing=members' % self.hooy_program.id)
     self.assertFalse(Membership.objects.get(member=self.laesq, group=self.hooy_program).is_current)
     edit = Edit.for_model(self.hooy_program, True).first()
     self.assertIn("changed member to LaesQ", edit.description)
Exemple #14
0
 def test_post_make_ex_subgroup(self):
     membership = Membership.objects.get(member=self.papaya_dezign, group=self.raww_arse)
     response = self.client.post('/groups/%d/edit_subgroup/%d/' % (self.raww_arse.id, membership.id), {
         'subgroup_nick_search': 'papaya dezign',
         'subgroup_nick_match_id': self.papaya_dezign.primary_nick.id,
         'subgroup_nick_match_name': 'papaya dezign',
     })
     self.assertRedirects(response, '/groups/%d/?editing=subgroups' % self.raww_arse.id)
     self.assertFalse(Membership.objects.get(member=self.papaya_dezign, group=self.raww_arse).is_current)
     edit = Edit.for_model(self.papaya_dezign, True).first()
     self.assertIn("set as ex-subgroup", edit.description)
Exemple #15
0
    def test_post_change_subgroup(self):
        membership = Membership.objects.get(member=self.papaya_dezign, group=self.raww_arse)

        response = self.client.post('/groups/%d/edit_subgroup/%d/' % (self.raww_arse.id, membership.id), {
            'subgroup_nick_search': 'limp ninja',
            'subgroup_nick_match_id': self.limp_ninja.primary_nick.id,
            'subgroup_nick_match_name': 'limp ninja',
            'is_current': 'is_current'
        })
        self.assertRedirects(response, '/groups/%d/?editing=subgroups' % self.raww_arse.id)
        self.assertTrue(Membership.objects.get(member=self.limp_ninja, group=self.raww_arse).is_current)
        edit = Edit.for_model(self.raww_arse, True).first()
        self.assertIn("changed subgroup to Limp Ninja", edit.description)
Exemple #16
0
 def test_post_set_not_current(self):
     response = self.client.post(
         '/bbs/%d/edit_operator/%d/' % (self.bbs.id, self.operator.id), {
             'releaser_nick_search': 'yerzmyey',
             'releaser_nick_match_id': self.yerzmyey.primary_nick.id,
             'releaser_nick_match_name': 'yerzmyey',
             'role': 'co-sysop',
         })
     self.assertRedirects(response, '/bbs/%d/?editing=staff' % self.bbs.id)
     self.operator.refresh_from_db()
     self.assertEqual(self.operator.role, "co-sysop")
     self.assertEqual(self.operator.releaser, self.yerzmyey)
     self.assertFalse(self.operator.is_current)
     edit = Edit.for_model(self.yerzmyey, True).first()
     self.assertIn("set as ex-staff", edit.description)
Exemple #17
0
    def test_edit_online_and_cancelled_flags(self):
        response = self.client.post('/parties/%d/edit/' % self.party.id, {
            'name': 'Forever 2000',
            'start_date': '17 march 2000',
            'end_date': '19 march 2000',
            'party_series_name': 'Forever',
            'website': 'http://forever.zeroteam.sk/',
            'is_online': 'is_online',
            'is_cancelled': 'is_cancelled',
        })
        self.assertRedirects(response, '/parties/%d/' % self.party.id)
        self.assertEqual(Party.objects.get(id=self.party.id).name, "Forever 2000")

        edit = Edit.for_model(self.party, True).first()
        self.assertIn("online to True", edit.description)
        self.assertIn("cancelled to True", edit.description)
Exemple #18
0
 def test_post_make_ex_member(self):
     membership = Membership.objects.get(member=self.gasman,
                                         group=self.hooy_program)
     response = self.client.post(
         '/sceners/%d/edit_membership/%d/' %
         (self.gasman.id, membership.id), {
             'group_nick_search': 'hooy-program',
             'group_nick_match_id': self.hooy_program.primary_nick.id,
             'group_nick_match_name': 'hooy-program',
         })
     self.assertRedirects(response,
                          '/sceners/%d/?editing=groups' % self.gasman.id)
     self.assertFalse(
         Membership.objects.get(member=self.gasman,
                                group=self.hooy_program).is_current)
     edit = Edit.for_model(self.gasman, True).first()
     self.assertIn("set as ex-member", edit.description)
Exemple #19
0
    def test_edit_all_fields(self):
        response = self.client.post('/parties/%d/edit/' % self.party.id, {
            'name': 'Forever 2000',
            'start_date': '18 march 2000',
            'end_date': '20 march 2000',
            'party_series_name': 'Forever',
            'tagline': "doo doo doo do do doo",
            'location': 'Oxford',
            'website': 'http://forever8.net/',
        })
        self.assertRedirects(response, '/parties/%d/' % self.party.id)
        self.assertEqual(Party.objects.get(id=self.party.id).name, "Forever 2000")

        edit = Edit.for_model(self.party, True).first()
        self.assertIn("start date to 18 March 2000", edit.description)
        self.assertIn("end date to 20 March 2000", edit.description)
        self.assertIn("tagline to 'doo doo doo do do doo'", edit.description)
        self.assertIn("location to Oxford", edit.description)
Exemple #20
0
 def test_post_change_group(self):
     membership = Membership.objects.get(member=self.gasman,
                                         group=self.hooy_program)
     response = self.client.post(
         '/sceners/%d/edit_membership/%d/' %
         (self.gasman.id, membership.id), {
             'group_nick_search': 'limp ninja',
             'group_nick_match_id': self.limp_ninja.primary_nick.id,
             'group_nick_match_name': 'limp ninja',
             'is_current': 'is_current',
         })
     self.assertRedirects(response,
                          '/sceners/%d/?editing=groups' % self.gasman.id)
     self.assertTrue(
         Membership.objects.get(member=self.gasman,
                                group=self.limp_ninja).is_current)
     edit = Edit.for_model(self.gasman, True).first()
     self.assertIn("changed group to Limp Ninja", edit.description)
Exemple #21
0
 def test_post_edit_alternate_names_only(self):
     response = self.client.post(
         '/bbs/%d/edit/' % self.bbs.id, {
             'name': 'StarPort',
             'location': 'Helsinki, Finland',
             'names-TOTAL_FORMS': '1',
             'names-INITIAL_FORMS': '1',
             'names-MIN_NUM_FORMS': '0',
             'names-MAX_NUM_FORMS': '1000',
             'names-0-name': 'Star Whisky episode V',
             'names-0-id': self.alt_name.id,
             'names-0-bbs': self.bbs.id
         })
     self.assertRedirects(response, '/bbs/%d/' % self.bbs.id)
     self.bbs.refresh_from_db()
     self.assertEqual(self.bbs.name, 'StarPort')
     self.assertEqual(self.bbs.names.count(), 2)
     self.assertTrue(self.bbs.names.filter(name='StarPort').exists())
     self.assertTrue(
         self.bbs.names.filter(name='Star Whisky episode V').exists())
     edit = Edit.for_model(self.bbs, True).first()
     self.assertEqual("Set alternative names to Star Whisky episode V",
                      edit.description)
Exemple #22
0
def series_history(request, party_series_id):
	party_series = get_object_or_404(PartySeries, id=party_series_id)
	return render(request, 'parties/series_history.html', {
		'party_series': party_series,
		'edits': Edit.for_model(party_series, request.user.is_staff),
	})
Exemple #23
0
def last_edited_by(context, item):
	edit = Edit.for_model(item, is_admin=context['request'].user.is_staff).order_by('-timestamp').first()
	return {
		'edit': edit,
		'item': item,
	}
Exemple #24
0
def history(request, group_id):
	group = get_object_or_404(Releaser, is_group=True, id=group_id)
	return render(request, 'groups/history.html', {
		'group': group,
		'edits': Edit.for_model(group, request.user.is_staff),
	})
Exemple #25
0
def history(request, party_id):
    party = get_object_or_404(Party, id=party_id)
    return render(request, 'parties/history.html', {
        'party': party,
        'edits': Edit.for_model(party, request.user.is_staff),
    })
Exemple #26
0
def history(request, scener_id):
    scener = get_object_or_404(Releaser, is_group=False, id=scener_id)
    return render(request, 'sceners/history.html', {
        'scener': scener,
        'edits': Edit.for_model(scener, request.user.is_staff),
    })
Exemple #27
0
def history(request, group_id):
    group = get_object_or_404(Releaser, is_group=True, id=group_id)
    return render(request, 'groups/history.html', {
        'group': group,
        'edits': Edit.for_model(group, request.user.is_staff),
    })
Exemple #28
0
def history(request, bbs_id):
    bbs = get_object_or_404(BBS, id=bbs_id)
    return render(request, 'bbs/history.html', {
        'bbs': bbs,
        'edits': Edit.for_model(bbs, request.user.is_staff),
    })
Exemple #29
0
def history(request, competition_id):
	competition = get_object_or_404(Competition, id=competition_id)
	return render(request, 'competitions/history.html', {
		'competition': competition,
		'edits': Edit.for_model(competition, request.user.is_staff),
	})
Exemple #30
0
def history(request, party_id):
	party = get_object_or_404(Party, id=party_id)
	return render(request, 'parties/history.html', {
		'party': party,
		'edits': Edit.for_model(party, request.user.is_staff),
	})
Exemple #31
0
def history(request, scener_id):
	scener = get_object_or_404(Releaser, is_group=False, id=scener_id)
	return render(request, 'sceners/history.html', {
		'scener': scener,
		'edits': Edit.for_model(scener, request.user.is_staff),
	})