Skip to content

Commit

Permalink
Merge branch 'main' of github.com:uktrade/orp into ORPD-31-document-d…
Browse files Browse the repository at this point in the history
…etails-page
  • Loading branch information
gdbarnes committed Oct 11, 2024
2 parents c9030f1 + 5c96352 commit 35c0ee6
Show file tree
Hide file tree
Showing 18 changed files with 8,092 additions and 61 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Create the initial database:
$ make database

> The `make database` command will create a `PostgreSQL` database. If you have
> an existing database and want to start from scratch, use `make drop-databse`
> an existing database and want to start from scratch, use `make drop-database`
> to delete an existing database first.
Prepare the application for first use:
Expand Down Expand Up @@ -98,3 +98,22 @@ With your Poetry shell active:
> This will ensure that your code passes quality checks before you commit it.
> Code quality checks are also performed when pushing your code to origin
> but pre-commit hooks catch issues early and will improve Developer Experience.

### Update database tables

> To update local database tables, you need to set the `DATABASE_URL` environment variable. You can set it in the terminal or in the `.env` file.
<!-- pragma: allowlist secret --> $ export DATABASE_URL=postgres://postgres:postgres@localhost:5432/orp

> If you want to migrate all apps then navigate /orp/orp and use the following command:
$ poetry run python manage.py migrate

> If you want to migrate a single app then navigate /orp/orp and use the following command:
$ poetry run python manage.py migrate <app_name>



poetry add boto3 awswrangler
Empty file added __init__.py
Empty file.
2 changes: 1 addition & 1 deletion front_end/images/icon-search-black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions front_end/stylesheets/helpers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,15 @@
.orp-flex--space-between {
justify-content: space-between;
}

.orp-secondary-text-colour {
color: govuk-colour("dark-grey");
}

.orp-link-text-decoration-none {
text-decoration: none;

&:hover {
text-decoration: underline;
}
}
22 changes: 22 additions & 0 deletions front_end/stylesheets/search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,25 @@
}
}
}

.orp-search-results {

.orp-topics-list {
display: flex;
flex-wrap: wrap;
margin: 0;
padding: 0;
list-style: none;

li {
padding-right: 10px;
margin-right: 10px;
margin-bottom: 10px;
border-right: 1px solid govuk-colour("dark-grey");
}

li:last-child {
border-right: none;
}
}
}
17 changes: 17 additions & 0 deletions orp/core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,20 @@ class RegulationSearchForm(forms.Form):
}
),
)

document_type = forms.MultipleChoiceField(
required=False,
choices=[
("employment-tribunal", "Legislation"),
("MOD", "Guidance"),
("DfT", "Statutory guidance"),
],
widget=forms.CheckboxSelectMultiple(
attrs={
"class": "govuk-checkboxes__input",
"data-module": "govuk-checkboxes",
}
),
label="Select document types",
help_text="You can select multiple document types.",
)
2 changes: 1 addition & 1 deletion orp/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def main():
"""Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand Down
41 changes: 41 additions & 0 deletions orp/orp_search/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import logging

logger = logging.getLogger(__name__)


class SearchDocumentConfig:
def __init__(
self, search_terms: str, document_types=None, timeout=None, dummy=False
):
"""
Initializes a new instance of the class.
:param searchTerms: A comma-separated string of search terms.
:param documentTypes: Optional. A list of document types
to filter the search.
:param timeout: Optional. The timeout in seconds for the search
request.
"""
self.search_terms = [term.strip() for term in search_terms.split(",")]
self.document_types = document_types
self.timeout = None if timeout is None else int(timeout)
self.dummy = dummy

def validate(self):
"""
Validates the presence of search terms.
Checks if the 'searchTerms' attribute exists and is non-empty. Logs
an error message and returns False if 'searchTerms' is missing or
empty.
Returns
-------
bool
True if 'searchTerms' is present and non-empty, False otherwise.
"""
if not self.search_terms:
logger.error("search terms are required")
return False
return True
Loading

0 comments on commit 35c0ee6

Please sign in to comment.