Example #1
0
def get_post(request):
    login = request.POST['login']
    name = request.POST['name']
    password = request.POST.get('password')
    passhash = crypt.hash_text(password)
    post = _get_post(login,name)
    if post and post.password == passhash:
        data = dict(name=name, login=login, text=crypt.decrypt_text(password,post.text))

        return render_to_json(dict(data=data,success=True))

    return render_to_json({'success': False})
Example #2
0
def add_post(request):
    params = request.POST
    text, login, name, password = (params['text'], params['login'], params['name'], params['password'])

    text = crypt.encrypt_text(password,text)
    passhash = crypt.hash_text(password)
    post = _get_post(login,name)
    if post:
        if passhash == post.password:
            post.text = text
            post.save()
            return render_to_json({'success': True})
        else:
         return render_to_json({'success': False})
    #create new post
    p = Post()
    p.text, p.login, p.name, p.password = text, login, name, passhash
    p.save()

    return render_to_json({'success': True})