Beispiel #1
0
class BasicStatsForm(forms.Form):
    timescale = forms.ChoiceField(
        label=_('Time Scale'),
        choices=(
            ('DAY',     _('Day')),
            ('WEEK',    _('Week')),
            ('MONTH',   _('Month'))
        )
    )
    start_date = forms.DateField(
        label=_('Start date'),
        widget=DatepickerInput(attrs={'class': "input-small"})
    )
    end_date = forms.DateField(
        label=_('End date'),
        widget=DatepickerInput(attrs={'class': "input-small"})
    )

    def serialize(self):
        import datetime
        from django.db.models import Model
        cd = self.cleaned_data

        for k, v in cd.iteritems():
            if isinstance(v, datetime.datetime):
                cd[k] = str(v)
            if isinstance(v, Model):
                cd[k] = v.pk

        return cd
Beispiel #2
0
class DeviceSearchForm(forms.Form):
    product_line = forms.MultipleChoiceField(
        choices=product_lines,
        required=False
    )
    warranty_status = forms.MultipleChoiceField(
        choices=Device.WARRANTY_CHOICES,
        required=False,
    )
    date_start = forms.DateField(
        required=False,
        label=_('Created between'),
        widget=DatepickerInput(attrs={'class': 'input-small'})
    )
    date_end = forms.DateField(
        required=False,
        label=mark_safe(' '),
        widget=DatepickerInput(attrs={'class': 'input-small'})
    )
    sn = forms.CharField(required=False, label=_('Serial number contains'))

    def __init__(self, *args, **kwargs):
        super(DeviceSearchForm, self).__init__(*args, **kwargs)
        self.fields['description'] = AutocompleteCharField(
            '/api/device_models/',
            max_length=128,
            required=False,
            label=_('Description contains')
        )
Beispiel #3
0
class DeviceStatsForm(forms.Form):
    start_date = forms.DateField(
        widget=DatepickerInput(attrs={'class': "input-small"}),
        initial=default_start_date
    )
    end_date = forms.DateField(
        widget=DatepickerInput(attrs={'class': "input-small"}),
        initial=default_end_date
    )
Beispiel #4
0
class InvoiceSearchForm(forms.Form):
    state = forms.ChoiceField(
        required=False,
        label=_('State is'),
        choices=(
            ('', _('Any')),
            ('OPEN', _('Open')),
            ('PAID', _('Paid')),
        ),
        widget=forms.Select(attrs={'class': 'input-small'}))
    payment_method = forms.ChoiceField(
        required=False,
        label=_('Payment method is'),
        choices=(('', _('Any')), ) + Payment.METHODS,
        widget=forms.Select(attrs={'class': 'input-medium'}))
    status_isnot = forms.ModelChoiceField(
        required=False,
        label=_('Status is not'),
        queryset=Status.objects.all(),
        widget=forms.Select(attrs={'class': 'input-medium'}))
    start_date = forms.DateField(
        required=False,
        label=_('Start date'),
        widget=DatepickerInput(attrs={
            'class': "input-small",
            'placeholder': _('Start date')
        }))
    end_date = forms.DateField(
        required=False,
        label=_('End date'),
        widget=DatepickerInput(attrs={
            'class': "input-small",
            'placeholder': _('End date')
        }))
    customer_name = NullCharField(required=False,
                                  label=_('Customer name contains'))
    service_order = NullCharField(required=False, label=_('Service Order is'))
Beispiel #5
0
class NewStatsForm(forms.Form):
    location = forms.ModelMultipleChoiceField(
        queryset=Location.objects.all()
    )
    queue = forms.ModelMultipleChoiceField(
        queryset=Queue.objects.all(),
        widget=forms.SelectMultiple
    )
    label = forms.ModelMultipleChoiceField(
        queryset=Tag.objects.filter(type="order"),
        required=False
    )
    status = forms.ModelMultipleChoiceField(
        queryset=Status.objects.all(),
        required=False
    )
    start_date = forms.DateField(
        widget=DatepickerInput(attrs={'class': "input-small"}),
        initial=default_start_date
    )
    end_date = forms.DateField(
        widget=DatepickerInput(attrs={'class': "input-small"}),
        initial=default_end_date
    )
Beispiel #6
0
 class Meta:
     model = Device
     exclude = ('spec', 'customers', 'files', 'image_url',
                'exploded_view_url', 'manual_url', )
     widgets = {'purchased_on': DatepickerInput()}