def logout_user(request): logout(request) blog = Blog.get_blog() login_form = AuthenticationForm() return render_to_response("home.html", { 'login_form': login_form, 'blog': blog }, context_instance=RequestContext(request))
def get_article(request): articles = [] if 'id' in request.POST.keys(): for art in Blog.get_blog().get_articles_before( before_id=int(request.POST['id']) + 1, quantity=1): articles.append(art.to_dict()) return HttpResponse( json.dumps({ "authenticated": request.user.is_authenticated(), "articles": articles }))
def pull_articles(request): articles = [] if 'last_id' in request.POST.keys(): for art in Blog.get_blog().get_articles_before( before_id=request.POST['last_id']): articles.append(art.to_dict()) return HttpResponse( json.dumps({ "authenticated": request.user.is_authenticated(), "articles": articles }))
def home(request): blog=Blog.get_blog() login_form=AuthenticationForm() filters = blog.get_filters() if request.method =='POST': login_form=AuthenticationForm(data=request.POST) if login_form.is_valid(): user = authenticate(username=login_form.cleaned_data['username'], password=login_form.cleaned_data['password']) if user is not None: if user.is_active: login(request, user) return render_to_response("home.html",{'login_form':login_form,'blog':blog, 'filters':filters},context_instance=RequestContext(request))
def home(request): blog = Blog.get_blog() login_form = AuthenticationForm() filters = blog.get_filters() if request.method == 'POST': login_form = AuthenticationForm(data=request.POST) if login_form.is_valid(): user = authenticate(username=login_form.cleaned_data['username'], password=login_form.cleaned_data['password']) if user is not None: if user.is_active: login(request, user) return render_to_response("home.html", { 'login_form': login_form, 'blog': blog, 'filters': filters }, context_instance=RequestContext(request))
def get_article(request): articles = [] if 'id' in request.POST.keys(): for art in Blog.get_blog().get_articles_before(before_id=int(request.POST['id'])+1, quantity=1): articles.append(art.to_dict()) return HttpResponse(json.dumps({"authenticated":request.user.is_authenticated(),"articles":articles}))
def pull_articles(request): articles = [] if 'last_id' in request.POST.keys(): for art in Blog.get_blog().get_articles_before(before_id=request.POST['last_id']): articles.append(art.to_dict()) return HttpResponse(json.dumps({"authenticated":request.user.is_authenticated(),"articles":articles}))
def logout_user(request): logout(request) blog=Blog.get_blog() login_form=AuthenticationForm() return render_to_response("home.html",{'login_form':login_form,'blog':blog},context_instance=RequestContext(request))