<commit_before># -*- coding: utf-8 -*-
# This file is part of Shuup BR.
#
# Copyright (c) 2016, Rockho Team. All rights reserved.
# Author: <NAME>
#
# This source code is licensed under the AGPLv3 license found in the
# LICENSE file in the root directory of this source tree.

from __future__ import unicode_literals

from shuup_br.models import ExtraMutableAddress, PersonType

from shuup.core.models import MutableAddress
from shuup.front.checkout import CheckoutPhaseViewMixin
from shuup.utils.form_group import FormGroup

from django import forms
from django.conf import settings
from django.forms.models import model_to_dict
from django.utils.translation import ugettext_lazy as _
from django.views.generic.edit import FormView

ESTADOS_CHOICES = (
    ('AC', _('Acre')),
    ('AL', _('Alagoas')),
    ('AP', _('Amapá')),
    ('AM', _('Amazonas')),
    ('BA', _('Bahia')),
    ('CE', _('Ceará')),
    ('DF', _('Distrito Federal')),
    ('ES', _('Espírito Santo')),
    ('GO', _('Goiás')),
    ('MA', _('Maranhão')),
    ('MT', _('Mato Grosso')),
    ('MS', _('Mato Grosso do Sul')),
    ('MG', _('Minas Gerais')),
    ('PA', _('Pará')),
    ('PB', _('Paraíba')),
    ('PR', _('Paraná')),
    ('PE', _('Pernambuco')),
    ('PI', _('Piauí')),
    ('RJ', _('Rio de Janeiro')),
    ('RN', _('Rio Grande do Norte')),
    ('RS', _('Rio Grande do Sul')),
    ('RO', _('Rondônia')),
    ('RR', _('Roraima')),
    ('SC', _('Santa Catarina')),
    ('SP', _('São Paulo')),
    ('SE', _('Sergipe')),
    ('TO', _('Tocantins')),
)


class AddressForm(forms.ModelForm):
    name = forms.CharField(label=_('Destinatário'))
    phone = forms.CharField(label=_('Telefone'), required=True)
    postal_code = forms.CharField(label=_('CEP'), required=True)
    street2 = forms.CharField(label=_('Complemento'), required=False)
    street3 = forms.CharField(label=_('Bairro'), required=True)
    region = forms.ChoiceField(label=_('Estado'), required=True, choices=ESTADOS_CHOICES)

    class Meta:
        model = MutableAddress
        fields = ("name", "phone", "postal_code", "street", "street2", "street3", "city", "region", "country")
        widgets = {
            'country': forms.HiddenInput(),
        }

    def __init__(self, **kwargs):
        super(AddressForm, self).__init__(**kwargs)
        if not kwargs.get("instance"):
            # Set default country
            self.fields["country"].initial = settings.SHUUP_ADDRESS_HOME_COUNTRY


class ExtraMutableAddressForm(forms.ModelForm):
    class Meta:
        model = ExtraMutableAddress
        fields = ("numero", "cel", "ponto_ref")


class AddressesPhase(CheckoutPhaseViewMixin, FormView):
    identifier = "addresses"
    title = _(u"Addresses")
    template_name = "shuup_br/checkout/addresses.jinja"

    address_kinds = ("shipping", "shipping_extra", "billing", "billing_extra")

    address_form_class = AddressForm
    address_form_classes = {"shipping_extra": ExtraMutableAddressForm, "billing_extra": ExtraMutableAddressForm}

    def get_context_data(self, **kwargs):<commit_msg>Fixed unicode issues for python 2.7 and 3.x<commit_after># -*- coding: utf-8 -*-
# This file is part of Shuup BR.
#
# Copyright (c) 2016, Rockho Team. All rights reserved.
# Author: <NAME>
#
# This source code is licensed under the AGPLv3 license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import unicode_literals

from shuup_br.models import ExtraMutableAddress, PersonType

from shuup.core.models import MutableAddress
from shuup.front.checkout import CheckoutPhaseViewMixin
from shuup.utils.form_group import FormGroup

from django import forms
from django.conf import settings
from django.forms.models import model_to_dict
from django.utils.translation import ugettext_lazy as _
from django.views.generic.edit import FormView

ESTADOS_CHOICES = (
    ('AC', _('Acre')),
    ('AL', _('Alagoas')),
    ('AP', _('Amapá')),
    ('AM', _('Amazonas')),
    ('BA', _('Bahia')),
    ('CE', _('Ceará')),
    ('DF', _('Distrito Federal')),
    ('ES', _('Espírito Santo')),
    ('GO', _('Goiás')),
    ('MA', _('Maranhão')),
    ('MT', _('Mato Grosso')),
    ('MS', _('Mato Grosso do Sul')),
    ('MG', _('Minas Gerais')),
    ('PA', _('Pará')),
    ('PB', _('Paraíba')),
    ('PR', _('Paraná')),
    ('PE', _('Pernambuco')),
    ('PI', _('Piauí')),
    ('RJ', _('Rio de Janeiro')),
    ('RN', _('Rio Grande do Norte')),
    ('RS', _('Rio Grande do Sul')),
    ('RO', _('Rondônia')),
    ('RR', _('Roraima')),
    ('SC', _('Santa Catarina')),
    ('SP', _('São Paulo')),
    ('SE', _('Sergipe')),
    ('TO', _('Tocantins')),
)


class AddressForm(forms.ModelForm):
    name = forms.CharField(label=_('Destinatário'))
    phone = forms.CharField(label=_('Telefone'), required=True)
    postal_code = forms.CharField(label=_('CEP'), required=True)
    street2 = forms.CharField(label=_('Complemento'), required=False)
    street3 = forms.CharField(label=_('Bairro'), required=True)
    region = forms.ChoiceField(label=_('Estado'), required=True, choices=ESTADOS_CHOICES)

    class Meta:
        model = MutableAddress
        fields = ("name", "phone", "postal_code", "street", "street2", "street3", "city", "region", "country")
        widgets = {
            'country': forms.HiddenInput(),
        }

    def __init__(self, **kwargs):
        super(AddressForm, self).__init__(**kwargs)
        if not kwargs.get("instance"):
            # Set default country
            self.fields["country"].initial = settings.SHUUP_ADDRESS_HOME_COUNTRY


class ExtraMutableAddressForm(forms.ModelForm):
    class Meta:
        model = ExtraMutableAddress
        fields = ("numero", "cel", "ponto_ref")


class AddressesPhase(CheckoutPhaseViewMixin, FormView):
    identifier = "addresses"
    title = _("Addresses")
    template_name = "shuup_br/checkout/addresses.jinja"

    address_kinds = ("shipping", "shipping_extra", "billing", "billing_extra")

    address_form_class = AddressForm
    address_form_classes = {"shipping_extra": ExtraMutableAddressForm, "billing_extra": ExtraMutableAddressForm}

    def get_context_data(self, **kwargs):
{'fraction_non_alphanumeric': 0.1715686274509804, 'fraction_numerical': 0.003758169934640523, 'mean_word_length': 4.046166529266282, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7196485', 'n_tokens_mistral': 2113, 'n_tokens_neox': 2069, 'n_words': 486}