示例#1
0
def deleteJourney(journey):
    
    if journey.image != None:
        image = Image.get(journey.image)
        if image != None:
            Image.delete(image)
        
    query = db.Query(Milestone)
    query.filter('journey_id = ',str(journey.key()))
    for milestone in query.run():
        deleteMilestone(milestone)
    
    if journey != None:
        Journey.delete(journey)
示例#2
0
 def get(self,journey_id):
     self.response.headers['Content-Type'] = 'application/json'
     
     journey = Journey.get(journey_id)
     if journey == None:
         self.response.write({'status' : 0})
         return
      
     deleteJourney(journey)
     
     self.response.write(json.dumps({'status' : 1}))
示例#3
0
 def post(self):
     self.response.headers['Content-Type'] = 'application/json'
     
     newJourney = Journey(user_id = str(self.current_user.key.id()))
     
     newJourney.name = self.request.get('name')
     newJourney.description = self.request.get('description')
     newJourney.image = PostImage(self.request.POST.multi['image'])
     newJourney.time = getTimeEpoch()
     
     newJourney.put()
     
     self.response.write(json.dumps({'journey_id' : str(newJourney.key())}))
示例#4
0
 def get(self,journey_id):
     self.response.headers['Content-Type'] = 'application/json'
     
     journey = Journey.get(journey_id)
     
     if journey == None:
         self.response.write({'journey' : None})
         return
     
     journeyInfo = dict(journey.__dict__['_entity'])
     journeyInfo['journey_id'] = journey_id
     
     query = db.Query(Milestone)
     query.filter('journey_id = ',journey_id)
     query.order('time')
     
     milestones = []
     for milestone in query.run():
         milestoneInfo = dict(milestone.__dict__['_entity'])
         milestoneInfo['milestone_id'] = str(milestone.key())
         
         query1 = db.Query(MilestoneAttachment)
         query1.filter('milestone_id = ',str(milestone.key()))
         query1.order('time')
         
         attachments = []
         for attachment in query1.run():
             attachmentInfo = dict(attachment.__dict__['_entity'])
             attachmentInfo['attachment_id'] = str(attachment.key())
             attachments.append(attachmentInfo)
         
         milestoneInfo['attachments'] = attachments
             
         milestones.append(milestoneInfo)
     
     journeyInfo['path'] = milestones
     
     self.response.write(json.dumps({'journey' : journeyInfo}))