<commit_before># django imports
from django.db import models
from django.db.models import SET_NULL
from django.template import RequestContext
from django.template.base import Context
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _

# lfs imports
from lfs.core.models import Country
from lfs.customer.models import Customer
from lfs.order.models import Order


class BaseAddress(models.Model):
    """
    Base class from which LFS addresses should inherit.

    **Attributes:**

    values_before_postal
        List of attributes which are supposed to be displayed before the postal
        form values. If the attribute ends with a ``+`` there will be no <div>
        around the value.

    values_before_postal
        List of attributes which are supposed to be displayed after the postal
        form values. If the attribute ends with a ``+`` there will be no <div>
        around the value.

    customer
        The customer the address belongs to

    order
        The order the address belongs to.

    """
    values_before_postal = None
    values_after_postal = None

    customer = models.ForeignKey(Customer, verbose_name=_(u"Customer"), blank=True, null=True, related_name="addresses",
                                 on_delete=SET_NULL)
    order = models.ForeignKey(Order, verbose_name=_(u"Order"), blank=True, null=True, related_name="addresses")

    firstname = models.CharField(_("Firstname"), max_length=50)
    lastname = models.CharField(_("Lastname"), max_length=50)
    line1 = models.CharField(_("Line 1"), max_length=100, blank=True, null=True)
    line2 = models.CharField(_("Line 2"), max_length=100, blank=True, null=True)
    zip_code = models.CharField(_("Zip code"), max_length=10)
    city = models.CharField(_("City"), max_length=50)
    state = models.CharField(_("State"), max_length=50, blank=True, null=True)
    country = models.ForeignKey(Country, verbose_name=_("Country"), blank=True, null=True)
    created = models.DateTimeField(_(u"Created"), auto_now_add=True)
    modified = models.DateTimeField(_(u"Modified"), auto_now=True)

    def get_values_before_postal(self, attributes="values_before_postal"):
        """
        Returns the values which are supposed to be displayed before the postal
        form values.
        """
        return self._get_values(attributes="values_before_postal")

    def get_values_after_postal(self):
        """
        Returns the values which are supposed to be displayed before the postal
        form values.
        """
        return self._get_values(attributes="values_after_postal")

    def as_html(self, request=None, type=None):
        """
        Returns the address as html.
        """
        templates = ["lfs/addresses/address_view.html"]
        if type:
            templates.insert(0, "lfs/addresses/%s_address_view.html" % type)

        if request:<commit_msg>set a default value for zip_code so we don't get an IntegrityError saving addresses for countries that don't have zip_codes<commit_after># django imports
from django.db import models
from django.db.models import SET_NULL
from django.template import RequestContext
from django.template.base import Context
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _

# lfs imports
from lfs.core.models import Country
from lfs.customer.models import Customer
from lfs.order.models import Order


class BaseAddress(models.Model):
    """
    Base class from which LFS addresses should inherit.

    **Attributes:**

    values_before_postal
        List of attributes which are supposed to be displayed before the postal
        form values. If the attribute ends with a ``+`` there will be no <div>
        around the value.

    values_before_postal
        List of attributes which are supposed to be displayed after the postal
        form values. If the attribute ends with a ``+`` there will be no <div>
        around the value.

    customer
        The customer the address belongs to

    order
        The order the address belongs to.

    """
    values_before_postal = None
    values_after_postal = None

    customer = models.ForeignKey(Customer, verbose_name=_(u"Customer"), blank=True, null=True, related_name="addresses",
                                 on_delete=SET_NULL)
    order = models.ForeignKey(Order, verbose_name=_(u"Order"), blank=True, null=True, related_name="addresses")

    firstname = models.CharField(_("Firstname"), max_length=50)
    lastname = models.CharField(_("Lastname"), max_length=50)
    line1 = models.CharField(_("Line 1"), max_length=100, blank=True, null=True)
    line2 = models.CharField(_("Line 2"), max_length=100, blank=True, null=True)
    zip_code = models.CharField(_("Zip code"), max_length=10, default=u"")
    city = models.CharField(_("City"), max_length=50)
    state = models.CharField(_("State"), max_length=50, blank=True, null=True)
    country = models.ForeignKey(Country, verbose_name=_("Country"), blank=True, null=True)
    created = models.DateTimeField(_(u"Created"), auto_now_add=True)
    modified = models.DateTimeField(_(u"Modified"), auto_now=True)

    def get_values_before_postal(self, attributes="values_before_postal"):
        """
        Returns the values which are supposed to be displayed before the postal
        form values.
        """
        return self._get_values(attributes="values_before_postal")

    def get_values_after_postal(self):
        """
        Returns the values which are supposed to be displayed before the postal
        form values.
        """
        return self._get_values(attributes="values_after_postal")

    def as_html(self, request=None, type=None):
        """
        Returns the address as html.
        """
        templates = ["lfs/addresses/address_view.html"]
        if type:
            templates.insert(0, "lfs/addresses/%s_address_view.html" % type)

        if request:
{'fraction_non_alphanumeric': 0.09557226399331663, 'fraction_numerical': 0.007017543859649123, 'mean_word_length': 3.437361008154188, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '320230', 'n_tokens_mistral': 1703, 'n_tokens_neox': 1640, 'n_words': 495}