示例#1
0
def fofrandom(request):
    loggedid = dbutils.getLoggedInUser(request)
    quotaover = dbutils.check_quota_over(loggedid)

    if quotaover:
	return redirect('/quotaover')

    gender = UserTomonotomo.objects.get(userid=loggedid).gender
    reqgender = 3
    if gender==1:
        reqgender = 2
    if gender==2:
        reqgender = 1

    fbid = dbutils.getRandFoF(loggedid, reqgender)

    if fbid == 0:
	logger.exception('dbutils.fofrandom - random friend of friend returned zero - ' + str(loggedid))
        return redirect('/nomatchforyou')

    try:
    	fbname = slugify(dbutils.getFullName(fbid))
    except:
	fbname = 'tomonotomo'

    if str(fbname)=='':
	fbname = 'tomonotomo'

    return redirect('/profile/'+str(fbname)+'/'+str(fbid))
示例#2
0
def profileredir(request, fbid):    
    try:
        fbname = slugify(dbutils.getFullName(fbid))
    except:
        fbname = 'tomonotomo'

    if str(fbname)=='':
	fbname='tomonotomo'

    return redirect('/profile/'+str(fbname)+'/'+str(fbid))
示例#3
0
def tntAction(request, fbid, action, fbfriend):
    ##fbid = 717323242
    ##action = 1
    ##userid = 717323242

    fbid = int(fbid)
    action = int(action)
    userid = dbutils.getLoggedInUser(request)
    userinfo = UserTomonotomo.objects.get(userid=userid)
    fbname = slugify(dbutils.getFullName(fbid))

    if UserFeedback.objects.filter(userid=userinfo, fbid=fbid, timestamp__gte=date.today()).count() == 0:
        dbutils.decrease_quota(userid)

    #actionbefore = UserFeedback.objects.filter(userid=userinfo, fbid=fbid).exclude(action=5).count()

    if UserFeedback.objects.filter(userid=userinfo, fbid=fbid, action=action, timestamp__gte=date.today()).exclude(action=1).count() > 0:
	if (action == 1) or (action == 2) or (action == 3):
		return redirect('/profile/'+str(fbname)+'/'+str(fbid)+'?rand='+str(randint(0,100)))
	if (action == 4) or (action ==5):
		return redirect('/fof')

    feedback = UserFeedback(userid=userinfo, fbid=fbid, action=action)
    feedback.save()

    logger.debug("view.tntAction - " + str(userid) + " " + str(fbid) + " " + str(action) + " " + str(fbfriend))
   
    if action == 1:
	dbutils.sendemailFriend(userid, fbid, fbfriend)
	dbutils.updateUserHappening(fbid, action)
	return redirect('/profile/'+str(fbname)+'/'+str(fbid))

    if action == 2:
        #mutualfriendlist = dbutils.getMutualFriends(userid, fbid)
        dbutils.sendemailFoF(userid, fbid)
	dbutils.updateUserHappening(fbid,action)
	return redirect('/profile/'+str(fbname)+'/'+str(fbid)+'?rand='+str(randint(0,100)))

    if action == 3:
	dbutils.updateUserHappening(fbid, action)
	try:
		fbidinfo = UserTomonotomo.objects.get(userid=fbid)
		if UserFeedback.objects.filter(userid=fbidinfo, fbid=userid, action=3).count() > 0:
			dbutils.sendemailCute(userid, fbid)
	except Exception as e:
		logger.exception('views.tntAction - checking if there is a reverse feedback for cure - error - '+str(e)+' - '+str(e.args)) 
		pass
	return redirect('/profile/'+str(fbname)+'/'+str(fbid)+'?rand='+str(randint(0,100)))

    return redirect('/fof')
示例#4
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))