예제 #1
0
파일: admin.py 프로젝트: zhigoo/youflog
def addLink(request):
    type= request.POST.get('type','add')
    text = request.POST.get('text','')
    href = request.POST.get('href','http://www.iyouf.info')
    if not href.startswith('http://'):
        href = 'http://'+href
    comment = request.POST.get('comment','')
    if type and type == 'add':
        link=Link(text=text,href=href,comment=comment)
        link.save()
    else:
        id=request.POST.get('id','')
        link=Link.objects.get(id=id)
        link.text=text
        link.href=href
        link.comment=comment
        link.save()
    return HttpResponseRedirect('/admin/links')