Beispiel #1
0
def create_collection(request):
    if request.method == 'POST':
        form = CreateCollectionForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('administration_gallery_index'))
    else:
        form = CreateCollectionForm()
    return direct_to_template(request, 'gallery/administration/create.html',
                              {'form': form,
                               'active_module': 'gallery'})
Beispiel #2
0
def edit_collection(request, collection_id):
    collection = get_object_or_404(Collection, id=collection_id)
    if request.method == 'POST':
        form = CreateCollectionForm(request.POST, instance=collection)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('administration_gallery_index'))
    else:

        form = CreateCollectionForm(model_to_dict(collection),instance=collection)
    return direct_to_template(request, 'gallery/administration/edit.html',
                              {'form': form,
                               'collection':collection,
                               'active_module': 'gallery'})