-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
…igned with djhtml
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> |
There was a problem hiding this comment.
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 #} |
There was a problem hiding this comment.
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>
?
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
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 |
There was a problem hiding this comment.
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'.") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good shout.
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 | ||
|
There was a problem hiding this comment.
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.
RICH_TEXT_BASIC = ["bold", "italic", "link", "ol", "ul"] | ||
RICH_TEXT_FULL = ["h3", "h4", *RICH_TEXT_BASIC, "document-link"] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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
return HomePage.objects.first() | |
return HomePage.objects.get() |
There was a problem hiding this comment.
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
https://jira.ons.gov.uk/browse/CMS-46 and https://jira.ons.gov.uk/browse/CMS-80
ContactDetails
snippetScreencast: https://www.loom.com/share/5a7d8a9ca004448981526056e28ab5cd
Dev walkthrough: https://www.loom.com/share/39f7bde66cdc48b9872fa3d5cace22d6