示例#1
0
文件: card_views.py 项目: prcek/TSReg
def delete(request, card_id):


    card = Card.get_by_id(int(card_id))

    if card is None:
        raise Http404

    card.delete()

    return HttpResponseRedirect('../..')
示例#2
0
文件: card_views.py 项目: prcek/TSReg
def edit(request, card_id):

    card = Card.get_by_id(int(card_id))

    if card is None:
        raise Http404

    if request.method == 'POST':
        form = CardForm(request.POST, instance=card)
        if form.is_valid():
            logging.info('edit card before %s'% card)
            form.save(commit=False)
            logging.info('edit card after %s'% card)
            card.save()
            return HttpResponseRedirect('../..')
    else:
        form = CardForm(instance=card)

    return render_to_response('admin/cards_edit.html', RequestContext(request, {'form':form}))