Пример #1
0
class FormInvoiceOrder(forms.ModelForm):
    corp_verbose_name = 'Nama Perusahaan'
    customer = CorpChoices(label=corp_verbose_name.capitalize(),
                           widget=AutoHeavySelect2Widget(
                               select2_options={
                                   'width': '220px',
                                   'placeholder': 'Cari %s ...' %
                                   corp_verbose_name
                               }))
    so_verbose_name = 'Nomer SO'
    so_reff = SOChoices(label=so_verbose_name.capitalize(),
                        widget=AutoHeavySelect2Widget(
                            select2_options={
                                'width': '220px',
                                'placeholder': 'Cari %s ...' % so_verbose_name
                            }))

    class Meta:
        model = ReceivableInvoice
        widgets = {
            'quotation': AutosizedTextarea(attrs={'rows': '3'}),
            'term_service': AutosizedTextarea(attrs={'rows': '3'}),
            'shipping_address': AutosizedTextarea(attrs={'rows': '3'}),
            'date': SuitDateWidget
        }
Пример #2
0
class CityForm(ModelForm):
    country_verbose_name = Country._meta.verbose_name
    country = CountryChoices(
        label=country_verbose_name.capitalize(),
        widget=AutoHeavySelect2Widget(
            select2_options={
                'width': '220px',
                'placeholder': 'Lookup %s ...' % country_verbose_name
            }))

    class Meta:
        model = City
        widgets = {
            'area':
            EnclosedInput(prepend='icon-globe',
                          append='km<sup>2</sup>',
                          attrs={'class': 'input-small'}),
            'population':
            EnclosedInput(prepend='icon-user',
                          append='<input type="button" '
                          'class="btn" onclick="window'
                          '.open(\'https://www.google'
                          '.com/\')" value="Search">',
                          attrs={'class': 'input-small'}),
        }
Пример #3
0
class MixedForm(forms.Form):
    emp1 = EmployeeChoices()
    rooms1 = ClassRoomChoices()
    emp2 = EmployeeChoices()
    rooms2 = ClassRoomChoices()
    rooms3 = ClassRoomSingleChoices()
    any_word = WordChoices()
    self_choices = SelfChoices(label='Self copy choices')
    self_multi_choices = SelfMultiChoices(label='Self copy multi-choices')
    issue11_test = EmployeeChoices(
        label='Issue 11 Test (Employee)',
        widget=AutoHeavySelect2Widget(select2_options={
            'width': '32em',
            'placeholder': u"Search foo"
        }))
    always_fail_rooms = ClassRoomSingleChoices(
        validators=[validate_fail_always])
    always_fail_rooms_multi = ClassRoomChoices(
        validators=[validate_fail_always])
    always_fail_self_choice = SelfChoices(validators=[validate_fail_always],
                                          auto_id='always_fail_self_choice')
    always_fail_self_choice_multi = SelfMultiChoices(
        validators=[validate_fail_always],
        auto_id='always_fail_self_choice_multi')
    model_with_both_required_and_empty_label_false = ModelSelect2Field(
        queryset=Employee.objects, empty_label=None,
        required=False)  # issue#26
Пример #4
0
 def add_fields(self, form, index):
     """that adds the field in, overwriting the previous default field"""
     super(ConsultantStaffingInlineFormset, self).add_fields(form, index)
     form.fields["mission"] = MissionChoices(label=_("Mission"), widget=AutoHeavySelect2Widget(select2_options={"dropdownAutoWidth": "true",
                                                                                                                "placeholder": _("Select a mission to add forecast...")}))
     form.fields["mission"].widget.attrs.setdefault("size", 8)  # Reduce default size
     form.fields["staffing_date"] = StaffingDateChoices(widget=Select2Widget(select2_options={"placeholder": _("Select a month...")}),
                                                        minDate=self.lowerDayBound)
     form.fields["charge"].widget.attrs.setdefault("size", 3)  # Reduce default size
Пример #5
0
class FormReturnOrder(forms.ModelForm):
    corp_verbose_name = 'Nama Perusahaan'
    customer = CorpChoices(label=corp_verbose_name.capitalize(),
                           widget=AutoHeavySelect2Widget(
                               select2_options={
                                   'width': '220px',
                                   'placeholder': 'Cari %s ...' %
                                   corp_verbose_name
                               }))
    so_verbose_name = 'Nomer SO'
    so_reff = SOChoices(label=so_verbose_name.capitalize(),
                        widget=AutoHeavySelect2Widget(
                            select2_options={
                                'width': '220px',
                                'placeholder': 'Cari %s ...' % so_verbose_name
                            }))

    class Meta:
        model = Sales_Return
        widgets = {'date': SuitDateWidget}
Пример #6
0
class FormDeliveryOrder(forms.ModelForm):
    staff_verbose_name = 'Staff Distribusi '
    corp_verbose_name = 'Nama Perusahaan'
    staff_delivery = StaffChoices(label=staff_verbose_name.capitalize(),
                                widget=AutoHeavySelect2Widget(select2_options=
                                                              {'width': '220px', 'placeholder': 'Cari %s ...'
                                                                                                % staff_verbose_name}))
    customer = CorpChoices(label=corp_verbose_name.capitalize(),
                                widget=AutoHeavySelect2Widget(select2_options=
                                                              {'width': '220px', 'placeholder': 'Cari %s ...'
                                                                                                % corp_verbose_name}))

    class Meta:
        model = DeliveryOrder
        widgets = {
            'date': SuitDateWidget,
            'ship_date': SuitDateWidget,
            'ship_address': AutosizedTextarea(attrs={'rows': '3'}),
            'term_service': AutosizedTextarea(attrs={'rows': '3'}),
            'quotation': AutosizedTextarea(attrs={'rows': '3'}),
        }
Пример #7
0
 def add_fields(self, form, index):
     """that adds the field in, overwriting the previous default field"""
     super(MissionStaffingInlineFormset, self).add_fields(form, index)
     minDate = self.instance.staffing_set.all().aggregate(Min("staffing_date")).values()
     if minDate and minDate[0]:
         minDate = min(minDate[0], date.today())
     else:
         minDate = None
     form.fields["consultant"] = ConsultantChoices(label=_("Consultant"), widget=AutoHeavySelect2Widget(select2_options={"dropdownAutoWidth": "true",
                                                                                                                         "placeholder": _("Select a consultant to add forecast...")}))
     form.fields["staffing_date"] = StaffingDateChoices(widget=Select2Widget(select2_options={"placeholder": _("Select a month...")}),
                                                        minDate=minDate)
     form.fields["charge"].widget.attrs.setdefault("size", 3)  # Reduce default size
Пример #8
0
class FormRequestOrder(forms.ModelForm):
    corp_verbose_name = 'Nama Perusahaan'
    customer = CorpChoices(label=corp_verbose_name.capitalize(),
                           widget=AutoHeavySelect2Widget(
                               select2_options={
                                   'width': '220px',
                                   'placeholder': 'Cari %s ...' %
                                   corp_verbose_name
                               }))

    class Meta:
        model = RequestOrder
        widgets = {
            'quotation': AutosizedTextarea(attrs={'rows': '5'}),
            'date': SuitDateWidget
        }
Пример #9
0
class PostDetailForm(BaseUrlForm):
    post = PostChoicesField(widget=AutoHeavySelect2Widget(
        attrs={"style": "width:400px;"}))

    def submit(self):
        post = self.cleaned_data["post"]
        url = "'%s' '%s' '%s' '%s' '%s' '%s'" % (
            self.Meta.url_name,
            post.categories.all()[0].slug,
            post.date_modified.year,
            post.date_modified.strftime('%b').lower(),
            post.date_modified.day,
            post.slug,
        )
        return url

    class Meta:
        verbose_name = 'Choose post'
        url_name = 'category_post_detail'
Пример #10
0
class AnotherWordForm(forms.ModelForm):
    word = WordChoices(widget=AutoHeavySelect2Widget())

    class Meta:
        model = WordList
        exclude = ['kind', 'words']