From 929803df9e2ea057898771544555fa249ce5034d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Panu=20Tulim=C3=A4ki?= Date: Thu, 24 Nov 2016 19:36:42 -0800 Subject: [PATCH] Initialize wizard form if needed Also add option to give service name in wizard --- shuup_checkoutfi/admin_forms.py | 21 +++++++++++++++---- .../shuup/checkoutfi/wizard_form.jinja | 4 +++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/shuup_checkoutfi/admin_forms.py b/shuup_checkoutfi/admin_forms.py index 6230a1a..a5d6d65 100644 --- a/shuup_checkoutfi/admin_forms.py +++ b/shuup_checkoutfi/admin_forms.py @@ -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 @@ -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): diff --git a/shuup_checkoutfi/templates/shuup/checkoutfi/wizard_form.jinja b/shuup_checkoutfi/templates/shuup/checkoutfi/wizard_form.jinja index e9ff42a..51299e2 100644 --- a/shuup_checkoutfi/templates/shuup/checkoutfi/wizard_form.jinja +++ b/shuup_checkoutfi/templates/shuup/checkoutfi/wizard_form.jinja @@ -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 Checkout.fi. 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] %} + {{ bs3.field(form.service_name) }} {{ bs3.field(form.merchant_id) }} {{ bs3.field(form.merchant_secret) }}