def post(self, pid, bid):
     last_merge_date = time.strftime("%c")
     project = db.getProjectById(pid)
     for index, bundle in enumerate(project['bundles']):
         if bundle['gid'] == bid:
             project['bundles'][index]['lastmerge'] = last_merge_date
             db.updateProject(project)
             self.set_status(200)
             return
     self.set_status(404)
 def delete(self, pid, bid):
     project = db.getProjectById(pid)
     for index, bundle in enumerate(project['bundles']):
         if bundle['gid'] == bid:
             if 'lastmerge' in bundle:
               del project['bundles'][index]['lastmerge']
               db.updateProject(project)
             self.set_status(200)
             return
     self.set_status(404)
    def get(self, pid, bid):
        last_merge_date = ''
        all_mergeable = True
        project = db.getProjectById(pid)
        for index, bundle in enumerate(project['bundles']):
            if not 'lastmerge' in bundle:
                all_mergeable = False
            if bundle['gid'] == bid:
                if 'lastmerge' in bundle:
                    last_merge_date = bundle['lastmerge']

        response = {'last_merge_date': last_merge_date, 'all_mergeable': all_mergeable}
        self.write(json.dumps(response))
        self.set_status(200)
 def get(self,prid=None):
     # Get username. We will retrieve only the requests where the user is involved
     username = self.get_argument('username')
     if username:
         if prid:
             # Retrieve the results from mongodb by id
             result = db.getProjectById(prid)
             self.write(json.dumps(result))
             self.set_status(200)
         else:
             # Retrieve the results from mongodb
             response = {'items' : db.getAllProjectsByUser(username)}
             self.write(json.dumps(response))
             self.set_status(200)
     else:
         self.set_status(404)
 def get(self, prid=None):
     # Get username. We will retrieve only the requests where the user is involved
     # TODO: That is not true
     username = self.get_argument('username')
     if username:
         if prid:
             # Retrieve the results from mongodb by id
             result = db.getProjectById(prid)
             self.write(json.dumps(result))
             self.set_status(200)
         else:
             # Retrieve the results from mongodb
             response = {'items': db.getAllProjectsByUser(username)}
             self.write(json.dumps(response))
             self.set_status(200)
     else:
         self.set_status(404)