Пример #1
0
def showPathway(request, email):
    LogRecord.emit(request.user, 'pathAdvisor/showPathway', email)
    
    template = loader.get_template('consentrecords/userHome.html')
    args = {
        'user': request.user,
        'backURL': '/',
    }
    
    if request.user.is_authenticated():
        user = Instance.getUserInstance(request.user)
        if not user:
            return HttpResponse("user is not set up: %s" % request.user.get_full_name())
        args['userID'] = user.id
        
    if settings.FACEBOOK_SHOW:
        args['facebookIntegration'] = True
    
    containerPath = '_user[_email=%s]' % email
    userInfo = UserInfo(request.user)
    objs = pathparser.selectAllObjects(containerPath, userInfo=userInfo, securityFilter=userInfo.findFilter)
    if len(objs) > 0:
        args['state'] = 'pathway%s' % objs[0].id

    context = RequestContext(request, args)
        
    return HttpResponse(template.render(context))
Пример #2
0
def orgHome(request):
    LogRecord.emit(request.user, 'pathAdvisor/orgHome', '')
    
    template = loader.get_template('consentrecords/orgHome.html')
    args = {
        'user': request.user,
        'backURL': '/',
    }
    
    if request.user.is_authenticated():
        user = Instance.getUserInstance(request.user)
        if not user:
            return HttpResponse("user is not set up: %s" % request.user.get_full_name())
        args['userID'] = user.id
        
    if settings.FACEBOOK_SHOW:
        args['facebookIntegration'] = True
    
    state = request.GET.get('state', None)
    if state:
        args['state'] = state

    context = RequestContext(request, args)
        
    return HttpResponse(template.render(context))
Пример #3
0
def find(request, serviceid, offeringid):
    LogRecord.emit(request.user, 'pathAdvisor/find', '')
    
    template = loader.get_template('consentrecords/userHome.html')
    args = {
        'user': request.user,
        'backURL': '/',
    }
    
    if request.user.is_authenticated():
        args['userID'] = Instance.getUserInstance(request.user).id
        
    if settings.FACEBOOK_SHOW:
        args['facebookIntegration'] = True
    
    args['state'] = "findNewExperience" + serviceid + offeringid
    
    if settings.FACEBOOK_SHOW:
        offering = Instance.objects.get(pk=offeringid)
        args['fbURL'] = request.build_absolute_uri()
        args['fbTitle'] = offering._description
        args['fbDescription'] = offering.parent and offering.parent.parent and offering.parent.parent._description

    context = RequestContext(request, args)
        
    return HttpResponse(template.render(context))
Пример #4
0
def showInstances(request):
    LogRecord.emit(request.user, 'pathAdvisor/list', '')
    
    try:
        # The type of the root object.
        rootType = request.GET.get('type', None)
        root = rootType and terms[rootType];
        path=request.GET.get('path', "_term")
        header=request.GET.get('header', "List")
            
        template = loader.get_template('consentrecords/configuration.html')
    
        argList = {
            'user': request.user,
            'canShowObjects': request.user.is_staff,
            'canAddObject': request.user.is_staff,
            'path': urllib.parse.unquote_plus(path),
            'header': header,
            }
        if root:
            argList["rootID"] = root.id
            argList["singularName"] = root._description
        
        if request.user.is_authenticated():
            user = Instance.getUserInstance(request.user)
            if not user:
                return HttpResponse("user is not set up: %s" % request.user.get_full_name())
            argList['userID'] = user.id
        
        context = RequestContext(request, argList)
        
        return HttpResponse(template.render(context))
    except Exception as e:
        return HttpResponse(str(e))
Пример #5
0
def showPathway(request, email):
    LogRecord.emit(request.user, 'pathAdvisor/showPathway', email)

    template = loader.get_template('consentrecords/userHome.html')
    args = {
        'user': request.user,
        'backURL': '/',
    }

    if request.user.is_authenticated():
        user = Instance.getUserInstance(request.user)
        if not user:
            return HttpResponse("user is not set up: %s" %
                                request.user.get_full_name())
        args['userID'] = user.id

    if settings.FACEBOOK_SHOW:
        args['facebookIntegration'] = True

    containerPath = '_user[_email=%s]' % email
    userInfo = UserInfo(request.user)
    objs = pathparser.selectAllObjects(containerPath,
                                       userInfo=userInfo,
                                       securityFilter=userInfo.findFilter)
    if len(objs) > 0:
        args['state'] = 'pathway%s' % objs[0].id

    context = RequestContext(request, args)

    return HttpResponse(template.render(context))
Пример #6
0
def orgHome(request):
    LogRecord.emit(request.user, 'pathAdvisor/orgHome', '')

    template = loader.get_template('consentrecords/orgHome.html')
    args = {
        'user': request.user,
        'backURL': '/',
    }

    if request.user.is_authenticated():
        user = Instance.getUserInstance(request.user)
        if not user:
            return HttpResponse("user is not set up: %s" %
                                request.user.get_full_name())
        args['userID'] = user.id

    if settings.FACEBOOK_SHOW:
        args['facebookIntegration'] = True

    state = request.GET.get('state', None)
    if state:
        args['state'] = state

    context = RequestContext(request, args)

    return HttpResponse(template.render(context))
Пример #7
0
def showInstances(request):
    LogRecord.emit(request.user, 'pathAdvisor/list', '')

    try:
        # The type of the root object.
        rootType = request.GET.get('type', None)
        root = rootType and terms[rootType]
        path = request.GET.get('path', "_term")
        header = request.GET.get('header', "List")

        template = loader.get_template('consentrecords/configuration.html')

        argList = {
            'user': request.user,
            'canShowObjects': request.user.is_staff,
            'canAddObject': request.user.is_staff,
            'path': urllib.parse.unquote_plus(path),
            'header': header,
        }
        if root:
            argList["rootID"] = root.id
            argList["singularName"] = root._description

        if request.user.is_authenticated():
            user = Instance.getUserInstance(request.user)
            if not user:
                return HttpResponse("user is not set up: %s" %
                                    request.user.get_full_name())
            argList['userID'] = user.id

        context = RequestContext(request, argList)

        return HttpResponse(template.render(context))
    except Exception as e:
        return HttpResponse(str(e))
Пример #8
0
def find(request, serviceid, offeringid):
    LogRecord.emit(request.user, 'pathAdvisor/find', '')

    template = loader.get_template('consentrecords/userHome.html')
    args = {
        'user': request.user,
        'backURL': '/',
    }

    if request.user.is_authenticated():
        args['userID'] = Instance.getUserInstance(request.user).id

    if settings.FACEBOOK_SHOW:
        args['facebookIntegration'] = True

    args['state'] = "findNewExperience" + serviceid + offeringid

    if settings.FACEBOOK_SHOW:
        offering = Instance.objects.get(pk=offeringid)
        args['fbURL'] = request.build_absolute_uri()
        args['fbTitle'] = offering._description
        args[
            'fbDescription'] = offering.parent and offering.parent.parent and offering.parent.parent._description

    context = RequestContext(request, args)

    return HttpResponse(template.render(context))
Пример #9
0
def log(request):
    try:
        if request.method != "POST":
            raise Exception("emit only responds to POST requests")
    
        user = request.user
        data = request.POST
    
        name = data.get('name', '')
        message = data.get('message', '')
        LogRecord.emit(user, name, message)
        
        results = {'success':True}
    except Exception as e:
        logger = logging.getLogger(__name__)
        logger.error("%s" % traceback.format_exc())
        results = {'success':False, 'error': str(e)}
    
    return JsonResponse(results)
Пример #10
0
def log(request):
    try:
        if request.method != "POST":
            raise Exception("emit only responds to POST requests")

        user = request.user
        data = request.POST

        name = data.get('name', '')
        message = data.get('message', '')
        LogRecord.emit(user, name, message)

        results = {'success': True}
    except Exception as e:
        logger = logging.getLogger(__name__)
        logger.error("%s" % traceback.format_exc())
        results = {'success': False, 'error': str(e)}

    return JsonResponse(results)
Пример #11
0
def addExperience(request, experienceID):
    LogRecord.emit(request.user, 'pathAdvisor/addExperience', experienceID)
    
    template = loader.get_template('consentrecords/userHome.html')
    args = {
        'user': request.user,
        'backURL': '/',
    }
    
    if request.user.is_authenticated():
        user = Instance.getUserInstance(request.user)
        if not user:
            return HttpResponse("user is not set up: %s" % request.user.get_full_name())
        args['userID'] = user.id
        
    if settings.FACEBOOK_SHOW:
        args['facebookIntegration'] = True
    
    args['state'] = 'addExperience%s' % experienceID

    context = RequestContext(request, args)
        
    return HttpResponse(template.render(context))
Пример #12
0
def addExperience(request, experienceID):
    LogRecord.emit(request.user, 'pathAdvisor/addExperience', experienceID)

    template = loader.get_template('consentrecords/userHome.html')
    args = {
        'user': request.user,
        'backURL': '/',
    }

    if request.user.is_authenticated():
        user = Instance.getUserInstance(request.user)
        if not user:
            return HttpResponse("user is not set up: %s" %
                                request.user.get_full_name())
        args['userID'] = user.id

    if settings.FACEBOOK_SHOW:
        args['facebookIntegration'] = True

    args['state'] = 'addExperience%s' % experienceID

    context = RequestContext(request, args)

    return HttpResponse(template.render(context))
Пример #13
0
def addToPathway(request):
    LogRecord.emit(request.user, 'pathAdvisor/addToPathway', str(request.user))
    
    organizationName = request.GET.get('o', None)
    siteName = request.GET.get('s', None)
    offeringName = request.GET.get('f', None)
    serviceName = request.GET.get('m', None)
    
    print(organizationName, siteName, offeringName, serviceName)

    userInfo = UserInfo(request.user)
    
    if offeringName and terms.isUUID(offeringName):
        offering = terms[offeringName]
    elif siteName and terms.isUUID(siteName):
        site = terms[siteName]
        if offeringName:
            offerings = site.getChildrenByName(terms['Offering'], terms.name, offeringName)
            offering = offerings[0] if len(offerings) else None
    elif organizationName and terms.isUUID(organizationName):
        organization = terms[organizationName]
        site, offering = _getOrganizationChildren(organization, siteName, offeringName)
    elif organizationName:
        organization = terms['Organization'].getInstanceByName(terms.name, organizationName, userInfo)
        if organization:
            site, offering = _getOrganizationChildren(organization, siteName, offeringName)
        else:
            site, offering = None, None
    
    if serviceName and terms.isUUID(serviceName):
        service = terms[serviceName]
    elif serviceName:
        service = terms['Service'].getInstanceByName(terms.name, serviceName, userInfo)
    else:
        service = None
        
    template = loader.get_template('consentrecords/userHome.html')
    args = {
        'user': request.user,
        'backURL': '/',
    }
    
    if settings.FACEBOOK_SHOW:
        args['fbURL'] = request.build_absolute_uri()
        args['fbTitle'] = 'Add %s'%(offeringName if offeringName else serviceName if serviceName else 'Experience')
        atText = (organizationName if organizationName == siteName else \
                ('%s//%s' % (organizationName, siteName)) if siteName else organizationName)
        args['fbDescription'] = atText

    if organizationName:
        args['organization'] = organization.id if organization else organizationName
    if siteName:
        args['site'] = site.id if site else siteName
    if offeringName:
        args['offering'] = offering.id if offering else offeringName
    if serviceName:
        args['service'] = service.id if service else serviceName
    
    if request.user.is_authenticated():
        user = Instance.getUserInstance(request.user)
        if not user:
            return HttpResponse("user is not set up: %s" % request.user.get_full_name())
        args['userID'] = user.id
        
    if settings.FACEBOOK_SHOW:
        args['facebookIntegration'] = True
    
    args['state'] = 'addToPathway'

    context = RequestContext(request, args)
        
    return HttpResponse(template.render(context))
Пример #14
0
def addToPathway(request):
    LogRecord.emit(request.user, 'pathAdvisor/addToPathway', str(request.user))

    organizationName = request.GET.get('o', None)
    siteName = request.GET.get('s', None)
    offeringName = request.GET.get('f', None)
    serviceName = request.GET.get('m', None)

    print(organizationName, siteName, offeringName, serviceName)

    userInfo = UserInfo(request.user)

    if offeringName and terms.isUUID(offeringName):
        offering = terms[offeringName]
    elif siteName and terms.isUUID(siteName):
        site = terms[siteName]
        if offeringName:
            offerings = site.getChildrenByName(terms['Offering'], terms.name,
                                               offeringName)
            offering = offerings[0] if len(offerings) else None
    elif organizationName and terms.isUUID(organizationName):
        organization = terms[organizationName]
        site, offering = _getOrganizationChildren(organization, siteName,
                                                  offeringName)
    elif organizationName:
        organization = terms['Organization'].getInstanceByName(
            terms.name, organizationName, userInfo)
        if organization:
            site, offering = _getOrganizationChildren(organization, siteName,
                                                      offeringName)
        else:
            site, offering = None, None

    if serviceName and terms.isUUID(serviceName):
        service = terms[serviceName]
    elif serviceName:
        service = terms['Service'].getInstanceByName(terms.name, serviceName,
                                                     userInfo)
    else:
        service = None

    template = loader.get_template('consentrecords/userHome.html')
    args = {
        'user': request.user,
        'backURL': '/',
    }

    if settings.FACEBOOK_SHOW:
        args['fbURL'] = request.build_absolute_uri()
        args['fbTitle'] = 'Add %s' % (
            offeringName
            if offeringName else serviceName if serviceName else 'Experience')
        atText = (organizationName if organizationName == siteName else \
                ('%s//%s' % (organizationName, siteName)) if siteName else organizationName)
        args['fbDescription'] = atText

    if organizationName:
        args[
            'organization'] = organization.id if organization else organizationName
    if siteName:
        args['site'] = site.id if site else siteName
    if offeringName:
        args['offering'] = offering.id if offering else offeringName
    if serviceName:
        args['service'] = service.id if service else serviceName

    if request.user.is_authenticated():
        user = Instance.getUserInstance(request.user)
        if not user:
            return HttpResponse("user is not set up: %s" %
                                request.user.get_full_name())
        args['userID'] = user.id

    if settings.FACEBOOK_SHOW:
        args['facebookIntegration'] = True

    args['state'] = 'addToPathway'

    context = RequestContext(request, args)

    return HttpResponse(template.render(context))