class ObjectChangeFilterForm(FilterForm): model = ObjectChange field_groups = [ ['q'], ['time_before', 'time_after', 'action'], ['user_id', 'changed_object_type_id'], ] time_after = forms.DateTimeField(required=False, label=_('After'), widget=DateTimePicker()) time_before = forms.DateTimeField(required=False, label=_('Before'), widget=DateTimePicker()) action = forms.ChoiceField( choices=add_blank_choice(ObjectChangeActionChoices), required=False, widget=StaticSelect()) user_id = DynamicModelMultipleChoiceField( queryset=User.objects.all(), required=False, label=_('User'), widget=APISelectMultiple(api_url='/api/users/users/', )) changed_object_type_id = DynamicModelMultipleChoiceField( queryset=ContentType.objects.all(), required=False, label=_('Object Type'), widget=APISelectMultiple(api_url='/api/extras/content-types/', ))
class ObjectChangeFilterForm(BootstrapMixin, forms.Form): model = ObjectChange field_groups = [ ['q'], ['time_before', 'time_after', 'action'], ['user_id', 'changed_object_type_id'], ] q = forms.CharField( required=False, widget=forms.TextInput(attrs={'placeholder': _('All Fields')}), label=_('Search')) time_after = forms.DateTimeField(required=False, label=_('After'), widget=DateTimePicker()) time_before = forms.DateTimeField(required=False, label=_('Before'), widget=DateTimePicker()) action = forms.ChoiceField( choices=add_blank_choice(ObjectChangeActionChoices), required=False, widget=StaticSelect()) user_id = DynamicModelMultipleChoiceField( queryset=User.objects.all(), required=False, label=_('User'), widget=APISelectMultiple(api_url='/api/users/users/', ), fetch_trigger='open') changed_object_type_id = DynamicModelMultipleChoiceField( queryset=ContentType.objects.all(), required=False, label=_('Object Type'), widget=APISelectMultiple(api_url='/api/extras/content-types/', ), fetch_trigger='open')
class ObjectChangeFilterForm(BootstrapMixin, forms.Form): model = ObjectChange q = forms.CharField( required=False, label='Search' ) time_after = forms.DateTimeField( label='After', required=False, widget=DateTimePicker() ) time_before = forms.DateTimeField( label='Before', required=False, widget=DateTimePicker() ) action = forms.ChoiceField( choices=add_blank_choice(ObjectChangeActionChoices), required=False, widget=StaticSelect2() ) # TODO: Convert to DynamicModelMultipleChoiceField once we have an API endpoint for users user = forms.ModelChoiceField( queryset=User.objects.order_by('username'), required=False, widget=StaticSelect2() ) changed_object_type = forms.ModelChoiceField( queryset=ContentType.objects.order_by('model'), required=False, widget=ContentTypeSelect(), label='Object Type' )
class JournalEntryFilterForm(BootstrapMixin, forms.Form): model = JournalEntry field_groups = [['q'], ['created_before', 'created_after', 'created_by_id'], ['assigned_object_type_id', 'kind']] q = forms.CharField( required=False, widget=forms.TextInput(attrs={'placeholder': _('All Fields')}), label=_('Search')) created_after = forms.DateTimeField(required=False, label=_('After'), widget=DateTimePicker()) created_before = forms.DateTimeField(required=False, label=_('Before'), widget=DateTimePicker()) created_by_id = DynamicModelMultipleChoiceField( queryset=User.objects.all(), required=False, label=_('User'), widget=APISelectMultiple(api_url='/api/users/users/', ), fetch_trigger='open') assigned_object_type_id = DynamicModelMultipleChoiceField( queryset=ContentType.objects.all(), required=False, label=_('Object Type'), widget=APISelectMultiple(api_url='/api/extras/content-types/', ), fetch_trigger='open') kind = forms.ChoiceField(choices=add_blank_choice(JournalEntryKindChoices), required=False, widget=StaticSelect())
class ScheduledTaskCreateForm(BootstrapMixin, forms.Form): model = ScheduledTask pk = forms.ModelMultipleChoiceField(queryset=Device.objects.all(), widget=forms.MultipleHiddenInput()) task_type = forms.ChoiceField( choices=TaskTypeChoices, required=True, label="Job Type", initial="", widget=StaticSelect2() ) scheduled_time = forms.DateTimeField( label="Scheduled Time", required=False, widget=DateTimePicker(), ) mw_duration = forms.IntegerField( required=True, initial=6, label="MW Duration, Hrs.", ) start_now = ["scheduled_time"] transfer_method = forms.ChoiceField( choices=TaskTransferMethod, required=True, label="Transfer Method", initial=DEFAULT_TRANSFER_METHOD, widget=StaticSelect2(), ) class Meta: start_now = ["scheduled_time"] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["mw_duration"].widget.attrs["max"] = 8 self.fields["mw_duration"].widget.attrs["min"] = 1
class Meta: model = Token fields = [ 'key', 'write_enabled', 'expires', 'description', ] widgets = { 'expires': DateTimePicker(), }
class ObjectChangeFilterForm(BootstrapMixin, forms.Form): model = ObjectChange q = forms.CharField(required=False, label='Search') time_after = forms.DateTimeField(label='After', required=False, widget=DateTimePicker()) time_before = forms.DateTimeField(label='Before', required=False, widget=DateTimePicker()) action = forms.ChoiceField( choices=add_blank_choice(OBJECTCHANGE_ACTION_CHOICES), required=False) user = forms.ModelChoiceField(queryset=User.objects.order_by('username'), required=False) changed_object_type = forms.ModelChoiceField( queryset=ContentType.objects.order_by('model'), required=False, widget=ContentTypeSelect(), label='Object Type')
class JournalEntryFilterForm(BootstrapMixin, forms.Form): model = JournalEntry q = forms.CharField(required=False, label=_('Search')) created_after = forms.DateTimeField(required=False, label=_('After'), widget=DateTimePicker()) created_before = forms.DateTimeField(required=False, label=_('Before'), widget=DateTimePicker()) created_by_id = DynamicModelMultipleChoiceField( queryset=User.objects.all(), required=False, label=_('User'), widget=APISelectMultiple(api_url='/api/users/users/', )) assigned_object_type_id = DynamicModelMultipleChoiceField( queryset=ContentType.objects.all(), required=False, label=_('Object Type'), widget=APISelectMultiple(api_url='/api/extras/content-types/', )) kind = forms.ChoiceField(choices=add_blank_choice(JournalEntryKindChoices), required=False, widget=StaticSelect2())
class ObjectChangeFilterForm(BootstrapMixin, forms.Form): model = ObjectChange q = forms.CharField( required=False, label='Search' ) time_after = forms.DateTimeField( label='After', required=False, widget=DateTimePicker() ) time_before = forms.DateTimeField( label='Before', required=False, widget=DateTimePicker() ) action = forms.ChoiceField( choices=add_blank_choice(ObjectChangeActionChoices), required=False, widget=StaticSelect2() ) user_id = DynamicModelMultipleChoiceField( queryset=User.objects.all(), required=False, display_field='username', label='User', widget=APISelectMultiple( api_url='/api/users/users/', ) ) changed_object_type_id = DynamicModelMultipleChoiceField( queryset=ContentType.objects.all(), required=False, display_field='display_name', label='Object Type', widget=APISelectMultiple( api_url='/api/extras/content-types/', ) )
class ScheduledTaskFilterForm(BootstrapMixin, forms.ModelForm): model = ScheduledTask q = forms.CharField(required=False, label="Search") task_type = forms.MultipleChoiceField( label="Type", choices=TaskTypeChoices, required=False, widget=StaticSelect2Multiple() ) status = forms.MultipleChoiceField( label="Status", choices=TaskStatusChoices, required=False, widget=StaticSelect2Multiple() ) confirmed = forms.NullBooleanField( required=False, label="Is Confirmed (ACK)", widget=StaticSelect2(choices=BOOLEAN_WITH_BLANK_CHOICES) ) scheduled_time_after = forms.DateTimeField( label=mark_safe("<br/>Scheduled After"), required=False, widget=DateTimePicker() ) scheduled_time_before = forms.DateTimeField(label="Scheduled Before", required=False, widget=DateTimePicker()) start_time_after = forms.DateTimeField( label=mark_safe("<br/>Started After"), required=False, widget=DateTimePicker() ) start_time_before = forms.DateTimeField(label="Started Before", required=False, widget=DateTimePicker()) end_time_after = forms.DateTimeField(label=mark_safe("<br/>Ended After"), required=False, widget=DateTimePicker()) end_time_before = forms.DateTimeField(label="Ended Before", required=False, widget=DateTimePicker()) class Meta: model = ScheduledTask fields = [ "q", "task_type", "status", "confirmed", "scheduled_time_after", "scheduled_time_before", "start_time_after", "start_time_before", "end_time_after", "end_time_before", ]