Пример #1
0
 def dontTouch(self, request):
     pid = ndb.Key('Profile',int(request.pid))
     clubId = Club.query(Club.admin==pid)
     pylist=[]
     for x in clubId:
         print x.key
         posts = Post.query(Post.club_id==x.key).order(-Post.timestamp)
         events = Event.query(Event.club_id==x.key).order(-Post.timestamp)
         list1=[]
         list2=[]
         list1 = [copyToCollegeFeed(y) for y in events]
         list2 = [copyToCollegeFeed(z) for z in posts]
         list1+=list2
         print "List-1",list1
         pylist+=list1
     pylist.sort(key=lambda x: x.timestamp, reverse=True)
     return CollegeFeed(items=pylist)
Пример #2
0
   def personalFeed(self, request):
       pid = ndb.Key('Profile',int(request.pid))
       profile = pid.get()
       posts = []
       events = []
       pylist = []
       pylist2 = []
       pageLimit = 5
       skipCount=0
       upperBound=pageLimit
       print request.pageNumber

       try:
        skipCount = (int(request.pageNumber)-1)*pageLimit
        upperBound = int(request.pageNumber)*pageLimit

       except:
          print "Didnt give pageNumber-Default to 1"



       list1=[]
       list2=[]
       for x in profile.follows:
           print x
           print "LOOP-1"
           posts = (Post.query(Post.club_id==x))
           events = (Event.query(Event.club_id==x))
           list1=[]
           list2=[]
           #list1 = [copyToCollegeFeed(y) for y in events]
           #list2 = [copyToCollegeFeed(z) for z in posts]
           iteration=0
           for y in posts:
               #if(iteration>=skipCount and iteration<upperBound):
               list1.append(copyToCollegeFeed(y))

               #iteration+=1
               #if(iteration==upperBound):
               #    break

           iteration=0

           for z in events:
               #if(iteration>=skipCount and iteration<upperBound):
                list1.append(copyToCollegeFeed(z))
                #iteration+=1
               #if(iteration==upperBound):
               #    break

           print "LIST-1"
           print list1
           pylist+=list1
           pylist2+=list2
       #for x in events:
       #    print x


       #pylist = [copyToCollegeFeed(x) for x in events]
       #pylist2 = [copyToCollegeFeed(x) for x in posts]
       pylist+=pylist2
       #pylist.append(copyToCollegeFeed(x) for x in events)
       pylist.sort(key=lambda x: x.timestamp, reverse=True)
       finalList = []
       for i in xrange(skipCount,upperBound):
           if(i>=len(pylist)):
            break
           finalList.append(pylist[i])

       cf = CollegeFeed()
       cf.items = finalList
       cf.completed=str(0)
       if(upperBound>=len(pylist)):
                cf.completed=str(1)
       #print pylist[1].timestamp
       #print pylist

       CollegeFeed(items=finalList)
       #return CollegeFeed(items=[copyToCollegeFeed(x) for x in events])
       return cf
Пример #3
0
   def collegeFeed(self, request):
       print "Entered the Like Posts Section"
       temp = request.clubId
       flag =0
       pageLimit = 5
       skipCount=0
       upperBound=pageLimit
       print request.pageNumber

       try:
        skipCount = (int(request.pageNumber)-1)*pageLimit
        upperBound = int(request.pageNumber)*pageLimit

       except:
          print "Didnt give pageNumber-Default to 1"

       if request.date != None:
        date = datetime.strptime(getattr(request,"date"),"%Y-%m-%d").date()
        flag = 1
       #print "TYPE-DATE", type(date)
       if (temp==None):
           collegeId = ndb.Key('CollegeDb',int(request.collegeId))
           posts = Post.query(Post.collegeId==collegeId).order(-Post.timestamp)
           events = Event.query(Event.collegeId==collegeId).order(-Event.timestamp)
           print "TEMP IS NONE"
       else:
           clubId = ndb.Key('Club',int(request.clubId))
           posts = Post.query(Post.club_id==clubId).order(-Post.timestamp)
           events = Event.query(Event.club_id==clubId).order(-Event.timestamp)

       print events
       #CollegeFeed(items=[copyEventToForm(x) for x in posts])
       #CollegeFeed(items=[copyEventToForm(x) for x in events])
       #pylist = [copyToCollegeFeed(x) for x in events]
       pylist=[]
       for x in events:
           print "TImestamp",type(x.timestamp.strftime("%Y-%m-%d"))
           if flag==1:
            if x.timestamp.strftime("%Y-%m-%d") == str(date):
                pylist.append(copyToCollegeFeed(x))
           else:
               pylist.append(copyToCollegeFeed(x))
       print pylist
       pylist2 = []
       for x in posts:
           print "TImestamp",type(x.timestamp.strftime("%Y-%m-%d"))
           if flag==1:
            if x.timestamp.strftime("%Y-%m-%d") == str(date):
                pylist.append(copyToCollegeFeed(x))
           else:
               pylist.append(copyToCollegeFeed(x))
       #pylist2 = [copyToCollegeFeed(x) for x in posts]
       pylist+=pylist2
       #pylist.append(copyToCollegeFeed(x) for x in events)
       pylist.sort(key=lambda x: x.timestamp, reverse=True)
       #print pylist[1].timestamp
       #print pylist
       #CollegeFeed(items=pylist)
       #return CollegeFeed(items=[copyToCollegeFeed(x) for x in events])
       #return CollegeFeed(items=pylist)

       finalList = []
       for i in xrange(skipCount,upperBound):
           if(i>=len(pylist)):
            break
           finalList.append(pylist[i])

       cf = CollegeFeed()
       cf.items = finalList
       cf.completed=str(0)
       if(upperBound>=len(pylist)):
                cf.completed=str(1)
       #print pylist[1].timestamp
       #print pylist

       CollegeFeed(items=finalList)
       #return CollegeFeed(items=[copyToCollegeFeed(x) for x in events])
       return cf