def loggedin(request): if request.user.id: loggedid = dbutils.getLoggedInUser(request) else: loggedid = 0 fbid = dbutils.getLoggedInUser(request) gender = UserTomonotomo.objects.get(userid=fbid).gender template = loader.get_template('tomonotomo/loggedin.html') friendsonTnT_count = len(dbutils.getFriendsonTnT(fbid)) friendsoffriends_count = dbutils.getFriendsofFriends_count(fbid) number_new_introductions = UserHappening.objects.filter(userid=fbid, action=1).count() number_new_connect_directly = UserHappening.objects.filter(userid=fbid, action=2).count() number_new_admire = UserHappening.objects.filter(userid=fbid, action=3).count() show_happening = 0 if number_new_introductions + number_new_connect_directly + number_new_admire > 0: show_happening = 1 try: UserHappening.objects.filter(userid=fbid).delete() except: pass try: userloggedin = UserTomonotomo.objects.get(userid=fbid) userlogin = UserLogin() userlogin.userlogin = userloggedin userlogin.friends = friendsonTnT_count userlogin.save() except Exception as e: logger.exception('views.loggedin - error while saving login information in table UserLogin - error - '+str(e)+' - '+str(e.args)) pass 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' ) dictin = { 'degree1': "{:,}".format(friendsonTnT_count), 'degree2': "{:,}".format(friendsoffriends_count), 'number_new_introductions': number_new_introductions, 'number_new_connect_directly': number_new_connect_directly, 'number_new_admire': number_new_admire, 'show_happening': show_happening, 'meta': meta, 'loggeduserid': loggedid, 'quota': dbutils.getQuota(loggedid), 'gender': gender, 'ismobile': request.mobile } context = RequestContext(request, dictin) return HttpResponse(template.render(context))
def index(request): if request.user.id: loggedid = dbutils.getLoggedInUser(request) else: loggedid = 0 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' ) template = loader.get_template('tomonotomo/index.html') context = RequestContext(request, { 'meta': meta, 'usersdatalen': "{:,}".format(654568), 'loggeduserid': loggedid, 'quota': dbutils.getQuota(loggedid), 'ismobile': request.mobile }) return HttpResponse(template.render(context))
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))
def nomatchforyou(request): template = loader.get_template('tomonotomo/nomatchforyou.html') loggedid = dbutils.getLoggedInUser(request) context = RequestContext(request, { 'loggeduserid': loggedid, 'quota': dbutils.getQuota(loggedid), 'ismobile': request.mobile }) return HttpResponse(template.render(context))
def dbsummary(request): logger.debug('dbsummary starts') profiler = Profiler('tomonotomo.views.dbsummary') profiler.start() if request.user.id: loggedid = dbutils.getLoggedInUser(request) else: loggedid = 0 try: secret = request.GET['secret'] except: raise Http404 createerrorlist = ['tomonotomo'] if 'createerror' in request.GET and request.GET['createerror']: createerrorlist = [] createerrorelem = createerrorlist[0] template = loader.get_template('tomonotomo/dbsummary.html') contextdict = { 'loggeduserid': loggedid, 'quota': dbutils.getQuota(loggedid), #'dbsummary_users_at': UserTomonotomo.objects.exclude(accesstoken=None).count(), 'dbsummary_users_email': UserTomonotomo.objects.exclude(email=None).count(), 'dbsummary_users_data': UserTomonotomo.objects.count(), #'dbsummary_userfriends': UserFriends.objects.count(), #'dbsummary_userfeedback': UserFeedback.objects.count(), #'dbsummary_usergender': UserTomonotomo.objects.values('gender').annotate(Count('gender')), #'dbsummary_userrelstatus': UserTomonotomo.objects.values('relstatus').annotate(Count('relstatus')), #'dbsummary_userinterests': UserTomonotomo.objects.exclude(interests='').exclude(interests=None).count(), #'dbsummary_users': UserTomonotomo.objects.exclude(email=None).values('userid','first_name','last_name','email'), 'dbsummary_quota': UserQuota.objects.exclude(quota=20).values('userid','quota'), 'dbsummary_quota_verification': UserFeedback.objects.filter(timestamp__gte=date.today()).values('userid').annotate(Count('fbid', distinct=True)), 'dbsummary_dbchecksstring': dbchecks.dbchecks2(), 'dbsummary_feedback': UserFeedback.objects.values('action').annotate(Count('action')).order_by(), 'dbsummary_users_login_24': UserLogin.objects.filter(timestamp__gte=datetime.now(pytz.timezone('America/Chicago'))+timedelta(hours=-24)).order_by('timestamp').values('userlogin','friends', 'timestamp'), 'dbsummary_users_register_24': list(set(map(lambda x: x['userlogin'], UserLogin.objects.filter(timestamp__gte=datetime.now(pytz.timezone('America/Chicago'))+timedelta(hours=-24)).values('userlogin')))-set(map(lambda x: x['userlogin'], UserLogin.objects.filter(timestamp__lte=datetime.now(pytz.timezone('America/Chicago'))+timedelta(hours=-24)).values('userlogin')))), 'ismobile': request.mobile } profiler.stop() context = RequestContext(request, contextdict) return HttpResponse(template.render(context))
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))