Exemple #1
0
def get_seesion_userlogin(request):
    user_auth_data = UserAuthData()
    if request.session.get('source_uid_str'):
        user_auth_data.source_uid_str = request.session.get('source_uid_str')
        user_auth_data.source_platform = request.session.get('source_platform','weibo')
        user_auth_data.screen_name = request.session.get('screen_name','NoName')
        user_auth_data.profile_image_url = request.session.get('profile_image_url','')
    return user_auth_data
Exemple #2
0
def apijson_to_UserAuthData(userinfo_json,source_platform):
    user_auth_data = UserAuthData()
    if userinfo_json:
        user_auth_data.source_platform = source_platform
        user_auth_data.source_uid_str = str(userinfo_json.id)
        user_auth_data.name = userinfo_json.name
        user_auth_data.screen_name = userinfo_json.screen_name
        user_auth_data.profile_image_url = userinfo_json.profile_image_url
        user_auth_data.domain = userinfo_json.domain
        user_auth_data.gender = userinfo_json.gender
        user_auth_data.online_status = userinfo_json.online_status
        user_auth_data.followers_count = userinfo_json.followers_count
        user_auth_data.friends_count = userinfo_json.friends_count
        user_auth_data.statuses_count = userinfo_json.statuses_count
        user_auth_data.favourites_count = userinfo_json.favourites_count
        user_auth_data.created_at = userinfo_json.created_at
        user_auth_data.verified = userinfo_json.verified
        try:
            user_auth_data_db = UserAuthData.objects.get(source_uid_str=user_auth_data.source_uid_str)
            user_auth_data_db.source_platform = user_auth_data.source_platform
            user_auth_data_db.source_uid_str = user_auth_data.source_uid_str
            user_auth_data_db.name = user_auth_data.name
            user_auth_data_db.screen_name = user_auth_data.screen_name
            user_auth_data_db.profile_image_url = user_auth_data.profile_image_url
            user_auth_data_db.domain = user_auth_data.domain
            user_auth_data_db.gender = user_auth_data.gender
            user_auth_data_db.online_status = user_auth_data.online_status
            user_auth_data_db.followers_count = user_auth_data.followers_count
            user_auth_data_db.friends_count = user_auth_data.friends_count
            user_auth_data_db.statuses_count = user_auth_data.statuses_count
            user_auth_data_db.favourites_count = user_auth_data.favourites_count
            user_auth_data_db.created_at = user_auth_data.created_at
            user_auth_data_db.verified = user_auth_data.verified
            user_auth_data_db.save()
        except UserAuthData.DoesNotExist:
            user_auth_data.save()
    return user_auth_data