Exemple #1
0
 async def post(self, request):
     request.json['creator_id'] = current_account.id
     start_time = request.json.get('start_time')
     if start_time:
         request.json['start_time'] = str_to_time(start_time)
     end_time = request.json.get('end_time')
     if end_time:
         request.json['end_time'] = str_to_time(end_time)
     test = Test.insert(**request.json)
     return test, 201
Exemple #2
0
 async def put(self, request, id):
     test = self._get_test(id)
     start_time = request.json.get('start_time')
     if start_time:
         request.json['start_time'] = str_to_time(start_time)
     end_time = request.json.get('end_time')
     if end_time:
         request.json['end_time'] = str_to_time(end_time)
     test.update(**request.json)
     test.save()
     return test, 200
Exemple #3
0
 async def post(self, request):
     request.json['creator_id'] = current_account.id
     start_time = request.json.get('start_time')
     if start_time:
         request.json['start_time'] = str_to_time(start_time)
     end_time = request.json.get('end_time')
     if end_time:
         request.json['end_time'] = str_to_time(end_time)
     request.json['id'] = generation_objectid()
     test = Test(**request.json).save()
     return test, 201
Exemple #4
0
 async def put(self, request, id):
     test = Test.get(_id=id)
     if not test or test.get('creator_id') != current_account.id:
         raise NotFound('test_not_found')
     start_time = request.json.get('start_time')
     if start_time:
         request.json['start_time'] = str_to_time(start_time)
     end_time = request.json.get('end_time')
     if end_time:
         request.json['end_time'] = str_to_time(end_time)
     result = Test.find_one_and_update(filter={'_id': ObjectId(id)},
                                       update={'$set': request.json})
     return result, 200