Exemplo n.º 1
0
def groups(request):
    form = GroupForm()
    if request.method == 'POST':
        if form.validate(request.form):
            form.save()
            return redirect('category/admin/groups')
    return render_to_response('category/admin/groups.html',
            {'form':form.as_widget(),
             'groups':Group.all().order('category').order('name')})
Exemplo n.º 2
0
def group_edit(request, id):
    group = Group.get_by_id(id)
    if not group:
        return redirect('category/admin/groups')
    form = GroupForm(instance=group)
    if request.method == 'POST':
        if form.validate(request.form):
            tmp = form.save(commit=False)
            if group.category != tmp.category:
                for gift in group.gifts:
                    gift.category = tmp.category
                    gift.push()
            group = tmp
            group.put()
            return redirect('category/admin/groups')
    return render_to_response('category/admin/groups.html',
            {'form':form.as_widget(),
             'groups':Group.all().order('category').order('name'),
             'edit_flag':True})