Beispiel #1
0
    def bulk_create(self, request, **kwargs):
        bulk_tasks = request.DATA.get('bulkTasks', None)
        if bulk_tasks is None:
            raise exc.BadRequest(_('bulkTasks parameter is mandatory'))

        project_id = request.DATA.get('projectId', None)
        if project_id is None:
            raise exc.BadRequest(_('projectId parameter is mandatory'))

        us_id = request.DATA.get('usId', None)
        if us_id is None:
            raise exc.BadRequest(_('usId parameter is mandatory'))

        project = get_object_or_404(Project, id=project_id)
        user_story = get_object_or_404(UserStory, id=us_id)

        if request.user != project.owner and not has_project_perm(request.user, project, 'add_task'):
            raise exc.PermissionDenied(_("You don't have permisions to create tasks."))

        service = services.TasksService()
        tasks = service.bulk_insert(project, request.user, user_story, bulk_tasks,
                                    callback_on_success=self.post_save)

        tasks_serialized = self.serializer_class(tasks, many=True)
        return Response(data=tasks_serialized.data)
Beispiel #2
0
    def bulk_update_order(self, request, **kwargs):
        # bulkStories should be:
        # [[1,1],[23, 2], ...]

        # TODO: Generate the histoy snaptshot when change the uss order in the backlog.
        #       Implement order with linked lists \o/.
        bulk_stories = request.DATA.get("bulkStories", None)

        if bulk_stories is None:
            raise exc.BadRequest(_("bulkStories parameter is mandatory"))

        project_id = request.DATA.get('projectId', None)
        if project_id is None:
            raise exc.BadRequest(_("projectId parameter ir mandatory"))

        project = get_object_or_404(Project, id=project_id)

        if request.user != project.owner and not has_project_perm(
                request.user, project, 'change_userstory'):
            raise exc.PermissionDenied(
                _("You don't have permisions to create user stories."))

        service = services.UserStoriesService()
        service.bulk_update_order(project, request.user, bulk_stories)

        return Response(data=None, status=status.HTTP_204_NO_CONTENT)
Beispiel #3
0
    def bulk_create(self, request, **kwargs):
        bulk_tasks = request.DATA.get('bulkTasks', None)
        if bulk_tasks is None:
            raise exc.BadRequest(_('bulkTasks parameter is mandatory'))

        project_id = request.DATA.get('projectId', None)
        if project_id is None:
            raise exc.BadRequest(_('projectId parameter is mandatory'))

        us_id = request.DATA.get('usId', None)
        if us_id is None:
            raise exc.BadRequest(_('usId parameter is mandatory'))

        project = get_object_or_404(Project, id=project_id)
        user_story = get_object_or_404(UserStory, id=us_id)

        if request.user != project.owner and not has_project_perm(request.user, project, 'add_task'):
            raise exc.PermissionDenied(_("You don't have permisions to create tasks."))

        service = services.TasksService()
        tasks = service.bulk_insert(project, request.user, user_story, bulk_tasks,
                                    callback_on_success=self.post_save)

        tasks_serialized = self.serializer_class(tasks, many=True)
        return Response(data=tasks_serialized.data)
Beispiel #4
0
    def bulk_create(self, request, **kwargs):
        bulk_tasks = request.DATA.get('bulkTasks', None)
        if bulk_tasks is None:
            raise exc.BadRequest(_('bulkTasks parameter is mandatory'))

        project_id = request.DATA.get('projectId', None)
        if project_id is None:
            raise exc.BadRequest(_('projectId parameter is mandatory'))

        us_id = request.DATA.get('usId', None)
        if us_id is None:
            raise exc.BadRequest(_('usId parameter is mandatory'))

        project = get_object_or_404(Project, id=project_id)
        us = get_object_or_404(UserStory, id=us_id)

        if request.user != project.owner and not has_project_perm(request.user, project, 'add_task'):
            raise exc.PermissionDenied(_("You don't have permisions to create tasks."))

        items = filter(lambda s: len(s) > 0,
                    map(lambda s: s.strip(), bulk_tasks.split("\n")))

        tasks = []
        for item in items:
            obj = models.Task.objects.create(subject=item, project=project,
                                             user_story=us, owner=request.user,
                                             status=project.default_task_status)
            tasks.append(obj)
            self._post_save_notification_sender(obj, True)

        tasks_serialized = self.serializer_class(tasks, many=True)
        return Response(data=tasks_serialized.data)
Beispiel #5
0
    def bulk_update_order(self, request, **kwargs):
        bulk_data = request.DATA.get(self.bulk_update_param, None)

        if bulk_data is None:
            raise exc.BadRequest(_("%s parameter is mandatory") % self.bulk_update_param)

        project_id = request.DATA.get('project', None)
        if project_id is None:
            raise exc.BadRequest(_("project parameter ir mandatory"))

        project = get_object_or_404(models.Project, id=project_id)

        if request.user != project.owner and not has_project_perm(request.user, project, self.bulk_update_perm):
            raise exc.PermissionDenied(_("You don't have permisions %s.") % self.bulk_update_perm)

        self.bulk_update_order(project, request.user, bulk_data)
        return Response(data=None, status=status.HTTP_204_NO_CONTENT)
Beispiel #6
0
    def bulk_create(self, request, **kwargs):
        bulk_stories = request.DATA.get('bulkStories', None)
        if bulk_stories is None:
            raise exc.BadRequest(_('bulkStories parameter is mandatory'))

        project_id = request.DATA.get('projectId', None)
        if project_id is None:
            raise exc.BadRequest(_('projectId parameter is mandatory'))

        project = get_object_or_404(Project, id=project_id)

        if request.user != project.owner and not has_project_perm(request.user, project, 'add_userstory'):
            raise exc.PermissionDenied(_("You don't have permisions to create user stories."))

        service = services.UserStoriesService()
        service.bulk_insert(project, request.user, bulk_stories,
                            callback_on_success=self._post_save_notification_sender)

        return Response(data=None, status=status.HTTP_204_NO_CONTENT)
Beispiel #7
0
    def bulk_update_order(self, request, **kwargs):
        bulk_data = request.DATA.get(self.bulk_update_param, None)

        if bulk_data is None:
            raise exc.BadRequest(
                _("%s parameter is mandatory") % self.bulk_update_param)

        project_id = request.DATA.get('project', None)
        if project_id is None:
            raise exc.BadRequest(_("project parameter ir mandatory"))

        project = get_object_or_404(models.Project, id=project_id)

        if request.user != project.owner and not has_project_perm(
                request.user, project, self.bulk_update_perm):
            raise exc.PermissionDenied(
                _("You don't have permisions %s.") % self.bulk_update_perm)

        self.bulk_update_order(project, request.user, bulk_data)
        return Response(data=None, status=status.HTTP_204_NO_CONTENT)
Beispiel #8
0
    def bulk_update_order(self, request, **kwargs):
        # bulkStories should be:
        # [[1,1],[23, 2], ...]

        bulk_stories = request.DATA.get("bulkStories", None)

        if bulk_stories is None:
            raise exc.BadRequest(_("bulkStories parameter is mandatory"))

        project_id = request.DATA.get('projectId', None)
        if project_id is None:
            raise exc.BadRequest(_("projectId parameter ir mandatory"))

        project = get_object_or_404(Project, id=project_id)

        if request.user != project.owner and not has_project_perm(request.user, project, 'change_userstory'):
            raise exc.PermissionDenied(_("You don't have permisions to create user stories."))

        service = services.UserStoriesService()
        service.bulk_update_order(project, request.user, bulk_stories)

        return Response(data=None, status=status.HTTP_204_NO_CONTENT)