Exemplo n.º 1
0
def fullpost(request, url):
    try:
        post = Post.objects.get(url=url)
    except Post.DoesNotExist:
        raise Http404
    return HttpResponse(
        render_template('blog/fullpost.tpl', request, {'post': post}))
Exemplo n.º 2
0
def register(request):
    if 'username' in request.POST:
        User.objects.create_user(request.POST['username'], request.POST['email'],
                                 request.POST['password'])
        template_name = 'users/success.tpl'
        context = {'mode': 'register'}
    else:
        template_name = 'users/register.tpl'
        context = {}
    return HttpResponse(render_template(template_name, request, context))
Exemplo n.º 3
0
def register(request):
    if 'username' in request.POST:
        User.objects.create_user(request.POST['username'],
                                 request.POST['email'],
                                 request.POST['password'])
        template_name = 'users/success.tpl'
        context = {'mode': 'register'}
    else:
        template_name = 'users/register.tpl'
        context = {}
    return HttpResponse(render_template(template_name, request, context))
Exemplo n.º 4
0
def connect(request):
    if 'username' in request.POST:
        user = authenticate(username=request.POST['username'],
                            password=request.POST['password'])
        if user is not None:
            if user.is_active:
                login(request, user)
                template_name = 'users/success.tpl'
                context = {'mode': 'connect'}
            else:
                template_name = 'users/fail.tpl'
                context = {'mode': 'connect', 'why': 'disabled'}
        else:
            template_name = 'users/fail.tpl'
            context = {'mode': 'connect', 'why': 'incorrect'}
    else:
        template_name = 'users/connect.tpl'
        context = {}
    return HttpResponse(render_template(template_name, request, context))
Exemplo n.º 5
0
def connect(request):
    if 'username' in request.POST:
        user = authenticate(username=request.POST['username'],
                            password=request.POST['password'])
        if user is not None:
            if user.is_active:
                login(request, user)
                template_name = 'users/success.tpl'
                context = {'mode': 'connect'}
            else:
                template_name = 'users/fail.tpl'
                context = {'mode': 'connect', 'why': 'disabled'}
        else:
            template_name = 'users/fail.tpl'
            context = {'mode': 'connect', 'why': 'incorrect'}
    else:
        template_name = 'users/connect.tpl'
        context = {}
    return HttpResponse(render_template(template_name, request, context))
Exemplo n.º 6
0
def index(request):
    post_list = Post.objects.all().order_by('-publishedDate')[:10]
    return HttpResponse(render_template('blog/index.tpl', request, {'post_list': post_list}))
Exemplo n.º 7
0
def fullpost(request, url):
    try:
        post = Post.objects.get(url=url)
    except Post.DoesNotExist:
        raise Http404
    return HttpResponse(render_template('blog/fullpost.tpl', request, {'post': post}))
Exemplo n.º 8
0
def index(request):
    post_list = Post.objects.all().order_by('-publishedDate')[:10]
    return HttpResponse(
        render_template('blog/index.tpl', request, {'post_list': post_list}))
Exemplo n.º 9
0
def disconnect(request):
    logout(request)
    template_name = 'users/success.tpl'
    context = {'mode': 'disconnect'}
    return HttpResponse(render_template(template_name, request, context))
Exemplo n.º 10
0
def disconnect(request):
    logout(request)
    template_name = 'users/success.tpl'
    context = {'mode': 'disconnect'}
    return HttpResponse(render_template(template_name, request, context))