Exemplo n.º 1
0
def create(request):
    form = forms.CreatePinForm()
    if request.method == 'POST':
        form = forms.CreatePinForm(uuid=get_user(request), data=request.POST)
        if form.is_valid():
            if getattr(form, 'buyer_exists', False):
                try:
                    res = client.change_pin(form.uuid,
                                            form.cleaned_data['pin'],
                                            etag=form.buyer_etag)
                except ResourceModified:
                    return system_error(request, code=msg.RESOURCE_MODIFIED)
            else:
                res = client.create_buyer(form.uuid, form.cleaned_data['pin'])
            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return http.HttpResponseRedirect(reverse('pin.confirm'))
    form.no_pin = True
    return render(request, 'pin/pin_form.html', {'form': form,
                  'title': _('Create a Pin'),
                  'action': reverse('pin.create'),
                  'pin_form_tracking' : {
                      'pin_error_codes': form.pin_error_codes,
                  },
                  'track_cancel': {
                      'action': 'pin cancel',
                      'label': 'Create Pin Page',
                  }})
Exemplo n.º 2
0
def create(request):
    form = forms.CreatePinForm()
    if request.method == 'POST':
        form = forms.CreatePinForm(uuid=get_user(request), data=request.POST)
        if form.is_valid():
            if getattr(form, 'buyer_exists', False):
                try:
                    res = client.change_pin(form.uuid,
                                            form.cleaned_data['pin'],
                                            etag=form.buyer_etag)
                except ResourceModified:
                    return system_error(request, code=msg.RESOURCE_MODIFIED)
            else:
                res = client.create_buyer(form.uuid, form.cleaned_data['pin'])
            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return http.HttpResponseRedirect(reverse('pin.confirm'))
    form.no_pin = True
    return render(
        request, 'pin/pin_form.html', {
            'form': form,
            'title': _('Create a Pin'),
            'action': reverse('pin.create'),
            'pin_form_tracking': {
                'pin_error_codes': form.pin_error_codes,
            },
            'track_cancel': {
                'action': 'pin cancel',
                'label': 'Create Pin Page',
            }
        })
Exemplo n.º 3
0
Arquivo: views.py Projeto: cvan/webpay
def reset_new_pin(request):
    form = forms.CreatePinForm()
    if request.method == "POST":
        form = forms.CreatePinForm(uuid=get_user(request), data=request.POST)
        if form.is_valid():
            res = client.set_new_pin(form.buyer, form.cleaned_data["pin"])
            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return http.HttpResponseRedirect(reverse("pin.reset_confirm"))
    return render(request, "pin/reset_create.html", {"form": form})
Exemplo n.º 4
0
def reset_new_pin(request):
    form = forms.CreatePinForm()
    if request.method == 'POST':
        form = forms.CreatePinForm(uuid=get_user(request), data=request.POST)
        if form.is_valid():
            res = client.set_new_pin(form.buyer, form.cleaned_data['pin'])
            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return http.HttpResponseRedirect(reverse('pin.reset_confirm'))
    return render(request, 'pin/pin_form.html', {'form': form,
                  'title': _('Enter your new PIN:'),
                  'action': reverse('pin.reset_new_pin') })
Exemplo n.º 5
0
Arquivo: views.py Projeto: cvan/webpay
def create(request):
    form = forms.CreatePinForm()
    if request.method == "POST":
        form = forms.CreatePinForm(uuid=get_user(request), data=request.POST)
        if form.is_valid():
            if hasattr(form, "buyer"):
                res = client.change_pin(form.buyer, form.cleaned_data["pin"])
            else:
                res = client.create_buyer(form.uuid, form.cleaned_data["pin"])
            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return http.HttpResponseRedirect(reverse("pin.confirm"))
    return render(request, "pin/create.html", {"form": form})
Exemplo n.º 6
0
Arquivo: api.py Projeto: Witia1/webpay
    def create(self, request):
        form = CreatePinForm(uuid=request.session['uuid'], data=request.DATA)
        if form.is_valid():
            res = client.change_pin(form.uuid,
                                    form.cleaned_data['pin'],
                                    etag=form.buyer_etag,
                                    pin_confirmed=True,
                                    clear_was_locked=True)

            if form.client_response_is_valid(res):
                set_user_has_pin(request, True)
                return response.Response(status=204)

        return api_error(form, request)
Exemplo n.º 7
0
    def create(self, request):
        form = CreatePinForm(uuid=request.session['uuid'], data=request.DATA)
        if form.is_valid():
            res = client.change_pin(form.uuid,
                                    form.cleaned_data['pin'],
                                    etag=form.buyer_etag,
                                    pin_confirmed=True,
                                    clear_was_locked=True)

            if form.client_response_is_valid(res):
                set_user_has_pin(request, True)
                return response.Response(status=204)

        return api_error(form, request)
Exemplo n.º 8
0
    def create(self, request):
        form = CreatePinForm(uuid=request.session["uuid"], data=request.DATA)
        if form.is_valid():
            if getattr(form, "buyer_exists", None):
                res = client.change_pin(form.uuid, form.cleaned_data["pin"], etag=form.buyer_etag)
            else:
                res = client.create_buyer(form.uuid, form.cleaned_data["pin"])

            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return response.Response(status=201)

            return response.Response(status=201)

        return app_error(request)
Exemplo n.º 9
0
def create(request):
    form = forms.CreatePinForm()
    if request.method == 'POST':
        form = forms.CreatePinForm(uuid=get_user(request), data=request.POST)
        if form.is_valid():
            if hasattr(form, 'buyer'):
                res = client.change_pin(form.buyer, form.cleaned_data['pin'])
            else:
                res = client.create_buyer(form.uuid, form.cleaned_data['pin'])
            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return http.HttpResponseRedirect(reverse('pin.confirm'))
    return render(request, 'pin/pin_form.html', {'form': form,
                  'title': _('Create your PIN:'),
                  'action': reverse('pin.create') })
Exemplo n.º 10
0
def create(request):
    form = forms.CreatePinForm()
    if request.method == 'POST':
        form = forms.CreatePinForm(uuid=get_user(request), data=request.POST)
        if form.is_valid():
            if getattr(form, 'buyer_exists', False):
                res = client.change_pin(form.uuid, form.cleaned_data['pin'])
            else:
                res = client.create_buyer(form.uuid, form.cleaned_data['pin'])
            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return http.HttpResponseRedirect(reverse('pin.confirm'))
    form.no_pin = True
    return render(request, 'pin/pin_form.html', {'form': form,
                  'title': _('Create a Pin'),
                  'action': reverse('pin.create')})
Exemplo n.º 11
0
Arquivo: api.py Projeto: lissyx/webpay
    def create(self, request):
        form = CreatePinForm(uuid=request.session['uuid'], data=request.DATA)
        if form.is_valid():
            if getattr(form, 'buyer_exists', None):
                res = client.change_pin(form.uuid,
                                        form.cleaned_data['pin'],
                                        etag=form.buyer_etag)
            else:
                res = client.create_buyer(form.uuid, form.cleaned_data['pin'])

            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return response.Response(status=201)

            return response.Response(status=201)

        return app_error(request)
Exemplo n.º 12
0
    def create(self, request):
        form = CreatePinForm(uuid=request.session['uuid'], data=request.DATA)
        if form.is_valid():
            if getattr(form, 'buyer_exists', None):
                res = client.change_pin(form.uuid,
                                        form.cleaned_data['pin'],
                                        etag=form.buyer_etag,
                                        pin_confirmed=True,
                                        clear_was_locked=True)
            else:
                res = client.create_buyer(form.uuid,
                                          pin=form.cleaned_data['pin'],
                                          pin_confirmed=True,
                                          email=request.session[
                                              'logged_in_user'])

            if form.handle_client_errors(res):
                set_user_has_pin(request, True)

            return response.Response(status=204)

        return app_error(request)