예제 #1
0
 def get(self):
     title_entity = Title(
         title_id='ABC-123',
         title='test title 1',
         video_path='test',
         file_names=['test file'],
         description='test des',
         stars=[str(uuid.uuid4())],
         video_size=1000000000,
         rate=8,
     )
     service = TitleService()
     try:
         title = yield service.create_with_entity(title_entity)
         self.write('Added {}'.format(title.uuid))
     except EntityAlreadyExistsError:
         self.write('{} already exists'.format(title_entity.title_id))
예제 #2
0
    def post(self):
        title_id = self.get_body_argument('title_id')
        title = self.get_body_argument('title')
        video_path = self.get_body_argument('video_path')
        file_names = self.get_body_argument('file_names')
        description = self.get_body_argument('description')
        maker = self.get_body_argument('maker')
        video_size = self.get_body_argument('video_size')
        rate = self.get_body_argument('rate')
        length = self.get_body_argument('length')
        published_date = self.get_body_argument('published_date')

        title_entity = Title(
            title_id=title_id,
            title=title,
            video_path=video_path,
            file_names=file_names,
            description=description,
            maker=maker,
            video_size=video_size,
            rate=rate,
            length=length,
            published_date=published_date,
        )
        service = TitleService()

        self.set_header('Content-Type', 'application/json')

        try:
            title = yield service.create_with_entity(title_entity)
            self.write({"status": "ok", "uuid": title.uuid})
        except EntityAlreadyExistsError:
            self.write({
                "status":
                "failed",
                "errorMessage":
                "Title title_id {} exist.".format(title_id)
            })