Skip to content

Commit

Permalink
Merge pull request #8603 from cfpb/event-venue-image
Browse files Browse the repository at this point in the history
Fix event image/venue map logic
  • Loading branch information
csebianlander authored Oct 15, 2024
2 parents ec9f3d4 + 8711654 commit 596ba96
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 75 deletions.
32 changes: 7 additions & 25 deletions cfgov/v1/jinja2/v1/events/_macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ <h2 class="event-venue__heading">
</div>
</div>
</div>
{% if event.venue_image != 'none'
or (event_state == 'past' and event.archive_video_id)
or (event_state == 'present' and event.live_video_id) %}
<footer>
<figure class="event-media__container">
{% if event_state == 'present' and event.live_video_id %}
Expand All @@ -128,27 +125,13 @@ <h2 class="event-venue__heading">
video_id=event.live_video_id,
button_pos='bottom-right'
) }}
{% elif event_state == 'past' %}
{% if event.archive_video_id %}
{# DISPLAY VIDEO RECORDING #}
{% import 'v1/includes/organisms/video-player.html' as video_player with context %}
{{ video_player.render(
video_id=event.archive_video_id,
button_pos='bottom-right'
) }}
{% elif event.post_event_image_type == 'image' %}
{# DISPLAY SPECIFICALLY-CHOSEN POST-EVENT IMAGE #}
{% set img = image(event.post_event_image, 'width-1416') %}
<img class="o-post-preview__image"
src="{{ img.url }}"
alt="{{ image_alt_value(img) }}">
{% else %}
{# DISPLAY PLACEHOLDER POST-EVENT IMAGE #}
{% set img = image(event.post_event_image, 'width-1416') %}
<img class="o-post-preview__image"
src="{{ static('img/cfpb_video_cover_card_1380x776.png') }}"
alt="">
{% endif %}
{% elif event_state == 'past' and event.archive_video_id %}
{# DISPLAY VIDEO RECORDING #}
{% import 'v1/includes/organisms/video-player.html' as video_player with context %}
{{ video_player.render(
video_id=event.archive_video_id,
button_pos='bottom-right'
) }}
{% elif event.venue_image_type == 'map' %}
{# DISPLAY MAP IMAGE #}
{# Note: Max dimesions for Mapbox static image API: 1280x1280. #}
Expand All @@ -162,7 +145,6 @@ <h2 class="event-venue__heading">
{% endif %}
</figure>
</footer>
{% endif %}
</section>
{% endmacro %}

Expand Down
21 changes: 21 additions & 0 deletions cfgov/v1/migrations/0039_remove_post_event_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.2.16 on 2024-10-15 14:48

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('v1', '0038_emailsignup_disclaimer_page_set_null'),
]

operations = [
migrations.RemoveField(
model_name='eventpage',
name='post_event_image',
),
migrations.RemoveField(
model_name='eventpage',
name='post_event_image_type',
),
]
51 changes: 7 additions & 44 deletions cfgov/v1/models/learn_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,27 +244,6 @@ class EventPage(AbstractFilterPage):
on_delete=models.SET_NULL,
related_name="+",
)
post_event_image_type = models.CharField(
max_length=16,
choices=(
("placeholder", "Placeholder image"),
("image", "Unique image (selected below)"),
),
default="placeholder",
verbose_name="Post-event image type",
help_text="Choose what to display after an event concludes. This will "
'be overridden by embedded video if the "YouTube video ID '
'(archive)" field on the previous tab is populated. If '
'"Unique image" is chosen here, you must select the image '
"you want below. It should be sized to 1416x796.",
)
post_event_image = models.ForeignKey(
"v1.CFGOVImage",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="+",
)

# Agenda content fields
agenda_items = StreamField(
Expand All @@ -281,14 +260,20 @@ class EventPage(AbstractFilterPage):
FieldPanel("end_dt", classname="col6"),
]
),
MultiFieldPanel(
[
FieldPanel("venue_image_type"),
FieldPanel("venue_image"),
],
heading="Image",
),
FieldPanel("future_body", heading="Content visible before event"),
FieldPanel("live_body", heading="Content visible during event"),
MultiFieldPanel(
[
FieldPanel(
"archive_body", heading="Content visible after event"
),
FieldPanel("archive_image", heading="Image shown after event"),
FieldPanel("archive_video_id"),
],
heading="Body and information visible after event",
Expand Down Expand Up @@ -316,20 +301,6 @@ class EventPage(AbstractFilterPage):
],
heading="Venue Address",
),
MultiFieldPanel(
[
FieldPanel("venue_image_type"),
FieldPanel("venue_image"),
],
heading="Venue Image",
),
MultiFieldPanel(
[
FieldPanel("post_event_image_type"),
FieldPanel("post_event_image"),
],
heading="Post-event Image",
),
]
# Agenda content tab
agenda_panels = [
Expand Down Expand Up @@ -410,14 +381,6 @@ def clean(self):
raise ValidationError(
{"venue_image": 'Required if "Venue image type" is "Image".'}
)
if self.post_event_image_type == "image" and not self.post_event_image:
raise ValidationError(
{
"post_event_image": (
'Required if "Post-event image type" is "Image".'
)
}
)
if self.live_stream_availability:
if not self.live_stream_date:
self.live_stream_date = self.start_dt
Expand Down
6 changes: 0 additions & 6 deletions cfgov/v1/tests/models/test_event_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,6 @@ def test_failing_validation_venue_image(self):
venue_image_type="image",
)

def test_failing_validation_post_event_image(self):
self.assertValidationFails(
'Required if "Post-event image type" is "Image".',
post_event_image_type="image",
)

def test_failing_validation_live_start_date(self):
self.assertValidationFails(
"Cannot be on or after Event End.",
Expand Down

0 comments on commit 596ba96

Please sign in to comment.