Skip to content

Commit

Permalink
feat: add more contact options for ask a question (#992)
Browse files Browse the repository at this point in the history
* feat: add more contact options for ask a question

this adds showing microsoft teams channels or team emails to direct questions to, where given

* feat: add entity custom properties for ms teams and email contacts

* test: update tests for additional contact properties

* Reformatted contact channels into a list

* Fixed tests

* Added ids to contact channels and added tests

* Removed old line of code

* less > fewer

* Change logic gate

* trying stuff

* fixing

* Fixing

---------

Co-authored-by: Murdo Moyse <murdo.moyse@digital.justice.gov.uk>
  • Loading branch information
LavMatt and murdo-moj authored Oct 30, 2024
1 parent 3146138 commit 8be635d
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 21 deletions.
21 changes: 21 additions & 0 deletions lib/datahub-client/data_platform_catalogue/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,27 @@ class FurtherInformation(BaseModel):
default="",
examples=["https://moj.enterprise.slack.com/archives/CXYZ1234E"],
)
dc_teams_channel_name: str = Field(
description=(
"The name of a Microsoft Teams channel to be used as a contact point for users of "
"the catalogue service to ask questions."
),
default="",
examples=["Data team"],
)
dc_teams_channel_url: str = Field(
description="The URL to the Teams channel",
default="",
examples=["https://teams.microsoft.com/l/channel/123"],
)
dc_team_email: str = Field(
description=(
"A shared email address for a team where they receive questions"
" about the data. Unrealted to Microsoft Teams"
),
default="",
examples=["best-data-team@justice.gov.uk"],
)


class DataSummary(BaseModel):
Expand Down
5 changes: 4 additions & 1 deletion lib/datahub-client/tests/snapshots/test_upsert_table.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
"refresh_period": "",
"last_updated": "",
"dc_slack_channel_name": "test-channel",
"dc_slack_channel_url": "test-url"
"dc_slack_channel_url": "test-url",
"dc_teams_channel_name": "",
"dc_teams_channel_url": "",
"dc_team_email": ""
},
"name": "Dataset",
"qualifiedName": "database.Dataset",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
"refresh_period": "",
"last_updated": "",
"dc_slack_channel_name": "test-channel",
"dc_slack_channel_url": "test-url"
"dc_slack_channel_url": "test-url",
"dc_teams_channel_name": "",
"dc_teams_channel_url": "",
"dc_team_email": ""
},
"name": "my_database",
"description": "little test db"
Expand Down Expand Up @@ -114,7 +117,10 @@
"refresh_period": "",
"last_updated": "",
"dc_slack_channel_name": "test-channel",
"dc_slack_channel_url": "test-url"
"dc_slack_channel_url": "test-url",
"dc_teams_channel_name": "",
"dc_teams_channel_url": "",
"dc_team_email": ""
},
"name": "Dataset",
"qualifiedName": "database.Dataset",
Expand Down
2 changes: 1 addition & 1 deletion locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ msgid ""
"For example: <strong>prisons | probation</strong> matches data mentioning "
"\"prisons\" OR \"probation\".</p>"
msgstr ""
"<p>Try including less words in your search query.</p> <p>If you want to "
"<p>Try including fewer words in your search query.</p> <p>If you want to "
"include results for multiple things, separate words with pipe characters. "
"For example: <strong>prisons | probation</strong> matches data mentioning "
"\"prisons\" OR \"probation\".</p>"
Expand Down
2 changes: 1 addition & 1 deletion templates/details_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ <h2 class="govuk-heading-s govuk-!-margin-top-3">
</div>
</div>
<div class="govuk-grid-column-one-third">
{% include "partial/contact_info.html" with entity_name=entity.name data_owner=entity.governance.data_owner.display_name data_owner_email=entity.governance.data_owner.email slack_channel=entity.custom_properties.further_information access_requirements=entity.custom_properties.access_information.dc_access_requirements is_access_url=is_access_requirements_a_url platform=entity.platform %}
{% include "partial/contact_info.html" with entity_name=entity.name data_owner=entity.governance.data_owner.display_name data_owner_email=entity.governance.data_owner.email further_information=entity.custom_properties.further_information access_requirements=entity.custom_properties.access_information.dc_access_requirements is_access_url=is_access_requirements_a_url platform=entity.platform %}
</div>
</div>

Expand Down
31 changes: 21 additions & 10 deletions templates/partial/contact_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,27 @@ <h2 class="govuk-heading-s govuk-!-margin-bottom-1">{% translate "Access require

<div class="govuk-body">
<h2 class="govuk-heading-s govuk-!-margin-bottom-1">{% translate "Contact channels for questions" %}</h2>
<p id="contact_channels" class="govuk-body">
{% if slack_channel.dc_slack_channel_url %}
<!-- This should become a list of populated contact channels -->
Slack channel: <a href="{{ slack_channel.dc_slack_channel_url }}" class="govuk-link" rel="noreferrer noopener" target="_blank">{{ slack_channel.dc_slack_channel_name }} (opens in new tab)</a>
{% elif data_owner_email %}
{% translate "Contact the data owner with questions." %}
{% else %}
{% translate 'Not provided' %}
<ul id="contact_channels" class="govuk-list">
{% if further_information.dc_slack_channel_url %}
<li id="contact_channels_slack">
<a href="{{ further_information.dc_slack_channel_url }}" class="govuk-link" rel="noreferrer noopener" target="_blank">Slack (opens in new tab)</a>
</li>
{% endif %}
</p>
{% if further_information.dc_teams_channel_url %}
<li id="contact_channels_ms_teams">
<a href="{{ further_information.dc_teams_channel_url }}" class="govuk-link" rel="noreferrer noopener" target="_blank">MS Teams (opens in new tab)</a>
</li>
{% endif %}
{% if further_information.dc_team_email %}
<li id="contact_channels_team_email" >{{ further_information.dc_team_email|urlize }}</li>
{% endif %}
{% if data_owner_email and not further_information.dc_teams_channel_url and not further_information.dc_slack_channel_url and not further_information.dc_team_email %}
<li id="contact_channels_data_owner">{% translate "Contact the data owner with questions." %}</li>
{% endif %}
{% if not further_information.dc_teams_channel_url and not further_information.dc_slack_channel_url and not further_information.dc_team_email and not data_owner_email%}
<li id="contact_channels_not_provided">{% translate "Not provided" %}</li>
{% endif %}
</ul>
</div>

<div class="govuk-body">
Expand All @@ -40,7 +51,7 @@ <h2 class="govuk-heading-s govuk-!-margin-bottom-1">{% translate "IAO or Data Ow
{% elif platform.urn == 'performance-hub' %}
No owner is listed as this data is undergoing a review of ownership.
{% else %}
{% blocktranslate %}Not provided - <a href="https://moj.enterprise.slack.com/archives/C06NPM2200N" class="govuk-link">contact the Data Catalogue team</a> about this data.{% endblocktranslate %}
{% blocktranslate %}Not provided - <a href="https://moj.enterprise.slack.com/archives/C06NPM2200N" class="govuk-link" rel="noreferrer noopener" target="_blank">contact the Data Catalogue team</a> about this data.{% endblocktranslate %}
{% endif %}
</p>
</div>
Expand Down
16 changes: 14 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,20 @@ class DetailsPage(Page):
def request_access(self):
return self.selenium.find_element(By.ID, "request_access")

def contact_channels(self):
return self.selenium.find_element(By.ID, "contact_channels")
def contact_channels_slack(self):
return self.selenium.find_element(By.ID, "contact_channels_slack")

def contact_channels_ms_teams(self):
return self.selenium.find_element(By.ID, "contact_channels_ms_teams")

def contact_channels_team_email(self):
return self.selenium.find_element(By.ID, "contact_channels_team_email")

def contact_channels_data_owner(self):
return self.selenium.find_element(By.ID, "contact_channels_data_owner")

def contact_channels_not_provided(self):
return self.selenium.find_element(By.ID, "contact_channels_not_provided")

def data_owner(self):
return self.selenium.find_element(By.ID, "data_owner")
Expand Down
48 changes: 44 additions & 4 deletions tests/integration/test_details_contact_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,39 @@ def test_access_requirements_fallbacks(
assert request_access_metadata.text == expected_text

@pytest.mark.parametrize(
"slack_channel, owner, expected_text",
"slack_channel, teams_channel, team_email, owner, expected_text",
[
(
"#contact-us",
"",
"",
"meta.data@justice.gov.uk",
"Slack (opens in new tab)",
),
(
"",
"Contact us on Teams",
"",
"meta.data@justice.gov.uk",
"Slack channel: #contact-us (opens in new tab)",
"MS Teams (opens in new tab)",
),
(
"",
"",
"some-team-email@justice.gov.uk",
"meta.data@justice.gov.uk",
"some-team-email@justice.gov.uk",
),
(
"",
"",
"",
"meta.data@justice.gov.uk",
"Contact the data owner with questions.",
),
(
"",
"",
"",
"",
"Not provided.",
Expand All @@ -166,6 +186,8 @@ def test_contact_channels_fallbacks(
database,
mock_catalogue,
slack_channel,
teams_channel,
team_email,
owner,
expected_text,
):
Expand All @@ -178,13 +200,31 @@ def test_contact_channels_fallbacks(
dc_slack_channel_name=slack_channel,
dc_slack_channel_url="http://bla.com",
)
if teams_channel:
database.custom_properties.further_information = FurtherInformation(
dc_teams_channel_name=teams_channel,
dc_teams_channel_url="http://bla.com",
)
if team_email:
database.custom_properties.further_information = FurtherInformation(
dc_team_email=team_email,
)

mock_get_database_details_response(mock_catalogue, database)

self.start_on_the_details_page()
request_access_metadata = self.details_database_page.contact_channels()

assert request_access_metadata.text == expected_text
if slack_channel:
assert self.details_database_page.contact_channels_slack()
if teams_channel:
assert self.details_database_page.contact_channels_ms_teams()
if team_email:
assert self.details_database_page.contact_channels_team_email()

if not slack_channel and not teams_channel and not team_email and owner:
assert self.details_database_page.contact_channels_data_owner()
if not slack_channel and not teams_channel and not team_email and not owner:
assert self.details_database_page.contact_channels_not_provided()

@pytest.mark.parametrize(
"owner, expected_text",
Expand Down

0 comments on commit 8be635d

Please sign in to comment.