from django import forms
#
from bags.models import BagMaterial
from django.utils.translation import ugettext_lazy as _
from core.widgets import CustomDateWidget

DATE_USAGE_CHOICES = [
    ('N', _('today')),
    ('M', _('manufacturing date')),
    ('C', _('custom')),
]

PATTERN_TOKENS = ['M', 'D', 'Y', 'V', 'A', 'B']


class BagBatchCreateForm(forms.Form):
    # first fixed bag name part, some arbitrary string which
    # may placed anywhere in the bag name
    fixed1 = forms.CharField(
        max_length=10,
        required=False,
        label=_('fixed part 1 (A):')
    )

    # second fixed part
    fixed2 = forms.CharField(
        max_length=10,
        required=False,
        label=_('fixed part 2 (B):')
    )

    # start value for the variable part, which is either a numerical value
    # or a letter sequence which gets counted up/down lexicographic order
    var_start = forms.CharField(
        max_length=5,
        required=True,
        label=_('start value for variable part')
    )

    # final value until that is counted up/down. the total amount if bags depends
    # on the values between variable_start/end or the limiter value, whichever is smaller.
    var_end = forms.CharField(
        max_length=5,
        required=True,
        label=_('final value for variable part')
    )

    # the actual funstuff. a pattern describing how the single parts of the form should
    # form the name for the bag.
    pattern = forms.CharField(
        max_length=32,
        required=True,
        label=_('pattern for bag name')
    )

    # a manufacturing date is required for a bag, this is the biggest limitation
    # since this only allows to batch create bags which where build on one day
    manufacturing_date = forms.DateField(
        required=True,
        widget=CustomDateWidget(),
        label=_('manufacturing date')
    )

    # material is necessary anyway
    material = forms.ModelChoiceField(queryset=BagMaterial.objects.all(),
                                      label=_('bag material'))
