예제 #1
0
    def put(self, request: Request, team: Team) -> Response:
        """
        Update the Notification Settings for a given Team.
        ````````````````````````````````
        :pparam string team_slug: The slug of the team to get.
        :param map <anonymous>: The POST data for this request should be several
            nested JSON mappings. The bottommost value is the "value" of the
            notification setting and the order of scoping is:
              - type (str),
              - scope_type (str),
              - scope_identifier (int)
              - provider (str)
            Example: {
                "workflow": {
                    "project": {
                        1: {
                            "email": "always",
                            "slack": "always"
                        },
                        2: {
                            "email": "subscribe_only",
                            "slack": "subscribe_only"
                        }
                    }
                }
            }

        :auth required:
        """

        notification_settings = validate(request.data, team=team)
        NotificationSetting.objects.update_settings_bulk(notification_settings,
                                                         team=team)

        return Response(status=status.HTTP_204_NO_CONTENT)
예제 #2
0
    def put(self, request: Request, user: User) -> Response:
        """
        Update the Notification Settings for a given User.
        ````````````````````````````````
        :pparam string user_id: A User's `user_id` or "me" for current user.
        :param map <anonymous>: The POST data for this request should be several
            nested JSON mappings. The bottommost value is the "value" of the
            notification setting and the order of scoping is:
              - type (str),
              - scope_type (str),
              - scope_identifier (int or str)
              - provider (str)
            Example: {
                "workflow": {
                    "user": {
                        "me": {
                            "email": "never",
                            "slack": "never"
                        },
                    },
                    "project": {
                        1: {
                            "email": "always",
                            "slack": "always"
                        },
                        2: {
                            "email": "subscribe_only",
                            "slack": "subscribe_only"
                        }
                    }
                }
            }

        :auth required:
        """
        validate_has_feature(user)

        notification_settings = validate(request.data, user=user)
        NotificationSetting.objects.update_settings_bulk(
            notification_settings, user.actor_id)

        return Response(status=status.HTTP_204_NO_CONTENT)