Skip to content

Commit

Permalink
Merge pull request #235 from digital-land/revert-233-entityRowValuesT…
Browse files Browse the repository at this point in the history
…oLinks

Revert "Entity row values to links"
  • Loading branch information
GeorgeGoodall authored Jan 22, 2024
2 parents d391626 + b07e29f commit 6ec1a7a
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 33 deletions.
26 changes: 1 addition & 25 deletions application/core/filters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from application.data_access.entity_queries import get_entity_query, get_entity_search
from application.data_access.entity_queries import get_entity_query
from application.core.utils import NoneToEmptyStringEncoder
from jinja2 import pass_eval_context
from markdown import markdown
Expand Down Expand Up @@ -174,30 +174,6 @@ def get_entity_name_filter(eval_ctx, entity):
return entity.reference


@pass_eval_context
def lookup_entity_filter(eval_ctx, value, dataset):
"lookup an entity by its name or reference"
search_parameters = {
"reference": [value],
"dataset": [dataset],
}
params, count, entities = get_entity_search(search_parameters).values()

if len(entities) == 1:
return entities[0].entity


@pass_eval_context
def lookup_entity_custom_filter(eval_ctx, value, dataset):

datasetMapping = {"permitted-development-rights": "permitted-development-right"}

if dataset in datasetMapping:
dataset = datasetMapping[dataset]

return lookup_entity_filter(eval_ctx, value, dataset)


def get_entity_name(entity):
if entity.name:
return entity.name
Expand Down
3 changes: 1 addition & 2 deletions application/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ class DatasetPublicationCountModel(DigitalLandBaseModel):

def entity_factory(entity_orm: EntityOrm):
e = EntityModel.from_orm(entity_orm)

if hasattr(entity_orm, "json") and entity_orm.json is not None:
if entity_orm.json is not None:
# if values in json present then extend the pydantic model
# TODO could add in additional validation using field informtion
field_definitions = {
Expand Down
4 changes: 0 additions & 4 deletions application/core/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
render_markdown,
entity_name_filter,
get_entity_name_filter,
lookup_entity_filter,
lookup_entity_custom_filter,
debug,
digital_land_to_json,
uri_encode,
Expand Down Expand Up @@ -75,8 +73,6 @@ def random_int(n=1):
templates.env.filters["render_markdown"] = render_markdown
templates.env.filters["entity_name"] = entity_name_filter
templates.env.filters["get_entity_name"] = get_entity_name_filter
templates.env.filters["lookup_entity"] = lookup_entity_filter
templates.env.filters["lookup_entity_custom"] = lookup_entity_custom_filter
templates.env.filters["debug"] = debug
templates.env.filters["digital_land_to_json"] = digital_land_to_json
templates.env.filters["uri_encode"] = uri_encode
Expand Down
2 changes: 0 additions & 2 deletions application/templates/components/entity-value/macro.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@
{{ value }}
{% endif %}
</a>
{%- elif field in ["article-4-direction", "permitted-development-rights", "tree-preservation-order"] %}
<a class ="govuk-link" href="/entity/{{ value | lookup_entity_custom(field) }}">{{ value }}</a>
{%- elif field in ["parliament-thesaurus"] %}
<a class ="govuk-link" href="{{ 'https://lda.data.parliament.uk/terms/' + value }}">{{ value }}</a>
{%- elif field in ["statistical-geography"] %}
Expand Down

0 comments on commit 6ec1a7a

Please sign in to comment.