Exemplo n.º 1
0
def table_create(request, category):
    category = get_object_or_404(Category, slug=category)
    if request.method == "POST":
        form = TableCreationForm(request.POST)
        if form.is_valid():
            table = Table.objects.create(
                owner=request.user,
                category=category,
                title=form.cleaned_data["title"],
                slug=slugify(form.cleaned_data["title"]),
                description=form.cleaned_data["description"],
            )
            return HttpResponseRedirect(
                reverse("esus-phorum-table", kwargs={"category": category.slug, "table": table.slug})
            )
    else:
        form = TableCreationForm()
    return direct_to_template(request, "esus/table_create.html", {"category": category, "form": form})
Exemplo n.º 2
0
def comments_create(request, event_id, template='con/comments/new.html'):
    event = get_object_or_404(Event, pk=event_id)

    if request.method == "POST":
        table_form = TableCreationForm(request.POST)
        if table_form.is_valid():
            table, category = create_table(
                event = event,
                owner = request.user,
                **table_form.cleaned_data
            )
            return HttpResponseRedirect(reverse('esus-phorum-table', kwargs={
                'category' : category.slug,
                'table' : table.slug,
            }))
    else:
        table_form = TableCreationForm()


    return render_to_response(template, {
        'event' : event,
        'table_form' : table_form,
    }, context_instance=RequestContext(request))