Skip to content

Commit

Permalink
Merge branch 'develop' into fix/DF-778-fixes-to-website-results-forma…
Browse files Browse the repository at this point in the history
…tting
  • Loading branch information
JohnHeeryTNA authored Jul 20, 2023
2 parents aa20fa7 + 22734be commit 65bdf78
Show file tree
Hide file tree
Showing 23 changed files with 961 additions and 287 deletions.
4 changes: 4 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@

WAGTAILIMAGES_IMAGE_MODEL = "images.CustomImage"

# Custom password template for private pages

PASSWORD_REQUIRED_TEMPLATE = "password_pages/password_required.html"

# Kong client

KONG_CLIENT_BASE_URL = os.getenv("KONG_CLIENT_BASE_URL")
Expand Down
47 changes: 43 additions & 4 deletions etna/records/templatetags/records_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,23 @@ def record_url(
record: Record,
is_editorial: bool = False,
order_from_discovery: bool = False,
use_non_reference_number_url: bool = False,
level_or_archive: str = "",
base_record: Record = None,
form_group: str = "",
) -> str:
"""
Return the URL for the provided `record`, which should always be a
fully-transformed `etna.records.models.Record` instance.
use_non_reference_number_url: set True to override reference number to disambiguation page
(multiple iaid share the same reference number) when its not required.
level_or_archive: Use api level name or "Archive" name. This value is checked
with a set of values in order to override reference number that show
disambiguation page (multiple iaid share the same reference number).
base_record: is the original record; use when record is not the original record
and record is a subset of the original record along with level_or_archive
in order to determine reference number override
form_group: use with results from search queries, value determines tna, nonTna results
"""
if is_editorial and settings.FEATURE_RECORD_LINKS_GO_TO_DISCOVERY and record.iaid:
return TNA_URLS.get("discovery_rec_default_fmt").format(iaid=record.iaid)
Expand All @@ -34,7 +43,37 @@ def record_url(
return TNA_URLS.get("discovery_rec_default_fmt").format(iaid=record.iaid)

if record:
if use_non_reference_number_url:
if form_group in ("archive", "creator"):
return record.non_reference_number_url
if form_group == "nonTna":
is_tna = False
elif form_group in ("tna", "digitised"):
is_tna = True
else:
is_tna = record.is_tna

if base_record:
is_tna = base_record.is_tna

if is_tna:
reference_number_override_list = [
"Lettercode", # same as Department, but returned in API response
level_name(level_code=1, is_tna=is_tna),
level_name(level_code=2, is_tna=is_tna),
level_name(level_code=4, is_tna=is_tna),
level_name(level_code=5, is_tna=is_tna),
"Archive", # no level specified for this value
]
else:
reference_number_override_list = [
level_name(level_code=1, is_tna=is_tna),
level_name(level_code=9, is_tna=is_tna),
level_name(level_code=10, is_tna=is_tna),
level_name(level_code=11, is_tna=is_tna),
"Archive", # no level specified for this value
]

if level_or_archive in reference_number_override_list:
return record.non_reference_number_url
else:
return record.url
Expand Down
Loading

0 comments on commit 65bdf78

Please sign in to comment.