From 7c68dc839ad7cca930cdadd8ab8998617e216c56 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Thu, 19 Dec 2024 18:46:52 -0500 Subject: [PATCH] Add geographic coordinates to Transportation model and update related components --- ...portation_destination_latitude_and_more.py | 33 + backend/server/adventures/models.py | 4 + backend/server/adventures/serializers.py | 2 +- frontend/src/lib/components/AboutModal.svelte | 173 ++++-- .../src/lib/components/MarkdownEditor.svelte | 3 +- .../lib/components/TransportationCard.svelte | 75 ++- .../lib/components/TransportationModal.svelte | 562 ++++++++++++++++++ frontend/src/lib/types.ts | 6 +- frontend/src/locales/en.json | 10 + .../src/routes/collections/[id]/+page.svelte | 70 +-- frontend/src/routes/settings/+page.svelte | 376 ++++++------ 11 files changed, 1025 insertions(+), 289 deletions(-) create mode 100644 backend/server/adventures/migrations/0015_transportation_destination_latitude_and_more.py create mode 100644 frontend/src/lib/components/TransportationModal.svelte diff --git a/backend/server/adventures/migrations/0015_transportation_destination_latitude_and_more.py b/backend/server/adventures/migrations/0015_transportation_destination_latitude_and_more.py new file mode 100644 index 0000000..7971839 --- /dev/null +++ b/backend/server/adventures/migrations/0015_transportation_destination_latitude_and_more.py @@ -0,0 +1,33 @@ +# Generated by Django 5.0.8 on 2024-12-19 17:16 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('adventures', '0014_alter_category_unique_together'), + ] + + operations = [ + migrations.AddField( + model_name='transportation', + name='destination_latitude', + field=models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True), + ), + migrations.AddField( + model_name='transportation', + name='destination_longitude', + field=models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True), + ), + migrations.AddField( + model_name='transportation', + name='origin_latitude', + field=models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True), + ), + migrations.AddField( + model_name='transportation', + name='origin_longitude', + field=models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True), + ), + ] diff --git a/backend/server/adventures/models.py b/backend/server/adventures/models.py index a8460d7..98ae268 100644 --- a/backend/server/adventures/models.py +++ b/backend/server/adventures/models.py @@ -167,6 +167,10 @@ class Transportation(models.Model): end_date = models.DateTimeField(blank=True, null=True) flight_number = models.CharField(max_length=100, blank=True, null=True) from_location = models.CharField(max_length=200, blank=True, null=True) + origin_latitude = models.DecimalField(max_digits=9, decimal_places=6, null=True, blank=True) + origin_longitude = models.DecimalField(max_digits=9, decimal_places=6, null=True, blank=True) + destination_latitude = models.DecimalField(max_digits=9, decimal_places=6, null=True, blank=True) + destination_longitude = models.DecimalField(max_digits=9, decimal_places=6, null=True, blank=True) to_location = models.CharField(max_length=200, blank=True, null=True) is_public = models.BooleanField(default=False) collection = models.ForeignKey('Collection', on_delete=models.CASCADE, blank=True, null=True) diff --git a/backend/server/adventures/serializers.py b/backend/server/adventures/serializers.py index 9b538ed..45a2141 100644 --- a/backend/server/adventures/serializers.py +++ b/backend/server/adventures/serializers.py @@ -170,7 +170,7 @@ class TransportationSerializer(CustomModelSerializer): fields = [ 'id', 'user_id', 'type', 'name', 'description', 'rating', 'link', 'date', 'flight_number', 'from_location', 'to_location', - 'is_public', 'collection', 'created_at', 'updated_at', 'end_date' + 'is_public', 'collection', 'created_at', 'updated_at', 'end_date', 'origin_latitude', 'origin_longitude', 'destination_latitude', 'destination_longitude' ] read_only_fields = ['id', 'created_at', 'updated_at', 'user_id'] diff --git a/frontend/src/lib/components/AboutModal.svelte b/frontend/src/lib/components/AboutModal.svelte index 60faa89..7b8fbf2 100644 --- a/frontend/src/lib/components/AboutModal.svelte +++ b/frontend/src/lib/components/AboutModal.svelte @@ -1,13 +1,14 @@ - - + - - + +
+

+ © {copyrightYear} + + Sean Morley + +

+

{$t('about.license')}

+

+ + {$t('about.source_code')} + +

+

{$t('about.message')}

+
+ + +
+ + +
+

+ {$t('about.oss_attributions')} +

+

+ {$t('about.nominatim_1')} + + OpenStreetMap + + . {$t('about.nominatim_2')} +

+

{$t('about.other_attributions')}

+
+ + +
+ +
+ + diff --git a/frontend/src/lib/components/MarkdownEditor.svelte b/frontend/src/lib/components/MarkdownEditor.svelte index 6ed5914..a280d7e 100644 --- a/frontend/src/lib/components/MarkdownEditor.svelte +++ b/frontend/src/lib/components/MarkdownEditor.svelte @@ -3,6 +3,7 @@ import { t } from 'svelte-i18n'; export let text: string | null | undefined = ''; // Markdown text + export let editor_height: string = 'h-64'; // Editor height let is_preview: boolean = false; // Toggle between Edit and Preview mode // Function to parse markdown to HTML @@ -46,7 +47,7 @@ {#if !is_preview}