Exemplo n.º 1
0
def create_admin_user(request,parms,browserAnalysis,__air_id__,__apiMap__):
    from g import make_admin_user
    make_admin_user()
    _user = User.objects.get(username=_admin_username)
    ignore = ['_entity','_parent','_password']
    valueOf = lambda v:_utils.getAsSimpleDateStr(v,str(_utils.formatDjangoDateTimeStr())) if (ObjectTypeName.typeClassName(v) == 'datetime.datetime') else str(v) if (v != None) else None
    d = dict([(str(k),valueOf(v)) for k,v in _user.__dict__.iteritems() if (k not in ignore) and (v)])
    d[_air_version_symbol] = air_version[__air_id__]
    if (d[_air_version_symbol] == None):
	d[_api_symbol] = __apiMap__.asMap(noIgnore=True)
    d[_isLoggedIn_symbol] = _user.is_active and _user.is_authenticated() and (not _user.is_anonymous())
    d['REMOTE_ADDR'] = django_utils.get_from_META(request,'REMOTE_ADDR','')
    uname = str(_user)
    u = {
        'id':_user.id, 
        'is_active':_user.is_active, 
        'is_anonymous':_user.is_anonymous(),
        'is_authenticated':_user.is_authenticated(),
        'is_staff':_user.is_staff,
        'is_superuser':_user.is_superuser if (settings.IS_PRODUCTION_SERVER) else (_user.username == settings.SUPER_USER),
        'username':_user.username,
        #'groups':_user._get_groups(),
        #'permissions':_user._get_user_permissions(),
        'name':uname if (len(uname) > 0) else str(_user.username.split('@')[0]).capitalize()
    }
    handle_geolocation(request)
    u = get_starbucks_data(u,_user,__air_id__,parms)
    d[_user_symbol] = u
    json = dict_to_json(d)
    return HttpResponse(content=json,mimetype=__jsonMimetype)
Exemplo n.º 2
0
def handle_get_smaato(request,parms,browserAnalysis,__air_id__,__apiMap__):
    from g import xml_to_python, xml_to_json, xml2json, json_to_python
    from vyperlogix.django.smaato import smaato_ad
    d = {}
    _user = get_user(request)
    ad_content = smaato_ad.smaato_ad(request, __alternate_admob_content__)
    logging.info(ad_content)
    _json = xml2json(ad_content)
    d = json_to_python(django_utils.compressContent(_json))
    _json = dict_to_json(d)
    return HttpResponse(content=_json,mimetype=__jsonMimetype)
Exemplo n.º 3
0
    uname = str(_user)
    u = {
        'id':_user.id, 
        'is_active':_user.is_active, 
        'is_anonymous':_user.is_anonymous(),
        'is_authenticated':_user.is_authenticated(),
        'is_staff':_user.is_staff,
        'is_superuser':_user.is_superuser if (settings.IS_PRODUCTION_SERVER) else (_user.username == settings.SUPER_USER),
        'username':_user.username,
        #'groups':_user._get_groups(),
        #'permissions':_user._get_user_permissions(),
        'name':uname if (len(uname) > 0) else str(_user.username.split('@')[0]).capitalize()
    }
    u = get_starbucks_data(u,_user,__air_id__,parms)
    d[_user_symbol] = u
    json = dict_to_json(d)
    return HttpResponse(content=json,mimetype=__jsonMimetype)

#def handle_geolocation(request):
    #post = django_utils.handle_json_post_vars(request)
    #geo = post['geo']
    #geolocation = None
    #if (geo): # and (ObjectTypeName.typeName(geo['latitude']) == 'float') and (ObjectTypeName.typeName(geo['longitude']) == 'float'):
	#gps = db.GeoPt(ensure_float(geo['latitude']),ensure_float(geo['longitude']))
	#geolocations = [s for s in models.Geolocation.all() if (s.gps == gps)]
	#if (len(geolocations) == 0):
	    #try:
		#geolocation = models.Geolocation(gps=gps)
		#try:
		    #if (geo['altitude']):
			#geolocation.altitude = ensure_float(geo['altitude'])