Ejemplo n.º 1
0
def index(request):
    bb = BbRest(KEY, SECRET, f"https://{LEARNFQDN}")
    resp = bb.GetVersion()
    access_token = bb.token_info['access_token']
    version_json = resp.json()

    bb_json = request.session.get('bb_json')
    if (bb_json is None):
        bb = BbRest(KEY, SECRET, f"https://{LEARNFQDN}")
        bb_json = jsonpickle.encode(bb)
        print("VIEWS: index request: pickled BbRest and putting it on session")
        request.session['bb_json'] = bb_json
        request.session['target_view'] = 'index'
        return HttpResponseRedirect(reverse('get_auth_code'))
    else:
        print('VIEWS: index request: got BbRest from session')
        bb = jsonpickle.decode(bb_json)
        if bb.is_expired():
            print('VIEWS.py: index request: expired token')
            request.session['bb_json'] = None
            index(request)
        bb.supported_functions()
        bb.method_generator()
        print(f'VIEWS: index request: expiration: {bb.expiration()}')

    context = {
        'learn_server': LEARNFQDN,
        'version_json': version_json,
        'access_token': access_token,
    }

    return render(request, 'index.html', context=context)
Ejemplo n.º 2
0
def index(request):
    """View function for home page of site."""
    # request.session.flush()  # If you uncomment you can use Home to clear out the 3LO token in session.
    bb = BbRest(KEY, SECRET, f"https://{LEARNFQDN}" )
    resp = bb.GetVersion()
    access_token = bb.token_info['access_token']
    version_json = resp.json()

    context = {
        'learn_server': LEARNFQDN,
        'version_json' : version_json,
        'access_token' : access_token,
    }

    # Render the HTML template index.html with the data in the context variable
    return render(request, 'index.html', context=context)
Ejemplo n.º 3
0
def threeindex(request):
    """View function for home page of site."""

    # The following gets/stores the object to access Learn in the user's session.
    # This is key for 3LO web applications so that when you use the app, your
    # session has your object for accessing
    bb = BbRest(KEY, SECRET, f"https://{LEARNFQDN}")
    resp = bb.GetVersion()
    version_json = resp.json()

    context = {
        'learn_server': LEARNFQDN,
        'version_json': version_json,
    }

    # Render the HTML template index.html with the data in the context variable
    return render(request, 'threeindex.html', context=context)