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

Feature/orpd 33 backend services #10

Merged
merged 6 commits into from
Oct 11, 2024
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
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.
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