예제 #1
0
파일: views.py 프로젝트: Frans/Boss-Spawns
def boss(request, server_id, boss_id):
    server = get_object_or_404(Server, pk=server_id)
    boss = get_object_or_404(Boss, pk=boss_id)
    form = DeathCountForm

    # If the user is posting a form, try to submit it
    if request.method == 'POST' and request.user.is_authenticated():
        form = DeathCountForm(request.POST)

        # IF the form is valid, redirect
        # otherwise, continue and draw the form with errors
        if form.is_valid():
            messages.success(request, 'Thanks for making Tyria a safer place.')
            form.save(request.user, boss, server)
            return HttpResponseRedirect(reverse('server-boss', args=[server.pk, boss.pk]))

    return render(request, 'boss_details.html', {
            'server': server,
            'boss': boss,
            'deaths': DeathCount.objects.in_spawn_range(boss, server),
            'death_form': form,
            'server_time': now().astimezone(server.tz)
    })
예제 #2
0
    def test_matching_submittions_dont_dupe(self):
        # Submit once
        form = DeathCountForm(self.data)
        data = form.save(self.user, self.boss, self.server)
        self.assertIsNotNone(data)
        self.assertIsInstance(data, DeathCount)

        # SUbmit twice
        form = DeathCountForm(self.data)
        data = form.save(self.user, self.boss, self.server)
        self.assertIsNotNone(data)
        self.assertIsInstance(data, DeathCount)

        self.assertEqual(
            DeathCount.objects.count(), 1,
            "Second matching submission should not create DeathCount")

        # SUbmit a new time
        self.data['death_time'] = self.data['death_time'].replace("38", "39")
        form = DeathCountForm(self.data)
        data = form.save(self.user, self.boss, self.server)
        self.assertEqual(DeathCount.objects.count(), 2,
                         "Non-existing submission should create DeathCount")
예제 #3
0
파일: tests.py 프로젝트: Frans/Boss-Spawns
    def test_matching_submittions_dont_dupe(self):
        # Submit once
        form = DeathCountForm(self.data)
        data = form.save(self.user, self.boss, self.server)
        self.assertIsNotNone(data)
        self.assertIsInstance(data, DeathCount)

        # SUbmit twice
        form = DeathCountForm(self.data)
        data = form.save(self.user, self.boss, self.server)
        self.assertIsNotNone(data)
        self.assertIsInstance(data, DeathCount)

        self.assertEqual(DeathCount.objects.count(), 1, "Second matching submission should not create DeathCount")

        # SUbmit a new time
        self.data['death_time'] = self.data['death_time'].replace("38", "39")
        form = DeathCountForm(self.data)
        data = form.save(self.user, self.boss, self.server)
        self.assertEqual(DeathCount.objects.count(), 2, "Non-existing submission should create DeathCount")
예제 #4
0
파일: tests.py 프로젝트: Frans/Boss-Spawns
 def test_form_save(self):
     form = DeathCountForm(self.data)
     data = form.save(self.user, self.boss, self.server)
     self.assertIsNotNone(data)
     self.assertIsInstance(data, DeathCount)
예제 #5
0
 def test_form_save(self):
     form = DeathCountForm(self.data)
     data = form.save(self.user, self.boss, self.server)
     self.assertIsNotNone(data)
     self.assertIsInstance(data, DeathCount)