Ejemplo n.º 1
0
def set_profile(request):
    '''set profile by user'''
    if request.method != 'POST':
        raise Http404()
    user = users.get_current_user()
    if not user:
        raise Http404()
    try:
        l = Profile.all().filter('user ='******'status =', 1).fetch(1)
        if not l:
            instance = Profile(nickname='', user=user)
        else:
            instance = l[0]
        if not request.POST.has_key(NICKNAME_PARAM):
            instance.nickname = request.POST[NICKNAME_PARAM]
        if not request.POST.has_key(CITY_PARAM):
            instance.city = request.POST[CITY_PARAM]
        if not request.POST.has_key(MOOD_PARAM):
            instance.mood = request.POST[MOOD_PARAM]
        if not request.POST.has_key(LOCATION_PARAM):
            value = request.POST[LOCATION_PARAM]
            values = value.split(',')
            value = db.GeoPt(float(values[0]), float(values[1]))
            instance.location = value

        instance.put()
        return okResponse(1, 'ok')
    except Exception, e:
        return getErrorResponse(e)
Ejemplo n.º 2
0
def set_profile(request):
    '''set profile by user'''
    if request.method != 'POST':
        raise Http404()
    user = users.get_current_user()
    if not user:
        raise Http404()
    try:
        l = Profile.all().filter('user ='******'status =', 1).fetch(1)
        if not l:
            instance = Profile(nickname='', user=user)
        else:
            instance = l[0]
        if not request.POST.has_key(NICKNAME_PARAM):
            instance.nickname = request.POST[NICKNAME_PARAM]
        if not request.POST.has_key(CITY_PARAM):
            instance.city = request.POST[CITY_PARAM]
        if not request.POST.has_key(MOOD_PARAM):
            instance.mood = request.POST[MOOD_PARAM]
        if not request.POST.has_key(LOCATION_PARAM):
            value = request.POST[LOCATION_PARAM]
            values = value.split(',')
            value = db.GeoPt(float(values[0]), float(values[1]))
            instance.location = value
        
        instance.put()
        return okResponse(1, 'ok')
    except Exception, e:
        return getErrorResponse(e)
Ejemplo n.º 3
0
def get_profile(request):
    '''get profile by user'''
    user = users.get_current_user()
    if not user:
        raise Http404()
    try:
        l = Profile.all().filter('user ='******'status =', 1).fetch(1)
        if not l:
            return getEmptyResponse()
        jsonInstance = getJsonInstanceWithCache(l[0])
        return getJsonResponse(jsonInstance)
    except Exception, e:
        return getErrorResponse(e)
Ejemplo n.º 4
0
def get_profile(request):
    '''get profile by user'''
    user = users.get_current_user()
    if not user:
        raise Http404()
    try:
        l = Profile.all().filter('user ='******'status =', 1).fetch(1)
        if not l:
            return getEmptyResponse()
        jsonInstance = getJsonInstanceWithCache(l[0])
        return getJsonResponse(jsonInstance)
    except Exception, e:
        return getErrorResponse(e)