示例#1
0
def view_raid(request, raid_id):
	raid = get_object_or_404(Raid, id=raid_id)
	if request.method == 'POST':
		form = RegistrationForm(request.POST)
		if form.is_valid():
			registration = Registration(player=request.user,
						    raid=raid,
						    role=form.cleaned_data['role'])
			if 'standby' in form.cleaned_data:
				registration.standby = form.cleaned_data['standby'] 
			registration.save()
	else:
		form = RegistrationForm()

	dps = Registration.objects.filter(raid=raid,role="dps").order_by("-won", "-number")
	tanks = Registration.objects.filter(raid=raid,role="tank").order_by("-won", "-number")
	healers = Registration.objects.filter(raid=raid,role="healer").order_by("-won", "-number")

	registered = { 'DPS': dps,
		       'Tanks': tanks,
		       'Healers': healers
		       }
	return render_to_response('raid/view.djhtml',
				  {'raid': raid,
				   'registered': registered,
				   'registration_form': form,
				   'is_registered': raid.is_registered(request.user)
				   },
				  context_instance=RequestContext(request))
示例#2
0
def view_raid(request, raid_id):
    raid = get_object_or_404(Raid, id=raid_id)
    if request.method == "POST":
        form = RegistrationForm(request.POST)
        if form.is_valid():
            registration = Registration(player=request.user, raid=raid, role=form.cleaned_data["role"])
            if "standby" in form.cleaned_data:
                registration.standby = form.cleaned_data["standby"]
            registration.save()
    else:
        form = RegistrationForm()

    dps = Registration.objects.filter(raid=raid, role="dps").order_by("-won", "-number")
    tanks = Registration.objects.filter(raid=raid, role="tank").order_by("-won", "-number")
    healers = Registration.objects.filter(raid=raid, role="healer").order_by("-won", "-number")

    registered = {"DPS": dps, "Tanks": tanks, "Healers": healers}
    return render_to_response(
        "raid/view.djhtml",
        {
            "raid": raid,
            "registered": registered,
            "registration_form": form,
            "is_registered": raid.is_registered(request.user),
        },
        context_instance=RequestContext(request),
    )
	def handle(self, *test_labels, **options):
            raid = Raid.objects.all()[0]
            raid.registered.clear()
            raid.has_rolled = False
            for player in User.objects.all():
		registration = Registration(player=player,
					    raid=raid,
					    standby=not random.randrange(10),
					    role=['dps', 'tank', 'healer'][random.randrange(3)])
		registration.save()
            raid.save()
            print "raid %s setup for testing" % raid