Skip to content

Commit

Permalink
Initialize wizard form if needed
Browse files Browse the repository at this point in the history
Also add option to give service name in wizard
  • Loading branch information
tulimaki committed Nov 25, 2016
1 parent 79aed40 commit 929803d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
21 changes: 17 additions & 4 deletions shuup_checkoutfi/admin_forms.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
from django import forms
from shuup.admin.forms import ShuupAdminForm
from shuup.admin.modules.service_providers.forms import (ServiceWizardForm,
ServiceWizardFormDef)
from shuup.core.models import Shop
from shuup.admin.modules.service_providers.wizard_form_defs import (
ServiceWizardFormDef
)
from shuup.admin.modules.service_providers.wizard_forms import (
ServiceWizardForm
)
from shuup.core.models import PaymentMethod, Shop

from .models import CheckoutFiPaymentProcessor

Expand All @@ -19,7 +23,16 @@ class Meta:


class CheckoutFiWizardForm(CheckoutFiAdminForm, ServiceWizardForm):
pass
def __init__(self, **kwargs):
super(CheckoutFiWizardForm, self).__init__(**kwargs)
if not self.provider:
return
service = self.get_payment_method()
if not service:
return
self.fields["service_name"].initial = service.name
self.fields["merchant_id"].initial = self.provider.merchant_id
self.fields["merchant_secret"].initial = self.provider.merchant_secret


class CheckoutFiWizardFormDef(ServiceWizardFormDef):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{% from "shuup/admin/service_providers/wizard_macros.jinja" import service_provider_section %}
{% set form = pane.forms[form_def.name] %}

{% call service_provider_section(
identifier=form_def.name,
header="Checkout.fi",
description=gettext("Accept credit cards using <a target='_blank' href='%(url)s'>Checkout.fi</a>. Checkout.fi is one of the largest Finnish payment service providers and supports bank payments, Visa, and Mastercard.", url="http://www.checkout.fi"),
is_active=form.is_active(),
allowed_countries="FI"
)%}
{% set form = pane.forms[form_def.name] %}
<input type="hidden" name="{{ form.name.html_name }}" value="Checkout.fi">
{{ bs3.field(form.service_name) }}
{{ bs3.field(form.merchant_id) }}
{{ bs3.field(form.merchant_secret) }}
<p class="text-center">
Expand Down

0 comments on commit 929803d

Please sign in to comment.