From 5621e906652bdbd0266bfdeb39628b738226efba Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Thu, 15 Aug 2024 19:36:42 -0400 Subject: [PATCH 01/22] new image features --- backend/server/adventures/admin.py | 17 ++++++++- .../migrations/0001_adventure_image.py | 19 ++++++++++ .../migrations/0002_adventureimage.py | 27 ++++++++++++++ .../0002_alter_adventureimage_adventure.py | 19 ++++++++++ .../adventures/migrations/migrate_images.py | 29 +++++++++++++++ backend/server/adventures/models.py | 10 ++++++ backend/server/adventures/serializers.py | 36 ++++++++++++------- 7 files changed, 143 insertions(+), 14 deletions(-) create mode 100644 backend/server/adventures/migrations/0001_adventure_image.py create mode 100644 backend/server/adventures/migrations/0002_adventureimage.py create mode 100644 backend/server/adventures/migrations/0002_alter_adventureimage_adventure.py create mode 100644 backend/server/adventures/migrations/migrate_images.py diff --git a/backend/server/adventures/admin.py b/backend/server/adventures/admin.py index 00294996..7ac68427 100644 --- a/backend/server/adventures/admin.py +++ b/backend/server/adventures/admin.py @@ -1,7 +1,7 @@ import os from django.contrib import admin from django.utils.html import mark_safe -from .models import Adventure, Checklist, ChecklistItem, Collection, Transportation, Note +from .models import Adventure, Checklist, ChecklistItem, Collection, Transportation, Note, AdventureImage from worldtravel.models import Country, Region, VisitedRegion @@ -57,6 +57,20 @@ def image_display(self, obj): else: return +class AdventureImageAdmin(admin.ModelAdmin): + list_display = ('user_id', 'image_display') + + def image_display(self, obj): + if obj.image: # Ensure this field matches your model's image field + public_url = os.environ.get('PUBLIC_URL', 'http://127.0.0.1:8000').rstrip('/') + public_url = public_url.replace("'", "") + return mark_safe(f' Date: Thu, 15 Aug 2024 21:16:02 -0400 Subject: [PATCH 02/22] carousel --- .../src/lib/components/AdventureCard.svelte | 21 +++++++++++++++++-- frontend/src/lib/types.ts | 5 ++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/components/AdventureCard.svelte b/frontend/src/lib/components/AdventureCard.svelte index fe7d41de..895c9681 100644 --- a/frontend/src/lib/components/AdventureCard.svelte +++ b/frontend/src/lib/components/AdventureCard.svelte @@ -154,8 +154,25 @@ >
- {#if adventure.image && adventure.image !== ''} - Adventure Image + {#if adventure.images && adventure.images.length > 0} + {:else} Date: Thu, 15 Aug 2024 21:29:36 -0400 Subject: [PATCH 03/22] Add rating stars --- .../src/lib/components/EditAdventure.svelte | 165 ++++++++++++------ .../src/lib/components/NewAdventure.svelte | 48 +++++ .../src/routes/adventures/[id]/+page.svelte | 4 +- 3 files changed, 159 insertions(+), 58 deletions(-) diff --git a/frontend/src/lib/components/EditAdventure.svelte b/frontend/src/lib/components/EditAdventure.svelte index 9774a780..806cdc7d 100644 --- a/frontend/src/lib/components/EditAdventure.svelte +++ b/frontend/src/lib/components/EditAdventure.svelte @@ -279,73 +279,126 @@ type="number" min="0" max="5" - name="rating" - id="rating" + hidden bind:value={adventureToEdit.rating} + id="rating" + name="rating" class="input input-bordered w-full max-w-xs mt-1" /> - - - - {#if adventureToEdit.collection === null} -
-
+
-
- {/if} - - {#if adventureToEdit.is_public} -
-

Share this Adventure!

-
-

- {window.location.origin}/adventures/{adventureToEdit.id} -

+ (adventureToEdit.rating = 1)} + /> + (adventureToEdit.rating = 2)} + checked={adventureToEdit.rating === 2} + /> + (adventureToEdit.rating = 3)} + checked={adventureToEdit.rating === 3} + /> + (adventureToEdit.rating = 4)} + checked={adventureToEdit.rating === 4} + /> + (adventureToEdit.rating = 5)} + checked={adventureToEdit.rating === 5} + /> + {#if adventureToEdit.rating} -
+ {/if}
- {/if} + + + {#if adventureToEdit.collection === null} +
+
+ +
+ {/if} + + {#if adventureToEdit.is_public} +
+

Share this Adventure!

+
+

+ {window.location.origin}/adventures/{adventureToEdit.id} +

+ +
+
+ {/if} - - - + + + +
diff --git a/frontend/src/lib/components/NewAdventure.svelte b/frontend/src/lib/components/NewAdventure.svelte index 48268a4d..c4bbe730 100644 --- a/frontend/src/lib/components/NewAdventure.svelte +++ b/frontend/src/lib/components/NewAdventure.svelte @@ -326,11 +326,59 @@ type="number" min="0" max="5" + hidden bind:value={newAdventure.rating} id="rating" name="rating" class="input input-bordered w-full max-w-xs mt-1" /> +
+ + (newAdventure.rating = 1)} + /> + (newAdventure.rating = 2)} + /> + (newAdventure.rating = 3)} + /> + (newAdventure.rating = 4)} + /> + (newAdventure.rating = 5)} + /> + {#if newAdventure.rating} + + {/if} +