Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite3125d9

Browse files
committed
Time Tag Now Shows Year For Events With Details Not Within The Current Year
The time tag now displays the year when an event will occur. This is only for events that have been scheduled to start or end in at a future year. The accompanying functional tests have also been included.
1 parentff1ad8b commite3125d9

File tree

2 files changed

+70
-2
lines changed

2 files changed

+70
-2
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
fromdjango.testimportLiveServerTestCase,TestCase
2+
fromdjango.utilsimporttimezone
3+
fromselenium.common.exceptionsimportWebDriverException
4+
fromselenium.webdriverimportChrome
5+
6+
from .test_viewsimportEventsViewsTests
7+
from ..modelsimportEvent
8+
9+
10+
classEventsPageFunctionalTests(LiveServerTestCase,TestCase):
11+
@classmethod
12+
defsetUpClass(cls):
13+
EventsViewsTests().setUpTestData()
14+
super().setUpClass()
15+
cls.now=timezone.now()
16+
17+
defsetUp(self)->None:
18+
try:
19+
self.browser=Chrome()
20+
self.browser.implicitly_wait(5)
21+
exceptWebDriverException:# GitHub Actions Django CI
22+
fromseleniumimportwebdriver
23+
self.browser=webdriver.FirefoxOptions()
24+
self.browser.headless=True
25+
webdriver.Firefox(options=self.browser)
26+
27+
deftearDown(self)->None:
28+
self.browser.quit()
29+
30+
deftest_event_starting_future_year_displays_year(self):
31+
event=Event.objects.get(title=f"Event Starts Following Year")
32+
self.browser.get(self.live_server_url+'/events/')
33+
future_event_span_value=self.browser.find_element_by_id(str(event.id))
34+
self.assertIn(str(event.next_time.dt_start.year),future_event_span_value.text)
35+
36+
deftest_event_ending_future_year_displays_year(self):
37+
event=Event.objects.get(title=f"Event Ends Following Year")
38+
self.browser.get(self.live_server_url+'/events/')
39+
future_event_span_value=self.browser.find_element_by_id(str(event.id))
40+
self.assertIn(str(event.next_time.dt_end.year),future_event_span_value.text)
41+
Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
{% if next_time.single_day %}
2-
<timedatetime="{{ next_time.dt_start|date:'c' }}">{{ next_time.dt_start|date:"d N" }}<spanclass="say-no-more"> {{ next_time.dt_start|date:"Y" }}</span>{% if not next_time.all_day %} {{ next_time.dt_start|date:"fA"|lower }} {{ next_time.dt_start|date:"e" }}{% if next_time.valid_dt_end %} – {{ next_time.dt_end|date:"fA"|lower }} {{ next_time.dt_end|date:"e" }}{% endif %}{% endif %}</time>
2+
<timeid="{{ object.id }}"datetime="{{ next_time.dt_start|date:'c' }}">{{ next_time.dt_start|date:"d N" }}
3+
<span{%ifscheduled_start_this_year%}class="say-no-more"{%endif%}>
4+
{{ next_time.dt_start|date:"Y" }}
5+
</span>
6+
7+
<span{%ifscheduled_end_this_year%}class="say-no-more"{%endif%}>
8+
{{ next_time.dt_start|date:"Y" }}
9+
</span>
10+
11+
{% if not next_time.all_day %}
12+
{{ next_time.dt_start|date:"fA"|lower }} {{ next_time.dt_start|date:"e" }}
13+
{% if next_time.valid_dt_end %} – {{ next_time.dt_end|date:"fA"|lower }}
14+
{{ next_time.dt_end|date:"e" }}
15+
{% endif %}
16+
{% endif %}
17+
</time>
318
{% else %}
4-
<timedatetime="{{ next_time.dt_start|date:'c' }}">{{ next_time.dt_start|date:"d N" }}{% if next_time.valid_dt_end %} &ndash; {{ next_time.dt_end|date:"d N" }}{% endif %}<spanclass="say-no-more"> {{ next_time.dt_end|date:"Y" }}</span></time>
19+
<timeid="{{ object.id }}"datetime="{{ next_time.dt_start|date:'c' }}">{{ next_time.dt_start|date:"d N" }}
20+
<span{%ifscheduled_start_this_year%}class="say-no-more"{%endif%}>
21+
{{ next_time.dt_start|date:"Y" }}
22+
</span>
23+
24+
{% if next_time.valid_dt_end %} &ndash;
25+
{{ next_time.dt_end|date:"d N" }}
26+
{% endif %}
27+
28+
<span{%ifscheduled_end_this_year%}class="say-no-more"{%endif%}>
29+
{{ next_time.dt_end|date:"Y" }}
30+
</span>
31+
</time>
532
{% endif %}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp