Esempio n. 1
0
def chapters_index(request):
    if request.method == 'GET':
        chapters = ChapterInfo.objects.all()
        return render_to_response(
                'networks/chapters_index.html',
                {
                    'chapters': chapters,
                },                    
                context_instance=RequestContext(request)
            )
    elif request.method == 'POST':
        form = ChapterInfoForm(request.POST)
        if form.is_valid():
            chapter = form.save()
            
            # also create exec list
            execlist = ExecList(name="%s Executive" % chapter.chapter_name,
                                description="%s Executive List" % chapter.chapter_name,
                                parent=chapter.network,
                                creator=request.user,
                                slug="%s-exec" % chapter.network.slug)
            execlist.save()
            
            return HttpResponseRedirect(reverse('chapter_detail', kwargs={'group_slug': chapter.network.slug}))
        else:
            return render_to_response(
                    'networks/new_chapter.html',
                    {
                        'form': form,
                    },
                    context_instance=RequestContext(request)
                )
Esempio n. 2
0
def chapters_index(request):
    if request.method == 'GET':
        chapters = ChapterInfo.objects.all()
        return render_to_response('networks/chapters_index.html', {
            'chapters': chapters,
        },
                                  context_instance=RequestContext(request))
    elif request.method == 'POST':
        form = ChapterInfoForm(request.POST)
        if form.is_valid():
            chapter = form.save()

            # also create exec list
            execlist = ExecList(name="%s Executive" % chapter.chapter_name,
                                description="%s Executive List" %
                                chapter.chapter_name,
                                parent=chapter.network,
                                creator=request.user,
                                slug="%s-exec" % chapter.network.slug)
            execlist.save()

            return HttpResponseRedirect(
                reverse('chapter_detail',
                        kwargs={'group_slug': chapter.network.slug}))
        else:
            return render_to_response('networks/new_chapter.html', {
                'form': form,
            },
                                      context_instance=RequestContext(request))
Esempio n. 3
0
def edit_chapter(request, group_slug):
    network = get_object_or_404(Network, slug=group_slug)
    chapter = get_object_or_404(ChapterInfo, network=network)

    if request.method == 'POST':
        form = ChapterInfoForm(request.POST, instance=chapter)
        if form.is_valid():
            form.save()
            return chapter_detail(request, group_slug)

    else:
        form = ChapterInfoForm(instance=chapter)

    return render_to_response('networks/edit_chapter.html', {
        'form': form,
        'chapter': chapter,
    },
                              context_instance=RequestContext(request))
Esempio n. 4
0
def edit_chapter(request, group_slug):
    network = get_object_or_404(Network, slug=group_slug)
    chapter = get_object_or_404(ChapterInfo, network=network)

    if request.method == 'POST':
        form = ChapterInfoForm(request.POST,
                               instance=chapter)
        if form.is_valid():
            form.save()
            return chapter_detail(request, group_slug)
    
    else:
        form = ChapterInfoForm(instance=chapter)
        
    return render_to_response(
            'networks/edit_chapter.html',
            {
                'form': form,
                'chapter': chapter,
            },
            context_instance=RequestContext(request)
        )
Esempio n. 5
0
def chapters_index(request):
    if request.method == 'GET':
        chapters = ChapterInfo.objects.all()
        return render_to_response(
                'networks/chapters_index.html',
                {
                    'chapters': chapters,
                },                    
                context_instance=RequestContext(request)
            )
    elif request.method == 'POST':
        form = ChapterInfoForm(request.POST)
        if form.is_valid():
            chapter = form.save()
            return HttpResponseRedirect(reverse('chapter_detail', kwargs={'group_slug': chapter.network.slug}))
        else:
            return render_to_response(
                    'networks/new_chapter.html',
                    {
                        'form': form,
                    },
                    context_instance=RequestContext(request)
                )