Beispiel #1
0
def homepage(request):

    talks = Talk.objects.filter().order_by("-when")

    if request.method == "POST":
        form = TalkForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('homepage'))
    else:
        form = TalkForm()

    return render_to_response("exampleapp/home.html", locals(), 
                              context_instance=RequestContext(request))
Beispiel #2
0
def homepage(request):

    collection = get_database()[Talk.collection_name]
    talks = collection.Talk.find()
    talks.sort('when', -1)

    if request.method == "POST":
        form = TalkForm(request.POST, collection=collection)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('homepage'))
    else:
        form = TalkForm(collection=collection)

    return render_to_response("exampleapp/home.html", locals(), 
                              context_instance=RequestContext(request))
Beispiel #3
0
def homepage(request):
    talks = Talk.objects.all().order_by('-when')
    if request.method == "POST":
        form = TalkForm(request.POST)
        if form.is_valid():
            topic = form.cleaned_data['topic']
            w = form.cleaned_data['when']
            when = datetime.datetime(w.year, w.month, w.day, 0,0,0)
            tags = form.cleaned_data['tags']
            duration = form.cleaned_data['duration']
            talk = Talk.objects.create(topic=topic, when=when,
                                       tags=tags, duration=duration)
            
            return HttpResponseRedirect(reverse('homepage'))
    else:
        form = TalkForm()
            
    return render_to_response("exampleapp/home.html", locals(), 
                              context_instance=RequestContext(request))
Beispiel #4
0
def homepage(request):
    talks = Talk.objects.all().order_by('-when')
    if request.method == "POST":
        form = TalkForm(request.POST)
        if form.is_valid():
            topic = form.cleaned_data['topic']
            w = form.cleaned_data['when']
            when = (datetime.datetime(w.year, w.month, w.day, 0, 0,
                                      0).replace(tzinfo=utc))
            tags = form.cleaned_data['tags']
            duration = form.cleaned_data['duration']
            talk = Talk.objects.create(topic=topic,
                                       when=when,
                                       tags=tags,
                                       duration=duration)
            return HttpResponseRedirect(reverse('homepage'))
    else:
        form = TalkForm()
    return render_to_response("exampleapp/home.html", {
        'talks': talks,
        'form': form
    },
                              context_instance=RequestContext(request))
Beispiel #5
0
def new(request, tmpl):
    syserr = None

    limit = datetime.strptime(settings.CFP_LIMIT_DATE, '%Y-%m-%d %H:%M:%S')
    if datetime.utcnow() > limit:
        return HttpResponseRedirect(settings.BASE_URL + '/talk/closed')

    if request.method == 'POST':
        form = TalkForm(request.POST)
        if form.is_valid():
            if form.save():
                return HttpResponseRedirect(settings.BASE_URL + '/talk/end')
            else:
                syserr = True
    else:
        form = TalkForm()
    return tmpl, locals()
Beispiel #6
0
def homepage(request):

    collection = get_database()[Talk.collection_name]
    talks = collection.Talk.find()
    talks.sort('when', -1)
    talks_count = talks.count()

    if request.method == "POST":
        form = TalkForm(request.POST, collection=collection)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('homepage'))
    else:
        form = TalkForm(collection=collection)

    return render_to_response(
        "exampleapp/home.html", {
            'talks': talks,
            'form': form,
            'talks_count': talks_count,
        },
        context_instance=RequestContext(request)
    )