Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Rename get_contained_events() to get_children for ICEkit content comp…
Browse files Browse the repository at this point in the history
…atibility. Boost upcoming events by 1.25.
  • Loading branch information
Greg Turner committed Dec 12, 2016
1 parent 90e7eba commit dac0352
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
7 changes: 4 additions & 3 deletions icekit_events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class EventBase(PolymorphicModel, AbstractBaseModel, ICEkitContentsMixin,
null=True,
help_text="If this event is part of another event, select it here.",
on_delete=models.SET_NULL
) # access visible contained_events via get_contained_events()
) # access visible contained_events via get_children()
derived_from = models.ForeignKey(
'self',
blank=True,
Expand Down Expand Up @@ -462,7 +462,7 @@ def start_times_set(self):
def get_absolute_url(self):
return reverse('icekit_events_eventbase_detail', args=(self.slug,))

def get_contained_events(self):
def get_children(self):
events = EventBase.objects.filter(
id__in=self.get_draft().contained_events.values_list('id', flat=True)
)
Expand All @@ -487,7 +487,8 @@ def is_educational(self):
def is_members(self):
return self.get_all_types().filter(slug='members')


def is_upcoming(self):
return self.get_occurrences().upcoming()


class AbstractEventWithLayouts(EventBase, FluentFieldsMixin):
Expand Down
3 changes: 2 additions & 1 deletion icekit_events/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ def prepare_search_types(self, obj):

def prepare(self, obj):
data = super(EventBaseIndex, self).prepare(obj)
data['boost'] = 1.2
if obj.is_upcoming():
data['boost'] *= 1.25
return data
2 changes: 1 addition & 1 deletion icekit_events/templates/icekit_events/event.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1>{{ event.title }}</h1>
<p><a href="{{ event.cta_url }}">{{ event.cta_text }}</a></p>
{% endif %}

{% with event.get_contained_events.visible as contained_events %}
{% with event.get_children.visible as contained_events %}
{% if contained_events %}
<h2>Contains</h2>
<ul>
Expand Down
8 changes: 4 additions & 4 deletions icekit_events/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,18 +779,18 @@ def test_upcoming(self):
])

def test_contained(self):
self.assertEqual(list(self.parent_event.get_contained_events()), [
self.assertEqual(list(self.parent_event.get_children()), [
self.child_event_1,
self.child_event_2,
self.child_event_3,
])
self.assertEqual(list(self.parent_event.get_contained_events().with_upcoming_occurrences()), [
self.assertEqual(list(self.parent_event.get_children().with_upcoming_occurrences()), [
self.child_event_2,
])
self.assertEqual(list(self.parent_event.get_contained_events().with_no_occurrences()), [
self.assertEqual(list(self.parent_event.get_children().with_no_occurrences()), [
self.child_event_3,
])
self.assertEqual(list(self.parent_event.get_contained_events().with_upcoming_or_no_occurrences()), [
self.assertEqual(list(self.parent_event.get_children().with_upcoming_or_no_occurrences()), [
self.child_event_2,
self.child_event_3,
])
Expand Down

0 comments on commit dac0352

Please sign in to comment.