Beispiel #1
0
    def reject(self, request, pk):
        if request and hasattr(request, "user"):
            if request.user.is_authenticated:
                try:
                    if 'status_reason' in request.data.keys():
                        PlaceName.reject(int(pk),
                                         request.data["status_reason"])

                        #Notifying the creator
                        try:
                            inform_placename_rejected_or_flagged(
                                int(pk), request.data["status_reason"],
                                PlaceName.REJECTED)
                        except Exception as e:
                            pass

                        return Response({"message": "Rejected!"})
                    else:
                        return Response({"message": "Reason must be provided"})
                except PlaceName.DoesNotExist:
                    return Response({
                        "message":
                        "No PlaceName with the given id was found"
                    })

        return Response(
            {"message", "Only Administrators can reject contributions"})
    def reject(self, request, pk):
        if request and hasattr(request, "user"):
            if request.user.is_authenticated:
                try:
                    if 'status_reason' in request.data.keys():
                        PlaceName.reject(int(pk),
                                         request.data["status_reason"])
                        return Response({"message": "Rejected!"})
                    else:
                        return Response({"message": "Reason must be provided"})
                except PlaceName.DoesNotExist:
                    return Response({
                        "message":
                        "No PlaceName with the given id was found"
                    })

        return Response(
            {"message", "Only Administrators can reject contributions"})