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

Release calendar pages #16

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Conversation

zerolab
Copy link
Contributor

@zerolab zerolab commented Nov 1, 2024

https://jira.ons.gov.uk/browse/CMS-46 and https://jira.ons.gov.uk/browse/CMS-80

  • Adds the ContactDetails snippet
  • add the release calendar index and page model and tests
  • plugs in the templates
  • adds test coverage
  • expands the core tests

Screencast: https://www.loom.com/share/5a7d8a9ca004448981526056e28ab5cd
Dev walkthrough: https://www.loom.com/share/39f7bde66cdc48b9872fa3d5cace22d6

@zerolab zerolab requested a review from a team as a code owner November 1, 2024 09:32
adds a few extra files to the ignore.

and explicitly filters the RemovedInDjango60Warning
@@ -0,0 +1,6 @@
<li class="ons-list__item">
<h3 class="ons-u-mb-no ons-u-fs-r--b">{{ _("Previous date") }}</h3>
<p>{{ value.previous_date|date("j F Y g:ia") }}</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Should this format be defined globally, since I suspect all will be shown in a standard way

</div>
{% endif %}

<p></p>{# added empty p for some margin #}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This feels like a hack - is there a better way to add some margin? Perhaps with CSS or a <br>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not doing all the front-end here. We have FE tasks for heroes

{% if page.next_release_date or page.next_release_text %}
<div class="ons-grid__col ons-col-8@m ons-col-12@s ons-u-p-no@xxs@m">
<span class="ons-u-fs-r--b">{{ _("Next release") }}:</span>
<span class="ons-u-nowrap">{{ page.next_release_date|date("j F Y g:ia") or page.next_release_text }}</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: How does |date handle receiving None? Might this need to be expanded to an if?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

|date returns an empty string for None

content_type=index_content_type,
depth=home_page.depth + 1,
url_path=f"{home_page.url_path}releases/",
locale=Locale.objects.first(), # cannot use Locale.get_default(), but since we only have one, this works
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Worth using .get to enforce there's only one?

Suggested change
locale=Locale.objects.first(), # cannot use Locale.get_default(), but since we only have one, this works
locale=Locale.objects.get(), # cannot use Locale.get_default(), but since we only have one, this works

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leaving this so things don't break when add i18n

blank=True, null=True, help_text=_("Required once the release has been confirmed.")
)
release_date_text = models.CharField(
max_length=50, blank=True, help_text=_("Format: 'Month YYYY', or 'Month YYYY to Month YYYY'.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Should this format be validated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good shout.

Comment on lines 76 to 86
del release_calendar_page.table_of_contents # clear the cached property
release_calendar_page.is_census = True
release_calendar_page.is_accredited = False

assert release_calendar_page.table_of_contents == expected_with_census_or_accredited
assert release_calendar_page.get_context(request)["table_of_contents"] == expected_with_census_or_accredited

del release_calendar_page.table_of_contents # clear the cached property
release_calendar_page.is_census = False
release_calendar_page.is_accredited = True

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: This feels like it's testing a number of different conditions in the same test. It's probably worth sticking to "Arrange Act Assert" where possible.

Comment on lines +713 to +714
RICH_TEXT_BASIC = ["bold", "italic", "link", "ol", "ul"]
RICH_TEXT_FULL = ["h3", "h4", *RICH_TEXT_BASIC, "document-link"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Why are these separate settings rather than using the editors setting below? Saves needing to import them around.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have two types of editors - basic for things like notices, summary etc. And full (for paragraph).

We can swap them around.. ie make basic the default and use the full one where needed

conftest.py Outdated

@pytest.fixture()
def home_page() -> HomePage:
"""Returns the home page."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Returns the home page."""
"""Returns the home page, which is created via a migration."""

@pytest.fixture()
def release_calendar_index() -> ReleaseCalendarIndex:
"""Returns the release calendar index page, which is created via a migration."""
return ReleaseCalendarIndex.objects.first()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought: Currently there's no constraint that only one of these exists.

  • Should there be a constraint, or
  • Should the fixture be a factory instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's one index per homepage.

@pytest.fixture()
def home_page() -> HomePage:
"""Returns the home page."""
return HomePage.objects.first()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Since there's only ever meant to be one homepage

Suggested change
return HomePage.objects.first()
return HomePage.objects.get()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we won't, since we will have translations

@zerolab zerolab mentioned this pull request Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants