示例#1
0
文件: clubapis.py 项目: RJJ11/SAMPLE
   def getEvents(self, request):
        print("Entered Get Events Portion")
        temp = request.collegeId
        temp2 = request.clubId
        date = request.date
        future_date = request.future_date
        

        print ("Future date is",future_date)
        if(temp2==None):
            print "No CLubId"
            collegeId = ndb.Key('CollegeDb',int(temp))
            events = Event.query(Event.collegeId==collegeId).order(-Event.start_time)
        elif(temp==None):
            print "No collegeID"
            clubId = ndb.Key('Club',int(temp2))
            events = Event.query(Event.club_id==clubId).order(-Event.start_time)

        else:
            print "Not None"
            collegeId = ndb.Key('CollegeDb',int(temp))
            clubId = ndb.Key('Club',int(temp2))
            events = Event.query(Event.collegeId==collegeId,Event.club_id==clubId).order(-Event.start_time)

        #All events have been obtained, check if date field is provided and take only those that have start date = req.date

        finalList = []
        if(future_date!=None):
           print ("Future Date part")
           for x in events:
              start_date = str(x.start_time.date())
              print("Retrieve start date",start_date)
              if(start_date >= future_date):
                 print ("Start Date is",start_date)
                 print ("Event to be added",x.title)
                 finalList.append(x)
           print("Returning all events from Final List")
           return Events(items=list(reversed([copyEventToForm(x) for x in finalList])))
        elif(date != None):
           for x in events:
              start_date = str(x.start_time.date())
              if(start_date == date):	
                 finalList.append(x)
           print("Returning all events from Final List")
           return Events(items=list(reversed([copyEventToForm(x) for x in finalList])))
        else:
           print("Returning all events from Events List")
           return Events(items=list(reversed([copyEventToForm(x) for x in events])))
示例#2
0
   def getEvents(self, request):
        print("Entered Get Events Portion")
        temp = request.collegeId
        temp2 = request.clubId
        print "temp2" + str(temp2)
        if(temp2==None):
            print "No CLubId"
            collegeId = ndb.Key('CollegeDb',int(temp))
            events = Event.query(Event.collegeId==collegeId)
        elif(temp==None):
            print "No collegeID"
            clubId = ndb.Key('Club',int(temp2))
            events = Event.query(Event.clubId==clubId)

        else:
            print "Not None"
            collegeId = ndb.Key('CollegeDb',int(temp))
            clubId = ndb.Key('Club',int(temp2))
            events = Post.query(Event.collegeId==collegeId,Event.clubId==clubId)


        return Events(items=[copyEventToForm(x) for x in events])