コード例 #1
0
ファイル: views.py プロジェクト: pinloveteam/pinloveweb
def no_read_comment_list(request, template_name):
    args = {}
    try:
        user = request.user
        userProfile = UserProfile.objects.get(user=user)
        commentList = FriendDynamicComment.objects.get_no_read_comment_by_user_id(
            user.id)
        args = page(request, commentList)
        from apps.pojo.dynamic import FriendDynamicCommentList_to_CommentDynamicList
        args[
            'pages'].object_list = FriendDynamicCommentList_to_CommentDynamicList(
                args['pages'].object_list)
        commentList.update(isRead=True)
        if args['pages'].has_next():
            args['next_page_number'] = args['pages'].next_page_number()
        else:
            args['next_page_number'] = -1
        #初始化个人信息模块
        from pinloveweb.method import init_person_info_for_card_page
        args.update(init_person_info_for_card_page(userProfile))
        if request.is_ajax():
            from django.core.serializers.json import DjangoJSONEncoder
            json = simplejson.dumps(
                {
                    'friendDynamicCommentList': args['pages'].object_list,
                    'next_page_number': args['next_page_number']
                },
                cls=DjangoJSONEncoder)
            return HttpResponse(json, mimetype='application/json')
        return render(request, template_name, args)
    except Exception, e:
        logger.exception('获取未读评论列表,出错')
コード例 #2
0
ファイル: views.py プロジェクト: pinloveteam/pinloveweb
def person_dynamic(request, template_name="dynamic.html"):
    arg = {}
    try:
        userId = int(request.REQUEST.get('userId'))
        arg['userId'] = userId
        userProfile = UserProfile.objects.get(user_id=request.user.id)
        from pinloveweb.method import init_person_info_for_card_page
        arg.update(init_person_info_for_card_page(userProfile))
        if int(request.user.id) == userId:
            arg['publish'] = True
            arg["title"] = '我的相册'
        else:
            arg["title"] = User.objects.get(id=userId).username
        if request.is_ajax():
            arg = init_dynamic(request, userId, arg, 1)
            json = simplejson.dumps(
                {
                    'friendDynamicList': arg['friendDynamicList'],
                    'next_page_number': arg['next_page_number']
                },
                cls=MyEncoder)
            return HttpResponse(json, mimetype='application/json')
        arg['result'] = 'success'
    except Exception as e:
        logger.expction('用户个人动态中心,出错!')
        arg = {'result': 'error', 'error_message': e.message}
        template_name = 'error.html'
    return render(request, template_name, arg)
コード例 #3
0
ファイル: views.py プロジェクト: pinloveteam/pinloveweb
def no_read_message(request, template_name):
    args = {}
    try:
        messageList = MessageLog.objects.get_no_read_messagelog(
            request.user.id)
        args = page(request, messageList)
        messageList = args['pages']
        messageList.object_list = MessageLog_to_Message(
            messageList.object_list, request.user.id)
        #用户消息标记为已读
        MessageLog.objects.clean_message(request.user.id)
        if request.is_ajax():
            data = {}
            data['messageList'] = messageList.object_list
            data['has_next'] = messageList.has_next()
            if messageList.has_next():
                data['next_page_number'] = messageList.next_page_number()
            json = simplejson.dumps(data, cls=MessageBeanEncoder)
            return HttpResponse(json)
        args['pages'] = messageList
        userProfile = UserProfile.objects.get(user_id=request.user.id)
        from pinloveweb.method import init_person_info_for_card_page
        args.update(init_person_info_for_card_page(userProfile))
        args['from'] = 'no_read_message'
        return render(request, template_name, args)
    except Exception, e:
        error_mesage = '获取用户未读消息,出错!'
        logger.exception(error_mesage)
コード例 #4
0
ファイル: views.py プロジェクト: pinloveteam/pinloveweb
def loggedin(request, template_name='index.html', **kwargs):
    arg = {}
    is_ajax = False
    try:
        userProfile = UserProfile.objects.get_user_info(request.user.id)
        if request.is_ajax():
            is_ajax = True
            matchResultList = get_recommend_list(request, userProfile)
            from pinloveweb.method import load_cards_by_ajax
            return load_cards_by_ajax(request, matchResultList)
        from pinloveweb.method import get_no_read_web_count
        arg.update(get_no_read_web_count(request.user.id, fromPage=u'card'))
        #判断是否是从注册页面过来
        if request.GET.get('previous_page', '') == 'register':
            arg['first'] = True
        #推荐信息完善
        if request.session.get('recommendStatus', False):
            arg['recommendStatus'] = request.session.pop('recommendStatus')
        from pinloveweb.method import init_person_info_for_card_page
        arg.update(init_person_info_for_card_page(userProfile))
        #检测设备
        if detect_device.detectTiermobileTablet(request):
            template_name = 'mobile_recommend.html'
    except Exception as e:
        errorMessage = '推荐页面出错,错误原因:' + e.message
        logger.exception(errorMessage)
        arg = {'result': 'error', 'error_message': errorMessage}
        template_name = 'error.html'
    if is_ajax:
        json = simplejson.dumps(arg)
        return HttpResponse(json)
    else:
        return render(request, template_name, arg)
コード例 #5
0
ファイル: views.py プロジェクト: pinloveteam/pinloveweb
def the_people_nearby(request):
    arg = {}
    userProfile = UserProfile.objects.get_user_info(request.user.id)
    userProfileList = UserProfile.objects.filter(
        lastLoginAddress=GetLocation(request)).exclude(
            user=request.user).filter(avatar_name_status='3').exclude(
                gender=userProfile.gender)
    #分页
    from util.page import page
    arg = page(request, userProfileList)
    userList = arg['pages']
    if len(userList.object_list) > 0:
        from apps.pojo.card import userProfileList_to_CardList
        userList.object_list = userProfileList_to_CardList(
            request.user.id, userList.object_list)
        from pinloveweb.method import is_focus_each_other
        userList = is_focus_each_other(request.user.id, userList)
    else:
        userList.object_list = []
    if request.is_ajax():
        from pinloveweb.method import load_cards_by_ajax
        return load_cards_by_ajax(request, userList)
    from apps.pojo.card import MyEncoder
    userList.object_list = simplejson.dumps(userList.object_list,
                                            cls=MyEncoder)
    arg['pages'] = userList
    from pinloveweb.method import init_person_info_for_card_page
    arg.update(init_person_info_for_card_page(userProfile))
    from pinloveweb.method import get_no_read_web_count
    arg.update(get_no_read_web_count(request.user.id, fromPage=u'card'))
    return render(request, 'the_people_nearby.html', arg)
コード例 #6
0
def member(request,template_name='buy.html'):
    try:
        args={}
        userProfile=UserProfile.objects.get(user=request.user)
        #获取城市代码
        from util.location import get_country_code
        countryCode=get_country_code(request)
        if countryCode=='US':
            chargeExchangeRelateList=ChargeExchangeRelate.objects.filter(currencyType=1)
        elif countryCode=='CN':
            chargeExchangeRelateList=ChargeExchangeRelate.objects.filter(currencyType=2)
        else:
            chargeExchangeRelateList=ChargeExchangeRelate.objects.filter(currencyType=2)
        charge=Charge.objects.get(user_id=request.user.id)
        args['chargeExchangeRelateList']=chargeExchangeRelateList
        #购买拼爱币
        args['charge']=charge
        #全部拼爱币
        from apps.pay_app.method import get_charge_amount
        args['pinLoveIcon']=get_charge_amount(request.user.id,vailPinLoveIcon=charge.validAmount)
        #初始化个人信息模块
        from pinloveweb.method import init_person_info_for_card_page
        args.update(init_person_info_for_card_page(userProfile))
        from pinloveweb.method import get_no_read_web_count
        args.update(get_no_read_web_count(request.user.id,fromPage=u'card'))
        return render(request,template_name,args)
    except Exception as e:
        error_message=('%s%s%s' %('会员购买页面出错!','出错原因:',e.message))
        logger.exception(error_message)
        return render(request,'error.html',{'error_message':error_message})
コード例 #7
0
ファイル: views.py プロジェクト: pinloveteam/pinloveweb
def pintu(request, template_name="mobile_pintu.html"):
    args = {}
    try:
        userProfile = UserProfile.objects.get_user_info(request.user.id)
        from pinloveweb.method import init_person_info_for_card_page
        args.update(init_person_info_for_card_page(userProfile))
        return render(request, template_name, args)
    except Exception as e:
        logger.exception(e.message)
        args = {'result': 'error', 'error_message': e.message}
        return render(request, ERROR_TEMLATE_NAMR, args)
コード例 #8
0
def pintu(request):
    args = {}
    userId = request.user.id
    userProfile = UserProfile.objects.get(user_id=userId)
    from apps.game_app.models import get_recommend_history_web
    facebookUserListDcit = get_recommend_history_web(userId)
    from apps.pay_app.method import get_charge_amount
    args = {
        'pinLoveIcon': get_charge_amount(userId),
        'facebookUserListDcit': facebookUserListDcit
    }
    from pinloveweb.method import init_person_info_for_card_page
    args.update(init_person_info_for_card_page(userProfile))
    from pinloveweb.method import get_no_read_web_count
    args.update(get_no_read_web_count(request.user.id))
    return render(request, 'pintu.html', args)
コード例 #9
0
ファイル: views.py プロジェクト: pinloveteam/pinloveweb
def account(request):
    '''
    获得账户信息
    '''
    args = {}
    try:
        userProfile = UserProfile.objects.get(user=request.user)
        args['avatar_name'] = userProfile.avatar_name
        from apps.pay_app.method import get_charge_amount
        args['pinLoveIcon'] = get_charge_amount(userId=request.user)
        from pinloveweb.method import init_person_info_for_card_page
        args.update(init_person_info_for_card_page(userProfile))
        return render(request, 'mobile_account.html', args)
    except Exception as e:
        logger.exception('手机获取账户信息出错:' + e.message)
        args = {'result': 'error', 'error_message': e.message}
        return render(request, ERROR_TEMLATE_NAMR, args)
コード例 #10
0
ファイル: views.py プロジェクト: pinloveteam/pinloveweb
def nearby(request, template_name="mobile_neardy.html"):
    '''
    附近的人
    '''
    args = {}
    try:
        userProfile = UserProfile.objects.get_user_info(request.user.id)
        from apps.the_people_nearby.views import GetLocation
        userProfileList = UserProfile.objects.filter(
            lastLoginAddress=GetLocation(request)).exclude(
                user=request.user).filter(avatar_name_status='3').exclude(
                    gender=userProfile.gender)
        #分页
        args = page(request, userProfileList)
        userList = args['pages']
        if len(userList.object_list) > 0:
            from apps.pojo.card import userProfileList_to_CardMobileList
            userList.object_list = userProfileList_to_CardMobileList(
                request.user.id, userList.object_list)
        else:
            userList.object_list = []
        #判断推荐完成情况
        recommend_status = recommend_info_status(request.user.id,
                                                 channel='mobile')
        if not recommend_status['result']:
            args['has_recommend'] = True
        else:
            args['recommend_finish'] = simplejson.dumps(
                simplejson.dumps(recommend_status['data']))
        if request.is_ajax():
            from pinloveweb.method import load_cards_by_ajax
            return load_cards_by_ajax(request, userList, chanel='mobile')
        userList.object_list = simplejson.dumps(userList.object_list,
                                                cls=CardMobileEncoder)
        args['pages'] = userList
        from pinloveweb.method import init_person_info_for_card_page
        args.update(init_person_info_for_card_page(userProfile))
        return render(request, template_name, args)
    except Exception as e:
        logger.exception(e.message)
        args = {'result': 'error', 'error_message': e.message}
        return render(request, ERROR_TEMLATE_NAMR, args)
コード例 #11
0
ファイル: views.py プロジェクト: pinloveteam/pinloveweb
def recommend(request, template_name='mobile_recommend.html', **kwargs):
    '''
    推荐功能
    '''
    args = {}
    try:
        #判断推荐分数是否生成
        flag = MatchResult.objects.is_exist_by_userid(request.user.id)
        userProfile = UserProfile.objects.get_user_info(request.user.id)
        #从缓存中获取不推荐用户id
        from util.cache import get_no_recomend_list_by_cache
        disLikeUserIdList = get_no_recomend_list_by_cache(request.user.id)
        #获取推荐列表
        matchResultList = get_recommend_list(request, flag, disLikeUserIdList,
                                             userProfile, **kwargs)
        from pinloveweb.method import get_no_read_web_count
        args.update(get_no_read_web_count(request.user.id, fromPage=u'card'))
        #判断推荐完成情况
        if kwargs.get('card') == True:
            return matchResultList
        if request.is_ajax():
            from pinloveweb.method import load_cards_by_ajax
            return load_cards_by_ajax(request,
                                      matchResultList,
                                      chanel='mobile')
        matchResultList.object_list = simplejson.dumps(
            matchResultList.object_list, cls=CardMobileEncoder)
        args['pages'] = matchResultList
        #判断是否是从注册页面过来
        if request.GET.get('previous_page', '') == 'register':
            args['first'] = True
        #推荐信息完善
        if request.session.get('recommendStatus', False):
            args['recommendStatus'] = request.session.pop('recommendStatus')
        from pinloveweb.method import init_person_info_for_card_page
        args.update(init_person_info_for_card_page(userProfile))
        return render(request, template_name, args)
    except Exception as e:
        logger.exception(e.message)
        args = {'result': 'error', 'error_message': e.message}
        return render(request, ERROR_TEMLATE_NAMR, args)
コード例 #12
0
ファイル: views.py プロジェクト: pinloveteam/pinloveweb
def get_free_pinloveicon(request,template_name):
    args={}
    try:
        userProfile=UserProfile.objects.get(user=request.user)
        args['link']=userProfile.link
        from apps.user_score_app.method import get_day_login_count
        #获取每日登陆
        args['dayLoginCount']=get_day_login_count(request.user.id)
        from apps.user_score_app.user_score_settings import DAY_INIVITE_FRIEND_COUNT,DAY_LOGIN_COUNT
        args['DAY_INIVITE_FRIEND_COUNT']=DAY_INIVITE_FRIEND_COUNT
        #获取邀请登录时间
        args['DAY_LOGIN_COUNT']=DAY_LOGIN_COUNT
        from apps.user_score_app.method import get_invite_friend_count
        args['inviteFriendLogin']=get_invite_friend_count(request.user.id)
        #认证
        userVerification=UserVerification.objects.get(user_id=request.user.id)
        args['avatar_name_status']=userProfile.avatar_name_status
        for field in ['incomeValid','educationValid']:
            args[field]=getattr(userVerification,field)
            
        
        args['userProfileFinish']=False
        fields = ( 'income','weight','jobIndustry',
        'height', 'education','educationSchool','city')
        if userProfile.finish!=None:
            finishList=simplejson.loads(userProfile.finish)
            for field in fields:
                if field not in finishList:
                    args['userProfileFinish']=True
        else:
            args['userProfileFinish']=True
        from pinloveweb.method import init_person_info_for_card_page
        args.update(init_person_info_for_card_page(userProfile))
        return render(request,template_name,args)
    except  Exception as e:
        args={'error_message':e.message}
        return render(request,'error.html',args)
コード例 #13
0
ファイル: views.py プロジェクト: pinloveteam/pinloveweb
def search(request, template_name='mobile_search.html'):
    '''
    搜索页面
    '''
    args = {}
    try:
        userProfile = UserProfile.objects.get_user_info(request.user.id)
        if request.method == 'POST':
            searchForm = SearchMobileForm(request.POST)
            if searchForm.is_valid():
                userProfileList = searchForm.select_data(
                    request.REQUEST.get('sunSign', '').rstrip(),
                    userProfile.gender, request.user.id)
                args = page(request, userProfileList)
                searchList = args['pages']
                from apps.pojo.card import userProfileList_to_CardMobileList
                searchList.object_list = userProfileList_to_CardMobileList(
                    request.user.id, searchList.object_list)
                searchList.object_list = simplejson.dumps(
                    searchList.object_list, cls=CardMobileEncoder)
                args['pages'] = searchList
                from pinloveweb.method import init_person_info_for_card_page
                args.update(init_person_info_for_card_page(userProfile))
                args['result'] = 'success'
                POSTcopy = request.POST.copy()
                POSTcopy.pop('csrfmiddlewaretoken')
                args['url'] = (request.path + '?' + urllib.urlencode(POSTcopy))
                #推荐信息完善情况
                recommend_status = recommend_info_status(request.user.id,
                                                         channel='mobile')
                if not recommend_status['result']:
                    args['has_recommend'] = True
                else:
                    args['recommend_finish'] = simplejson.dumps(
                        simplejson.dumps(recommend_status['data']))
                return render(request, 'mobile_search_result.html', args)
        elif request.is_ajax():
            searchForm = SearchMobileForm(request.GET)
            if searchForm.is_valid():
                userProfileList = searchForm.select_data(
                    request.REQUEST.get('sunSign', '').rstrip(),
                    userProfile.gender, request.user.id)
                args = page(request, userProfileList)
                searchList = args['pages']
                from apps.pojo.card import userProfileList_to_CardMobileList
                searchList.object_list = userProfileList_to_CardMobileList(
                    request.user.id, searchList.object_list)
                searchList.object_list = simplejson.dumps(
                    searchList.object_list, cls=CardMobileEncoder)
                args['pages'] = searchList
                args['result'] = 'success'

        else:
            searchForm = SearchMobileForm()
            searchForm.init_search_condition(request.user.id)
            from apps.search_app.views import get_disable_condition
            args.update(get_disable_condition(userProfile))
            args['searchForm'] = searchForm
            from apps.search_app.forms import SUN_SIGN_CHOOSICE
            args['sunSign'] = SUN_SIGN_CHOOSICE
            from pinloveweb.method import get_no_read_web_count
            args.update(
                get_no_read_web_count(request.user.id, fromPage=u'card'))
            args['result'] = 'success'
        if args.get('result', False) != 'success':
            args['result'] = 'error'
            args['error_message'] = []
            errorList = searchForm.errors.items()
            for error in errorList:
                args['error_message'].append([
                    SearchMobileForm.base_fields[error[0]].label, error[1][0]
                ])
            json = simplejson.dumps(args)
            return HttpResponse(json)
    except Exception as e:
        error_message = '搜索也卖弄出错:出错原因:' + e.message
        logger.exception(error_message)
        args['result'] = 'success'
        args['error_message'] = error_message
        template_name = 'error.html'
    if request.is_ajax():
        from pinloveweb.method import load_cards_by_ajax
        return load_cards_by_ajax(request, searchList, chanel='mobile')
    else:
        return render(request, template_name, args)
コード例 #14
0
ファイル: views.py プロジェクト: pinloveteam/pinloveweb
def follow(request, type, ajax='false', template_name="mobile_follow.html"):
    args = {}
    try:
        try:
            type = int(type)
        except ValueError:
            raise Http404()
        if type == 1:
            #获得我的关注列表
            fllowList = Follow.objects.filter(my=request.user)
            theme = '关注'
        elif type == 2:
            #获得我的粉丝列表
            fllowList = Follow.objects.filter(follow=request.user)
            theme = '粉丝'
        elif type == 3:
            #获得相互关注列表
            fllowList = Follow.objects.follow_each(request.user.id)
            theme = '相互关注'

        userProfile = UserProfile.objects.get(user_id=request.user.id)
        #分页
        args = page(request, fllowList)
        cardList = args.get('pages')
        #将关注列表转换成Card列表
        if len(cardList.object_list) > 0:
            from apps.pojo.card import fllowList_to_CardMobileList
            cardList.object_list = fllowList_to_CardMobileList(
                request.user.id, cardList.object_list, type)
        else:
            cardList.object_list = []
        if cardList.has_next():
            args['next_page_number'] = cardList.next_page_number()
        else:
            args['next_page_number'] = -1
        #判断推荐完成情况
        recommend_status = recommend_info_status(request.user.id,
                                                 channel='mobile')
        if not recommend_status['result']:
            args['has_recommend'] = True
        else:
            args['recommend_finish'] = simplejson.dumps(
                simplejson.dumps(recommend_status['data']))
        if request.is_ajax():
            data = {}
            if cardList.has_next():
                data['next_page_number'] = args['next_page_number']
            else:
                data['next_page_number'] = -1
            data['result'] = 'success'
            data['cards'] = cardList.object_list
            json = simplejson.dumps(data, cls=CardMobileEncoder)
            return HttpResponse(json)
        cardList.object_list = simplejson.dumps(cardList.object_list,
                                                cls=CardMobileEncoder)
        args['pages'] = cardList
        from pinloveweb.method import init_person_info_for_card_page
        args.update(init_person_info_for_card_page(userProfile))
        args['title'] = theme
        return render(request, template_name, args)
    except Exception as e:
        logger.exception(e.message)
        args = {'result': 'error', 'error_message': e.message}
        return render(request, ERROR_TEMLATE_NAMR, args)