-
-
Notifications
You must be signed in to change notification settings - Fork 666
Fix #2626: Duplicate scheduled year for single day events #2934
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
Open
iampujan
wants to merge
4
commits into
python:main
Choose a base branch
from
iampujan:feature/issue-2626-duplicate-event-year
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+55
−4
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
56c8f01
Fix #2626: Duplicate scheduled year for single day events
iampujan 270125b
Update apps/events/tests/test_templates.py
iampujan 8d9db16
Update apps/events/tests/test_templates.py
iampujan 3dec0eb
Merge branch 'main' into feature/issue-2626-duplicate-event-year
iampujan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import datetime | ||
|
|
||
| from django.template.loader import render_to_string | ||
| from django.test import TestCase | ||
|
|
||
| from apps.events.models import Event, Calendar | ||
|
|
||
|
|
||
| class TimeTagTemplateTests(TestCase): | ||
| def test_single_day_event_year_rendering(self): | ||
| """ | ||
| Verify that a single-day event does not render the year twice (Issue #2626). | ||
| """ | ||
| # Create a single day event in the future to trigger the year rendering condition | ||
| future_year = datetime.date.today().year + 1 | ||
|
|
||
| calendar = Calendar.objects.create( | ||
| name="Test Calendar", | ||
| slug="test-calendar-time-tag-single-day-event", | ||
| ) | ||
|
|
||
| event = Event.objects.create( | ||
| title="Single Day Future Event", | ||
| description="Test event", | ||
| calendar=calendar, | ||
| ) | ||
|
|
||
| # Manually create the next_time context object | ||
| class MockTime: | ||
| def __init__(self): | ||
| self.dt_start = datetime.datetime(future_year, 5, 25, 12, 0) | ||
| self.dt_end = datetime.datetime(future_year, 5, 25, 14, 0) | ||
| self.single_day = True | ||
| self.all_day = False | ||
| self.valid_dt_end = True | ||
|
|
||
| context = { | ||
| "next_time": MockTime(), | ||
| "scheduled_start_this_year": False, # Event is in the future year | ||
| "scheduled_end_this_year": False, | ||
| "object": event, | ||
| } | ||
|
|
||
| rendered = render_to_string("events/includes/time_tag.html", context) | ||
|
|
||
| # The year should only appear visibly once in the output (not counting the datetime ISO tag). | ||
| year_str = str(future_year) | ||
| # Using string splitting to exclude the `datetime="2027...` occurrence by checking how many times | ||
| # it appears wrapped with whitespace or inside a span. | ||
| visible_occurrences = rendered.split(">\n " + year_str + "\n </span>") | ||
| self.assertEqual( | ||
| len(visible_occurrences) - 1, | ||
| 1, | ||
| f"Expected the visible span containing {year_str} to appear exactly once, but it was duplicated: {rendered}" | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.