예제 #1
0
 def temp_save(self, request, pk):
     task = PageTask.objects.get(pk=pk)
     if (task.status != TaskStatus.NOT_READY and task.owner != request.user) or \
     (task.status == TaskStatus.NOT_READY and request.user.is_authenticated):
         if not request.user.is_admin:
             return Response({"status": -1, "msg": "No Permission!"})
     if PageVerifyTask.objects.filter(
             schedule=task.schedule,
             pagerect=task.pagerect,
             status__gte=TaskStatus.HANDLING).first():
         return Response({"status": -1, "msg": "审定任务已开始,保存已屏蔽!"})
     if 'current_x' in request.data:
         task.current_x = request.data['current_x']
         task.current_y = request.data['current_y']
         task.save(update_fields=['current_x', 'current_y'])
     rects = request.data['rects']
     DeletionCheckItem.direct_delete_rects(rects, task)
     _rects = [rect for rect in filter(lambda x: x['op'] != 3, rects)]
     for r in _rects:
         r['page_pid'] = task.pagerect.page.pk
         r['line_no'] = 0
         r['char_no'] = 0
     rectset = RectWriterSerializer(data=_rects, many=True)
     rectset.is_valid()
     Rect.bulk_insert_or_replace(rectset.data)
     PageRect.reformat_rects(task.pagerect.page.pk)
     return Response({"status": 0, "task_id": pk})
예제 #2
0
 def task_done(self, rects, task):
     # 直接過濾掉被刪除的框
     DeletionCheckItem.direct_delete_rects(rects, task)
     _rects = [rect for rect in filter(lambda x: x['op'] != 3, rects)]
     for r in _rects:
         r['page_pid'] = task.pagerect.page.pk
         r['line_no'] = 0
         r['char_no'] = 0
     rectset = RectWriterSerializer(data=_rects, many=True)
     rectset.is_valid()
     Rect.bulk_insert_or_replace(rectset.data)
     PageRect.reformat_rects(task.pagerect.page.pk)
     task.done()
예제 #3
0
 def task_redo(self, request, pk):
     task = PageVerifyTask.objects.get(pk=pk)
     if (task.owner != request.user):
         return Response({"status": -1, "msg": "No Permission!"})
     if 'current_x' in request.data:
         task.current_x = request.data['current_x']
         task.current_y = request.data['current_y']
         task.save(update_fields=['current_x', 'current_y'])
     rects = request.data['rects']
     DeletionCheckItem.direct_delete_rects(rects, task)
     _rects = [rect for rect in filter(lambda x: x['op'] != 3, rects)]
     for r in _rects:
         r['page_pid'] = task.pagerect.page.pk
         r['line_no'] = 0
         r['char_no'] = 0
     rectset = RectWriterSerializer(data=_rects, many=True)
     rectset.is_valid()
     Rect.bulk_insert_or_replace(rectset.data)
     PageRect.reformat_rects(task.pagerect.page.pk)
     task.redo()
     return Response({"status": 0, "task_id": pk})
예제 #4
0
파일: tasks.py 프로젝트: ncc0706/cutrect
    def tobe_done(self, request, pk):
        task = DelTask.objects.get(pk=pk)
        can_write_fields = getattr(DeletionCheckItemSerializer.Meta, 'can_write_fields', [])
        if (task.owner != request.user):
            return Response({"status": -1,
                             "msg": "No Permission!"})
        rects = request.data['rects']

        _items = [dict((k,v) for (k,v) in filter(lambda x: x[0] in can_write_fields, rect_del.items())) for rect_del in rects]

        del_items = [DeletionCheckItem(**_rect) for _rect in _items]
        for it in del_items:
            it.verifier = task.owner
        DeletionCheckItem.objects.bulk_update(del_items, update_fields=['result', 'verifier'])

        task.done()
        task.execute()
        return Response({"status": 0, "task_id": pk })
예제 #5
0
파일: tasks.py 프로젝트: lishikuan/cutrect
 def task_done(self, rects, task):
     rectset = RectWriterSerializer(data=rects, many=True)
     rectset.is_valid()
     Rect.bulk_insert_or_replace(rectset.data)
     DeletionCheckItem.create_from_rect(rects, task)
     task.done()