Exemplo n.º 1
0
    def update(self, request, *args, **kwargs):
        self.object = self.get_object()
        form = BangoPaymentAccountForm(request.DATA, account=True)
        if form.is_valid():
            self.object.update_account_details(**form.data)
            return Response(status=status.HTTP_204_NO_CONTENT)

        return Response(form.errors, status=status.HTTP_400_BAD_REQUEST)
Exemplo n.º 2
0
    def update(self, request, *args, **kwargs):
        self.object = self.get_object()
        form = BangoPaymentAccountForm(request.DATA, account=True)
        if form.is_valid():
            self.object.update_account_details(**form.data)
            return Response(status=status.HTTP_204_NO_CONTENT)

        return Response(form.errors, status=status.HTTP_400_BAD_REQUEST)
Exemplo n.º 3
0
 def is_valid(self, bundle, request=None):
     data = bundle.data or {}
     if request.method == 'PUT':
         form = BangoPaymentAccountForm(data, account=True)
     else:
         form = BangoPaymentAccountForm(data)
     if form.is_valid():
         return {}
     return form.errors
Exemplo n.º 4
0
    def update(self, request, *args, **kwargs):
        self.object = self.get_object()
        form = BangoPaymentAccountForm(request.data, account=True)
        if form.is_valid():
            self.object.get_provider().account_update(self.object,
                                                      form.cleaned_data)
            return Response(status=status.HTTP_204_NO_CONTENT)

        return Response(form.errors, status=status.HTTP_400_BAD_REQUEST)
Exemplo n.º 5
0
    def update(self, request, *args, **kwargs):
        self.object = self.get_object()
        form = BangoPaymentAccountForm(request.data, account=True)
        if form.is_valid():
            self.object.get_provider().account_update(self.object,
                                                      form.cleaned_data)
            return Response(status=status.HTTP_204_NO_CONTENT)

        return Response(form.errors, status=status.HTTP_400_BAD_REQUEST)
Exemplo n.º 6
0
Arquivo: api.py Projeto: at13/zamboni
 def is_valid(self, bundle, request=None):
     data = bundle.data or {}
     if request.method == 'PUT':
         form = BangoPaymentAccountForm(data, account=True)
     else:
         form = BangoPaymentAccountForm(data)
     if form.is_valid():
         return {}
     return form.errors
Exemplo n.º 7
0
 def create(self, request, *args, **kwargs):
     form = BangoPaymentAccountForm(request.DATA)
     if form.is_valid():
         try:
             provider = get_provider()
             obj = provider.account_create(request.amo_user, form.data)
         except HttpClientError as e:
             log.error('Client error creating Bango account; %s' % e)
             return Response(e.content,
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
         except HttpServerError as e:
             log.error('Error creating Bango payment account; %s' % e)
             return Response(_(u'Could not connect to payment server.'),
                            status=status.HTTP_500_INTERNAL_SERVER_ERROR)
         serializer = self.get_serializer(obj)
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(form.errors, status=status.HTTP_400_BAD_REQUEST)
Exemplo n.º 8
0
 def create(self, request, *args, **kwargs):
     form = BangoPaymentAccountForm(request.DATA)
     if form.is_valid():
         try:
             provider = get_provider()
             obj = provider.account_create(request.amo_user, form.data)
         except HttpClientError as e:
             log.error('Client error creating Bango account; %s' % e)
             return Response(e.content,
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
         except HttpServerError as e:
             log.error('Error creating Bango payment account; %s' % e)
             return Response(_(u'Could not connect to payment server.'),
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
         serializer = self.get_serializer(obj)
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(form.errors, status=status.HTTP_400_BAD_REQUEST)