Esempio n. 1
0
def blog_page(request):
    '''
    handles the dashobard landing page
    if user not logged in and not stuff we show them the login page
    @request  request object
    '''
    if not request.user.is_active or not request.user.is_staff:
        return render_view(request, 'login.html', {})
    if request.POST:
        print request.POST
        form = AddPostForm(request.POST, request.FILES)
        if not form.is_valid():
            error_message(request, "addpost")
        else:
            post = form.save()
            success_message(request, "addpost", {'post': post, 'is_published': request.POST['is_published']})
    return render_view(request, 'dashboard-index.html', {})
Esempio n. 2
0
def login_page(request):
    '''
    handles the dashobard landing page
    if user not logged in and not stuff we show them the login page
    @request  request object
    '''
    if request.POST:
        form = loginForm(request.POST)
        if form.is_valid():
            username = request.POST.get('username')
            password = request.POST.get('password')
            user = authenticate(username=username, password=password)
            if user is not None:
                if user.is_active and user.is_staff:
                    login(request, user)
                    success_message(request, "login")
                    return HttpResponseRedirect(settings.DASHBOARD_URL)
                else:
                    error_message(request, "login")
            else:
                error_message(request, "login")
        else:
            error_message(request, "login")
    return render_view(request, 'login.html')