예제 #1
0
    def post(self, request, format=None, **kwargs):
        """
           Current user's identity endpoint.

        """
        serializer = ProjectDataSerializers(data=request.data)
        if serializer.is_valid():
            project_id = uuid.uuid4()
            project_name = request.data.get("project_name", )
            project_start = request.data.get("project_start", )
            project_end = request.data.get("project_end", )
            project_owner = request.data.get("project_owner", )
            project_disc = request.data.get("project_disc", )
            save_project = project_db(
                project_name=project_name,
                project_id=project_id,
                project_start=project_start,
                project_end=project_end,
                project_owner=project_owner,
                project_disc=project_disc,
            )
            save_project.save()

            if not project_name:
                return Response({"error": "No name passed"})
            return Response({"message": "Project Created"})
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
예제 #2
0
파일: views.py 프로젝트: sinnik/archerysec
    def post(self, request, format=None, **kwargs):
        """
           Current user's identity endpoint.

        """
        username = request.user.username
        _project_name = None
        _project_id = None

        serializer = ProjectDataSerializers(data=request.data)
        if serializer.is_valid():
            project_id = uuid.uuid4()
            project_name = request.data.get("project_name", )
            project_start = request.data.get("project_start", )
            project_end = request.data.get("project_end", )
            project_owner = request.data.get("project_owner", )
            project_disc = request.data.get("project_disc", )

            all_project = project_db.objects.filter(project_name=project_name,
                                                    username=username)

            for project in all_project:
                _project_name = project.project_name
                _project_id = project.project_id

            if _project_name == project_name:
                return Response({
                    "message": "Project already existed",
                    "project_id": _project_id
                })

            else:
                save_project = project_db(project_name=project_name,
                                          project_id=project_id,
                                          project_start=project_start,
                                          project_end=project_end,
                                          project_owner=project_owner,
                                          project_disc=project_disc,
                                          username=username)
                save_project.save()

                if not project_name:
                    return Response({"error": "No name passed"})
                return Response({
                    "message": "Project Created",
                    "project_id": project_id
                })
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
예제 #3
0
    def post(self, request, format=None, **kwargs):
        """
           Current user's identity endpoint.

        """
        serializer = ProjectDataSerializers(data=request.data)
        if serializer.is_valid():
            project_id = uuid.uuid4()
            project_name = request.data.get("project_name",)
            project_start = request.data.get("project_start",)
            project_end = request.data.get("project_end",)
            project_owner = request.data.get("project_owner",)
            project_disc = request.data.get("project_disc",)
            save_project = project_db(project_name=project_name, project_id=project_id,
                                      project_start=project_start, project_end=project_end,
                                      project_owner=project_owner, project_disc=project_disc, )
            save_project.save()

            if not project_name:
                return Response({"error": "No name passed"})
            return Response({"message": "Project Created"})
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
예제 #4
0
    def post(self, request):
        """
        Current user's identity endpoint.
        """
        _project_name = None
        _project_id = None

        serializer = ProjectDataSerializers(data=request.data)
        if serializer.is_valid():
            project_name = request.data.get("project_name", )

            project_disc = request.data.get("project_disc", )

            all_project = ProjectDb.objects.filter(project_name=project_name)

            for project in all_project:
                _project_name = project.project_name
                _project_id = project.uu_id

            if _project_name == project_name:
                return Response({
                    "message": "Project already existed",
                    "project_id": _project_id
                })

            else:
                project = ProjectDb(
                    project_name=project_name,
                    project_disc=project_disc,
                    # created_by=request.user,
                    total_vuln=0,
                    total_high=0,
                    total_medium=0,
                    total_low=0,
                    total_open=0,
                    total_false=0,
                    total_close=0,
                    total_net=0,
                    total_web=0,
                    total_static=0,
                    high_net=0,
                    high_web=0,
                    high_static=0,
                    medium_net=0,
                    medium_web=0,
                    medium_static=0,
                    low_net=0,
                    low_web=0,
                    low_static=0,
                )
                project.save()

                all_month_data_display = MonthDb.objects.filter()

                if len(all_month_data_display) == 0:
                    save_months_data = MonthDb(
                        project_id=project.id,
                        month=datetime.datetime.now().month,
                        high=0,
                        medium=0,
                        low=0,
                    )
                    save_months_data.save()

                if not project_name:
                    return Response({"error": "No name passed"})
                return Response({
                    "message": "Project Created",
                    "project_id": project.uu_id
                })
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)