예제 #1
0
def personalprofile(request):

    loggedid = dbutils.getLoggedInUser(request)
    logger.debug('view.personalprofile - ' + str(loggedid))

    template = loader.get_template('tomonotomo/personalprofile.html')
    profile = UserTomonotomo.objects.get(userid=loggedid)

    meta = Meta(
        use_og=1,
        url='http://www.tomonotomo.com',
        use_sites=True,
        description='Looking for interesting people in your network? We are revolutionising the way you meet new people right now. Please give us a try, if you believe in safe, secure and friendly relationship based on trust and respect',
        keywords=['dating', 'tomonotomo', 'friend'],
        image='http://www.tomonotomo.com/static/tomonotomo/img/logo.jpg',
        title='tomonotomo - meet friends of friends'
    )
    
    if profile.work == "":
        worklist = []
    else:
        worklist = profile.work.split('---')
        worklist = filter(lambda x: len(x), worklist)

    if profile.education == "":
        educationlist = []
    else:
        educationlist = profile.education.split('---')
        educationlist.reverse()
        educationlist = filter(lambda x: len(x), educationlist)

    if profile.get_age() != "[Age N.A.]":
        if profile.location != "":
                agelocation = str(profile.get_age()) + ", " + profile.location
        else:
                agelocation = profile.get_age()
    else:
        agelocation = profile.location

    context = RequestContext(request, {
		'loggeduserid': loggedid,
                'fbid': loggedid,
                'fullname': profile.get_full_name(),
                'agelocation': agelocation,
                'worklist': worklist,
                'educationlist': educationlist,
                'meta': meta,
                'connectfriendslist': list(set(map(lambda x: x['fbid'], UserFeedback.objects.filter(userid=loggedid,action=1).values('fbid')))),
		'connectdirectlist': list(set(map(lambda x: x['fbid'], UserFeedback.objects.filter(userid=loggedid,action=2).values('fbid')))),
		'admirelist': list(set(map(lambda x: x['fbid'], UserFeedback.objects.filter(userid=loggedid,action=3).values('fbid')))),
		'connecteddirectlybylist': list(set(map(lambda x: x['userid'], UserFeedback.objects.filter(fbid=loggedid,action=2).values('userid')))),
		'nevershowlist': list(set(map(lambda x: x['fbid'], UserFeedback.objects.filter(userid=loggedid,action=4).values('fbid')))),
		'mostadmiredfriends': dbutils.getMostAdmiredFriends(loggedid, 15),
		'quota': dbutils.getQuota(loggedid),
		'secretadmirers': dbutils.getSecretAdmirersCount(loggedid),
		'ismobile': request.mobile
        })

    return HttpResponse(template.render(context))
예제 #2
0
def profile(request, fbname, fbid):
    logger.debug('view.profile - ' + fbname + ' - ' + str(fbid))
    #fbid = 717323242
    show_button = 1
    notify_hover_on_button = 0
    notify_invite_friends = 0
    notify_welcome = 0
    notify_like_follow = 0
    notify_tip_arrowkey = 0
    loggedid=0
    if request.user.id:
        loggedid = dbutils.getLoggedInUser(request)
        mutualfriends = map(lambda x: {'name': dbutils.getFullName(x), 'id': x}, dbutils.getMutualFriends(loggedid, fbid))
	commoninterests = map(lambda x: x['name'], dbutils.getCommonInterests(loggedid, fbid))
        historyFeedback = dbutils.historyFeedback(loggedid, fbid)
        deactivateList = historyFeedback['deactivate']
        doneList = historyFeedback['donelist']
        infoList = historyFeedback['info']
        if len(mutualfriends) == 0:
                show_button=0

	if int(loggedid) == int(fbid):
		show_button=0

	lastfeedback = dbutils.getLastFeedback(loggedid,30)

	if len(lastfeedback)==0:
		logger.info('view.profile - Showed Gritter Notification - for welcome - ' + str(loggedid))
		notify_welcome=1

	if len(lastfeedback)==3:
		logger.info('view.profile - Showed Gritter Notification - for arrowkeys - ' + str(loggedid))
		notify_tip_arrowkey = 1

	if len(lastfeedback)==10:
		lastfeedback = filter(lambda x: x not in [4,5], lastfeedback)
		if len(lastfeedback)<2:
			logger.info('view.profile - Showed Gritter Notification - for hover on button - ' + str(loggedid))
			notify_hover_on_button=1

	if (len(lastfeedback)>=13) and (len(lastfeedback)<=22):
		if lastfeedback[0] not in [4,5]:
			lastfeedback = filter(lambda x: x not in [4,5], lastfeedback)
			if len(lastfeedback)==4:
				logger.info('view.profile - Showed Gritter Notification - for like / follow - ' + str(loggedid))
				notify_like_follow=1

	if len(lastfeedback)==25:
		logger.info('view.profile - Showed Gritter Notification - for invite friends - ' + str(loggedid))
		notify_invite_friends=1

    else:
        commoninterests = []
	mutualfriends = []
        deactivateList = [1, 2, 3, 4]
        infoList = []
        doneList = []
        show_button = 0


    template = loader.get_template('tomonotomo/profile.html')
    try:
    	profile = UserTomonotomo.objects.get(userid=fbid)
    except ObjectDoesNotExist:
	logger.exception('views.profile - Requested id for profile page invalid - ' + str(fbid))
        raise Http404

    if UserTomonotomo.objects.get(userid=fbid).email == None:
        email_exists = 0
    else:
        email_exists = 1

    meta = Meta(
        use_og=1,
        url='http://www.tomonotomo.com/profile/' + str(fbid),
        use_sites=True,
        description='Looking for interesting people in your network? We are revolutionising the way you meet new people right now. Please give us a try, if you believe in safe, secure and friendly relationship based on trust and respect',
        keywords=['dating', 'tomonotomo', 'friend'],
        image='http://graph.facebook.com/'+str(fbid)+'/picture?type=square',
        title= 'tomonotomo - meet friends of friends',
    )


    if profile.work == "":
        worklist = []
    else:
        worklist = profile.work.split('---')
        worklist = filter(lambda x: len(x), worklist)

    if profile.education == "":
        educationlist = []
    else:
        educationlist = profile.education.split('---')
        educationlist.reverse()
        educationlist = filter(lambda x: len(x), educationlist)

    if profile.get_age() != "[Age N.A.]":
        if profile.location != "":
                agelocation = str(profile.get_age()) + ", " + profile.location
        else:
                agelocation = profile.get_age()
    else:
        agelocation = profile.location

    #if int(loggedid)==717323242:
    #		notify_invite_friends=1
    #		notify_hover_on_button=1
    #		notify_welcome=1
    #		notify_like_follow=1
    #		notify_tip_arrowkey=1
	
    context = RequestContext(request, {
		'loggeduserid': loggedid,
                'fbid': fbid,
                'fullname': profile.get_full_name(),
                'agelocation': agelocation,
                'worklist': worklist,
                'educationlist': educationlist,
                'mutualfriends': mutualfriends,
		'commoninterests': commoninterests,
                'meta': meta,
	        'deactivateList': deactivateList,
	        'infoList': infoList,
	        'doneList': doneList,
	        'email_exists': email_exists,
	        'show_button': show_button,
		'notify_invite_friends': notify_invite_friends,
		'notify_hover_on_button': notify_hover_on_button,
		'notify_welcome': notify_welcome,
		'notify_like_follow': notify_like_follow,
		'notify_tip_arrowkey': notify_tip_arrowkey,
		'quota': dbutils.getQuota(loggedid),
		'secretadmirers': dbutils.getSecretAdmirersCount(fbid),
		'lovequote': dbutils.getRandomLoveQuote(),
		'ismobile': request.mobile
        })

    return HttpResponse(template.render(context))