Ejemplo n.º 1
0
def oauth_stmts(req, access_token=None):
    info = {'req': req, 'page': 'report/home.html'}
    try:
        user = User.objects.get(username__exact=TESTUSER['name'])
    except User.DoesNotExist:
        user = User.objects.create_user(TESTUSER['name'], TESTUSER['email'], TESTUSER['password'])
    
    consumer = connecttolrs.get_consumer(KEY, SECRET)

    try:
        if access_token:
            token = access_token
            rec, created = Tokens.objects.get_or_create(user=user)
            rec.token_str = token.to_string()
            rec.save()
        else:
            tstr = Tokens.objects.get(user=user).token_str
            if tstr:
                token = connecttolrs.get_token(tstr)
            else:
                raise Tokens.DoesNotExist("token string was empty")
        return connecttolrs.get_statements(display, info, consumer=consumer, token=token)
    except Tokens.DoesNotExist:
        return connecttolrs.request_token(oauth_stmts, info, consumer)
Ejemplo n.º 2
0
def home(req):
    info = {'req': req, 'page': 'report/home.html'}
    return connecttolrs.get_statements(display, info, verb="http://adlnet.gov/xapi/verbs/completed")