Esempio n. 1
0
def index(request):
    if QotdGame.disabled():
        return HttpResponseRedirect(reverse('wouso.interface.views.homepage'))
    qotd = QotdGame.get_for_today()

    profile = request.user.get_profile()
    qotd_user = profile.get_extension(QotdUser)

    if qotd_user.has_answered:
        return HttpResponseRedirect(reverse('games.qotd.views.done'))

    if qotd is None:
        form = None

    elif request.method == "POST":
        form = QotdForm(qotd, request.POST)
        if form.is_valid():
            choice = int(form.cleaned_data['answers'])
            QotdGame.answered(qotd_user, qotd, choice)

            return HttpResponseRedirect(reverse('games.qotd.views.done'))
    else:
        form = QotdForm(qotd)

    return render_to_response('qotd/index.html',
            {'question': qotd, 'form': form},
            context_instance=RequestContext(request))
Esempio n. 2
0
def index(request):
    if QotdGame.disabled():
        return HttpResponseRedirect(reverse('wouso.interface.views.homepage'))
    qotd = QotdGame.get_for_today()

    profile = request.user.get_profile()
    qotd_user = profile.get_extension(QotdUser)

    if qotd_user.has_answered:
        return HttpResponseRedirect(reverse('games.qotd.views.done'))

    if qotd is None:
        form = None

    elif request.method == "POST":
        form = QotdForm(qotd, request.POST)
        if form.is_valid():
            choice = int(form.cleaned_data['answers'])
            QotdGame.answered(qotd_user, qotd, choice)

            return HttpResponseRedirect(reverse('games.qotd.views.done'))
    else:
        form = QotdForm(qotd)

    return render_to_response('qotd/index.html', {
        'question': qotd,
        'form': form
    },
                              context_instance=RequestContext(request))
Esempio n. 3
0
    def post(self, request, *args, **kwargs):
        if self.qotd is None:
            form = None
        else:
            form = QotdForm(self.qotd, request.POST)
            if form.is_valid():
                choice = int(form.cleaned_data['answers'])
                QotdGame.answered(self.qotd_user, self.qotd, choice)
                return redirect('games.qotd.views.done')

        return render_to_response('qotd/index.html',
                                  {'question': self.qotd, 'form': form},
                                  context_instance=RequestContext(request))
Esempio n. 4
0
    def post(self, request, *args, **kwargs):
        if self.qotd is None:
            form = None
        else:
            form = QotdForm(self.qotd, request.POST)
            if form.is_valid():
                choice = int(form.cleaned_data["answers"])
                QotdGame.answered(self.qotd_user, self.qotd, choice)
                return redirect("games.qotd.views.done")

        return render_to_response(
            "qotd/index.html", {"question": self.qotd, "form": form}, context_instance=RequestContext(request)
        )
Esempio n. 5
0
    def post(self, request, *args, **kwargs):
        if self.qotd is None:
            form = None
        else:
            form = QotdForm(self.qotd, request.POST)
            if form.is_valid():
                choice = int(form.cleaned_data['answers'])
                QotdGame.answered(self.qotd_user, self.qotd, choice)
                return redirect('games.qotd.views.done')

        return render_to_response('qotd/index.html', {
            'question': self.qotd,
            'form': form
        },
                                  context_instance=RequestContext(request))
Esempio n. 6
0
def index(request):
    if QotdGame.disabled():
        return HttpResponseRedirect(reverse('wouso.interface.views.homepage'))

    profile = request.user.get_profile()
    qotd_user = profile.get_extension(QotdUser)

    if qotd_user.magic.has_modifier('qotd-blind'):
        messages.error(
            request,
            _("You have been blinded,you cannot answer to the Question of the Day"
              ))
        return redirect('games.qotd.views.history')
    elif not qotd_user.has_question:
        qotd = QotdGame.get_for_today()
        qotd_user.set_question(qotd)
    else:
        qotd = qotd_user.my_question

    if qotd_user.has_answered:
        qotd_user.reset_question()
        extra = request.GET.urlencode()
        if extra:
            extra = '?' + extra
        return HttpResponseRedirect(
            reverse('games.qotd.views.history') + extra)

    if qotd is None:
        form = None

    elif request.method == "POST":
        form = QotdForm(qotd, request.POST)
        if form.is_valid():
            choice = int(form.cleaned_data['answers'])
            QotdGame.answered(qotd_user, qotd, choice)
            extra = request.GET.urlencode()
            if extra:
                extra = '?' + extra
            return HttpResponseRedirect(
                reverse('games.qotd.views.done') + extra)
    else:
        form = QotdForm(qotd)

    return render_to_response('qotd/index.html', {
        'question': qotd,
        'form': form
    },
                              context_instance=RequestContext(request))
Esempio n. 7
0
def index(request):
    if QotdGame.disabled():
        return HttpResponseRedirect(reverse('wouso.interface.views.homepage'))

    profile = request.user.get_profile()
    qotd_user = profile.get_extension(QotdUser)
    
    if qotd_user.has_modifier('qotd-blind'):
        return render_to_response('qotd/index.html', {"error":_("You have been blinded,you cannot answer to the Question of the Day")}, context_instance=RequestContext(request))

    if not qotd_user.has_question:
        qotd = QotdGame.get_for_today()
        qotd_user.set_question(qotd)
    else:
        qotd = qotd_user.my_question

    if qotd_user.has_answered:
        qotd_user.reset_question()
        extra = request.GET.urlencode()
        if extra:
            extra = '?' + extra
        return HttpResponseRedirect(reverse('games.qotd.views.done') + extra)

    if qotd is None:
        form = None

    elif request.method == "POST":
        form = QotdForm(qotd, request.POST)
        if form.is_valid():
            choice = int(form.cleaned_data['answers'])
            QotdGame.answered(qotd_user, qotd, choice)
            extra = request.GET.urlencode()
            if extra:
                extra = '?' + extra
            return HttpResponseRedirect(reverse('games.qotd.views.done') + extra)
    else:
        form = QotdForm(qotd)

    return render_to_response('qotd/index.html',
            {'question': qotd, 'form': form},
            context_instance=RequestContext(request))
Esempio n. 8
0
def index(request):
    if QotdGame.disabled():
        return HttpResponseRedirect(reverse("wouso.interface.views.homepage"))

    profile = request.user.get_profile()
    qotd_user = profile.get_extension(QotdUser)

    if qotd_user.magic.has_modifier("qotd-blind"):
        messages.error(request, _("You have been blinded,you cannot answer to the Question of the Day"))
        return redirect("games.qotd.views.history")
    elif not qotd_user.has_question:
        qotd = QotdGame.get_for_today()
        qotd_user.set_question(qotd)
    else:
        qotd = qotd_user.my_question

    if qotd_user.has_answered:
        qotd_user.reset_question()
        extra = request.GET.urlencode()
        if extra:
            extra = "?" + extra
        return HttpResponseRedirect(reverse("games.qotd.views.done") + extra)

    if qotd is None:
        form = None

    elif request.method == "POST":
        form = QotdForm(qotd, request.POST)
        if form.is_valid():
            choice = int(form.cleaned_data["answers"])
            QotdGame.answered(qotd_user, qotd, choice)
            extra = request.GET.urlencode()
            if extra:
                extra = "?" + extra
            return HttpResponseRedirect(reverse("games.qotd.views.done") + extra)
    else:
        form = QotdForm(qotd)

    return render_to_response(
        "qotd/index.html", {"question": qotd, "form": form}, context_instance=RequestContext(request)
    )