similar to a hybrid of the random facts (but defined more simply) and the dice rolling (but not picking from dice), this allows for definition of "choice sets" (only in the admin for the moment) and then getting a random pull from that set (only in the web interface for the moment)
26 lines
623 B
Python
26 lines
623 B
Python
"""Display choice sets."""
|
|
|
|
import logging
|
|
|
|
from django.shortcuts import get_object_or_404, render
|
|
|
|
from choices.models import ChoiceSet
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
def index(request):
|
|
"""Display nothing, for the moment."""
|
|
|
|
choicesets = ChoiceSet.objects.all()
|
|
|
|
return render(request, 'choices/index.html', {'choicesets': choicesets})
|
|
|
|
|
|
def choiceset_detail(request, set_name):
|
|
"""Display info, and a random choice, for the requested choice set."""
|
|
|
|
choiceset = get_object_or_404(ChoiceSet, name=set_name)
|
|
|
|
return render(request, 'choices/choiceset_detail.html', {'choiceset': choiceset})
|