Пример #1
0
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))
Пример #2
0
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
        }))
Пример #3
0
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
        }))
Пример #4
0
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))
Пример #5
0
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))
Пример #6
0
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}))
Пример #7
0
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}))
Пример #8
0
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))