Duplicate a task
(self, request, pk=None, project_pk=None)
| 355 | |
| 356 | @action(detail=True, methods=['post']) |
| 357 | def duplicate(self, request, pk=None, project_pk=None): |
| 358 | """ |
| 359 | Duplicate a task |
| 360 | """ |
| 361 | try: |
| 362 | task = self.queryset.get(pk=pk, project=project_pk) |
| 363 | check_project_perms(request, task.project, ('change_project', )) |
| 364 | except (ObjectDoesNotExist, ValidationError): |
| 365 | raise exceptions.NotFound() |
| 366 | |
| 367 | new_task = task.duplicate() |
| 368 | if new_task: |
| 369 | return Response({'success': True, 'task': TaskSerializer(new_task).data}, status=status.HTTP_200_OK) |
| 370 | else: |
| 371 | return Response({'error': _("Cannot duplicate task")}, status=status.HTTP_200_OK) |
| 372 | |
| 373 | def create(self, request, project_pk=None): |
| 374 | project = get_and_check_project(request, project_pk, ('change_project', )) |
nothing calls this directly
no test coverage detected