Exemple #1
0
def agenda_add_view(request):
    allowed_methods = ['GET', 'POST']
    template_name = 'agendas/agenda_add.html'

    if not request.user.is_superuser:
        return HttpResponseRedirect('/agenda/')

    if request.method == 'POST':
        form = AddAgendaForm(request.POST)
        if form.is_valid():
            agenda = Agenda()
            agenda.name = form.cleaned_data['name']
            agenda.public_owner_name = form.cleaned_data['public_owner_name']
            agenda.description = form.cleaned_data['description']
            agenda.save()
            agenda.editors.add(request.user)
            return HttpResponseRedirect(
                agenda.get_absolute_url())  # Redirect after POST
    else:
        initial_data = {'public_owner_name': request.user.username}
        form = AddAgendaForm(
            initial=initial_data)  # An unbound form with initial data

    return render_to_response(template_name, {'form': form},
                              context_instance=RequestContext(request))
Exemple #2
0
def agenda_add_view(request):
    allowed_methods = ['GET', 'POST']
    template_name = 'agendas/agenda_add.html'

    if not request.user.is_superuser:
        return HttpResponseRedirect('/agenda/')

    if request.method == 'POST':
        form = AddAgendaForm(request.POST)
        if form.is_valid():
            agenda = Agenda()
            agenda.name = form.cleaned_data['name']
            agenda.public_owner_name = form.cleaned_data['public_owner_name']
            agenda.description = form.cleaned_data['description']
            agenda.save()
            agenda.editors.add(request.user)
            return HttpResponseRedirect('/agenda/') # Redirect after POST
    else:
        initial_data = {'public_owner_name': request.user.username}
        form = AddAgendaForm(initial=initial_data) # An unbound form with initial data

    return render_to_response(template_name, {'form': form}, context_instance=RequestContext(request))
Exemple #3
0
def agenda_add_view(request):
    allowed_methods = ["GET", "POST"]
    template_name = "agendas/agenda_add.html"

    if not request.user.is_superuser:
        return HttpResponseRedirect("/agenda/")

    if request.method == "POST":
        form = AddAgendaForm(request.POST)
        if form.is_valid():
            agenda = Agenda()
            agenda.name = form.cleaned_data["name"]
            agenda.public_owner_name = form.cleaned_data["public_owner_name"]
            agenda.description = form.cleaned_data["description"]
            agenda.save()
            agenda.editors.add(request.user)
            return HttpResponseRedirect("/agenda/")  # Redirect after POST
    else:
        initial_data = {"public_owner_name": request.user.username}
        form = AddAgendaForm(initial=initial_data)  # An unbound form with initial data

    return render_to_response(template_name, {"form": form}, context_instance=RequestContext(request))