def post_entry_add(request):

    engine = CryptoEngine(master_key=request.user.password)

    e = None
    attributes = set(['title', 'password', 'category'])
    if attributes <= set(request.POST.keys()):

        e = Entry(title=request.POST['title'],
                  password=request.POST['password'])

        for k, v in request.POST.items():
            if k == 'username':
                e.username = v
            elif k == 'url':
                e.url = v
            elif k == 'comment':
                e.comment = v
            elif k == 'expires':
                # date formated: m/d/Y
                e.expires = datetime.datetime.strptime(v, "%m/%d/%Y").date()
            elif k == 'category':
                c = Category.objects.filter(id=int(v))
                if len(c) == 0:
                    return HttpResponse(0)
                else:
                    e.category_id = int(v)
        try:
            e.save()
            return HttpResponse(1)
        except:
            return HttpResponse(0)
    else:
        return HttpResponse(0)
def post_entry_add(request):

    engine = CryptoEngine(master_key=request.user.password)

    e = None
    attributes = set(['title', 'password', 'category'])
    if attributes <= set(request.POST.keys()):

        e = Entry(title=request.POST['title'],
                  password=request.POST['password'])

        for k, v in request.POST.items():
            if k == 'username':
                e.username = v
            elif k == 'url':
                e.url = v
            elif k == 'comment':
                e.comment = v
            elif k == 'expires':
                # date formated: m/d/Y
                e.expires = datetime.datetime.strptime(v, "%m/%d/%Y").date()
            elif k == 'category':
                c = Category.objects.filter(id=int(v))
                if len(c) == 0:
                    return HttpResponse(0)
                else:
                    e.category_id = int(v)
        try:
            e.save()
            return HttpResponse(1)
        except:
            return HttpResponse(0)
    else:
        return HttpResponse(0)