Exemplo n.º 1
0
    class Meta:
        model = AssignQuota
        fields = (
            'assigned_to',
            'start_month',
            'end_month',
            'a_senior_high',
            'a_higher_education',
            'a_retail',
            'a_corporate',
            'a_owwa',
        )
        
        labels = {
            'assigned_to': 'Assign User ',
            'a_senior_high': 'Senior High',
            'a_higher_education': 'Higher Education',
            'a_retail': 'Retail',
            'a_corporate': 'Corporate',
            'a_owwa':'OWWA',
        }
        
        

        widgets ={
            'start_month': MonthPickerInput().start_of('Assign Quota'),
            'end_month': MonthPickerInput().end_of('Assign Quota'),
        }
        validators = {
            'start_month':[present_or_future_date],
            'end_month':[present_or_future_date],
        }
Exemplo n.º 2
0
 class Meta:
     model=HistoryInput
     fields=['what', 'start', 'end_date', 'ing', 'desc']
     widgets = {
         'authuser':forms.HiddenInput(),
         'start': MonthPickerInput(
             options={'format':'YYYY-MM-01', 'locale':'ko'}
         ),
         'end_date': MonthPickerInput(
             options={'format':'YYYY-MM-01', 'locale':'ko'}
         ),
     }
Exemplo n.º 3
0
 class Meta:
     model = BudgetTracker
     exclude =('user','monthly_spend')
     #fields='__all__'
     widgets = {
         'date': MonthPickerInput(), # default date-format %m/%d/%Y will be used
     }
 class Meta:
     model = Event
     fields = ['start_date', 'start_time', 'start_datetime', 'start_month', 'start_year']
     widgets = {
         'start_date': DatePickerInput(),
         'start_time': TimePickerInput(),
         'start_datetime': DateTimePickerInput(),
         'start_month': MonthPickerInput(),
         'start_year': YearPickerInput(),
     }
Exemplo n.º 5
0
 class Meta:
     model = Invoice
     fields = ('paid_amount', 'Payment_Method', 'Cheque_Number',
               'Bank_Name', 'note')
     widgets = {
         'note': Textarea(attrs={
             'cols': 30,
             'rows': 2
         }),
         'month': MonthPickerInput(),
     }
Exemplo n.º 6
0
 def set_month(self, month):
     self.fields['month'] = forms.DateField(widget=MonthPickerInput(
         format="YYYY-MM",
         options={
             "format": "YYYY-MM",
             "showClose": False,
             "showClear": False,
             "showTodayButton": False,
         },
         attrs={'value': month},
     ),
                                            required=False)
Exemplo n.º 7
0
 def set_timely(self, type, value):
     self.fields['time'] = forms.DateField(widget=MonthPickerInput(
         format=type,
         options={
             "format": type,
             "showClose": False,
             "showClear": False,
             "showTodayButton": False,
         },
         attrs={'value': value},
     ),
                                           required=False)
Exemplo n.º 8
0
 class Meta:
     model = Invoice
     fields = ('paid_amount', 'discount', 'classroom', 'student',
               'fee_type', 'fee_amount', 'month', 'paid_status',
               'Payment_Method', 'Cheque_Number', 'Bank_Name', 'note',
               'net_amount')
     widgets = {
         'note': Textarea(attrs={
             'cols': 30,
             'rows': 2
         }),
         'month': MonthPickerInput(),
     }
Exemplo n.º 9
0
 class Meta:
     model = NewEvent
     fields = [
         'when', 'what', 'img1', 'img2', 'img3', 'kw1', 'kw2', 'kw3',
         'emoji'
     ]
     widgets = {
         'when':
         MonthPickerInput(options={
             'format': 'YYYY-MM-DD',
             'locale': 'ko'
         })
     }
Exemplo n.º 10
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        now = datetime.now()
        year = now.year
        month = now.month

        self.fields['month'] = forms.DateField(widget=MonthPickerInput(
            format="YYYY-MM",
            options={
                "format": "YYYY-MM",
                "showClose": False,
                "showClear": False,
                "showTodayButton": False,
            },
            attrs={'value': str(year) + '-' + str(month)},
        ),
                                               required=False)
Exemplo n.º 11
0
    def _get_form_fields(self, parent, questionnaire_id):

        # Set fields
        fields = {}
        for item in parent.item:

            # Required items are only truly required if root
            required = item.required and not item.enableWhen and not (hasattr(parent, 'enableWhen') and parent.enableWhen)

            # Set widget attributes
            attrs = {
                'data-required': 'true' if item.required else 'false',
            }
            if required:
                # Only set widgets as hard required if they are root level items
                attrs['required'] = 'required'

            # Check for dependent items
            if self._get_dependent_items(item.linkId):
                attrs['data-details'] = item.linkId

            # Check type
            if (item.type == 'string' or item.type == 'text') and item.option:

                # Set the choices
                choices = ()
                for option in item.option:

                    # Assume valueString
                    if not option.valueString:
                        logger.error('Unsupported choice type for question on Questionnaire',
                                        extra={'questionnaire': questionnaire_id, 'question': item.linkId,})
                    else:
                        choices = choices + ((option.valueString, option.valueString),)

                # Set the input
                fields[item.linkId] = forms.TypedChoiceField(
                    label=item.text,
                    choices=choices,
                    widget=forms.RadioSelect(attrs=attrs),
                    required=required
                )

            elif item.type == 'string' or item.type == 'text' or (item.type == 'question' and not item.option):

                if item.initialString:

                    # Make this a textbox-style input with minimum width
                    fields[item.linkId] = forms.CharField(
                        label=item.text,
                        required=required,
                        widget=forms.Textarea(attrs={**{
                            'placeholder': item.initialString,
                            'pattern': ".{6,}",
                            'title': 'Please be as descriptive as possible for this question',
                            'oninvalid': "setCustomValidity('Please be as "
                                        "descriptive as possible for "
                                        "this question')",
                            'oninput': "setCustomValidity('')",
                        }, **attrs})
                    )

                else:

                    # Plain old text field
                    fields[item.linkId] = forms.CharField(
                        label=item.text,
                        required=required,
                        widget=forms.TextInput(attrs=attrs)
                    )

            elif item.type == 'date':

                # Determine types
                month_year = False

                # Check for coding on type of picker
                if item.code:
                    for code in [c.code for c in item.code if c.system == FHIR.input_type_system]:

                        # Check type of picker
                        if code == 'month-year':
                            month_year = True

                # Set options
                max_date = timezone.now().replace(hour=23, minute=59).strftime("%Y-%m-%dT%H:%M:%S")
                options = {
                    'maxDate': max_date,
                    'useCurrent': False,
                }

                # Create widget
                if month_year:
                    widget = MonthPickerInput(
                        format='%m/%Y',
                        options=options,
                        attrs=attrs,
                    )
                else:
                    widget = DatePickerInput(
                        format='%m/%d/%Y',
                        options=options,
                        attrs=attrs,
                    )

                # Check for coding on ranges
                if item.code:
                    for code in [c.code for c in item.code if c.system == FHIR.input_range_system]:

                        # Check linking
                        if code.startswith('start-of|'):

                            # Set it
                            widget = widget.start_of(code.split('|')[1])

                        elif code.startswith('end-of|'):

                            # Set it
                            widget = widget.end_of(code.split('|')[1])


                # Check for date or month field
                if month_year:
                    # Setup the month field
                    fields[item.linkId] = forms.DateField(
                        input_formats=["%m/%Y"],
                        widget=widget,
                        label=item.text,
                        required=required
                    )

                else:
                    # Setup the date field
                    fields[item.linkId] = forms.DateField(
                        widget=widget,
                        label=item.text,
                        required=required
                    )

            elif item.type == 'boolean':

                fields[item.linkId] = forms.TypedChoiceField(
                    label=item.text,
                    coerce=lambda x: bool(int(x)),
                    choices=((1, 'Yes'), (0, 'No')),
                    widget=forms.RadioSelect(attrs=attrs),
                    required=required
                )

            elif item.type == 'choice':

                # Set the choices
                choices = ()
                for option in item.option:

                    # Assume valueString
                    if not option.valueString:
                        logger.error('Unsupported choice type for question on Questionnaire',
                                     extra={'questionnaire': questionnaire_id, 'question': item.linkId,})
                    else:
                        choices = choices + ((option.valueString, option.valueString),)

                # Set the input
                fields[item.linkId] = forms.TypedChoiceField(
                    label=item.text,
                    choices=choices,
                    widget=forms.CheckboxSelectMultiple(attrs=attrs),
                    required=required
                )

            elif item.type == 'question' and item.option:

                # Set the choices
                choices = ()
                for option in item.option:

                    # Assume valueString
                    if not option.valueString:
                        logger.error('Unsupported choice type for question on Questionnaire',
                                    extra={'questionnaire': questionnaire_id, 'question': item.linkId,})
                    else:
                        choices = choices + ((option.valueString, option.valueString),)

                # Check if repeats
                if item.repeats:
                    # Set the input
                    fields[item.linkId] = forms.MultipleChoiceField(
                        label=item.text,
                        choices=choices,
                        widget=forms.CheckboxSelectMultiple(attrs=attrs),
                        required=required
                    )

                else:
                    # Set the input
                    fields[item.linkId] = forms.TypedChoiceField(
                        label=item.text,
                        choices=choices,
                        widget=forms.RadioSelect(attrs=attrs),
                        required=required
                    )

            elif item.type == 'display' or item.type == 'group':
                # Nothing to do here
                pass

            else:
                logger.warning(f'Unsupported question type on Questionnaire: {item.linkId}/{item.type}/{item.__dict__}')
                logger.error('Unsupported question type on Questionnaire',
                             extra={'questionnaire': questionnaire_id, 'question': item.linkId, 'type': item.type})
                #continue

            # Process child items
            if item.item:

                # Process the group
                fields.update(self._get_form_fields(item, questionnaire_id))

        return fields
Exemplo n.º 12
0
class GetDateForm(forms.Form):
    start_month = forms.DateField(widget=MonthPickerInput(format='%Y-%m'),
                                  initial=datetime.date.today(),
                                  input_formats=["%Y-%m"])
Exemplo n.º 13
0
class LeaveApplicationFilter(django_filters.FilterSet):
	created_at = DateFilter(label= 'Date Created', lookup_expr='gte')
	startdate = DateFilter(input_formats=('%d/%m/%Y'),label= 'Start Date', lookup_expr='gte', widget=MonthPickerInput(
            format='%d/%m/%Y',
            attrs={
                'class': 'datepicker'
            }
        ))
	

	class Meta:
		model = LeaveApplication
		fields = [
		
		'alltimeofftype',
		'stafftype',
		'user',
		'created_at',
		'startdate',
		'attachmentreceived',
		'attachmentrequired'
		]