Пример #1
0
    def get(self, *args, **kwargs):
        project_id = None
        try:
            if not any(args):
                print u"projects list get"
                response = yield ProjectBL.get_all()
            else:
                project_id = args[0].replace(u"/", u"")
                print u"get project:", project_id
                response = yield ProjectBL.get(project_id)

        except Exception, ex:
            logging.info(PROJECT_EXC(project_id=project_id))
            logging.exception(ex)
            response = dict(message=ex.message)
Пример #2
0
    def get(self, *args, **kwargs):
        project_id = None
        try:
            if not any(args):
                print u'projects list get'
                response = yield ProjectBL.get_all()
            else:
                project_id = args[0].replace(u'/', u'')
                print u'get project:', project_id
                response = yield ProjectBL.get(project_id)

        except Exception, ex:
            logging.info(PROJECT_EXC(project_id=project_id))
            logging.exception(ex)
            response = dict(message=ex.message)
Пример #3
0
 def delete(self, project_id):
     print u'delete like in project:', project_id
     response = {}
     scientist_id = self.current_user_id
     try:
         yield ProjectBL.delete_like(project_id, scientist_id)
     except Exception, ex:
         logging.info('Exc on delete like: {}'.format(project_id))
         logging.exception(ex)
         response = dict(message=ex.message)
Пример #4
0
 def delete(self, project_id):
     print u'delete project:', project_id
     response = {}
     project_id = project_id.replace(u'/', u'')
     try:
         yield ProjectBL.delete(project_id)
     except Exception, ex:
         logging.info('Exc on delete project: {}'.format(project_id))
         logging.exception(ex)
         response = dict(message=ex.message)
Пример #5
0
 def delete(self, project_id):
     print u"delete project:", project_id
     response = {}
     project_id = project_id.replace(u"/", u"")
     try:
         yield ProjectBL.delete(project_id)
     except Exception, ex:
         logging.info("Exc on delete project: {}".format(project_id))
         logging.exception(ex)
         response = dict(message=ex.message)
Пример #6
0
 def delete(self, project_id):
     print u"delete like in project:", project_id
     response = {}
     scientist_id = self.current_user_id
     try:
         yield ProjectBL.delete_like(project_id, scientist_id)
     except Exception, ex:
         logging.info("Exc on delete like: {}".format(project_id))
         logging.exception(ex)
         response = dict(message=ex.message)
Пример #7
0
 def put(self, project_id):
     print 'add like: ', project_id
     scientist_id = self.current_user_id
     if not scientist_id:
         return
     response = {}
     try:
         yield ProjectBL.add_like(project_id, scientist_id)
     except Exception, ex:
         logging.info('Exc on add like:')
         logging.exception(ex)
         response = dict(message=ex.message)
Пример #8
0
 def put(self, project_id):
     print "add like: ", project_id
     scientist_id = self.current_user_id
     if not scientist_id:
         return
     response = {}
     try:
         yield ProjectBL.add_like(project_id, scientist_id)
     except Exception, ex:
         logging.info("Exc on add like:")
         logging.exception(ex)
         response = dict(message=ex.message)
Пример #9
0
 def delete(self, project_id):
     print u'delete project:', project_id
     response = {}
     data = json.loads(self.get_argument(u'data', u'{}'))
     if not self.current_user_id:
         self.send_error(status_code=403)
         return
     data.update(scientist_id=self.current_user_id)
     try:
         yield ProjectBL.delete_participation(data)
     except Exception, ex:
         logging.info('Exc on delete like: {}'.format(project_id))
         logging.exception(ex)
         response = dict(message=ex.message)
Пример #10
0
 def delete(self, project_id):
     print u"delete project:", project_id
     response = {}
     data = json.loads(self.get_argument(u"data", u"{}"))
     if not self.current_user_id:
         self.send_error(status_code=403)
         return
     data.update(scientist_id=self.current_user_id)
     try:
         yield ProjectBL.delete_participation(data)
     except Exception, ex:
         logging.info("Exc on delete like: {}".format(project_id))
         logging.exception(ex)
         response = dict(message=ex.message)
Пример #11
0
    def post(self, project_id, **kwargs):
        print 'add participation'

        data = json.loads(self.get_argument(u'data', u'{}'))
        print data
        if not self.current_user_id:
            self.send_error(status_code=403)
            return
        data.update(scientist_id=self.current_user_id, project_id=project_id)
        response = {}
        try:
            yield ProjectBL.add_participation(data)
        except Exception, ex:
            logging.info('Exc on add like:')
            logging.exception(ex)
            response = dict(message=ex.message)
Пример #12
0
    def post(self, project_id, **kwargs):
        print "add participation"

        data = json.loads(self.get_argument(u"data", u"{}"))
        print data
        if not self.current_user_id:
            self.send_error(status_code=403)
            return
        data.update(scientist_id=self.current_user_id, project_id=project_id)
        response = {}
        try:
            yield ProjectBL.add_participation(data)
        except Exception, ex:
            logging.info("Exc on add like:")
            logging.exception(ex)
            response = dict(message=ex.message)
Пример #13
0
    def put(self, project_id, **kwargs):
        print "updating response", project_id

        data = json.loads(self.get_argument(u"data", u"{}"))
        if not self.current_user_id:
            self.send_error(status_code=403)

        print data

        data.update(project_id=project_id)
        response = {}
        try:
            yield ProjectBL.update_response(data)

        except Exception, ex:
            logging.info("Exc on accept response:")
            logging.exception(ex)
            response = dict(message=ex.message)
Пример #14
0
    def put(self, project_id, **kwargs):
        print 'updating response', project_id

        data = json.loads(self.get_argument(u'data', u'{}'))
        if not self.current_user_id:
            self.send_error(status_code=403)

        print data

        data.update(project_id=project_id)
        response = {}
        try:
            yield ProjectBL.update_response(data)

        except Exception, ex:
            logging.info('Exc on accept response:')
            logging.exception(ex)
            response = dict(message=ex.message)
Пример #15
0
    def post(self, *args, **kwargs):
        print u'create project'
        project_dict = json.loads(self.get_argument(u'data', u'{}'))
        if u'in_progress' in project_dict:
            project_dict.update(in_progress='true')
        else:
            project_dict.update(in_progress='false')

        manager_id = self.current_user_id
        if not manager_id:
            self.send_error(status_code=403)
            return
        project_dict.update(manager_id=manager_id)
        try:
            response = yield ProjectBL.create(project_dict)
        except Exception, ex:
            logging.info('Exc on create project:')
            logging.exception(ex)
            response = dict(message=ex.message)
Пример #16
0
    def post(self, *args, **kwargs):
        print u"create project"
        project_dict = json.loads(self.get_argument(u"data", u"{}"))
        if u"in_progress" in project_dict:
            project_dict.update(in_progress="true")
        else:
            project_dict.update(in_progress="false")

        manager_id = self.current_user_id
        if not manager_id:
            self.send_error(status_code=403)
            return
        project_dict.update(manager_id=manager_id)
        try:
            response = yield ProjectBL.create(project_dict)
        except Exception, ex:
            logging.info("Exc on create project:")
            logging.exception(ex)
            response = dict(message=ex.message)
Пример #17
0
    def put(self, project_id):
        print u"update project"
        try:
            project_id = project_id.replace(u"/", u"")
        except:
            self.send_error(status_code=403)
            return
        project_dict = json.loads(self.get_argument(u"data", u"{}"))
        if u"in_progress" in project_dict:
            project_dict.update(in_progress="true")
        else:
            project_dict.update(in_progress="false")

        try:
            response = yield ProjectBL.update(project_id, project_dict)
        except Exception, ex:
            logging.info("Exc on update project:")
            logging.exception(ex)
            response = dict(message=ex.message)
Пример #18
0
    def put(self, project_id):
        print u'update project'
        try:
            project_id = project_id.replace(u'/', u'')
        except:
            self.send_error(status_code=403)
            return
        project_dict = json.loads(self.get_argument(u'data', u'{}'))
        if u'in_progress' in project_dict:
            project_dict.update(in_progress='true')
        else:
            project_dict.update(in_progress='false')

        try:
            response = yield ProjectBL.update(project_id, project_dict)
        except Exception, ex:
            logging.info('Exc on update project:')
            logging.exception(ex)
            response = dict(message=ex.message)
Пример #19
0
    try:
        yield momoko.Op(conn.execute, query)
    except Exception, ex:
        print ex


@gen.coroutine
def fill_init_data():
    from tests.scientist_data import Scientist
    from scientist.scientist_bl import ScientistBL

    from tests.project_data import Project
    from project.project_bl import ProjectBL

    scientist_data = Scientist.get_scientist()
    print 'Creating init scientists'
    try:
        for k, val in scientist_data.iteritems():
            yield ScientistBL.create(scientist_dict=val, test_mode=True)
    except Exception, ex:
        logging.exception(ex)
        raise

    project_data = Project.get_project()
    print 'Creating init projects'
    try:
        for k, val in project_data.iteritems():
            yield ProjectBL.create(val, test_mode=True)
    except Exception, ex:
        logging.exception(ex)
        raise