Skip to content

Added filter by base_for field #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/signals/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class SignalFilter(django_filters.FilterSet):
format_type = django_filters.MultipleChoiceFilter(choices=FormatChoices.choices)
source = django_filters.ModelMultipleChoiceFilter(queryset=SourceSubdivision.objects.all())
time_type = django_filters.MultipleChoiceFilter(choices=TimeTypeChoices.choices)
base_signal = django_filters.BooleanFilter(lookup_expr='isnull', field_name='base_for')

class Meta:
model = Signal
Expand All @@ -57,6 +58,7 @@ class Meta:
'format_type',
'source',
'time_type',
'base_signal',
]

def filter_search(self, queryset, name, value) -> Any:
Expand Down
2 changes: 2 additions & 0 deletions src/signals/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SignalFilterForm(forms.ModelForm):
format_type = forms.ChoiceField(choices=FormatChoices.choices, widget=forms.CheckboxSelectMultiple())
source = forms.ModelMultipleChoiceField(queryset=SourceSubdivision.objects.all(), widget=forms.CheckboxSelectMultiple())
time_type = forms.ChoiceField(choices=TimeTypeChoices.choices, widget=forms.CheckboxSelectMultiple())
base_signal = forms.ChoiceField(choices=[('', _('All')), (True, _('Yes')), (False, _('No'))], required=False, widget=forms.RadioSelect())

class Meta:
model = Signal
Expand Down Expand Up @@ -79,6 +80,7 @@ class Meta:
'data-bs-toggle': 'tooltip',
'data-bs-placement': 'bottom',
}),

}

def __init__(self, *args, **kwargs) -> None:
Expand Down
3 changes: 2 additions & 1 deletion src/signals/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def get_url_params(self):
else None,
"format_type": [el for el in self.request.GET.getlist("format_type")],
"source": [int(el) for el in self.request.GET.getlist("source")],
"time_type": [el for el in self.request.GET.getlist("time_type")]
"time_type": [el for el in self.request.GET.getlist("time_type")],
"base_signal": self.request.GET.get("base_signal"),
}
url_params_str = ""
for param_name, param_value in url_params_dict.items():
Expand Down
20 changes: 19 additions & 1 deletion src/templates/signals/signals.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,25 @@ <h2 class="accordion-header" id="available_geography-heading">
</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#base_signal-collapse" aria-expanded="false" aria-controls="active-collapse">
<label for="id_base_signal" class="form-label">
Base Signal
<a tabindex="0" role="button" class="info-button" data-bs-toggle="popover" data-bs-title="Base Signal" data-bs-content="{{ filters_descriptions.SignalFilter.base_signal }}"><i class="bi bi-info-circle"></i></a>
</label>
</button>
</h2>
{% if form.base_signal.value %}
<div id="base_signal-collapse" class="accordion-collapse" aria-labelledby="base_signal-heading">
{% else %}
<div id="base_signal-collapse" class="accordion-collapse collapse" aria-labelledby="base_signal-heading">
{% endif %}
<div class="accordion-body">
{{ form.base_signal|as_crispy_field }}
</div>
</div>
</div>
</div>
<div class="card-body">
<div class="d-grid gap-2 mt-3">
Expand Down Expand Up @@ -281,7 +300,6 @@ <h2 class="accordion-header" id="available_geography-heading">
</div>
</div>
</form>

<script>

const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]');
Expand Down
Loading