-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
362 additions
and
121 deletions.
There are no files selected for viewing
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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
95 changes: 95 additions & 0 deletions
95
src/events/migrations/0004_remove_eventpage_end_time_and_more.py
This file contains 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,95 @@ | ||
# Generated by Django 4.2.15 on 2024-10-02 12:42 | ||
|
||
import datetime | ||
from django.db import migrations, models | ||
from datetime import datetime as dt | ||
import django.utils.timezone | ||
|
||
|
||
def copy_events(apps, schema_editor): | ||
EventPage = apps.get_model("events", "EventPage") | ||
|
||
for event_page in EventPage.objects.all(): | ||
event_page.event_start = dt.combine( | ||
event_page.event_date, event_page.start_time | ||
) | ||
event_page.event_end = dt.combine(event_page.event_date, event_page.end_time) | ||
event_page.save() | ||
|
||
|
||
def reverse_copy_events(apps, schema_editor): | ||
EventPage = apps.get_model("events", "EventPage") | ||
|
||
for event_page in EventPage.objects.all(): | ||
event_page.event_date = event_page.event_start.date() | ||
event_page.start_time = event_page.event_start.time() | ||
event_page.end_time = event_page.event_end.time() | ||
event_page.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("events", "0003_alter_eventpage_event_recording_url_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="eventpage", | ||
name="event_start", | ||
field=models.DateTimeField( | ||
default=django.utils.timezone.now, | ||
help_text="Start date/time of the event.", | ||
), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name="eventpage", | ||
name="event_end", | ||
field=models.DateTimeField( | ||
default=datetime.datetime( | ||
2024, 10, 2, 12, 42, 15, 793134, tzinfo=datetime.timezone.utc | ||
), | ||
help_text="End date/time of the event.", | ||
), | ||
preserve_default=False, | ||
), | ||
migrations.AlterField( | ||
model_name="eventpage", | ||
name="event_date", | ||
field=models.DateField( | ||
help_text="Date and time should be entered based on the time in London/England.", | ||
blank=True, | ||
null=True, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="eventpage", | ||
name="start_time", | ||
field=models.TimeField( | ||
blank=True, | ||
null=True, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="eventpage", | ||
name="end_time", | ||
field=models.TimeField( | ||
blank=True, | ||
null=True, | ||
), | ||
), | ||
migrations.RunPython(copy_events, reverse_code=reverse_copy_events), | ||
migrations.RemoveField( | ||
model_name="eventpage", | ||
name="event_date", | ||
), | ||
migrations.RemoveField( | ||
model_name="eventpage", | ||
name="start_time", | ||
), | ||
migrations.RemoveField( | ||
model_name="eventpage", | ||
name="end_time", | ||
), | ||
] |
This file contains 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 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 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 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 |
---|---|---|
@@ -1,17 +1,27 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
from django.utils.safestring import mark_safe | ||
|
||
from core.utils import format_time | ||
|
||
|
||
if TYPE_CHECKING: | ||
from events.models import EventPage | ||
|
||
|
||
def get_event_date(event: "EventPage") -> str: | ||
return event.event_date.strftime("%-d %B %Y") | ||
def get_event_datetime_display_string(event: "EventPage") -> str: | ||
event_start_date = event.event_start.strftime("%-d %B %Y") | ||
event_end_date = event.event_end.strftime("%-d %B %Y") | ||
event_start_time = format_time(event.event_start.time()) | ||
event_end_time = format_time(event.event_end.time()) | ||
|
||
if event_start_date == event_end_date: | ||
event_post_title = mark_safe( # noqa S308 | ||
f"{event_start_date} <br>{event_start_time} - {event_end_time}" | ||
) | ||
else: | ||
event_post_title = mark_safe( # noqa S308 | ||
f"{event_start_date} {event_start_time} - <br>{event_end_date} {event_end_time}" | ||
) | ||
|
||
def get_event_time(event: "EventPage") -> str: | ||
start_time = format_time(event.start_time) | ||
end_time = format_time(event.end_time) | ||
return f"{start_time} - {end_time}" | ||
return event_post_title |
This file contains 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 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