mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
FEAT(Asset): Add filter for only cables
This commit is contained in:
@@ -32,6 +32,7 @@ class AssetSearchForm(forms.Form):
|
||||
q = forms.CharField(required=False)
|
||||
category = forms.ModelMultipleChoiceField(models.AssetCategory.objects.all(), required=False)
|
||||
status = forms.ModelMultipleChoiceField(models.AssetStatus.objects.all(), required=False)
|
||||
is_cable = forms.BooleanField(required=False)
|
||||
|
||||
|
||||
class SupplierForm(forms.ModelForm):
|
||||
|
||||
@@ -74,6 +74,10 @@
|
||||
<label for="status" class="sr-only">Status</label>
|
||||
{% render_field form.status|attr:'multiple'|add_class:'form-control custom-select selectpicker col-sm' data-none-selected-text="Statuses" data-header="Statuses" data-actions-box="true" %}
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
{% render_field form.is_cable|add_class:'form-check-input' %}
|
||||
<label class="form-check-label" for="is_cable">Only Cables?</label>
|
||||
</div>
|
||||
<button id="filter-submit" type="submit" class="btn btn-secondary" style="width: 6em">Filter</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -52,6 +52,9 @@ class AssetList(LoginRequiredMixin, generic.ListView):
|
||||
else:
|
||||
queryset = self.model.objects.filter(Q(asset_id__exact=query_string.upper()))
|
||||
|
||||
if form.cleaned_data['is_cable']:
|
||||
queryset = queryset.filter(is_cable=True)
|
||||
|
||||
if form.cleaned_data['category']:
|
||||
queryset = queryset.filter(category__in=form.cleaned_data['category'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user