Skip to content
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

ICMSLST-1088 Use select2 in search for country selection. #592

Merged
merged 1 commit into from Sep 13, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 23 additions & 2 deletions web/domains/case/forms_search.py
Expand Up @@ -2,10 +2,12 @@
from typing import Optional

from django import forms
from django_select2.forms import Select2MultipleWidget

from web.domains.case._import.models import ImportApplicationType
from web.domains.case.export.models import ExportApplicationType
from web.domains.case.models import ApplicationBase
from web.domains.country.models import Country
from web.forms.widgets import DateInput
from web.models.shared import YesNoChoices

Expand Down Expand Up @@ -103,8 +105,19 @@ class ExportSearchForm(SearchFormBase):
closed_from = forms.DateField(label="Closed date", required=False, widget=DateInput)
closed_to = forms.DateField(label="To", required=False, widget=DateInput)

cert_country = forms.CharField(label="Certificate country", required=False)
manufacture_country = forms.CharField(label="Country of manufacture", required=False)
cert_country = forms.ModelMultipleChoiceField(
label="Certificate country",
required=False,
queryset=Country.objects.none(),
widget=Select2MultipleWidget,
)

manufacture_country = forms.ModelMultipleChoiceField(
label="Country of manufacture",
required=False,
queryset=Country.objects.none(),
widget=Select2MultipleWidget,
)
kevinetienne marked this conversation as resolved.
Show resolved Hide resolved

pending_firs = forms.ChoiceField(
label="Pending Further Information Requests",
Expand All @@ -118,6 +131,14 @@ class ExportSearchForm(SearchFormBase):
required=False,
)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

countries = Country.objects.filter(is_active=True, type=Country.SOVEREIGN_TERRITORY)

self.fields["cert_country"].queryset = countries
self.fields["manufacture_country"].queryset = countries

def clean(self):
cd = super().clean()

Expand Down
2 changes: 2 additions & 0 deletions web/domains/case/views_search.py
Expand Up @@ -81,4 +81,6 @@ def _get_search_terms_from_form(case_type: str, form: SearchForm) -> SearchTerms
issue_date_end=cd.get("issue_to"),
reassignment_search=cd.get("reassignment"),
# TODO: add all the export search fields
# cert_country=cd.get("cert_country"),
# manufacture_country=cd.get("manufacture_country"),
)
1 change: 1 addition & 0 deletions web/templates/web/domains/case/search/search.html
Expand Up @@ -3,6 +3,7 @@
{% import "forms/fields.html" as fields %}

{% block css %}
{{ form.media.css }}
<link rel="stylesheet" type="text/css" href="{{ static('web/css/pages/search.css') }}">
{% endblock %}

Expand Down