Skip to content
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

Feature/kak/multiple event destinations#1107 #1128

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/cac_tripplanner/destinations/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class EventAdmin(ImageCroppingMixin, admin.ModelAdmin):

fields = ('name', 'website_url', 'description', 'image', 'image_raw', 'wide_image',
'wide_image_raw', 'published', 'priority', 'accessible', 'activities',
'start_date', 'end_date', 'destination')
'start_date', 'end_date', 'destinations')
list_display = ('name', 'published', 'priority', )
actions = ('make_published', 'make_unpublished', )
ordering = ('name', )
Expand Down
6 changes: 3 additions & 3 deletions python/cac_tripplanner/destinations/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class Meta:

def __init__(self, *args, **kwargs):
super(EventForm, self).__init__(*args, **kwargs)
self.fields['destination'].widget.can_delete_related = False
self.fields['destination'].widget.can_add_related = False
self.fields['destination'].widget.can_change_related = False
self.fields['destinations'].widget.can_delete_related = False
self.fields['destinations'].widget.can_add_related = False
self.fields['destinations'].widget.can_change_related = False

def clean(self):
"""Validate start date is less than end date"""
Expand Down
10 changes: 6 additions & 4 deletions python/cac_tripplanner/destinations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,13 @@ def set_event_properties(event):

extra_images = ExtraEventPicture.objects.filter(event=event)
obj = set_attraction_properties(obj, event, extra_images)
# add properties of related destination, if any
obj = set_location_properties(obj, event.destination)
# add properties of first related destination, if any
obj = set_location_properties(obj, event.destinations.first())

# if related destination belongs to Watershed Alliance, so does this event
obj['watershed_alliance'] = event.destination.watershed_alliance if event.destination else False
obj['destinations'] = [set_destination_properties(x) for x in event.destinations.all()]

# if the first related destination belongs to Watershed Alliance, so does this event
obj['watershed_alliance'] = event.destinations.first().watershed_alliance if event.destinations.count() else False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the first one special, or should any Watershed Alliance destination cause the event to get the label? This could also be something like event.destinations.filter(watershed_alliance=True).exists(), right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interim fix that should be revisited with #1127, when we have answers on how these properties should be assigned (does it apply if any destination has the property? if all do?).

return obj


Expand Down